Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA-184-Fix-functional-test-crashs #54

Merged
merged 10 commits into from
Feb 15, 2024
4 changes: 3 additions & 1 deletion .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name: Functional Tests
on:
pull_request:
branches: [main, develop]
types: [opened, edited]
types: [opened, synchronize]
paths:
- 'frontend/tests/**'
workflow_dispatch:

env:
Expand Down
2 changes: 1 addition & 1 deletion frontend/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config: PlaywrightTestConfig = {
globalTimeout: 60 * 60 * 1000,
timeout: 50 * 1000,
expect : {
timeout: 7 * 1000
timeout: 10 * 1000
},
reporter: [
[process.env.CI ? 'github' : 'list'],
Expand Down
23 changes: 7 additions & 16 deletions frontend/tests/functional/detailed/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,23 @@ for (const key of testPages) {

setHttpResponsesListener(page);

if (await pages[key].getRow("loading").first().isVisible()) {
await pages[key].getRow("loading").first().waitFor({state: 'hidden'});
}

await pages[key].waitUntilLoaded();
await pages[key].createItem(items[key].build, "dependency" in items[key] ? items[key].dependency : null);

if (await pages[key].getRow(items[key].build.name).isHidden()) {
await pages[key].searchInput.fill(items[key].build.name);
}


await pages[key].waitUntilLoaded();
await pages[key].viewItemDetail(items[key].build.name);
await pages[key].itemDetail.hasTitle();
//wait fore the file to load to prevent crashing
page.url().includes('evidences') ? await pages[key].page.getByTestId("attachment-name-title").waitFor({state: 'visible'}) : null;
});

test(`${items[key].displayName} item details are showing properly`, async ({ pages, page }) => {
await pages[key].itemDetail.verifyItem(items[key].build);
//wait fore the file to load to prevent crashing
page.url().includes('evidences') ? await pages[key].page.getByTestId("attachment-name-title").waitFor({state: 'visible'}) : null;
page.url().includes('evidences') ? await pages[key].page.waitForTimeout(1000) : null; // prevent crashing
});

test(`user can edit ${items[key].displayName.toLowerCase()} item`, async ({ pages, page }, testInfo) => {
Expand All @@ -70,13 +69,5 @@ for (const key of testPages) {
test.afterAll(async () => {
writeFileSync(file_path, JSON.stringify(history));
});

// test.afterEach('cleanup', async ({ pages, page }) => {
// await pages[key].goto()
// await page.waitForURL(pages[key].url);
// await pages[key].deleteItemButton(vars.folderName).click();
// await pages[key].deleteModalConfirmButton.click();
// await expect(pages[key].getRow(vars.folderName)).not.toBeVisible();
// });
});
}
5 changes: 2 additions & 3 deletions frontend/tests/functional/nav.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ test('sidebar navigation tests', async ({ logedPage, analyticsPage, sideBar, pag
//TODO delete this when page titles are fixed
const temporaryPageTitle: StringMap = {
'X-Rays': "X rays",
'Backup & restore': "Backup restore",
'Policies': "Security measures"
};
'Backup & restore': "Backup restore"
};

for await (const [key, value] of sideBar.items) {
for await (const item of value) {
Expand Down
6 changes: 6 additions & 0 deletions frontend/tests/utils/page-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export class PageContent extends BasePage {
await this.page.waitForURL(new RegExp("^.*\\" + this.url + "\/.+"));
}

async waitUntilLoaded() {
if (await this.getRow("loading").first().isVisible()) {
await this.getRow("loading").first().waitFor({state: 'hidden'});
}
}

getRow(value?: string, additional?: any) {
return value ? additional ? this.page.getByRole('row', { name: value }).filter({ has: this.page.getByText(additional).first() }) : this.page.getByRole('row', { name: value }) : this.page.getByRole('row').first();
}
Expand Down
Loading