11import { version } from '../../package.json' ;
22
33export enum FileNames {
4- eepOutJsonOut = 'cypress/io/LUA/ce/databridge/exchange/ak-eep-out.json ' ,
5- eepOutJsonOutFinished = 'cypress/io/LUA/ce/databridge/exchange/ak-eep-out-json.isfinished ' ,
6- eepOutLog = 'cypress/io/LUA/ce/databridge/exchange/ak-eep-out.log ' ,
7- serverOutCommands = 'cypress/io/LUA/ce/databridge/exchange/ak-eep-in.commands ' ,
8- serverWatching = 'cypress/io/LUA/ce/databridge/exchange/ak- server.iswatching ' ,
4+ eventsFromCe = 'cypress/io/LUA/ce/databridge/exchange/events-from-ce ' ,
5+ eventsFromCePending = 'cypress/io/LUA/ce/databridge/exchange/events-from-ce.pending ' ,
6+ logFromCe = 'cypress/io/LUA/ce/databridge/exchange/log-from-ce ' ,
7+ commandsToCe = 'cypress/io/LUA/ce/databridge/exchange/commands-to-ce ' ,
8+ serverIsRunning = 'cypress/io/LUA/ce/databridge/exchange/server-is-running ' ,
99}
1010
1111const resetMarker = '@@CE_LOG_RESET@@' ;
@@ -18,19 +18,19 @@ export default class EepSimulator {
1818
1919 reset = ( ) => {
2020 this . eventCounter = 0 ;
21- cy . task ( 'deleteEepLogFile' , FileNames . eepOutLog ) ;
22- cy . readFile ( FileNames . eepOutLog ) . should ( 'not.exist' ) ;
23- cy . readFile ( FileNames . serverWatching ) . should ( 'exist' ) ;
24- cy . writeFile ( FileNames . eepOutLog , '' , 'latin1' ) ;
25- cy . writeFile ( FileNames . serverOutCommands , '' ) ;
21+ cy . task ( 'deleteEepLogFile' , FileNames . logFromCe ) ;
22+ cy . readFile ( FileNames . logFromCe ) . should ( 'not.exist' ) ;
23+ cy . readFile ( FileNames . serverIsRunning ) . should ( 'exist' ) ;
24+ cy . writeFile ( FileNames . logFromCe , '' , 'latin1' ) ;
25+ cy . writeFile ( FileNames . commandsToCe , '' ) ;
2626 this . eepEvent ( 'reset.json' ) ;
2727 } ;
2828
29- loadFixtures = ( fixtures : string [ ] ) => {
30- const res = < any > [ ] ;
29+ loadFixtures = ( fixtures : string [ ] ) : Cypress . Chainable < any [ ] > => {
30+ const res : any [ ] = [ ] ;
3131 // could also use `res.push(f)` they should be equivalent
3232 fixtures . map ( ( name , i ) => cy . fixture ( name ) . then ( ( f ) => ( res [ i ] = f ) ) ) ;
33- return cy . wrap ( res ) ;
33+ return cy . wrap < any [ ] > ( res ) ;
3434 } ;
3535
3636 simulateMap ( mapName : string , startEvent : number , endEvent : number ) {
@@ -41,7 +41,7 @@ export default class EepSimulator {
4141 }
4242 const eventJsons = this . loadFixtures ( eventFileNames ) . then ( ( jsons ) => {
4343 cy . log ( jsons . length . toLocaleString ( ) ) ;
44- cy . writeFile ( FileNames . serverOutCommands , '' ) ;
44+ cy . writeFile ( FileNames . commandsToCe , '' ) ;
4545 this . writeNewEepEventFile ( jsons . map ( ( x ) => JSON . stringify ( x ) ) . join ( '\n' ) ) ;
4646 } ) ;
4747 }
@@ -61,10 +61,10 @@ export default class EepSimulator {
6161
6262 // Append complete log lines like LogOutputFileWriter does.
6363 writeLogLine ( line : string ) {
64- cy . readFile ( FileNames . eepOutLog , 'latin1' ) . then ( ( oldLines ) => {
64+ cy . readFile ( FileNames . logFromCe , 'latin1' ) . then ( ( oldLines ) => {
6565 cy . log ( oldLines ) ;
6666 const prefix = oldLines . length > 0 && ! oldLines . endsWith ( '\n' ) ? oldLines + '\n' : oldLines ;
67- cy . writeFile ( FileNames . eepOutLog , prefix + line + '\n' , 'latin1' ) ;
67+ cy . writeFile ( FileNames . logFromCe , prefix + line + '\n' , 'latin1' ) ;
6868 cy . wait ( 100 ) ; // Give the web server some time to read new log lines
6969 } ) ;
7070 }
@@ -74,8 +74,8 @@ export default class EepSimulator {
7474 }
7575
7676 private writeNewEepEventFile ( eventLines : string ) {
77- cy . writeFile ( FileNames . eepOutJsonOut , eventLines , 'latin1' ) ;
78- cy . writeFile ( FileNames . eepOutJsonOutFinished , '' ) ;
79- cy . readFile ( FileNames . eepOutJsonOutFinished ) . should ( 'not.exist' ) ;
77+ cy . writeFile ( FileNames . eventsFromCe , eventLines , 'latin1' ) ;
78+ cy . writeFile ( FileNames . eventsFromCePending , '' ) ;
79+ cy . task ( 'waitForFileMissing' , FileNames . eventsFromCePending ) ;
8080 }
8181}
0 commit comments