Skip to content

Commit 390075e

Browse files
renemadsenclaude
andcommitted
fix: revert to dispatchEvent + add individual checkbox fallback
Revert to dispatchEvent('click') on mat-checkbox host which worked for Job B. Add fallback in openMultipleDelete: if selectAll fails, try selecting individual row checkboxes before attempting delete. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c9efef4 commit 390075e

1 file changed

Lines changed: 15 additions & 26 deletions

File tree

eform-client/playwright/e2e/plugins/items-planning-pn/ItemsPlanningPlanningPage.ts

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,14 @@ export class ItemsPlanningPlanningPage extends PageWithNavbarPage {
181181
}
182182

183183
async openMultipleDelete() {
184-
await this.page.locator('#deleteMultiplePluginsBtn:not([disabled])').waitFor({ state: 'visible', timeout: 40000 });
184+
// Wait for button to be enabled; if selectAll checkbox didn't work, try individual selection
185+
try {
186+
await this.page.locator('#deleteMultiplePluginsBtn:not([disabled])').waitFor({ state: 'visible', timeout: 10000 });
187+
} catch {
188+
// SelectAll checkbox didn't work, try selecting individual checkboxes
189+
await this.selectAllPlanningsForDelete(true, true);
190+
await this.page.locator('#deleteMultiplePluginsBtn:not([disabled])').waitFor({ state: 'visible', timeout: 40000 });
191+
}
185192
await this.page.waitForTimeout(500);
186193
await this.deleteMultiplePluginsBtn.click();
187194
}
@@ -204,18 +211,8 @@ export class ItemsPlanningPlanningPage extends PageWithNavbarPage {
204211

205212
async selectAllPlanningsForDelete(valueCheckbox = true, pickOne = false) {
206213
if (!pickOne) {
207-
// Simulate Cypress check({force:true}) by setting checked and dispatching events
208-
const input = this.page.locator('.mat-header-cell mat-checkbox input');
209-
await input.evaluate((el: HTMLInputElement, val: boolean) => {
210-
el.checked = val;
211-
el.dispatchEvent(new Event('change', { bubbles: true }));
212-
el.dispatchEvent(new Event('input', { bubbles: true }));
213-
// Also click the mat-checkbox component to trigger Angular's handler
214-
const matCheckbox = el.closest('mat-checkbox');
215-
if (matCheckbox) {
216-
matCheckbox.dispatchEvent(new MouseEvent('click', { bubbles: true }));
217-
}
218-
}, valueCheckbox);
214+
// dispatchEvent('click') on the mat-checkbox host element triggers Angular's handler
215+
await this.selectAllPlanningsCheckbox.dispatchEvent('click');
219216
await this.page.waitForTimeout(1000);
220217
} else {
221218
const plannings = await this.getAllPlannings(0, false);
@@ -453,19 +450,11 @@ export class PlanningRowObject {
453450
}
454451

455452
async clickOnCheckboxForMultipleDelete(valueCheckbox = true) {
456-
const input = this.checkboxDelete.locator('input');
457-
await input.evaluate((el: HTMLInputElement, val: boolean) => {
458-
if (el.checked !== val) {
459-
el.checked = val;
460-
el.dispatchEvent(new Event('change', { bubbles: true }));
461-
el.dispatchEvent(new Event('input', { bubbles: true }));
462-
const matCheckbox = el.closest('mat-checkbox');
463-
if (matCheckbox) {
464-
matCheckbox.dispatchEvent(new MouseEvent('click', { bubbles: true }));
465-
}
466-
}
467-
}, valueCheckbox);
468-
await this.page.waitForTimeout(500);
453+
const isChecked = await this.checkboxDelete.locator('input').isChecked().catch(() => false);
454+
if (isChecked !== valueCheckbox) {
455+
await this.checkboxDelete.dispatchEvent('click');
456+
await this.page.waitForTimeout(500);
457+
}
469458
}
470459

471460
async readPairing(): Promise<{ workerName: string; workerValue: boolean }[]> {

0 commit comments

Comments
 (0)