From 1a20bacbfb18db2d1c8dd38a8e1ec055c971149f Mon Sep 17 00:00:00 2001 From: Nassim <71079376+nas-tabchiche@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:06:42 +0100 Subject: [PATCH] Ci/improve functional tests reliability (#1129) --- .../tests/functional/detailed/common.test.ts | 1 - .../tests/functional/detailed/login.test.ts | 1 - frontend/tests/functional/nav.test.ts | 9 ++++----- frontend/tests/utils/base-page.ts | 6 ------ frontend/tests/utils/test-data.ts | 4 ++-- frontend/tests/utils/test-utils.ts | 18 +++++++++--------- 6 files changed, 15 insertions(+), 24 deletions(-) diff --git a/frontend/tests/functional/detailed/common.test.ts b/frontend/tests/functional/detailed/common.test.ts index a078d399f..da8fc6ae3 100644 --- a/frontend/tests/functional/detailed/common.test.ts +++ b/frontend/tests/functional/detailed/common.test.ts @@ -74,7 +74,6 @@ for (const key of testPages) { page }) => { await pages[key].itemDetail.verifyItem(items[key].build); - await pages[key].checkForUndefinedText(); page.url().includes('evidences') ? await pages[key].page.waitForTimeout(1000) : null; // prevent crashing }); diff --git a/frontend/tests/functional/detailed/login.test.ts b/frontend/tests/functional/detailed/login.test.ts index f41c56aa3..f72a3e752 100644 --- a/frontend/tests/functional/detailed/login.test.ts +++ b/frontend/tests/functional/detailed/login.test.ts @@ -18,7 +18,6 @@ test('login / logout process is working properly', async ({ }) => { await loginPage.hasUrl(1); await expect.soft(page.getByTestId('login')).toBeVisible(); - await loginPage.checkForUndefinedText(); await loginPage.login(); await analyticsPage.hasUrl(); await sideBar.logout(); diff --git a/frontend/tests/functional/nav.test.ts b/frontend/tests/functional/nav.test.ts index ac1e9293a..84eb33b1f 100644 --- a/frontend/tests/functional/nav.test.ts +++ b/frontend/tests/functional/nav.test.ts @@ -42,19 +42,18 @@ test('sidebar navigation tests', async ({ logedPage, analyticsPage, sideBar, pag await test.step('user profile panel is working properly', async () => { await sideBar.moreButton.click(); await expect(sideBar.morePanel).not.toHaveAttribute('inert'); - await logedPage.checkForUndefinedText(); + await expect(sideBar.profileButton).toBeVisible(); await sideBar.profileButton.click(); await expect(sideBar.morePanel).not.toBeVisible(); await expect(page).toHaveURL('/my-profile'); await expect.soft(logedPage.pageTitle).toHaveText('My profile'); - await logedPage.checkForUndefinedText(); }); await test.step('docs button is working properly and redirects to gitbook docs', async () => { await sideBar.moreButton.click(); await expect(sideBar.morePanel).not.toHaveAttribute('inert'); - await logedPage.checkForUndefinedText(); + await expect(sideBar.docsButton).toBeVisible(); }); @@ -79,13 +78,13 @@ test('sidebar navigation tests', async ({ logedPage, analyticsPage, sideBar, pag await test.step('about panel is working properly', async () => { await sideBar.moreButton.click(); await expect(sideBar.morePanel).not.toHaveAttribute('inert'); - await logedPage.checkForUndefinedText(); + await expect(sideBar.aboutButton).toBeVisible(); await sideBar.aboutButton.click(); await expect(sideBar.morePanel).toHaveAttribute('inert'); await expect(logedPage.modalTitle).toBeVisible(); await expect.soft(logedPage.modalTitle).toHaveText('About CISO Assistant'); - await logedPage.checkForUndefinedText(); + await expect(logedPage.page.getByTestId('version-key')).toContainText('version', { ignoreCase: true }); diff --git a/frontend/tests/utils/base-page.ts b/frontend/tests/utils/base-page.ts index e50b607b2..7c38547e4 100644 --- a/frontend/tests/utils/base-page.ts +++ b/frontend/tests/utils/base-page.ts @@ -60,12 +60,6 @@ export abstract class BasePage { } } - async checkForUndefinedText() { - await expect - .soft(this.page.getByText('undefined'), 'An undefined text is visible on the page') - .toHaveCount(0); - } - async waitUntilLoaded() { const loadingFields = this.page.getByTestId('loading-field'); if ((await loadingFields.count()) > 0) { diff --git a/frontend/tests/utils/test-data.ts b/frontend/tests/utils/test-data.ts index 0a1a7989c..3af3cf2b4 100644 --- a/frontend/tests/utils/test-data.ts +++ b/frontend/tests/utils/test-data.ts @@ -250,7 +250,7 @@ export default { referenceControl: { name: 'POL.PHYSICAL - Physical security policy', category: 'policy', - csf_function: 'govern', + // csf_function: 'govern', library: { name: 'Documents and policies', ref: 'doc-pol', @@ -261,7 +261,7 @@ export default { referenceControl2: { name: 'DOC.CONTROLS - Controls accountability matrix', category: 'process', - csf_function: 'protect', + // csf_function: 'protect', library: { name: 'Documents and policies', ref: 'doc-pol', diff --git a/frontend/tests/utils/test-utils.ts b/frontend/tests/utils/test-utils.ts index 2e54bbdcf..31ced0da6 100644 --- a/frontend/tests/utils/test-utils.ts +++ b/frontend/tests/utils/test-utils.ts @@ -212,7 +212,7 @@ export const test = base.extend({ { name: 'name', type: type.TEXT }, { name: 'description', type: type.TEXT }, { name: 'category', type: type.SELECT }, - { name: 'csf_function', type: type.SELECT }, + // { name: 'csf_function', type: type.SELECT }, { name: 'provider', type: type.TEXT }, { name: 'folder', type: type.SELECT_AUTOCOMPLETE } ]); @@ -422,7 +422,7 @@ export class TestContent { name: vars.referenceControlName, description: vars.description, category: 'Technical', - csf_function: 'protect', + // csf_function: 'protect', provider: 'Test provider', folder: vars.folderName }, @@ -430,7 +430,7 @@ export class TestContent { name: '', description: '', category: 'Physical', - csf_function: 'detect', + // csf_function: 'detect', provider: '' } }, @@ -441,7 +441,7 @@ export class TestContent { reference_control: { value: 'Global/' + vars.referenceControl.name, category: vars.referenceControl.category, - csf_function: vars.referenceControl.csf_function, + // csf_function: vars.referenceControl.csf_function, request: { url: 'reference-controls' } @@ -454,14 +454,14 @@ export class TestContent { link: 'https://intuitem.com/', effort: 'Large', folder: vars.folderName, - category: vars.referenceControl.category, - csf_function: vars.referenceControl.csf_function + category: vars.referenceControl.category + // csf_function: vars.referenceControl.csf_function }, editParams: { reference_control: { value: 'Global/' + vars.referenceControl2.name, category: vars.referenceControl2.category, - csf_function: vars.referenceControl2.csf_function, + // csf_function: vars.referenceControl2.csf_function, request: { url: 'reference-controls' } @@ -473,8 +473,8 @@ export class TestContent { expiry_date: '2026-02-25', link: 'https://intuitem.com/community/', effort: 'Medium', - category: vars.referenceControl2.category, - csf_function: vars.referenceControl2.csf_function + category: vars.referenceControl2.category + // csf_function: vars.referenceControl2.csf_function } }, complianceAssessmentsPage: {