1- import TopBar , {
2- configName ,
3- getRunstate ,
4- runStateStr ,
5- } from "@/app/components/TopBar" ;
6- import { IfcPV } from "@/app/types" ;
1+ import TopBar , { getRunstate , runStateStr } from "@/app/components/TopBar" ;
2+ import { tBlockMapping } from "@/app/types" ;
73import { render } from "@testing-library/react" ;
84import { Instrument } from "@/app/components/Instrument" ;
9- import { findPVByHumanReadableName } from "@/app/components/PVutils" ;
105
116test ( "GetRunstate returns the runstate when it exists and is of string type" , ( ) => {
7+ const prefix = "TESTING:" ;
8+
129 const expected = "SETUP" ;
13- const PVToTest : IfcPV = {
14- pvaddress : "" ,
10+ let blocks : tBlockMapping = new Map ( ) ;
11+ blocks . set ( prefix + "DAE:RUNSTATE_STR" , {
12+ pvaddress : prefix + "DAE:RUNSTATE_STR" ,
1513 value : expected ,
1614 human_readable_name : runStateStr ,
17- } ;
18- const PVArr = [ PVToTest ] ;
19- expect ( getRunstate ( PVArr ) ) . toBe ( expected ) ;
15+ } ) ;
16+ expect ( getRunstate ( prefix , blocks ) ) . toBe ( expected ) ;
2017} ) ;
2118
2219test ( "GetRunstate returns unknown when no runstate PV in array" , ( ) => {
23- const PVArr : Array < IfcPV > = [ ] ;
24- expect ( getRunstate ( PVArr ) ) . toBe ( "UNREACHABLE" ) ;
20+ expect ( getRunstate ( "" , new Map ( ) ) ) . toBe ( "UNREACHABLE" ) ;
2521} ) ;
2622
2723it ( "renders topbar unchanged" , ( ) => {
28- let instrument = new Instrument ( "TESTING" ) ;
24+ const prefix = "TESTING:" ;
25+
26+ let instrument = new Instrument ( prefix ) ;
2927 const instName = "Instrument" ;
3028 const { container } = render (
3129 TopBar ( {
3230 dashboard : instrument . dashboard ,
3331 instName : instName ,
3432 runInfoPVs : instrument . runInfoPVs ,
33+ prefix : prefix ,
3534 } ) ,
3635 ) ;
3736 expect ( container ) . toMatchSnapshot ( ) ;
3837} ) ;
3938
4039it ( "draws instName expectedly" , ( ) => {
41- let instrument = new Instrument ( "TESTING" ) ;
40+ const prefix = "TESTING:" ;
41+
42+ let instrument = new Instrument ( prefix ) ;
4243 const instName = "Instrument" ;
4344 const { container } = render (
4445 TopBar ( {
4546 dashboard : instrument . dashboard ,
4647 instName : instName ,
4748 runInfoPVs : instrument . runInfoPVs ,
49+ prefix : prefix ,
4850 } ) ,
4951 ) ;
5052 expect ( container . querySelector ( "#instNameLabel" ) ! . innerHTML ) . toContain (
@@ -53,18 +55,19 @@ it("draws instName expectedly", () => {
5355} ) ;
5456
5557it ( "draws configName expectedly" , ( ) => {
56- let instrument = new Instrument ( "TESTING" ) ;
57- let configNamePV = findPVByHumanReadableName (
58- instrument . runInfoPVs ,
59- configName ,
60- ) ! ;
58+ const prefix = "TESTING:" ;
59+ let instrument = new Instrument ( prefix ) ;
60+ let configNamePV = instrument . runInfoPVs . get (
61+ prefix + "CS:BLOCKSERVER:CURR_CONFIG_NAME" ,
62+ ) ;
6163 const expectedConfigName = "Aconfig" ;
62- configNamePV . value = expectedConfigName ;
64+ configNamePV ! . value = expectedConfigName ;
6365 const { container } = render (
6466 TopBar ( {
6567 dashboard : instrument . dashboard ,
6668 instName : "Instrument" ,
6769 runInfoPVs : instrument . runInfoPVs ,
70+ prefix : prefix ,
6871 } ) ,
6972 ) ;
7073 expect ( container . querySelector ( "#configNameSpan" ) ! . innerHTML ) . toBe (
0 commit comments