Skip to content

Commit fa59147

Browse files
authored
Merge pull request #7307 from microting/copilot/migrate-actions-menu-design
Migrate sites, workers, device-users, users, security-groups, and email-recipients to actions menu pattern
2 parents fc05c8a + e85f51c commit fa59147

File tree

21 files changed

+375
-180
lines changed

21 files changed

+375
-180
lines changed

eform-client/cypress/e2e/DeviceUsers.page.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ class DeviceUsersPage extends PageWithNavbarPage{
156156
name = '',
157157
surname = ''
158158
): void {
159-
deviceUser.editBtn().should('be.visible').click();
159+
const index = deviceUser.index - 1;
160+
deviceUser.openRowMenu();
161+
cy.get(`#editDeviceUserBtn${index}`).should('be.visible').click();
160162
// @ts-ignore
161163
cy.get('#firstName').should('be.visible');
162164
if (name !== '') {
@@ -178,6 +180,7 @@ const deviceUsersPage = new DeviceUsersPage();
178180
export default deviceUsersPage;
179181

180182
export class DeviceUsersRowObject {
183+
index: number;
181184
siteId: number;
182185
firstName: string;
183186
lastName: string;
@@ -187,6 +190,7 @@ export class DeviceUsersRowObject {
187190
deleteBtn: Cypress.Chainable<JQuery<HTMLElement>>;
188191

189192
getRow(rowNum: number) {
193+
this.index = rowNum;
190194
// @ts-ignore
191195
if (cy.get('#deviceUserId').eq(rowNum - 1).should('exist')) {
192196
// @ts-ignore
@@ -203,8 +207,16 @@ export class DeviceUsersRowObject {
203207
return this;
204208
}
205209

210+
openRowMenu() {
211+
const index = this.index - 1;
212+
cy.get(`#action-items-${index} #actionMenu`).should('be.visible').click();
213+
cy.wait(200);
214+
}
215+
206216
delete() {
207-
this.deleteBtn.should('be.visible').click();
217+
const index = this.index - 1;
218+
this.openRowMenu();
219+
cy.get(`#deleteDeviceUserBtn${index}`).should('be.visible').click();
208220
deviceUsersPage.saveDeleteBtn().should('be.visible').click();
209221
// @ts-ignore
210222
cy.get('#spinner-animation').should('not.exist', { timeout: 40000 });

eform-client/cypress/e2e/Sites.page.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export default sitesPage;
125125
export class SitesRowObject {
126126
constructor() {}
127127

128+
index: number;
128129
element: Cypress.Chainable<JQuery<HTMLElement>>;
129130
siteId: number;
130131
units: string;
@@ -134,6 +135,7 @@ export class SitesRowObject {
134135
deleteBtn: Cypress.Chainable<JQuery<HTMLElement>>;
135136

136137
getRow(rowNum): Promise<SitesRowObject> {
138+
this.index = rowNum;
137139
this.element = cy.get('tbody > tr').eq(rowNum - 1);
138140
if (this.element) {
139141
this.siteId = +(this.element.find('#siteUUId').invoke('text'));
@@ -146,6 +148,13 @@ export class SitesRowObject {
146148
}
147149
return this;
148150
}
151+
152+
openRowMenu() {
153+
const index = this.index - 1;
154+
cy.get(`#action-items-${index} #actionMenu`).should('be.visible').click();
155+
cy.wait(200);
156+
}
157+
149158
closeEditModal(clickCancel = false) {
150159
if (clickCancel) {
151160
sitesPage.siteEditCancelBtn().click();
@@ -156,22 +165,10 @@ export class SitesRowObject {
156165
sitesPage.sitesManageTagsBtn().should('be.visible', { timeout: 40000 });
157166
}
158167

159-
getRow(rowNum): Promise<SitesRowObject> {
160-
this.element = Cypress.$$('tbody > tr').eq(rowNum - 1);
161-
if (this.element) {
162-
this.siteId = +this.element.find('#siteUUId').text();
163-
this.units = this.element.find('#units').text();
164-
this.siteName = this.element.find('#siteName').text();
165-
const list = this.element.find('mat-chip-list mat-chip > span');
166-
this.tags = Promise.all(list.map((_, element) => Cypress.$(element).text()));
167-
this.editBtn = this.element.find('#editSiteBtn');
168-
this.deleteBtn = this.element.find('#deleteSiteBtn');
169-
}
170-
return this;
171-
}
172-
173168
openEditModal(site?: { name?: string; tags?: string[] }) {
174-
this.editBtn.click();
169+
const index = this.index - 1;
170+
this.openRowMenu();
171+
cy.get(`#editSiteBtn${index}`).should('be.visible').click();
175172
cy.wait(500);
176173
sitesPage.siteEditCancelBtn().should('be.visible', {timeout: 40000});
177174
if (site) {
@@ -196,7 +193,9 @@ export class SitesRowObject {
196193
}
197194

198195
openDeleteModal() {
199-
this.deleteBtn.click();
196+
const index = this.index - 1;
197+
this.openRowMenu();
198+
cy.get(`#deleteSiteBtn${index}`).should('be.visible').click();
200199
cy.wait(500);
201200
sitesPage.siteDeleteCancelBtn().should('be.visible', {timeout: 40000}).click();
202201
}

eform-client/cypress/e2e/UserAdministration.page.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const userAdministrationPage = new UserAdministrationPage();
170170
export default userAdministrationPage;
171171

172172
export class UserAdministrationRowObject {
173+
index: number;
173174
id: number;
174175
email: string;
175176
fullName: string;
@@ -178,6 +179,7 @@ export class UserAdministrationRowObject {
178179
deleteBtn: Cypress.Chainable<JQuery<HTMLElement>>;
179180

180181
getRow(rowNum: number) {
182+
this.index = rowNum;
181183
const index = rowNum - 1;
182184

183185
cy.get(`#userAdministrationId-${index}`).invoke('text').then(text => {
@@ -199,8 +201,16 @@ export class UserAdministrationRowObject {
199201
return this;
200202
}
201203

204+
openRowMenu() {
205+
const index = this.index - 1;
206+
cy.get(`#action-items-${index} #actionMenu`).should('be.visible').click();
207+
cy.wait(200);
208+
}
209+
202210
edit(user: UserAdministrationObject, clickCancel = false) {
203-
this.editBtn.should('be.visible').click();
211+
const index = this.index - 1;
212+
this.openRowMenu();
213+
cy.get(`#userAdministrationEditBtn-${index}`).should('be.visible').click();
204214
cy.get('#editFirstName').should('be.visible');
205215

206216
if (user.firstName) {
@@ -257,7 +267,9 @@ export class UserAdministrationRowObject {
257267
}
258268

259269
delete(clickCancel = false) {
260-
this.deleteBtn.should('be.visible').click();
270+
const index = this.index - 1;
271+
this.openRowMenu();
272+
cy.get(`#userAdministrationDeleteBtn-${index}`).should('be.visible').click();
261273
cy.get('#userDeleteCancelBtn').should('be.visible');
262274

263275
if (clickCancel) {

eform-client/cypress/e2e/Workers.page.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ class WorkersPage extends PageWithNavbarPage {
127127
firstName = '',
128128
lastName = ''
129129
): void {
130-
worker.editBtn().should('be.visible').click();
130+
const index = worker.index - 1;
131+
worker.openRowMenu();
132+
cy.get(`#workerEditBtn${index}`).should('be.visible').click();
131133
// @ts-ignore
132134
cy.get('#firstNameEdit').should('be.visible');
133135
if (firstName !== '') {
@@ -152,6 +154,7 @@ const workersPage = new WorkersPage();
152154
export default workersPage;
153155

154156
export class WorkersRowObject {
157+
index: number;
155158
siteId: number;
156159
firstName: string;
157160
lastName: string;
@@ -161,6 +164,7 @@ export class WorkersRowObject {
161164
deleteBtn: Cypress.Chainable<JQuery<HTMLElement>>;
162165

163166
getRow(rowNum: number) {
167+
this.index = rowNum;
164168
// @ts-ignore
165169
if (cy.get('#workerUID').eq(rowNum - 1).should('exist')) {
166170
// @ts-ignore
@@ -176,4 +180,10 @@ export class WorkersRowObject {
176180
}
177181
return this;
178182
}
183+
184+
openRowMenu() {
185+
const index = this.index - 1;
186+
cy.get(`#action-items-${index} #actionMenu`).should('be.visible').click();
187+
cy.wait(200);
188+
}
179189
}

eform-client/e2e/Page objects/DeviceUsers.page.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ class DeviceUsersPage extends PageWithNavbarPage {
139139
name = '',
140140
surname = ''
141141
) {
142-
deviceUser.editBtn.click();
142+
await deviceUser.openRowMenu();
143+
const index = deviceUser.index - 1;
144+
const editBtn = await $(`#editDeviceUserBtn${index}`);
145+
await editBtn.waitForDisplayed({ timeout: 5000 });
146+
await editBtn.waitForClickable({ timeout: 5000 });
147+
await editBtn.click();
143148
// browser.pause(5000);
144149
await (await $('#firstName')).waitForDisplayed({ timeout: 40000 });
145150
if (name != null) {
@@ -164,13 +169,15 @@ export default deviceUsersPage;
164169
export class DeviceUsersRowObject {
165170
constructor() {}
166171

172+
index: number;
167173
siteId: number;
168174
firstName: string;
169175
lastName: string;
170176
editBtn;
171177
deleteBtn;
172178

173179
async getRow(rowNum: number) {
180+
this.index = rowNum;
174181
if ((await $$('#deviceUserId'))[rowNum - 1]) {
175182
this.siteId = +(await (await $$('#deviceUserId')[rowNum - 1]).getText());
176183
try {
@@ -189,9 +196,23 @@ export class DeviceUsersRowObject {
189196
return this;
190197
}
191198

199+
async openRowMenu() {
200+
const index = this.index - 1;
201+
const menuBtn = await $(`#action-items-${index} #actionMenu`);
202+
await menuBtn.waitForDisplayed({ timeout: 5000 });
203+
await menuBtn.waitForClickable({ timeout: 5000 });
204+
await menuBtn.scrollIntoView();
205+
await menuBtn.click();
206+
await browser.pause(200);
207+
}
208+
192209
async delete() {
193-
this.deleteBtn.waitForClickable({ timeout: 40000 });
194-
this.deleteBtn.click();
210+
const index = this.index - 1;
211+
await this.openRowMenu();
212+
const deleteBtn = await $(`#deleteDeviceUserBtn${index}`);
213+
await deleteBtn.waitForDisplayed({ timeout: 5000 });
214+
await deleteBtn.waitForClickable({ timeout: 5000 });
215+
await deleteBtn.click();
195216
await (await deviceUsersPage.saveDeleteBtn()).waitForClickable({
196217
timeout: 40000,
197218
});

eform-client/e2e/Page objects/Sites.page.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export default sitesPage;
139139
export class SitesRowObject {
140140
constructor() {}
141141

142+
index: number;
142143
element: WebdriverIO.Element;
143144
siteId: number;
144145
units: string;
@@ -148,6 +149,7 @@ export class SitesRowObject {
148149
deleteBtn: WebdriverIO.Element;
149150

150151
async getRow(rowNum): Promise<SitesRowObject> {
152+
this.index = rowNum;
151153
this.element = (await $$('tbody > tr'))[rowNum - 1];
152154
if (this.element) {
153155
this.siteId = +(await this.element.$('#siteUUId')).getText();
@@ -173,8 +175,23 @@ export class SitesRowObject {
173175
return this;
174176
}
175177

178+
async openRowMenu() {
179+
const index = this.index - 1;
180+
const menuBtn = await $(`#action-items-${index} #actionMenu`);
181+
await menuBtn.waitForDisplayed({ timeout: 5000 });
182+
await menuBtn.waitForClickable({ timeout: 5000 });
183+
await menuBtn.scrollIntoView();
184+
await menuBtn.click();
185+
await browser.pause(200);
186+
}
187+
176188
async openEditModal(site?: { name?: string; tags?: string[] }) {
177-
this.editBtn.click();
189+
await this.openRowMenu();
190+
const index = this.index - 1;
191+
const editBtn = await $(`#editSiteBtn${index}`);
192+
await editBtn.waitForDisplayed({ timeout: 5000 });
193+
await editBtn.waitForClickable({ timeout: 5000 });
194+
await editBtn.click();
178195
await browser.pause(500);
179196
await (await sitesPage.siteEditCancelBtn()).waitForDisplayed({ timeout: 40000 });
180197
if (site) {
@@ -209,7 +226,12 @@ export class SitesRowObject {
209226
}
210227

211228
async openDeleteModal() {
212-
await this.deleteBtn.click();
229+
await this.openRowMenu();
230+
const index = this.index - 1;
231+
const deleteBtn = await $(`#deleteSiteBtn${index}`);
232+
await deleteBtn.waitForDisplayed({ timeout: 5000 });
233+
await deleteBtn.waitForClickable({ timeout: 5000 });
234+
await deleteBtn.click();
213235
await browser.pause(500);
214236
await (await sitesPage.siteDeleteCancelBtn()).waitForClickable({ timeout: 40000 });
215237
}

eform-client/e2e/Page objects/UserAdministration.page.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export default userAdministration;
196196
export class UserAdministrationRowObject {
197197
constructor() {}
198198

199+
index: number;
199200
element;
200201
id: number;
201202
email: string;
@@ -205,6 +206,7 @@ export class UserAdministrationRowObject {
205206
deleteBtn;
206207

207208
async getRow(rowNum: number): Promise<UserAdministrationRowObject> {
209+
this.index = rowNum;
208210
rowNum = rowNum - 1;
209211
this.id = +await (await $('#userAdministrationId-'+rowNum)).getText();
210212
this.email = await (await $('#userAdministrationEmail-'+rowNum)).getText();
@@ -215,8 +217,23 @@ export class UserAdministrationRowObject {
215217
return this;
216218
}
217219

220+
async openRowMenu() {
221+
const index = this.index - 1;
222+
const menuBtn = await $(`#action-items-${index} #actionMenu`);
223+
await menuBtn.waitForDisplayed({ timeout: 5000 });
224+
await menuBtn.waitForClickable({ timeout: 5000 });
225+
await menuBtn.scrollIntoView();
226+
await menuBtn.click();
227+
await browser.pause(200);
228+
}
229+
218230
public async openEdit(user: UserAdministrationObject) {
219-
await this.editBtn.click();
231+
await this.openRowMenu();
232+
const index = this.index - 1;
233+
const editBtn = await $(`#userAdministrationEditBtn-${index}`);
234+
await editBtn.waitForDisplayed({ timeout: 5000 });
235+
await editBtn.waitForClickable({ timeout: 5000 });
236+
await editBtn.click();
220237
await (await userAdministration.editFirstName()).waitForDisplayed({ timeout: 40000 });
221238
if (user.firstName) {
222239
await (await userAdministration.editFirstName()).clearValue();
@@ -278,7 +295,12 @@ export class UserAdministrationRowObject {
278295
}
279296

280297
public async openDelete() {
281-
await this.deleteBtn.click();
298+
await this.openRowMenu();
299+
const index = this.index - 1;
300+
const deleteBtn = await $(`#userAdministrationDeleteBtn-${index}`);
301+
await deleteBtn.waitForDisplayed({ timeout: 5000 });
302+
await deleteBtn.waitForClickable({ timeout: 5000 });
303+
await deleteBtn.click();
282304
await (await userAdministration.userDeleteCancelBtn()).waitForDisplayed({ timeout: 40000 });
283305
}
284306

0 commit comments

Comments
 (0)