@@ -2,22 +2,106 @@ import type { Locator, Page } from '@playwright/test';
2
2
import { FlawCreatePage } from './flawCreate' ;
3
3
import { faker } from '@faker-js/faker' ;
4
4
5
+ export type CommentType = 'public' | 'private' | 'internal' ;
6
+
5
7
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 ;
9
30
10
31
constructor ( page : Page ) {
11
32
super ( page ) ;
33
+
34
+ this . publicCommentTab = this . page . getByRole ( 'button' , { name : 'Public Comments' , exact : true } ) ;
12
35
this . publicCommentButton = this . page . getByRole ( 'button' , { name : 'Add Public Comment' } ) ;
13
36
this . publicCommentBox = this . page . locator ( 'label' ) . filter ( { hasText : 'New Public Comment' } ) ;
14
37
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' ) ;
15
57
this . submitButton = page . getByRole ( 'button' , { name : 'Save Changes' , exact : true } ) ;
16
58
}
17
59
18
- async addPublicComment ( ) {
60
+ private async addPublicComment ( ) {
61
+ await this . publicCommentTab . click ( ) ;
19
62
await this . publicCommentButton . click ( ) ;
20
63
await this . fillTextArea ( this . publicCommentBox , faker . hacker . phrase ( ) ) ;
21
64
await this . savePublicCommentBox . click ( ) ;
22
65
}
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
+ }
23
107
}
0 commit comments