diff --git a/frontend/tests/functional/detailed/common.test.ts b/frontend/tests/functional/detailed/common.test.ts index 5c700ccbe..da8a5d565 100644 --- a/frontend/tests/functional/detailed/common.test.ts +++ b/frontend/tests/functional/detailed/common.test.ts @@ -68,6 +68,7 @@ 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 1f9362f0c..1c47dba4f 100644 --- a/frontend/tests/functional/detailed/login.test.ts +++ b/frontend/tests/functional/detailed/login.test.ts @@ -11,6 +11,7 @@ baseTest.skip('login page as expected title', async ({ page }) => { test('login / logout process is working properly', async ({ loginPage, analyticsPage, sideBar, page }) => { await loginPage.hasUrl(1); await expect.soft(page.getByRole('heading', { name: 'Login into your account' })).toBeVisible(); + await loginPage.checkForUndefinedText(); await loginPage.login(); await analyticsPage.hasUrl(); sideBar.moreButton.click(); diff --git a/frontend/tests/functional/nav.test.ts b/frontend/tests/functional/nav.test.ts index 6efd16fea..c12961562 100644 --- a/frontend/tests/functional/nav.test.ts +++ b/frontend/tests/functional/nav.test.ts @@ -23,21 +23,20 @@ test('sidebar navigation tests', async ({ logedPage, analyticsPage, sideBar, pag }; const locals = localItems(languageTag()); - - for await (const [key, value] of sideBar.items) { - for await (const item of value) { - if (item.href !== '/role-assignments') { - await sideBar.click(key, item.href); - await expect(page).toHaveURL(item.href); - if (item.name in temporaryPageTitle) { - await expect.soft(logedPage.pageTitle).toHaveText(temporaryPageTitle[item.name]); - } else { - await expect.soft(logedPage.pageTitle).toHaveText(locals[item.name]); - } - } - } + for await (const [key, value] of sideBar.items) { + for await (const item of value) { + if (item.href !== '/role-assignments') { + await sideBar.click(key, item.href); + await expect(page).toHaveURL(item.href); + if (item.name in temporaryPageTitle) { + await expect.soft(logedPage.pageTitle).toHaveText(temporaryPageTitle[item.name]); + } else { + await expect.soft(logedPage.pageTitle).toHaveText(locals[item.name]); + } + } } - }); + } +}); await test.step('user email is showing properly', async () => { await expect(page.getByTestId('sidebar-user-account-display')).toHaveText(logedPage.email); @@ -47,19 +46,23 @@ test('sidebar navigation tests', async ({ logedPage, analyticsPage, sideBar, pag await test.step('more panel links are 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).toHaveAttribute('inert'); await expect(page).toHaveURL('/my-profile'); await expect.soft(logedPage.pageTitle).toHaveText('My profile'); - + await logedPage.checkForUndefinedText(); + 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 page.mouse.click(20, 20); // click outside the modal to close it await expect(logedPage.modalTitle).not.toBeVisible(); diff --git a/frontend/tests/functional/user-route.test.ts b/frontend/tests/functional/user-route.test.ts index 7ebb19df3..459b23300 100644 --- a/frontend/tests/functional/user-route.test.ts +++ b/frontend/tests/functional/user-route.test.ts @@ -72,7 +72,7 @@ test('user usual routine actions are working correctly', async ({ await pages.librariesPage.hasTitle(); await pages.librariesPage.hasTitle(); - await pages.librariesPage.importLibrary(vars.framework.name, vars.framework.urn); + await pages.librariesPage.importLibrary(vars.framework.ref, vars.framework.urn); await sideBar.click('Compliance', pages.frameworksPage.url); await pages.frameworksPage.hasUrl(); diff --git a/frontend/tests/utils/base-page.ts b/frontend/tests/utils/base-page.ts index 42fd6c347..b68376058 100644 --- a/frontend/tests/utils/base-page.ts +++ b/frontend/tests/utils/base-page.ts @@ -24,6 +24,10 @@ export abstract class BasePage { //TODO function to assert breadcrumb path is accurate + async checkForUndefinedText() { + await expect.soft(this.page.getByText('undefined'), "An undefined text is visible on the page").toHaveCount(0); + } + async isToastVisible(value: string, flags?: string | undefined, options?: {} | undefined) { const toast = this.page.getByTestId('toast').filter({ hasText: new RegExp(value, flags) }); await expect(toast).toBeVisible(options); diff --git a/frontend/tests/utils/page-content.ts b/frontend/tests/utils/page-content.ts index eeefe2634..153cd0588 100644 --- a/frontend/tests/utils/page-content.ts +++ b/frontend/tests/utils/page-content.ts @@ -45,7 +45,7 @@ export class PageContent extends BasePage { await this.page.goto('/libraries'); await this.page.waitForURL('/libraries'); - await this.importLibrary(dependency.name, dependency.urn); + await this.importLibrary(dependency.ref || dependency.name, dependency.urn); await this.goto(); } @@ -69,22 +69,22 @@ export class PageContent extends BasePage { } } - async importLibrary(name: string, urn: string, language: string = 'English') { + async importLibrary(ref: string, urn: string, language: string = 'English') { if (await this.tab('Imported libraries').isVisible()) { - if (await this.getRow(name).isHidden()) { + if (await this.getRow(ref).isHidden()) { await this.tab('Libraries store').click(); expect(this.tab('Libraries store').getAttribute('aria-selected')).toBeTruthy(); } else { return; } } - await this.importItemButton(name, language).click(); + await this.importItemButton(ref, language).click(); await this.isToastVisible('Successfully imported library ' + urn + '.+', undefined, { timeout: 15000 }); await this.tab('Imported libraries').click(); expect(this.tab('Imported libraries').getAttribute('aria-selected')).toBeTruthy(); - expect(this.getRow(name)).toBeVisible(); + expect(this.getRow(ref)).toBeVisible(); } async viewItemDetail(value?: string) { @@ -134,6 +134,6 @@ export class PageContent extends BasePage { importItemButton(value: string, language?: string) { return language ? this.getRow(value, language).getByTestId('tablerow-import-button') - : this.getRow(value).getByTestId('tablerow-import-button').first(); + : this.getRow(value).getByTestId('tablerow-import-button'); } } diff --git a/frontend/tests/utils/test-data.ts b/frontend/tests/utils/test-data.ts index 2f697a4ed..0b801a3c8 100644 --- a/frontend/tests/utils/test-data.ts +++ b/frontend/tests/utils/test-data.ts @@ -26,7 +26,8 @@ export default { validator: 'Validator' }, framework: { - name: 'NIST CSF', + name: 'NIST CSF v1.1', + ref: 'NIST-CSF-1.1', urn: 'urn:intuitem:risk:library:nist-csf-1.1' }, matrix: { @@ -39,6 +40,7 @@ export default { category: 'policy', library: { name: 'Documents and policies', + ref: 'doc-pol', urn: 'urn:intuitem:risk:library:doc-pol' }, urn: 'urn:intuitem:risk:function:POL.PHYSICAL' @@ -48,6 +50,7 @@ export default { category: 'process', library: { name: 'Documents and policies', + ref: 'doc-pol', urn: 'urn:intuitem:risk:library:doc-pol' }, urn: 'urn:intuitem:risk:function:DOC.CONTROLS' @@ -56,6 +59,7 @@ export default { name: 'Exfiltration Over Other Network Medium', library: { name: 'Mitre ATT&CK v14 - Threats and mitigations', + ref: 'mitre-attack', urn: 'urn:intuitem:risk:library:mitre-attack-v14' }, urn: 'urn:intuitem:risk:threat:mitre-attack:T1011' @@ -64,6 +68,7 @@ export default { name: 'Exfiltration Over Physical Medium', library: { name: 'Mitre ATT&CK v14 - Threats and mitigations', + ref: 'mitre-attack', urn: 'urn:intuitem:risk:library:mitre-attack-v14' }, urn: 'urn:intuitem:risk:threat:mitre-attack:T1052' @@ -71,14 +76,16 @@ export default { requirement_assessment: { name: 'RC.RP - Recovery Planning', library: { - name: 'NIST CSF', + name: 'NIST CSF v1.1', + ref: 'NIST-CSF-1.1', urn: 'urn:intuitem:risk:library:nist-csf-1.1' } }, requirement_assessment2: { name: 'ID.GV - Governance', library: { - name: 'NIST CSF', + name: 'NIST CSF v1.1', + ref: 'NIST-CSF-1.1', urn: 'urn:intuitem:risk:library:nist-csf-1.1' } }