Skip to content

Commit

Permalink
test(Table/DownloadManager): fix event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
KostyaAvtushko committed Feb 4, 2025
1 parent 93722c7 commit 1c9089f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/ui/tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
/playwright-report/
/playwright/.cache/
.env
/downloads/
25 changes: 16 additions & 9 deletions packages/ui/tests/e2e/pages/table.download-manager.base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,25 @@ test('Download manager: downloaded file should be equal to ideal', async ({page}
await downloadButton.waitFor();
await downloadButton.click();

const downloadButtonModal = page.locator('[data-qa="download-static-table"]');
const downloadButtonModal = page.getByTestId('download-static-table');
await downloadButtonModal.waitFor();

const downloadPromise = page.waitForEvent('download');
await downloadButtonModal.click();

page.on('download', async (download) => {
const destination = './downloads/' + download.suggestedFilename();
await download.saveAs(destination);

const fileHash = getFileHash(destination);
const idealFileHash = getFileHash('./data/static-table/static-table');
expect(fileHash).toEqual(idealFileHash);
});
const download = await downloadPromise;

const toastTitle = page.locator('.g-toast__title');
await toastTitle.waitFor();
const text = await toastTitle.innerText();
expect(text).toBe('Success');

const destination = './downloads/' + download.suggestedFilename();
await download.saveAs(destination);

const fileHash = getFileHash(destination);
const idealFileHash = getFileHash('./data/static-table/static-table');
expect(fileHash).toEqual(idealFileHash);
});

function getFileHash(filePath: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"license": "ISC",
"private": true,
"devDependencies": {
"@playwright/test": "^1.44.1"
"@playwright/test": "^1.50.1"
}
}

0 comments on commit 1c9089f

Please sign in to comment.