@@ -70,18 +70,22 @@ describe('db editor tests', async function () {
7070 } ) ;
7171
7272 this . timeout ( 60000 ) ;
73- const CAREER_FILE_PATH = path . join ( __dirname , '../../../data/db/BLUS30128-CAREER-TEST/USR-DATA' ) ;
73+ const PRISTINE_CAREER_FILE_PATH = path . join ( __dirname , '../../../data/db/BLUS30128-CAREER-TEST/USR-DATA' ) ;
74+ const CAREER_FILE_PATH = path . join ( __dirname , '../../../data/db/BLUS30128-CAREER-TEST/USR-DATA-MODIFIED' ) ;
7475
7576 const PRISTINE_DB_FILE_PATH = path . join ( __dirname , '../../../data/db/pristine/pristine-roster.db' ) ;
7677 const DB_FILE_PATH = path . join ( __dirname , '../../../data/db/end-to-end-test.db' ) ;
78+ const SAVE_DB_AS_PATH = path . join ( __dirname , '../../../data/db/end-to-end-test-save-as.db' ) ;
7779
7880 const EXPORT_PATH = path . join ( __dirname , '../../../data/db/export-test.csv' ) ;
7981 const EXPORT_COMPARE_PATH = path . join ( __dirname , '../../../data/db/pristine/export-compare.csv' ) ;
8082
8183 const IMPORT_PATH = path . join ( __dirname , '../../../data/db/pristine/import-test.csv' ) ;
8284
85+
8386 beforeEach ( async ( ) => {
8487 await cloneFile ( PRISTINE_DB_FILE_PATH , DB_FILE_PATH ) ;
88+ await cloneFile ( PRISTINE_CAREER_FILE_PATH , CAREER_FILE_PATH ) ;
8589 } )
8690
8791 it ( 'can open and modify a DB file' , async ( ) => {
@@ -352,22 +356,35 @@ describe('db editor tests', async function () {
352356 const saveKeyShortcutSeverity = await toast . readToastSeverity ( ) ;
353357 expect ( saveKeyShortcutSeverity ) . to . equal ( 'success' ) ;
354358
359+ await toast . closeToast ( ) ;
360+
355361 const fileNameAfterSaveKey = await dbEditorData . readFileName ( ) ;
356362 expect ( fileNameAfterSaveKey ) . to . equal ( DB_FILE_PATH ) ;
363+
364+ // save as
365+ await dbEditorData . saveFileAs ( SAVE_DB_AS_PATH ) ;
366+ await toast . waitForToast ( ) ;
367+ await toast . closeToast ( ) ;
368+
369+ const saveAsFile = fs . readFileSync ( SAVE_DB_AS_PATH ) ;
370+ const saveFile = fs . readFileSync ( DB_FILE_PATH ) ;
371+ testBufferHashes ( saveFile , saveAsFile ) ;
372+
373+ await dbEditorData . closeFile ( ) ;
374+ await dbEditorHome . waitForPageLoad ( ) ;
375+ await recentFiles . removeAllRecentFiles ( ) ;
357376 } ) ;
358377
359378 it ( 'undo and redo tests' , async ( ) => {
360379 const home = new HomePage ( page ) ;
361380 await home . waitForPageLoad ( ) ;
362381 await home . openDbEditor ( ) ;
363382
364- const recentFiles = new RecentFiles ( page ) ;
365-
366383 const dbEditorHome = new DbEditorHome ( page ) ;
367384 await dbEditorHome . waitForPageLoad ( ) ;
385+ await dbEditorHome . openDbFile ( DB_FILE_PATH ) ;
368386
369387 const dbEditorData = new DbEditorData ( page ) ;
370- await recentFiles . openRecentFile ( 1 ) ;
371388 await dbEditorData . waitForPageLoad ( ) ;
372389 await dbEditorData . waitForTableToLoad ( ) ;
373390
@@ -431,6 +448,90 @@ describe('db editor tests', async function () {
431448
432449 const notTest9 = await dbEditorData . readTableDataAtIndicies ( 5 , 52 ) ;
433450 expect ( notTest9 ) . to . equal ( originalTest9 ) ;
451+
452+ await dbEditorData . closeFile ( ) ;
453+
454+ const modal = new UnsavedChangesModal ( page ) ;
455+ await modal . closeWithoutSaving ( ) ;
456+
457+ await dbEditorHome . waitForPageLoad ( ) ;
458+
459+ const recentFiles = new RecentFiles ( page ) ;
460+ await recentFiles . removeAllRecentFiles ( ) ;
461+ } ) ;
462+
463+ it ( 'can open a HC09 career file in the DB editor' , async ( ) => {
464+ const home = new HomePage ( page ) ;
465+ await home . waitForPageLoad ( ) ;
466+ await home . openDbEditor ( ) ;
467+
468+ const dbEditorHome = new DbEditorHome ( page ) ;
469+ await dbEditorHome . waitForPageLoad ( ) ;
470+ await dbEditorHome . openDbFile ( CAREER_FILE_PATH ) ;
471+
472+ const dbEditorData = new DbEditorData ( page ) ;
473+ await dbEditorData . waitForPageLoad ( ) ;
474+ await dbEditorData . waitForTableToLoad ( ) ;
475+
476+ // auto-opens the first table
477+ const firstTableName = await dbEditorData . readTableName ( ) ;
478+ expect ( firstTableName ) . to . equal ( 'AWPL' ) ;
479+
480+ // can search the tables
481+ await dbEditorData . searchTables ( 'TEAM' ) ;
482+
483+ // can select and load a table
484+ await dbEditorData . openTableAtIndex ( 1 ) ;
485+ await dbEditorData . waitForTableToLoad ( ) ;
486+
487+ // displays the expected table name
488+ const teamTableName = await dbEditorData . readTableName ( ) ;
489+ expect ( teamTableName ) . to . equal ( 'TEAM' ) ;
490+
491+ // displays all the table columns
492+ const tableColumns = await dbEditorData . readTableColumns ( ) ;
493+ expect ( tableColumns . length ) . to . equal ( 127 ) ;
494+
495+ // displays the table data
496+ const browns = await dbEditorData . readTableDataAtIndicies ( 5 , 10 ) ;
497+ expect ( browns ) . to . equal ( 'Browns' ) ;
498+
499+ // displays a limited number of rows
500+ const numberOfRowsDisplayed = await dbEditorData . readNumberOfRows ( ) ;
501+ expect ( numberOfRowsDisplayed ) . to . equal ( 10 ) ;
502+
503+ await dbEditorData . editTableDataAtIndicies ( 5 , 10 , 'Test' ) ;
504+ await dbEditorData . saveFile ( ) ;
505+
506+ const toast = new ToastMessage ( page ) ;
507+ await toast . waitForToast ( ) ;
508+ await toast . closeToast ( ) ;
509+
510+ await dbEditorData . closeFile ( ) ;
511+ await dbEditorHome . waitForPageLoad ( ) ;
512+
513+ const recentFiles = new RecentFiles ( page ) ;
514+ await recentFiles . openRecentFile ( 1 ) ;
515+ await dbEditorData . waitForPageLoad ( ) ;
516+ await dbEditorData . waitForTableToLoad ( ) ;
517+
518+ await dbEditorData . openTable ( 'TEAM' ) ;
519+ const newBrowns = await dbEditorData . readTableDataAtIndicies ( 5 , 10 ) ;
520+ expect ( newBrowns ) . to . equal ( 'Test' ) ;
521+
522+ await dbEditorData . editTableDataAtIndicies ( 5 , 10 , 'Browns' ) ;
523+ await dbEditorData . saveFile ( ) ;
524+
525+ await toast . waitForToast ( ) ;
526+ await toast . closeToast ( ) ;
527+
528+ const careerFile = fs . readFileSync ( CAREER_FILE_PATH ) ;
529+ const pristineCareer = fs . readFileSync ( PRISTINE_CAREER_FILE_PATH ) ;
530+ testBufferHashes ( careerFile , pristineCareer ) ;
531+
532+ await dbEditorData . closeFile ( ) ;
533+ await dbEditorHome . waitForPageLoad ( ) ;
534+ await recentFiles . removeAllRecentFiles ( ) ;
434535 } ) ;
435536} ) ;
436537
0 commit comments