@@ -42,21 +42,26 @@ describe('Time planning plugin working hours export', () => {
4242 const downloadedExcelFilename = path . join ( downloadsFolder , `${ fileNameExcelReport } .xlsx` ) ;
4343 const fixturesExcelFilename = path . join ( < string > fixturesFolder , `${ fileNameExcelReport } .xlsx` ) ;
4444
45- cy . readFile ( fixturesExcelFilename , 'binary' ) . then ( ( file1Content ) => {
46- cy . readFile ( downloadedExcelFilename , 'binary' ) . then ( ( file2Content ) => {
47-
48- const workbook1 = read ( file1Content , { type : 'binary' } ) ;
49- const sheetName1 = workbook1 . SheetNames [ 0 ] ; // Assuming you're comparing the first sheet
50- const sheet1 = workbook1 . Sheets [ sheetName1 ] ;
51- const jsonData1 = utils . sheet_to_json ( sheet1 , { header : 1 } ) ; // Convert sheet to array of arrays
52- const workbook = read ( file2Content , { type : 'binary' } ) ;
53- const sheetName = workbook . SheetNames [ 0 ] ; // Assuming you're comparing the first sheet
54- const sheet = workbook . Sheets [ sheetName ] ;
55- const jsonData = utils . sheet_to_json ( sheet , { header : 1 } ) ; // Convert sheet to array of arrays
56- console . log ( jsonData ) ;
57- console . log ( jsonData1 ) ;
58- expect ( jsonData ) . to . deep . equal ( jsonData1 ) ;
59- //expect(read(file1Content, {type: 'binary'}), 'excel file').to.deep.equal(read(file2Content, {type: 'binary'}));
45+ // Save the generated Excel file to a location for GitHub Actions artifact upload
46+ cy . readFile ( downloadedExcelFilename , 'binary' ) . then ( ( generatedContent ) => {
47+ // Copy the generated file to cypress/downloads for artifact collection
48+ cy . writeFile ( path . join ( downloadsFolder , 'generated-excel-report.xlsx' ) , generatedContent , 'binary' ) ;
49+
50+ cy . log ( 'Generated Excel file saved for artifact upload' ) ;
51+
52+ // Compare with fixture file
53+ cy . readFile ( fixturesExcelFilename , 'binary' ) . then ( ( fixtureContent ) => {
54+ const workbookGenerated = read ( generatedContent , { type : 'binary' } ) ;
55+ const sheetGenerated = workbookGenerated . Sheets [ workbookGenerated . SheetNames [ 0 ] ] ;
56+ const jsonDataGenerated = utils . sheet_to_json ( sheetGenerated , { header : 1 } ) ;
57+
58+ const workbookFixture = read ( fixtureContent , { type : 'binary' } ) ;
59+ const sheetFixture = workbookFixture . Sheets [ workbookFixture . SheetNames [ 0 ] ] ;
60+ const jsonDataFixture = utils . sheet_to_json ( sheetFixture , { header : 1 } ) ;
61+
62+ console . log ( 'Generated:' , jsonDataGenerated ) ;
63+ console . log ( 'Fixture:' , jsonDataFixture ) ;
64+ expect ( jsonDataGenerated ) . to . deep . equal ( jsonDataFixture ) ;
6065 } ) ;
6166 } ) ;
6267 } ) ;
0 commit comments