From 3df05b19a531d1dddc44d97066b04397673e93df Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 05:49:01 +0100 Subject: [PATCH 01/10] wait until load before and after item creation during common functional tests --- frontend/tests/functional/detailed/common.test.ts | 9 ++++----- frontend/tests/utils/page-content.ts | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/tests/functional/detailed/common.test.ts b/frontend/tests/functional/detailed/common.test.ts index 8d560e304..a499dcb85 100644 --- a/frontend/tests/functional/detailed/common.test.ts +++ b/frontend/tests/functional/detailed/common.test.ts @@ -37,16 +37,15 @@ 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(); }); diff --git a/frontend/tests/utils/page-content.ts b/frontend/tests/utils/page-content.ts index d7d81c481..8ec531446 100644 --- a/frontend/tests/utils/page-content.ts +++ b/frontend/tests/utils/page-content.ts @@ -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(); } From 278f54a7a9047746781011de911f74f36fdabd7d Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 06:13:57 +0100 Subject: [PATCH 02/10] fix Policies page check name after it was changed --- frontend/tests/functional/nav.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/tests/functional/nav.test.ts b/frontend/tests/functional/nav.test.ts index 618370fcc..dd0f0b8cf 100644 --- a/frontend/tests/functional/nav.test.ts +++ b/frontend/tests/functional/nav.test.ts @@ -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) { From 28c06993ce558318cf75daac39eb4e27119e48b0 Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 06:15:07 +0100 Subject: [PATCH 03/10] increase global expect timeout to 10s to avoid some tests to fail because of a slow run --- frontend/playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts index 2823fb463..67fd69ae1 100644 --- a/frontend/playwright.config.ts +++ b/frontend/playwright.config.ts @@ -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'], From 856cfc73c3dcf6f34dad3f1c1e53404d1cd8f173 Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 07:51:08 +0100 Subject: [PATCH 04/10] trigger the functional tests when a test file is modified in a PR as well as when a PR is opened --- .github/workflows/functional-tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index 558afc600..f501226dd 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -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: From 47544c547532cdda10b769309ad4308cb2e5ec9f Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 08:09:19 +0100 Subject: [PATCH 05/10] check that file preview is visible in beforeeach hook rather than in the tests --- frontend/tests/functional/detailed/common.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/tests/functional/detailed/common.test.ts b/frontend/tests/functional/detailed/common.test.ts index a499dcb85..062f74fe4 100644 --- a/frontend/tests/functional/detailed/common.test.ts +++ b/frontend/tests/functional/detailed/common.test.ts @@ -48,12 +48,12 @@ for (const key of testPages) { 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; }); test(`user can edit ${items[key].displayName.toLowerCase()} item`, async ({ pages, page }, testInfo) => { From 7a1f1dcbf258075504146c533e16b8084c24ae86 Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 08:11:05 +0100 Subject: [PATCH 06/10] temporarily force video recording and trace reporting to debug --- frontend/playwright.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts index 67fd69ae1..b484ab51f 100644 --- a/frontend/playwright.config.ts +++ b/frontend/playwright.config.ts @@ -28,8 +28,8 @@ const config: PlaywrightTestConfig = { ], use: { screenshot: 'only-on-failure', - video: process.env.CI ? 'retain-on-failure' : 'on', - trace: process.env.CI ? 'retain-on-failure' : 'on', + video: process.env.CI || true ? 'retain-on-failure' : 'on', + trace: process.env.CI || true ? 'retain-on-failure' : 'on', contextOptions: { recordVideo: { dir: "tests/results/videos"} } From 228e05dbfc87060bf22aac1dba2817abea8d6e20 Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 08:21:37 +0100 Subject: [PATCH 07/10] temporarily force video recording and trace reports --- frontend/playwright.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts index b484ab51f..b17d445e7 100644 --- a/frontend/playwright.config.ts +++ b/frontend/playwright.config.ts @@ -28,8 +28,8 @@ const config: PlaywrightTestConfig = { ], use: { screenshot: 'only-on-failure', - video: process.env.CI || true ? 'retain-on-failure' : 'on', - trace: process.env.CI || true ? 'retain-on-failure' : 'on', + video: process.env.CI && false ? 'retain-on-failure' : 'on', + trace: process.env.CI && false ? 'retain-on-failure' : 'on', contextOptions: { recordVideo: { dir: "tests/results/videos"} } From 9dc2b0e90e50e58d18bc16fe3cb6c99c02f688d7 Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 09:15:57 +0100 Subject: [PATCH 08/10] remove forced recording and tracing --- frontend/playwright.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts index b17d445e7..67fd69ae1 100644 --- a/frontend/playwright.config.ts +++ b/frontend/playwright.config.ts @@ -28,8 +28,8 @@ const config: PlaywrightTestConfig = { ], use: { screenshot: 'only-on-failure', - video: process.env.CI && false ? 'retain-on-failure' : 'on', - trace: process.env.CI && false ? 'retain-on-failure' : 'on', + video: process.env.CI ? 'retain-on-failure' : 'on', + trace: process.env.CI ? 'retain-on-failure' : 'on', contextOptions: { recordVideo: { dir: "tests/results/videos"} } From 151f097bfdfab80feeadf05d091136be283b6810 Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 11:26:45 +0100 Subject: [PATCH 09/10] try to add an extra timeout after the evidences test to fix the crash issue --- frontend/tests/functional/detailed/common.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/tests/functional/detailed/common.test.ts b/frontend/tests/functional/detailed/common.test.ts index 062f74fe4..df576a282 100644 --- a/frontend/tests/functional/detailed/common.test.ts +++ b/frontend/tests/functional/detailed/common.test.ts @@ -51,9 +51,10 @@ for (const key of testPages) { //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); + page.url().includes('evidences') ? await pages[key].page.waitForTimeout(1000) : null; }); test(`user can edit ${items[key].displayName.toLowerCase()} item`, async ({ pages, page }, testInfo) => { From c9729409250c43dfb3bfb1ac4a26647025a3ca1b Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 14 Feb 2024 11:43:51 +0100 Subject: [PATCH 10/10] cleaning --- frontend/tests/functional/detailed/common.test.ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/frontend/tests/functional/detailed/common.test.ts b/frontend/tests/functional/detailed/common.test.ts index df576a282..f77e17233 100644 --- a/frontend/tests/functional/detailed/common.test.ts +++ b/frontend/tests/functional/detailed/common.test.ts @@ -40,7 +40,6 @@ for (const key of testPages) { 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); } @@ -54,7 +53,7 @@ for (const key of testPages) { test(`${items[key].displayName} item details are showing properly`, async ({ pages, page }) => { await pages[key].itemDetail.verifyItem(items[key].build); - page.url().includes('evidences') ? await pages[key].page.waitForTimeout(1000) : 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) => { @@ -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(); - // }); }); }