Skip to content

Commit 3afe2ba

Browse files
author
sgauruseu
committed
fix for failed ui-tests
1 parent 3a1be94 commit 3afe2ba

File tree

1 file changed

+89
-49
lines changed

1 file changed

+89
-49
lines changed

testing/page_objects/edit.permissions.dialog.js

Lines changed: 89 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ const Page = require('./page');
22
const appConst = require('../libs/app_const');
33
const lib = require('../libs/elements');
44
const AccessControlComboBox = require('./components/selectors/access.control.combobox');
5+
56
const xpath = {
67
container: `//div[contains(@id,'EditPermissionsDialog')]`,
78
accessSelector: "//div[contains(@id,'AccessSelector')]",
89
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')]`,
1311
permissionSelector: `//[contains(@id,'PermissionSelector')]`,
14-
aceSelectedOptions: "//div[contains(@id,'ACESelectedOptionsView')]",
12+
aceSelectedOptionsView: "//div[contains(@id,'ACESelectedOptionsView')]",
13+
dialogButtonRow: `//div[contains(@class,'button-container')]`,
1514
permissionToggleByOperationName: name => `//a[contains(@id,'PermissionToggle') and text()='${name}']`,
1615
aclEntryByName:
1716
name => `//div[contains(@id,'PrincipalContainerSelectedOptionView') and descendant::p[contains(@class,'sub-name') and contains(.,'${name}')]]`,
@@ -28,24 +27,68 @@ class EditPermissionsDialog extends Page {
2827
}
2928

3029
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');
3243
}
3344

34-
get overwriteChildPermissionsCheckbox() {
35-
return xpath.container + xpath.overwriteChildPermissionsCheckbox;
45+
get publicRadioButton() {
46+
return xpath.container + lib.radioButtonByLabel('Public');
3647
}
3748

38-
get inheritPermissionsCheckbox() {
39-
return xpath.container + xpath.inheritPermissionsCheckbox;
49+
get restrictedRadioButton() {
50+
return xpath.container + lib.radioButtonByLabel('Restricted');
4051
}
4152

4253
get contentPath() {
4354
return xpath.container + xpath.contentPath;
4455
}
4556

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+
4684
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+
}
4992
}
5093

5194
waitForDialogClosed() {
@@ -58,21 +101,23 @@ class EditPermissionsDialog extends Page {
58101
}
59102

60103
getDisplayNameOfSelectedPrincipals() {
61-
let selector = xpath.container + lib.H6_DISPLAY_NAME;
104+
let selector = xpath.container + xpath.aceSelectedOptionsView + lib.H6_DISPLAY_NAME;
62105
return this.getTextInElements(selector);
63106
}
64107

65108
getNameOfAccessControlEntries() {
66-
let selector = xpath.container + xpath.aceSelectedOptions + lib.P_SUB_NAME;
109+
let selector = xpath.container + xpath.aceSelectedOptionsView + lib.P_SUB_NAME;
67110
return this.getTextInElements(selector);
68111
}
69112

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+
}
76121
}
77122

78123
// filters and select a principal
@@ -83,7 +128,7 @@ class EditPermissionsDialog extends Page {
83128
console.log("Edit Permissions Dialog, principal is selected: " + principalDisplayName);
84129
} catch (err) {
85130
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);
87132
}
88133
}
89134

@@ -98,8 +143,8 @@ class EditPermissionsDialog extends Page {
98143
//Select a menu item: Custom, Can Write, Can Read....
99144
return await this.clickOnElement(menuItemXpath);
100145
} 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);
103148
}
104149
}
105150

@@ -112,8 +157,8 @@ class EditPermissionsDialog extends Page {
112157
await this.waitForElementDisplayed(selector, appConst.shortTimeout);
113158
return await this.clickOnElement(selector);
114159
} 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);
117162
}
118163
}
119164

@@ -123,17 +168,31 @@ class EditPermissionsDialog extends Page {
123168
await this.clickOnElement(this.applyButton);
124169
return await this.pause(500);
125170
} 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);
128173
}
129174
}
130175

131176
waitForApplyButtonEnabled() {
132-
return this.waitForElementEnabled(this.cancelButton, appConst.mediumTimeout);
177+
return this.waitForElementEnabled(this.applyButton, appConst.mediumTimeout);
133178
}
134179

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+
}
137196
}
138197

139198
async isOperationAllowed(principalName, operation) {
@@ -163,25 +222,6 @@ class EditPermissionsDialog extends Page {
163222
}
164223
}
165224

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-
185225
async waitForAccessSelectorDisabled(principalName) {
186226
let locator = xpath.aclEntryByDisplayName(principalName) + xpath.accessSelector;
187227
await this.getBrowser().waitUntil(async () => {

0 commit comments

Comments
 (0)