Skip to content

Commit 77f3d1e

Browse files
committed
test affect creation
1 parent 4b5bd18 commit 77f3d1e

File tree

2 files changed

+106
-8
lines changed

2 files changed

+106
-8
lines changed

pages/flawEdit.ts

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,106 @@ import type { Locator, Page } from '@playwright/test';
22
import { FlawCreatePage } from './flawCreate';
33
import { faker } from '@faker-js/faker';
44

5+
export type CommentType = 'public' | 'private' | 'internal';
6+
57
export class FlawEditPage extends FlawCreatePage {
6-
public readonly publicCommentButton: Locator;
7-
public readonly publicCommentBox: Locator;
8-
public readonly savePublicCommentBox: Locator;
8+
readonly publicCommentButton: Locator;
9+
readonly publicCommentTab: Locator;
10+
readonly publicCommentBox: Locator;
11+
readonly savePublicCommentBox: Locator;
12+
13+
readonly privateCommentButton: Locator;
14+
readonly privateCommentTab: Locator;
15+
readonly privateCommentBox: Locator;
16+
readonly savePrivateCommentBox: Locator;
17+
18+
readonly internalCommentButton: Locator;
19+
readonly internalCommentTab: Locator;
20+
readonly internalCommentBox: Locator;
21+
readonly saveInternalCommentBox: Locator;
22+
readonly addAffectButton: Locator;
23+
readonly editAffectButton: Locator;
24+
readonly affectModuleBox: Locator;
25+
readonly affectComponentBox: Locator;
26+
readonly affectAffectednessBox: Locator;
27+
readonly affectResolutionBox: Locator;
28+
readonly affectImpactBox: Locator;
29+
readonly affectCommitButton: Locator;
930

1031
constructor(page: Page) {
1132
super(page);
33+
34+
this.publicCommentTab = this.page.getByRole('button', { name: 'Public Comments', exact: true });
1235
this.publicCommentButton = this.page.getByRole('button', { name: 'Add Public Comment' });
1336
this.publicCommentBox = this.page.locator('label').filter({ hasText: 'New Public Comment' });
1437
this.savePublicCommentBox = this.page.getByRole('button', { name: 'Save Public Comment' });
38+
39+
this.privateCommentTab = this.page.getByRole('button', { name: 'Private Comments', exact: true });
40+
this.privateCommentButton = this.page.getByRole('button', { name: 'Add Private Comment' });
41+
this.privateCommentBox = this.page.locator('label').filter({ hasText: 'New Private Comment' });
42+
this.savePrivateCommentBox = this.page.getByRole('button', { name: 'Save Private Comment' });
43+
44+
this.internalCommentTab = this.page.getByRole('button', { name: 'Internal Comments', exact: true });
45+
this.internalCommentButton = this.page.getByRole('button', { name: 'Add Internal Comment' });
46+
this.internalCommentBox = this.page.locator('label').filter({ hasText: 'New Internal Comment' });
47+
this.saveInternalCommentBox = this.page.getByRole('button', { name: 'Save Internal Comment' });
48+
49+
this.addAffectButton = this.page.getByRole('button', { name: 'Add New Affect' });
50+
this.editAffectButton = this.page.getByTitle('Edit affect');
51+
this.affectModuleBox = this.page.getByRole('cell', { name: 'NewModule' }).getByRole('textbox');
52+
this.affectComponentBox = this.page.getByRole('cell', { name: 'NewComponent' }).getByRole('textbox');
53+
this.affectAffectednessBox = this.page.getByRole('cell', { name: 'NEW', exact: true }).getByRole('combobox');
54+
this.affectResolutionBox = this.page.locator('td').filter({ hasText: 'DEFER' }).getByRole('combobox');
55+
this.affectImpactBox = this.page.locator('td').filter({ hasText: 'LOW' }).getByRole('combobox');
56+
this.affectCommitButton = this.page.getByTitle('Commit edit');
1557
this.submitButton = page.getByRole('button', { name: 'Save Changes', exact: true });
1658
}
1759

18-
async addPublicComment() {
60+
private async addPublicComment() {
61+
await this.publicCommentTab.click();
1962
await this.publicCommentButton.click();
2063
await this.fillTextArea(this.publicCommentBox, faker.hacker.phrase());
2164
await this.savePublicCommentBox.click();
2265
}
66+
67+
private async addPrivateComment() {
68+
await this.privateCommentTab.click();
69+
await this.privateCommentButton.click();
70+
await this.fillTextArea(this.privateCommentBox, faker.hacker.phrase());
71+
await this.savePrivateCommentBox.click();
72+
}
73+
74+
private async addInternalComment() {
75+
await this.internalCommentTab.click();
76+
await this.internalCommentButton.click();
77+
await this.fillTextArea(this.internalCommentBox, faker.hacker.phrase());
78+
await this.saveInternalCommentBox.click();
79+
}
80+
81+
async addComment(type: CommentType) {
82+
switch (type) {
83+
case 'public':
84+
await this.addPublicComment();
85+
break;
86+
case 'private':
87+
await this.addPrivateComment();
88+
break;
89+
case 'internal':
90+
await this.addInternalComment();
91+
break;
92+
}
93+
}
94+
95+
async addAffect(module = 'rhel-8', component = 'kernel') {
96+
await this.addAffectButton.click();
97+
await this.editAffectButton.click();
98+
99+
await this.affectModuleBox.fill(module);
100+
await this.affectComponentBox.fill(component);
101+
102+
await this.affectAffectednessBox.selectOption('AFFECTED');
103+
await this.affectResolutionBox.selectOption('DEFER');
104+
await this.affectImpactBox.selectOption('LOW');
105+
await this.affectCommitButton.click();
106+
}
23107
}

tests/flaw.spec.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CommentType } from 'pages/flawEdit';
12
import { FlawCreatePage, type FlawType } from '../pages/flawCreate';
23
import { test, expect } from '../playwright/fixtures';
34

@@ -71,17 +72,30 @@ test.describe('flaw edition', () => {
7172
await page.goto(`/flaws/${flawId}`);
7273
});
7374

74-
test('can add a comment', async ({ page, flawEditPage }) => {
75-
await flawEditPage.addPublicComment();
75+
(['public', 'private', 'internal'] as const).forEach((type: CommentType) => {
76+
test(`can add a ${type} comment`, async ({ page, flawEditPage }) => {
77+
await flawEditPage.addComment(type);
7678

77-
await expect(page.getByText('Public comment saved.')).toBeVisible();
79+
await expect(page.getByText(new RegExp(`${type} comment saved`, 'i'))).toBeVisible();
80+
});
7881
});
7982

8083
test('can change the title', async ({ page, flawEditPage }) => {
8184
const title = await flawEditPage.titleBox.locator('span', { hasNotText: 'Title' }).innerText();
82-
await flawEditPage.fillTextBox(flawEditPage.titleBox, title + ' edited');
85+
const newTitle = title + ' edited';
86+
87+
await flawEditPage.fillTextBox(flawEditPage.titleBox, newTitle);
8388
await flawEditPage.submitButton.click();
8489

8590
await expect(page.getByText('Flaw saved')).toBeVisible();
91+
await expect(page.getByText(newTitle)).toBeVisible();
92+
});
93+
94+
test.describe('affects', () => {
95+
test('can add an affect', async ({ page, flawEditPage }) => {
96+
await flawEditPage.addAffect();
97+
await flawEditPage.submitButton.click();
98+
await expect(page.getByText('Affects Created.')).toBeVisible();
99+
});
86100
});
87101
});

0 commit comments

Comments
 (0)