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

Check for undefined text #87

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/tests/functional/detailed/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down
1 change: 1 addition & 0 deletions frontend/tests/functional/detailed/login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test('login / logout process is working properly', async ({
}) => {
await loginPage.hasUrl(1);
await expect.soft(page.getByRole('heading', { name: 'Login into your account' })).toBeVisible();
await loginPage.checkForUndefinedText();
await loginPage.login();
await overviewPage.hasUrl();
sideBar.moreButton.click();
Expand Down
7 changes: 6 additions & 1 deletion frontend/tests/functional/nav.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test('sidebar navigation tests', async ({ logedPage, analyticsPage, sideBar, pag
if (item.href !== '/role-assignments') {
await sideBar.click(key, item.href);
await expect(page).toHaveURL(item.href);
await logedPage.checkForUndefinedText();
if (item.name in temporaryPageTitle) {
await expect.soft(logedPage.pageTitle).toHaveText([temporaryPageTitle[item.name]]);
} else {
Expand All @@ -47,19 +48,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();

Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/functional/user-route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test('user usual routine actions are working correctly', async ({
await expect(page).toHaveURL(pages.librariesPage.url);
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 expect(page).toHaveURL(pages.frameworksPage.url);
Expand Down
4 changes: 4 additions & 0 deletions frontend/tests/utils/base-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions frontend/tests/utils/page-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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');
}
}
13 changes: 10 additions & 3 deletions frontend/tests/utils/test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -64,21 +68,24 @@ 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'
},
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'
}
}
Expand Down
Loading