Skip to content

Commit 21eed0d

Browse files
committed
MUI upgrade e2e test fixes for basic cash transfer tests
And similar fixes are applied to grievance and payment tests
1 parent a18b320 commit 21eed0d

11 files changed

Lines changed: 111 additions & 79 deletions

cypress/e2e/cash-transfer.cy.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe('Cash transfer program update workflows', () => {
111111

112112
cy.enterMuiInput('Description', updatedDescription, 'textarea')
113113

114-
cy.get('[title="Save changes"] button').click()
114+
cy.get('[aria-label="Save changes"] button').click()
115115

116116
cy.checkProgramUpdateCompleted()
117117

@@ -220,7 +220,7 @@ describe('Cash transfer program update workflows', () => {
220220

221221
cy.contains('h2', 'Assign Active Beneficiaries')
222222
cy.contains('h6', '0 active beneficiaries selected')
223-
cy.get('[role="dialog"] [title="Previous Page"]')
223+
cy.get('[role="dialog"] [aria-label="Previous Page"]')
224224
.next('span')
225225
.invoke('text')
226226
.then((text) => {
@@ -232,13 +232,13 @@ describe('Cash transfer program update workflows', () => {
232232
// filter beneficiaries by number of children
233233
cy.contains('[role="dialog"] button', '=').trigger('mouseover');
234234
cy.contains('li', '<').click();
235-
cy.get('[role="dialog"] input[type="number"]').clear().type('5');
235+
cy.get('[role="dialog"] input[type="number"]').first().clear({force: true}).type('5', {force: true});
236236

237237
cy.get('[role="progressbar"]').should('exist')
238238
cy.get('[role="progressbar"]').should('not.exist')
239239

240240
cy.get('@numCandidates').then((prevTotal) => {
241-
cy.get('[role="dialog"] [title="Previous Page"]')
241+
cy.get('[role="dialog"] [aria-label="Previous Page"]')
242242
.next('span')
243243
.invoke('text')
244244
.then((text) => {
@@ -249,7 +249,7 @@ describe('Cash transfer program update workflows', () => {
249249
});
250250

251251
// assign all matching beneficiaries from the first page
252-
cy.get('th input[type="checkbox"]').check()
252+
cy.get('[role="dialog"] th input[type="checkbox"]').first().check({force: true})
253253
cy.contains('h6', '0 active beneficiaries selected').should('not.exist')
254254
cy.get('[role="dialog"] h6')
255255
.invoke('text')
@@ -287,7 +287,7 @@ describe('Cash transfer program update workflows', () => {
287287
.type('Ter')
288288
cy.wait(500) // give the filter results to settle down
289289
cy.get('@assignedProjectBeneficiaries').then((assignedProjectBeneficiaries) => {
290-
cy.get('[title="Previous Page"]')
290+
cy.get('[aria-label="Previous Page"]')
291291
.next('span')
292292
.invoke('text')
293293
.then((text) => {
@@ -320,11 +320,11 @@ describe('Cash transfer program update workflows', () => {
320320
const workingDaysUpdated = "10"
321321
cy.enterMuiInput('Working Days', workingDaysUpdated)
322322

323-
cy.get('[title="Save"] button').click()
323+
cy.get('[aria-label="Save"] button').click()
324324

325325
// Wait for update to complete
326-
cy.get('ul.MuiList-root li div[role="progressbar"]').should('exist')
327-
cy.get('ul.MuiList-root li div[role="progressbar"]').should('not.exist')
326+
cy.get('ul.MuiList-root li [role="progressbar"]').should('exist')
327+
cy.get('ul.MuiList-root li [role="progressbar"]').should('not.exist')
328328

329329
// Check last journal message
330330
cy.get('ul.MuiList-root li').first().click()
@@ -356,7 +356,7 @@ describe('Cash transfer program update workflows', () => {
356356

357357
cy.contains('td', name)
358358
.parent('tr').within(() => {
359-
cy.get('button[title="Edit"]').click({force: true});
359+
cy.get('button[aria-label="Edit"]').click({force: true});
360360
})
361361

362362
cy.assertMuiInputDisabled('Name', name)
@@ -367,12 +367,12 @@ describe('Cash transfer program update workflows', () => {
367367
cy.assertMuiInputDisabled('Status')
368368
cy.assertMuiInputDisabled('Program')
369369

370-
cy.get('button[title="Undo Delete"]').click()
370+
cy.get('button[aria-label="Undo Delete"]').click()
371371
cy.contains('button', 'Ok').click();
372372

373373
// Wait for undo to complete
374-
cy.get('ul.MuiList-root li div[role="progressbar"]').should('exist')
375-
cy.get('ul.MuiList-root li div[role="progressbar"]').should('not.exist')
374+
cy.get('ul.MuiList-root li [role="progressbar"]').should('exist')
375+
cy.get('ul.MuiList-root li [role="progressbar"]').should('not.exist')
376376

377377
// Check last journal message
378378
cy.get('ul.MuiList-root li').first().click()
@@ -427,7 +427,7 @@ describe('Cash transfer program update workflows', () => {
427427

428428
cy.enterMuiInput('Description', updatedDescription, 'textarea')
429429

430-
cy.get('[title="Save changes"] button').click()
430+
cy.get('[aria-label="Save changes"] button').click()
431431

432432
cy.checkProgramUpdateCompleted()
433433

@@ -557,7 +557,9 @@ describe('Cash transfer program update workflows', () => {
557557

558558
cy.contains('h2', 'Assign Active Beneficiaries')
559559
cy.contains('h6', '0 active beneficiaries selected')
560-
cy.get('[role="dialog"] [title="Previous Page"]')
560+
561+
// Verify there are candidates to assign
562+
cy.get('[role="dialog"] [aria-label="Previous Page"]')
561563
.next('span')
562564
.invoke('text')
563565
.then((text) => {
@@ -644,11 +646,11 @@ describe('Cash transfer program update workflows', () => {
644646
const workingDaysUpdated = "10"
645647
cy.enterMuiInput('Working Days', workingDaysUpdated)
646648

647-
cy.get('[title="Save"] button').click()
649+
cy.get('[aria-label="Save"] button').click()
648650

649651
// Wait for update to complete
650-
cy.get('ul.MuiList-root li div[role="progressbar"]').should('exist')
651-
cy.get('ul.MuiList-root li div[role="progressbar"]').should('not.exist')
652+
cy.get('ul.MuiList-root li [role="progressbar"]').should('exist')
653+
cy.get('ul.MuiList-root li [role="progressbar"]').should('not.exist')
652654

653655
// Check last journal message
654656
cy.get('ul.MuiList-root li').first().click()
@@ -680,7 +682,7 @@ describe('Cash transfer program update workflows', () => {
680682

681683
cy.contains('td', name)
682684
.parent('tr').within(() => {
683-
cy.get('button[title="Edit"]').click({force: true});
685+
cy.get('button[aria-label="Edit"]').click({force: true});
684686
})
685687

686688
cy.assertMuiInputDisabled('Name', name)
@@ -691,12 +693,12 @@ describe('Cash transfer program update workflows', () => {
691693
cy.assertMuiInputDisabled('Status')
692694
cy.assertMuiInputDisabled('Program')
693695

694-
cy.get('button[title="Undo Delete"]').click()
696+
cy.get('button[aria-label="Undo Delete"]').click()
695697
cy.contains('button', 'Ok').click();
696698

697699
// Wait for undo to complete
698-
cy.get('ul.MuiList-root li div[role="progressbar"]').should('exist')
699-
cy.get('ul.MuiList-root li div[role="progressbar"]').should('not.exist')
700+
cy.get('ul.MuiList-root li [role="progressbar"]').should('exist')
701+
cy.get('ul.MuiList-root li [role="progressbar"]').should('not.exist')
700702

701703
// Check last journal message
702704
cy.get('ul.MuiList-root li').first().click()

cypress/e2e/grievance.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,9 @@ describe('Grievance module workflows', () => {
545545
cy.visit('/front/ticket/tickets');
546546
cy.contains('tfoot', 'Rows Per Page').should('be.visible');
547547

548-
cy.get('[title="Add Grievance"] button').should('exist');
548+
cy.get('[aria-label="Add Grievance"] button').should('exist');
549549

550-
cy.get('[title="Add Grievance"] button').click();
550+
cy.get('[aria-label="Add Grievance"] button').click();
551551
cy.url().should('include', '/front/ticket/ticket');
552552
});
553553
});

cypress/e2e/payment-point.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ describe('Payment point workflows', () => {
161161

162162
cy.contains('label', 'District')
163163
.siblings('.MuiInputBase-root')
164-
.find('[role="button"]')
164+
.find('[role="combobox"], [role="button"]')
165165
.click();
166166
cy.get('[role="listbox"] li', { timeout: TIMEOUTS.BACKEND_VALIDATION })
167167
.should('have.length.at.least', 1);

cypress/support/commands/form.commands.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export function registerFormCommands() {
1717
// Wait for the journal-progress indicator to appear and then disappear.
1818
// This is the "async mutation finished" signal used throughout the app.
1919
Cypress.Commands.add('waitForJournalProgress', () => {
20-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: TIMEOUTS.BACKEND_VALIDATION })
20+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: TIMEOUTS.BACKEND_VALIDATION })
2121
.should('exist');
22-
cy.get('ul.MuiList-root li div[role="progressbar"]').should('not.exist');
22+
cy.get('ul.MuiList-root li [role="progressbar"]').should('not.exist');
2323
});
2424

2525
// Open the journal drawer (if not already open) and assert its first entry.
@@ -35,7 +35,7 @@ export function registerFormCommands() {
3535
});
3636

3737
Cypress.Commands.add('clickCreate', (createTitle = 'Create') => {
38-
cy.get(`[title="${createTitle}"] button`, { timeout: TIMEOUTS.BACKEND_VALIDATION })
38+
cy.get(`[aria-label="${createTitle}"] button`, { timeout: TIMEOUTS.BACKEND_VALIDATION })
3939
.should('not.be.disabled')
4040
.click();
4141
});
@@ -46,14 +46,14 @@ export function registerFormCommands() {
4646
Cypress.Commands.add('clickSave', (saveTitle) => {
4747
const titles = saveTitle ? [saveTitle] : KNOWN_SAVE_TITLES;
4848
cy.get('body', { timeout: TIMEOUTS.BACKEND_VALIDATION }).should(($body) => {
49-
const hit = titles.find((t) => $body.find(`[title="${t}"] button`).length);
49+
const hit = titles.find((t) => $body.find(`[aria-label="${t}"] button`).length);
5050
expect(
5151
hit,
5252
`clickSave: no Save FAB found with any known title (${titles.join(', ')})`,
5353
).to.exist;
5454
}).then(($body) => {
55-
const hit = titles.find((t) => $body.find(`[title="${t}"] button`).length);
56-
cy.get(`[title="${hit}"] button`, { timeout: TIMEOUTS.BACKEND_VALIDATION })
55+
const hit = titles.find((t) => $body.find(`[aria-label="${t}"] button`).length);
56+
cy.get(`[aria-label="${hit}"] button`, { timeout: TIMEOUTS.BACKEND_VALIDATION })
5757
.should('not.be.disabled')
5858
.click();
5959
});
@@ -62,7 +62,7 @@ export function registerFormCommands() {
6262
// Click the Save FAB and wait for the async journal to finish.
6363
//
6464
// Options:
65-
// saveTitle — exact `[title="..."]` of the Save FAB. When omitted
65+
// saveTitle — exact `[aria-label="..."]` of the Save FAB. When omitted
6666
// the helper tries KNOWN_SAVE_TITLES in order.
6767
// mutationLabel — if set, asserts the first journal entry contains this text
6868
// assertNoFail — if set, asserts the first journal entry doesn't start with 'Failed to'
@@ -86,14 +86,14 @@ export function registerFormCommands() {
8686
Cypress.Commands.add('assertSave', (enabled = true, tooltipText) => {
8787
const titles = tooltipText ? [tooltipText] : KNOWN_SAVE_TITLES;
8888
cy.get('body').then(($body) => {
89-
const hit = titles.find((t) => $body.find(`[title="${t}"] button`).length);
89+
const hit = titles.find((t) => $body.find(`[aria-label="${t}"] button`).length);
9090
if (!hit) {
9191
throw new Error(
9292
`assertSave: no Save FAB found with any known title (${titles.join(', ')})`,
9393
);
9494
}
9595
const assertion = enabled ? 'not.be.disabled' : 'be.disabled';
96-
cy.get(`[title="${hit}"] button`).should(assertion);
96+
cy.get(`[aria-label="${hit}"] button`).should(assertion);
9797
});
9898
});
9999

cypress/support/commands/grievance.commands.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export function registerGrievanceCommands() {
7373
cy.get('label[role="button"].MuiIconButton-colorPrimary').click();
7474

7575
// Wait for creation to complete
76-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('exist');
77-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('not.exist');
76+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('exist');
77+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('not.exist');
7878

7979
// Check journal for success
8080
cy.get('ul.MuiList-root li').first().click();
@@ -95,7 +95,7 @@ export function registerGrievanceCommands() {
9595
cy.contains('td', grievanceCode)
9696
.parent('tr')
9797
.within(() => {
98-
cy.get('button[title="Edit"]').click();
98+
cy.get('button[aria-label="Edit"]').click();
9999
});
100100

101101
if (immutableFields.reporterType) {
@@ -145,8 +145,8 @@ export function registerGrievanceCommands() {
145145
cy.get('label[role="button"].MuiIconButton-colorPrimary').click();
146146

147147
// Wait for update to complete
148-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('exist');
149-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('not.exist');
148+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('exist');
149+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('not.exist');
150150

151151
// Check journal for success
152152
cy.get('ul.MuiList-root li').first().click();
@@ -159,11 +159,11 @@ export function registerGrievanceCommands() {
159159
cy.addGrievanceComment(comment);
160160

161161
// Click the tick mark icon on the first/latest comment to resolve
162-
cy.get('button[title="Resolve grievance with this comment."]').first().click();
162+
cy.get('button[aria-label="Resolve grievance with this comment."]').first().click();
163163

164164
// Wait for resolve to complete
165-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('exist');
166-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('not.exist');
165+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('exist');
166+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('not.exist');
167167

168168
// Check journal for success
169169
cy.get('ul.MuiList-root li').first().click();
@@ -177,8 +177,8 @@ export function registerGrievanceCommands() {
177177
// Click the unlock icon (lock icon in header action area)
178178
cy.get('div[class*="paperHeaderAction"] button.MuiIconButton-root').click();
179179

180-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('exist');
181-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('not.exist');
180+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('exist');
181+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('not.exist');
182182

183183
cy.get('ul.MuiList-root li').first().click();
184184
cy.contains('Failed').should('not.exist');
@@ -240,7 +240,7 @@ export function registerGrievanceCommands() {
240240
cy.contains('td', grievanceCode)
241241
.parent('tr')
242242
.within(() => {
243-
cy.get('button[title="Edit"]').click();
243+
cy.get('button[aria-label="Edit"]').click();
244244
});
245245
});
246246

@@ -295,8 +295,8 @@ export function registerGrievanceCommands() {
295295
cy.contains('button', 'Save').click();
296296

297297
// Wait for save mutation to complete before reloading
298-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('exist');
299-
cy.get('ul.MuiList-root li div[role="progressbar"]', { timeout: 15000 }).should('not.exist');
298+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('exist');
299+
cy.get('ul.MuiList-root li [role="progressbar"]', { timeout: 15000 }).should('not.exist');
300300

301301
cy.contains(commentText).should('exist');
302302
});

cypress/support/commands/payments/payment-cycle.commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function registerPaymentCycleCommands() {
5757
Cypress.Commands.add('savePaymentCycle', () => {
5858
cy.contains('label', 'Status')
5959
.siblings('.MuiInputBase-root')
60-
.find('[role="button"]')
60+
.find('[role="combobox"], [role="button"]')
6161
.invoke('text')
6262
.then((statusText) => {
6363
const expectDialog = statusText.trim().toUpperCase() === 'ACTIVE';

cypress/support/commands/payments/payment-plan.commands.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ function fillCriterionRow(index, { field, filter, value, amount }) {
2525
.should('have.length.at.least', index + 1)
2626
.eq(index)
2727
.siblings('.MuiInputBase-root')
28-
.find('[role="button"]')
28+
.find('[role="combobox"], [role="button"]')
2929
.click();
3030
cy.contains('[role="listbox"] li', field, { timeout: TIMEOUTS.BACKEND_VALIDATION }).click();
3131

3232
cy.get('label').filter(':contains("Confirm Filters")')
3333
.should('have.length.at.least', index + 1)
3434
.eq(index)
3535
.siblings('.MuiInputBase-root')
36-
.find('[role="button"]')
36+
.find('[role="combobox"], [role="button"]')
3737
.click();
3838
cy.contains('[role="listbox"] li', filter).click();
3939

0 commit comments

Comments
 (0)