From 3e90051885ef3ac4ecf51c818214af0c0368d29c Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sun, 4 Dec 2022 01:15:00 +0800 Subject: [PATCH] fix(playwright): export test --- .../pages/Dashboard/common/Toolbar/ViewMenu.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts index 838bf6adbf..508e958be9 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts @@ -39,11 +39,11 @@ export class ToolbarViewMenuPage extends BasePage { ]); // Save downloaded file somewhere - await download.saveAs('./output/at.txt'); + await download.saveAs('./output/test.txt'); // verify downloaded content against expected content - const expectedData = fs.readFileSync(expectedDataFile, 'utf8'); - const file = fs.readFileSync('./output/at.txt', 'utf8'); + const expectedData = fs.readFileSync(expectedDataFile, 'utf8').replace(/\r/g, '').split('\n'); + const file = fs.readFileSync('./output/test.txt', 'utf8').replace(/\r/g, '').split('\n'); await expect(file).toEqual(expectedData); } @@ -71,7 +71,8 @@ export class ToolbarViewMenuPage extends BasePage { // verify downloaded content against expected content const expectedData = fs.readFileSync(expectedDataFile, 'utf8'); const file = fs.readFileSync('./output/test.txt', 'utf8'); - await expect(file).toEqual(expectedData); + // XLSX writes file with UTF-8 BOM, adds '\ufeff' to cater it + await expect(file).toEqual('\ufeff' + expectedData); } // menu items