@@ -2,16 +2,15 @@ const Page = require('./page');
2
2
const appConst = require ( '../libs/app_const' ) ;
3
3
const lib = require ( '../libs/elements' ) ;
4
4
const AccessControlComboBox = require ( './components/selectors/access.control.combobox' ) ;
5
+
5
6
const xpath = {
6
7
container : `//div[contains(@id,'EditPermissionsDialog')]` ,
7
8
accessSelector : "//div[contains(@id,'AccessSelector')]" ,
8
9
contentPath : "//p[@class='path']" ,
9
- applyButton : `//button[contains(@id,'DialogButton') and child::span[contains(.,'Apply')]]` ,
10
- cancelButton : `//button/span[text()='Cancel']` ,
11
- overwriteChildPermissionsCheckbox : `//div[contains(@class,'overwrite-child')]` ,
12
- inheritPermissionsCheckbox : `//div[contains(@class,'inherit-perm')]` ,
10
+ accessModeDiv : `//div[contains(@class,'access-mode-container')]` ,
13
11
permissionSelector : `//[contains(@id,'PermissionSelector')]` ,
14
- aceSelectedOptions : "//div[contains(@id,'ACESelectedOptionsView')]" ,
12
+ aceSelectedOptionsView : "//div[contains(@id,'ACESelectedOptionsView')]" ,
13
+ dialogButtonRow : `//div[contains(@class,'button-container')]` ,
15
14
permissionToggleByOperationName : name => `//a[contains(@id,'PermissionToggle') and text()='${ name } ']` ,
16
15
aclEntryByName :
17
16
name => `//div[contains(@id,'PrincipalContainerSelectedOptionView') and descendant::p[contains(@class,'sub-name') and contains(.,'${ name } ')]]` ,
@@ -28,24 +27,68 @@ class EditPermissionsDialog extends Page {
28
27
}
29
28
30
29
get applyButton ( ) {
31
- return xpath . container + xpath . applyButton ;
30
+ return xpath . container + xpath . dialogButtonRow + lib . dialogButton ( 'Apply' ) ;
31
+ }
32
+
33
+ get nextButton ( ) {
34
+ return xpath . container + xpath . dialogButtonRow + lib . dialogButton ( 'Next' ) ;
35
+ }
36
+
37
+ get resetButton ( ) {
38
+ return xpath . container + xpath . accessModeDiv + lib . dialogButton ( 'Reset' ) ;
39
+ }
40
+
41
+ get backButton ( ) {
42
+ return xpath . container + xpath . dialogButtonRow + lib . dialogButton ( 'Back' ) ;
32
43
}
33
44
34
- get overwriteChildPermissionsCheckbox ( ) {
35
- return xpath . container + xpath . overwriteChildPermissionsCheckbox ;
45
+ get publicRadioButton ( ) {
46
+ return xpath . container + lib . radioButtonByLabel ( 'Public' ) ;
36
47
}
37
48
38
- get inheritPermissionsCheckbox ( ) {
39
- return xpath . container + xpath . inheritPermissionsCheckbox ;
49
+ get restrictedRadioButton ( ) {
50
+ return xpath . container + lib . radioButtonByLabel ( 'Restricted' ) ;
40
51
}
41
52
42
53
get contentPath ( ) {
43
54
return xpath . container + xpath . contentPath ;
44
55
}
45
56
57
+ async waitForNextButtonDisabled ( ) {
58
+ try {
59
+ return await this . waitForElementDisabled ( this . nextButton , appConst . mediumTimeout ) ;
60
+ } catch ( err ) {
61
+ let screenshot = await this . saveScreenshotUniqueName ( 'err_next_button' ) ;
62
+ throw new Error ( `Next button should be disabled ${ screenshot } ` + err ) ;
63
+ }
64
+ }
65
+
66
+ async waitForResetButtonDisabled ( ) {
67
+ try {
68
+ return await this . waitForElementDisabled ( this . resetButton , appConst . mediumTimeout ) ;
69
+ } catch ( err ) {
70
+ let screenshot = await this . saveScreenshotUniqueName ( 'err_reset_button' ) ;
71
+ throw new Error ( `Reset button should be disabled ${ screenshot } ` + err ) ;
72
+ }
73
+ }
74
+
75
+ async waitForResetButtonEnabled ( ) {
76
+ try {
77
+ return await this . waitForElementEnabled ( this . resetButton , appConst . mediumTimeout ) ;
78
+ } catch ( err ) {
79
+ let screenshot = await this . saveScreenshotUniqueName ( 'err_reset_button' ) ;
80
+ throw new Error ( `Reset button should be enabled ${ screenshot } ` + err ) ;
81
+ }
82
+ }
83
+
46
84
async waitForDialogLoaded ( ) {
47
- await this . waitForElementDisplayed ( this . applyButton , appConst . mediumTimeout ) ;
48
- return await this . pause ( 300 ) ;
85
+ try {
86
+ await this . waitForElementDisplayed ( xpath . dialogButtonRow , appConst . mediumTimeout ) ;
87
+ return await this . pause ( 300 ) ;
88
+ } catch ( err ) {
89
+ let screenshot = await this . saveScreenshotUniqueName ( 'err_edit_perm_dlg_not_loaded' ) ;
90
+ throw new Error ( "Edit permissions dialog was not loaded! " + err ) ;
91
+ }
49
92
}
50
93
51
94
waitForDialogClosed ( ) {
@@ -58,21 +101,23 @@ class EditPermissionsDialog extends Page {
58
101
}
59
102
60
103
getDisplayNameOfSelectedPrincipals ( ) {
61
- let selector = xpath . container + lib . H6_DISPLAY_NAME ;
104
+ let selector = xpath . container + xpath . aceSelectedOptionsView + lib . H6_DISPLAY_NAME ;
62
105
return this . getTextInElements ( selector ) ;
63
106
}
64
107
65
108
getNameOfAccessControlEntries ( ) {
66
- let selector = xpath . container + xpath . aceSelectedOptions + lib . P_SUB_NAME ;
109
+ let selector = xpath . container + xpath . aceSelectedOptionsView + lib . P_SUB_NAME ;
67
110
return this . getTextInElements ( selector ) ;
68
111
}
69
112
70
- removeAclEntry ( principalName ) {
71
- let selector = xpath . container + xpath . aclEntryByName ( principalName ) + lib . REMOVE_ICON ;
72
- return this . clickOnElement ( selector ) . catch ( err => {
73
- this . saveScreenshot ( "err_remove_acl_entry" ) ;
74
- throw new Error ( "Error when remove acl entry " + err ) ;
75
- } ) ;
113
+ async removeAclEntry ( principalName ) {
114
+ try {
115
+ let selector = xpath . container + xpath . aclEntryByName ( principalName ) + lib . REMOVE_ICON ;
116
+ return await this . clickOnElement ( selector )
117
+ } catch ( err ) {
118
+ let screenshot = await this . saveScreenshotUniqueName ( 'err_remove_acl_entry' ) ;
119
+ throw new Error ( `Error when remove acl entry, screenshot: ${ screenshot } ` + err ) ;
120
+ }
76
121
}
77
122
78
123
// filters and select a principal
@@ -83,7 +128,7 @@ class EditPermissionsDialog extends Page {
83
128
console . log ( "Edit Permissions Dialog, principal is selected: " + principalDisplayName ) ;
84
129
} catch ( err ) {
85
130
let screenshot = await this . saveScreenshotUniqueName ( 'err_perm_dlg' ) ;
86
- throw new Error ( " Error during updating permissions, screenshot:" + screenshot + " " + err ) ;
131
+ throw new Error ( ` Error during updating permissions, screenshot:${ screenshot } ` + err ) ;
87
132
}
88
133
}
89
134
@@ -98,8 +143,8 @@ class EditPermissionsDialog extends Page {
98
143
//Select a menu item: Custom, Can Write, Can Read....
99
144
return await this . clickOnElement ( menuItemXpath ) ;
100
145
} catch ( err ) {
101
- this . saveScreenshot ( 'err_click_on_ace_menu_button' ) ;
102
- throw new Error ( ' Error when selecting an operation in Principal SelectedOptionView ' + err ) ;
146
+ let screenshot = await this . saveScreenshotUniqueName ( 'err_click_on_ace_menu_button' ) ;
147
+ throw new Error ( ` Error when selecting an operation in Principal SelectedOptionView , ${ screenshot } ` + err ) ;
103
148
}
104
149
}
105
150
@@ -112,8 +157,8 @@ class EditPermissionsDialog extends Page {
112
157
await this . waitForElementDisplayed ( selector , appConst . shortTimeout ) ;
113
158
return await this . clickOnElement ( selector ) ;
114
159
} catch ( err ) {
115
- this . saveScreenshot ( 'err_click_on_permission_toggle' ) ;
116
- throw new Error ( ' Error when clicking on Permission Toggle ' + err ) ;
160
+ let screenshot = await this . saveScreenshotUniqueName ( 'err_click_on_permission_toggle' ) ;
161
+ throw new Error ( ` Error when clicking on Permission Toggle , ${ screenshot } ` + err ) ;
117
162
}
118
163
}
119
164
@@ -123,17 +168,31 @@ class EditPermissionsDialog extends Page {
123
168
await this . clickOnElement ( this . applyButton ) ;
124
169
return await this . pause ( 500 ) ;
125
170
} catch ( err ) {
126
- await this . saveScreenshot ( 'err_click_on_apply_button_permis_dialog' ) ;
127
- throw new Error ( ' Error when clicking Apply dialog must be closed ' + err ) ;
171
+ let screenshot = await this . saveScreenshotUniqueName ( 'err_click_on_apply_button_permis_dialog' ) ;
172
+ throw new Error ( ` Error when clicking Apply dialog must be closed screenshot: ${ screenshot } ` + err ) ;
128
173
}
129
174
}
130
175
131
176
waitForApplyButtonEnabled ( ) {
132
- return this . waitForElementEnabled ( this . cancelButton , appConst . mediumTimeout ) ;
177
+ return this . waitForElementEnabled ( this . applyButton , appConst . mediumTimeout ) ;
133
178
}
134
179
135
- waitForApplyButtonDisabled ( ) {
136
- return this . waitForElementDisabled ( this . applyButton , appConst . mediumTimeout ) ;
180
+ async waitForApplyButtonEnabled ( ) {
181
+ try {
182
+ return await this . waitForElementEnabled ( this . applyButton , appConst . mediumTimeout ) ;
183
+ } catch ( err ) {
184
+ let screenshot = await this . saveScreenshotUniqueName ( 'err_apply_button' ) ;
185
+ throw new Error ( `Apply button should be enabled, screenshot: ${ screenshot } ` + err ) ;
186
+ }
187
+ }
188
+
189
+ async waitForNextButtonDisabled ( ) {
190
+ try {
191
+ return await this . waitForElementDisabled ( this . nextButton , appConst . mediumTimeout ) ;
192
+ } catch ( err ) {
193
+ let screenshot = await this . saveScreenshot ( 'err_next_button_disabled' ) ;
194
+ throw new Error ( `Edit Permissions dialog, Next button should be disabled screenshot:${ screenshot } ` + err ) ;
195
+ }
137
196
}
138
197
139
198
async isOperationAllowed ( principalName , operation ) {
@@ -163,25 +222,6 @@ class EditPermissionsDialog extends Page {
163
222
}
164
223
}
165
224
166
- clickOnOverwriteChildPermissionsCheckBox ( ) {
167
- return this . clickOnElement ( this . overwriteChildPermissionsCheckbox + '/label' ) . catch ( err => {
168
- this . saveScreenshot ( 'err_click_on_inherit_permis_dialog' ) ;
169
- throw new Error ( 'Error when clicking on Inherit permissions ' + err ) ;
170
- } )
171
- }
172
-
173
- isInheritPermissionsCheckBoxSelected ( ) {
174
- return this . isSelected ( this . inheritPermissionsCheckbox + '//input' ) . catch ( err => {
175
- throw new Error ( 'Error when checking Inherit permissions link ' + err ) ;
176
- } )
177
- }
178
-
179
- isOverwriteChildPermissionsCheckBoxSelected ( ) {
180
- return this . isSelected ( this . overwriteChildPermissionsCheckbox + '//input' ) . catch ( err => {
181
- throw new Error ( 'Error when checking Overwrite child permissions link ' + err ) ;
182
- } )
183
- }
184
-
185
225
async waitForAccessSelectorDisabled ( principalName ) {
186
226
let locator = xpath . aclEntryByDisplayName ( principalName ) + xpath . accessSelector ;
187
227
await this . getBrowser ( ) . waitUntil ( async ( ) => {
0 commit comments