Skip to content

Commit f1557ec

Browse files
renemadsenclaude
andcommitted
fix: use Playwright click({force:true}) for mat-checkbox trusted events
Non-trusted events (evaluate/dispatchEvent) don't trigger Angular Material MDC change detection. Playwright's click({force:true}) fires trusted events while bypassing visibility checks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cd63fc8 commit f1557ec

2 files changed

Lines changed: 10 additions & 37 deletions

File tree

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

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,16 @@ export class PairingRowObject {
142142
clickCancel = false
143143
) {
144144
if (clickOnPairRow) {
145-
await this.pairRowForClick.evaluate((el: HTMLElement) => {
146-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
147-
if (input) input.click();
148-
});
145+
await this.pairRowForClick.click({ force: true });
149146
await this.page.waitForTimeout(500);
150147
if ((await this.pairRow.locator('input').isChecked()) !== pair) {
151-
await this.pairRowForClick.evaluate((el: HTMLElement) => {
152-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
153-
if (input) input.click();
154-
});
148+
await this.pairRowForClick.click({ force: true });
155149
await this.page.waitForTimeout(500);
156150
}
157151
} else {
158152
for (let i = 0; i < this.pairCheckboxesForClick.length; i++) {
159153
if ((await this.pairCheckboxes[i].locator('input').isChecked()) !== pair) {
160-
await this.pairCheckboxesForClick[i].evaluate((el: HTMLElement) => {
161-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
162-
if (input) input.click();
163-
});
154+
await this.pairCheckboxesForClick[i].click({ force: true });
164155
await this.page.waitForTimeout(500);
165156
}
166157
}
@@ -173,10 +164,7 @@ export class PairingRowObject {
173164
indexDeviceForPair: number,
174165
clickCancel = false
175166
) {
176-
await this.pairCheckboxesForClick[indexDeviceForPair].evaluate((el: HTMLElement) => {
177-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
178-
if (input) input.click();
179-
});
167+
await this.pairCheckboxesForClick[indexDeviceForPair].click({ force: true });
180168
await this.page.waitForTimeout(1000);
181169
await this.pairingPage.savePairing(clickCancel);
182170
}
@@ -228,25 +216,16 @@ export class PairingColObject {
228216
clickCancel = false
229217
) {
230218
if (clickOnPairRow) {
231-
await this.pairColForClick.evaluate((el: HTMLElement) => {
232-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
233-
if (input) input.click();
234-
});
219+
await this.pairColForClick.click({ force: true });
235220
await this.page.waitForTimeout(500);
236221
if ((await this.pairCol.locator('input').isChecked()) !== pair) {
237-
await this.pairColForClick.evaluate((el: HTMLElement) => {
238-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
239-
if (input) input.click();
240-
});
222+
await this.pairColForClick.click({ force: true });
241223
await this.page.waitForTimeout(500);
242224
}
243225
} else {
244226
for (let i = 0; i < this.pairCheckboxesForClick.length; i++) {
245227
if ((await this.pairCheckboxes[i].locator('input').isChecked()) !== pair) {
246-
await this.pairCheckboxesForClick[i].evaluate((el: HTMLElement) => {
247-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
248-
if (input) input.click();
249-
});
228+
await this.pairCheckboxesForClick[i].click({ force: true });
250229
await this.page.waitForTimeout(500);
251230
}
252231
}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,8 @@ export class ItemsPlanningPlanningPage extends PageWithNavbarPage {
211211

212212
async selectAllPlanningsForDelete(valueCheckbox = true, pickOne = false) {
213213
if (!pickOne) {
214-
// Click the native input inside mat-checkbox — triggers Angular Material's _handleInputClick
215-
await this.selectAllPlanningsCheckbox.evaluate((el: HTMLElement) => {
216-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
217-
if (input) input.click();
218-
});
214+
// Use force:true to fire a trusted click on the mat-checkbox even if visually hidden
215+
await this.selectAllPlanningsCheckbox.click({ force: true });
219216
await this.page.waitForTimeout(1000);
220217
} else {
221218
const plannings = await this.getAllPlannings(0, false);
@@ -455,10 +452,7 @@ export class PlanningRowObject {
455452
async clickOnCheckboxForMultipleDelete(valueCheckbox = true) {
456453
const isChecked = await this.checkboxDelete.locator('input').isChecked().catch(() => false);
457454
if (isChecked !== valueCheckbox) {
458-
await this.checkboxDelete.evaluate((el: HTMLElement) => {
459-
const input = el.querySelector('input[type="checkbox"]') as HTMLInputElement;
460-
if (input) input.click();
461-
});
455+
await this.checkboxDelete.click({ force: true });
462456
await this.page.waitForTimeout(500);
463457
}
464458
}

0 commit comments

Comments
 (0)