-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroles.js
95 lines (91 loc) · 2.62 KB
/
roles.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const common = require("./common");
var faker = require('faker');
const addNewRoleBtn =
"#roles-container > div > div > div > div.dnn-persona-bar-page-header > div > button";
const newRolePanel = {
path: "div.role-details-editor",
mainDiv: {
path: " > div.dnn-grid-system",
leftColumn: {
path: " > div:nth-child(1) > div.editor-container",
roleName: " > div:nth-child(1) input[type='text']",
description: " > div:nth-child(2) textarea",
status: " > div:nth-child(3) div.dnn-dropdown",
public: " > div:nth-child(4) span.dnn-switch"
},
rightColumn: {
path: " > div:nth-child(2) > div.editor-container",
roleGroup: " > div:nth-child(1) div.dnn-dropdown",
securityMode: " > div:nth-child(2) div.dnn-dropdown",
rsvpCode: " > div:nth-child(3) input[type='text']",
autoAssign: " > div:nth-child(5) span.dnn-switch"
}
},
buttons: {
path: " div.buttons-box",
cancel: " button[role='secondary']",
save: " button[role='primary']"
}
};
exports.addRole = async function(
page,
roleName,
description,
status,
publicRole,
roleGroup,
securityMode,
rsvpCode,
autoAssign
) {
const frames = await page.frames();
const personaBar = frames.find(f => f.name() === "personaBar-iframe");
if (personaBar) {
await personaBar.click(addNewRoleBtn);
await personaBar.waitForSelector(newRolePanel.path);
await personaBar.click(newRolePanel.getPath("roleName"));
await page.keyboard.type(roleName);
if (description) {
await personaBar.click(newRolePanel.getPath("description"));
await page.keyboard.type(description);
}
if (status) {
await common.dropdownSelect(
personaBar,
newRolePanel.getPath("status"),
status
);
}
if (publicRole) {
await personaBar.click(newRolePanel.getPath("public"));
}
if (roleGroup) {
await common.dropdownSelect(
personaBar,
newRolePanel.getPath("roleGroup"),
roleGroup
);
}
if (securityMode) {
await common.dropdownSelect(
personaBar,
newRolePanel.getPath("securityMode"),
securityMode
);
}
if (rsvpCode) {
await personaBar.click(newRolePanel.getPath("rsvpCode"));
await page.keyboard.type(rsvpCode);
}
if (autoAssign) {
await personaBar.click(newRolePanel.getPath("autoAssign"));
}
await personaBar.click(newRolePanel.getPath("save"));
await page.waitFor(5000);
}
};
exports.addRandomRole = async function(page) {
var roleName = faker.company.bs;
await this.addRole(page, roleName, "Random role");
return roleName;
};