-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMemberUiHelper.ts
156 lines (131 loc) · 5.27 KB
/
MemberUiHelper.ts
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import {Page, Locator, expect} from "@playwright/test";
import {UiBaseLocators} from "./UiBaseLocators";
import {ConstantHelper} from "./ConstantHelper";
export class MemberUiHelper extends UiBaseLocators {
private readonly membersTab: Locator;
private readonly searchTxt: Locator;
private readonly memberNameTxt: Locator;
private readonly commentsTxt: Locator;
private readonly memberTab: Locator;
private readonly detailsTab: Locator;
private readonly usernameTxt: Locator;
private readonly emailTxt: Locator;
private readonly passwordTxt: Locator;
private readonly confirmNewPasswordTxt: Locator;
private readonly approvedToggle: Locator;
private readonly lockedOutToggle: Locator;
private readonly twoFactorAuthenticationToggle: Locator;
private readonly memberInfoItems: Locator;
private readonly changePasswordBtn: Locator;
private readonly membersMenu: Locator;
private readonly infoTab: Locator;
constructor(page: Page) {
super(page);
this.membersTab = page.locator('uui-tab[label="Members"]');
this.searchTxt = page.locator('#input-search');
this.memberNameTxt = page.locator('#name-input #input');
this.commentsTxt = page.locator('umb-content-workspace-view-edit-tab').locator('umb-property').filter({hasText: 'Comments'}).locator('#textarea');
this.memberTab = page.locator('uui-tab').filter({hasText: 'Member'}).locator('svg');
this.detailsTab = page.locator('uui-tab').filter({hasText: 'Details'}).locator('svg');
this.usernameTxt = page.getByLabel('Username', {exact: true});
this.emailTxt = page.getByLabel('Email', {exact: true});
this.passwordTxt = page.getByLabel('Enter your new password', {exact: true});
this.confirmNewPasswordTxt = page.getByLabel('Confirm new password', {exact: true});
this.approvedToggle = page.locator('[label="Approved"] #toggle');
this.lockedOutToggle = page.locator('[label="Locked out"] #toggle');
this.twoFactorAuthenticationToggle = page.locator('[label="Two-Factor authentication"] #toggle');
this.memberInfoItems = page.locator('umb-stack > div');
this.changePasswordBtn = page.getByLabel('Change password', {exact: true});
this.membersMenu = page.locator('umb-menu').getByLabel('Members', {exact: true});
this.infoTab = page.locator('uui-tab').filter({hasText: 'Info'}).locator('svg');
}
async clickMembersTab() {
await this.membersTab.click();
}
async clickMemberTab() {
await expect(this.memberTab).toBeVisible();
await this.memberTab.click();
}
async clickDetailsTab() {
await expect(this.detailsTab).toBeVisible();
await this.detailsTab.click();
}
async clickMemberLinkByName(memberName: string) {
await this.page.getByRole('link', {name: memberName}).click();
}
async enterSearchKeyword(keyword: string) {
await expect(this.searchTxt).toBeVisible();
await this.searchTxt.clear();
await this.searchTxt.fill(keyword);
}
async enterMemberName(name: string) {
await expect(this.memberNameTxt).toBeVisible();
await this.memberNameTxt.clear();
await this.memberNameTxt.fill(name);
}
async enterComments(comment: string) {
await expect(this.commentsTxt).toBeVisible();
await this.commentsTxt.clear();
await this.commentsTxt.fill(comment);
}
async enterUsername(username: string) {
await expect(this.usernameTxt).toBeVisible();
await this.usernameTxt.clear();
await this.usernameTxt.fill(username);
}
async enterEmail(email: string) {
await expect(this.emailTxt).toBeVisible();
await this.emailTxt.clear();
await this.emailTxt.fill(email);
}
async enterPassword(password: string) {
await this.passwordTxt.clear();
await this.passwordTxt.fill(password);
}
async enterConfirmPassword(password: string) {
await this.confirmPasswordTxt.clear();
await this.confirmPasswordTxt.fill(password);
}
async enterConfirmNewPassword(password: string) {
await this.confirmNewPasswordTxt.clear();
await this.confirmNewPasswordTxt.fill(password);
}
async chooseMemberGroup(memberGroupName: string) {
await this.clickChooseButton();
await this.page.getByText(memberGroupName, {exact: true}).click();
await this.clickChooseContainerButton();
}
async doesMemberInfoHaveValue(infoName: string, value: string) {
return expect(this.memberInfoItems.filter({hasText: infoName}).locator('span')).toHaveText(value);
}
async clickApprovedToggle() {
await this.approvedToggle.click();
}
async clickLockedOutToggle() {
await this.lockedOutToggle.click();
}
async clickTwoFactorAuthenticationToggle() {
await this.twoFactorAuthenticationToggle.click();
}
async clickChangePasswordButton() {
await this.changePasswordBtn.click();
}
async clickRemoveMemberGroupByName(memberGroupName: string) {
await this.page.locator('[name="' + memberGroupName + '"]').getByLabel('Remove').click();
}
async enterNewPassword(password: string) {
await this.newPasswordTxt.clear();
await this.newPasswordTxt.fill(password);
}
async clickMembersMenu() {
await this.membersMenu.click();
}
async goToMembers() {
await this.goToSection(ConstantHelper.sections.members);
await this.clickMembersMenu();
}
async clickInfoTab() {
await expect(this.infoTab).toBeVisible();
await this.infoTab.click();
}
}