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

Fix functional tests #78

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion frontend/src/lib/components/SideBar/navData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ export const navData = {
name: 'calendar',
fa_icon: 'fa-solid fa-calendar-days',
href: '/calendar',
permissions: ['view_event']
permissions: [
'view_securitymeasure',
'view_riskacceptance',
'view_riskassessment',
'view_complianceassessment'
]
}
]
},
Expand Down
4 changes: 3 additions & 1 deletion frontend/tests/functional/nav.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'Backup & restore': 'Backup restore'
};

const locals = localItems(languageTag());

for await (const [key, value] of sideBar.items) {
for await (const item of value) {
if (item.href !== '/role-assignments') {
Expand All @@ -30,7 +32,7 @@
if (item.name in temporaryPageTitle) {
await expect.soft(logedPage.pageTitle).toHaveText([temporaryPageTitle[item.name]]);
} else {
await expect.soft(logedPage.pageTitle).toHaveText(localItems(languageTag())[item.name]);
await expect.soft(logedPage.pageTitle).toHaveText(locals[item.name]);
}
}
}
Expand All @@ -49,7 +51,7 @@
await sideBar.profileButton.click();
await expect(sideBar.morePanel).toHaveAttribute('inert');
await expect(page).toHaveURL('/profile');
await expect.soft(logedPage.pageTitle).toHaveText('Profile');

Check failure on line 54 in frontend/tests/functional/nav.test.ts

View workflow job for this annotation

GitHub Actions / functional-tests (3.11)

[chromium] › functional/nav.test.ts:9:1 › sidebar navigation tests

1) [chromium] › functional/nav.test.ts:9:1 › sidebar navigation tests › more panel links are working properly Error: Timed out 10000ms waiting for expect(locator).toHaveText(expected) Locator: locator('#page-title') Expected string: "Profile" Received string: "profile" Call log: - expect.soft.toHaveText with timeout 10000ms - waiting for locator('#page-title') - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" 52 | await expect(sideBar.morePanel).toHaveAttribute('inert'); 53 | await expect(page).toHaveURL('/profile'); > 54 | await expect.soft(logedPage.pageTitle).toHaveText('Profile'); | ^ 55 | 56 | await sideBar.moreButton.click(); 57 | await expect(sideBar.morePanel).not.toHaveAttribute('inert'); at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:54:42 at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:47:2

Check failure on line 54 in frontend/tests/functional/nav.test.ts

View workflow job for this annotation

GitHub Actions / functional-tests (3.11)

[chromium] › functional/nav.test.ts:9:1 › sidebar navigation tests

1) [chromium] › functional/nav.test.ts:9:1 › sidebar navigation tests › more panel links are working properly Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 10000ms waiting for expect(locator).toHaveText(expected) Locator: locator('#page-title') Expected string: "Profile" Received string: "profile" Call log: - expect.soft.toHaveText with timeout 10000ms - waiting for locator('#page-title') - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" 52 | await expect(sideBar.morePanel).toHaveAttribute('inert'); 53 | await expect(page).toHaveURL('/profile'); > 54 | await expect.soft(logedPage.pageTitle).toHaveText('Profile'); | ^ 55 | 56 | await sideBar.moreButton.click(); 57 | await expect(sideBar.morePanel).not.toHaveAttribute('inert'); at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:54:42 at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:47:2

Check failure on line 54 in frontend/tests/functional/nav.test.ts

View workflow job for this annotation

GitHub Actions / functional-tests (3.11)

[chromium] › functional/nav.test.ts:9:1 › sidebar navigation tests

1) [chromium] › functional/nav.test.ts:9:1 › sidebar navigation tests › more panel links are working properly Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 10000ms waiting for expect(locator).toHaveText(expected) Locator: locator('#page-title') Expected string: "Profile" Received string: "profile" Call log: - expect.soft.toHaveText with timeout 10000ms - waiting for locator('#page-title') - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" 52 | await expect(sideBar.morePanel).toHaveAttribute('inert'); 53 | await expect(page).toHaveURL('/profile'); > 54 | await expect.soft(logedPage.pageTitle).toHaveText('Profile'); | ^ 55 | 56 | await sideBar.moreButton.click(); 57 | await expect(sideBar.morePanel).not.toHaveAttribute('inert'); at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:54:42 at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:47:2

Check failure on line 54 in frontend/tests/functional/nav.test.ts

View workflow job for this annotation

GitHub Actions / functional-tests (3.11)

[firefox] › functional/nav.test.ts:9:1 › sidebar navigation tests

2) [firefox] › functional/nav.test.ts:9:1 › sidebar navigation tests › more panel links are working properly Error: Timed out 10000ms waiting for expect(locator).toHaveText(expected) Locator: locator('#page-title') Expected string: "Profile" Received string: "profile" Call log: - expect.soft.toHaveText with timeout 10000ms - waiting for locator('#page-title') - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" 52 | await expect(sideBar.morePanel).toHaveAttribute('inert'); 53 | await expect(page).toHaveURL('/profile'); > 54 | await expect.soft(logedPage.pageTitle).toHaveText('Profile'); | ^ 55 | 56 | await sideBar.moreButton.click(); 57 | await expect(sideBar.morePanel).not.toHaveAttribute('inert'); at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:54:42 at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:47:2

Check failure on line 54 in frontend/tests/functional/nav.test.ts

View workflow job for this annotation

GitHub Actions / functional-tests (3.11)

[firefox] › functional/nav.test.ts:9:1 › sidebar navigation tests

2) [firefox] › functional/nav.test.ts:9:1 › sidebar navigation tests › more panel links are working properly Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 10000ms waiting for expect(locator).toHaveText(expected) Locator: locator('#page-title') Expected string: "Profile" Received string: "profile" Call log: - expect.soft.toHaveText with timeout 10000ms - waiting for locator('#page-title') - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" 52 | await expect(sideBar.morePanel).toHaveAttribute('inert'); 53 | await expect(page).toHaveURL('/profile'); > 54 | await expect.soft(logedPage.pageTitle).toHaveText('Profile'); | ^ 55 | 56 | await sideBar.moreButton.click(); 57 | await expect(sideBar.morePanel).not.toHaveAttribute('inert'); at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:54:42 at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:47:2

Check failure on line 54 in frontend/tests/functional/nav.test.ts

View workflow job for this annotation

GitHub Actions / functional-tests (3.11)

[firefox] › functional/nav.test.ts:9:1 › sidebar navigation tests

2) [firefox] › functional/nav.test.ts:9:1 › sidebar navigation tests › more panel links are working properly Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 10000ms waiting for expect(locator).toHaveText(expected) Locator: locator('#page-title') Expected string: "Profile" Received string: "profile" Call log: - expect.soft.toHaveText with timeout 10000ms - waiting for locator('#page-title') - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" - locator resolved to <span id="page-title" class="text-2xl font-bold pb-1">profile</span> - unexpected value "profile" 52 | await expect(sideBar.morePanel).toHaveAttribute('inert'); 53 | await expect(page).toHaveURL('/profile'); > 54 | await expect.soft(logedPage.pageTitle).toHaveText('Profile'); | ^ 55 | 56 | await sideBar.moreButton.click(); 57 | await expect(sideBar.morePanel).not.toHaveAttribute('inert'); at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:54:42 at /home/runner/work/ciso-assistant-community/ciso-assistant-community/frontend/tests/functional/nav.test.ts:47:2

await sideBar.moreButton.click();
await expect(sideBar.morePanel).not.toHaveAttribute('inert');
Expand Down
3 changes: 2 additions & 1 deletion frontend/tests/utils/page-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export class PageContent extends BasePage {
? this.page
.getByRole('row', { name: value })
.filter({ has: this.page.getByText(additional).first() })
: this.page.getByRole('row', { name: value })
.first()
: this.page.getByRole('row', { name: value }).first()
: this.page.getByRole('row').first();
}

Expand Down
12 changes: 10 additions & 2 deletions frontend/tests/utils/page-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,17 @@ export class PageDetail extends BasePage {
} else {
for (const key in values) {
if (await this.page.getByTestId(key.replaceAll('_', '-') + '-field-title').isVisible()) {
await expect
if (key === 'lc_status') {
//TODO replace this with a better solution
await expect
.soft(this.page.getByTestId(key.replaceAll('_', '-') + '-field-title'))
.toHaveText(new RegExp(key.replaceAll('_', ' '), 'i'));
.toHaveText(new RegExp(key.replaceAll('_', ' ').replace('lc ', ''), 'i'));
}
else {
await expect
.soft(this.page.getByTestId(key.replaceAll('_', '-') + '-field-title'))
.toHaveText(new RegExp(key.replaceAll('_', ' '), 'i'));
}

if (this.form.fields.get(key)?.type === FormFieldType.CHECKBOX) {
await expect
Expand Down
Loading