Skip to content

Commit 9350268

Browse files
committed
expanded focus-trap workaround coverage and added cleanup step
Signed-off-by: Isabela Guimaraes <isabela.guimaraes@suse.com>
1 parent aa2ca5c commit 9350268

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

cypress/e2e/tests/pages/generic/diagnostic.spec.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import DiagnosticsPagePo from '@/cypress/e2e/po/pages/diagnostics.po';
22
import * as path from 'path';
33

44
const downloadsFolder = Cypress.config('downloadsFolder');
5+
const downloadedFilename = path.join(downloadsFolder, 'rancher-diagnostic-data.json');
56

67
describe('Diagnostics Page', { tags: ['@generic', '@adminUser'] }, () => {
78
beforeEach(() => {
@@ -11,10 +12,14 @@ describe('Diagnostics Page', { tags: ['@generic', '@adminUser'] }, () => {
1112
it('User should be able to download the diagnostics package JSON', () => {
1213
// Ignore the focus-trap error that fires when the modal closes immediately
1314
// after the download is triggered (known cosmetic side-effect of the dialog)
15+
// Also the focus-trap error triggered when it can’t find any tabbable node inside its container
16+
1417
cy.on('uncaught:exception', (err) => {
15-
if (err.message.includes('focus-trap')) {
18+
if (err.message.includes('focus-trap' ) || err.message.includes('tabbable')) {
1619
return false;
1720
}
21+
22+
return true;
1823
});
1924

2025
const diagnosticsPage = new DiagnosticsPagePo();
@@ -33,10 +38,12 @@ describe('Diagnostics Page', { tags: ['@generic', '@adminUser'] }, () => {
3338
// modal button to actually trigger the download
3439
diagnosticsPage.downloadDiagnosticsModalActionBtn().click(true);
3540

36-
const downloadedFilename = path.join(downloadsFolder, 'rancher-diagnostic-data.json');
37-
3841
cy.readFile(downloadedFilename).should('exist').then((file: any) => {
3942
expect(Object.keys(file).length).to.equal(4);
4043
});
4144
});
45+
afterEach(() => {
46+
// Keep the downloads directory clean between tests.
47+
cy.exec(`rm -f "${ downloadedFilename }"`, { failOnNonZeroExit: false });
48+
});
4249
});

0 commit comments

Comments
 (0)