@@ -135,7 +135,18 @@ export class ItemsPlanningPlanningPage extends PageWithNavbarPage {
135135 public async clearTable ( deleteWithMultipleDelete : boolean = true ) {
136136 if ( deleteWithMultipleDelete ) {
137137 await this . selectAllPlanningsForDelete ( ) ;
138- await this . multipleDelete ( ) ;
138+ // Check if delete button is enabled (checkbox selection worked)
139+ const isDisabled = await this . deleteMultiplePluginsBtn . evaluate ( ( el : HTMLElement ) => el . hasAttribute ( 'disabled' ) ) ;
140+ if ( ! isDisabled ) {
141+ await this . multipleDelete ( ) ;
142+ } else {
143+ // Fallback to single delete if checkbox selection failed
144+ await this . page . waitForTimeout ( 2000 ) ;
145+ const rowCount = await this . rowNum ( ) ;
146+ for ( let i = 1 ; i <= rowCount ; i ++ ) {
147+ await ( await this . getFirstPlanningRowObject ( ) ) . delete ( ) ;
148+ }
149+ }
139150 } else {
140151 await this . page . waitForTimeout ( 2000 ) ;
141152 const rowCount = await this . rowNum ( ) ;
@@ -195,9 +206,26 @@ export class ItemsPlanningPlanningPage extends PageWithNavbarPage {
195206 if ( ! pickOne ) {
196207 const isChecked = await this . selectAllPlanningsCheckbox . locator ( 'input' ) . isChecked ( ) . catch ( ( ) => false ) ;
197208 if ( isChecked !== valueCheckbox ) {
198- // Use JavaScript click on the internal checkbox input to ensure Angular detects the change
199- await this . selectAllPlanningsCheckbox . locator ( 'input' ) . evaluate ( ( el : HTMLInputElement ) => el . click ( ) ) ;
200- await this . page . waitForTimeout ( 1000 ) ;
209+ // Try multiple click strategies for MDC mat-checkbox
210+ const checkbox = this . selectAllPlanningsCheckbox ;
211+ // Strategy: use Playwright's click with force on the label element
212+ const label = checkbox . locator ( 'label' ) ;
213+ if ( ( await label . count ( ) ) > 0 ) {
214+ await label . click ( { force : true } ) ;
215+ } else {
216+ await checkbox . click ( { force : true } ) ;
217+ }
218+ await this . page . waitForTimeout ( 500 ) ;
219+ // Verify the click worked, if not try evaluate
220+ const nowChecked = await checkbox . locator ( 'input' ) . isChecked ( ) . catch ( ( ) => false ) ;
221+ if ( nowChecked === isChecked ) {
222+ // Click didn't register, try JS click on the native control
223+ await checkbox . evaluate ( ( el : HTMLElement ) => {
224+ const input = el . querySelector ( 'input[type="checkbox"]' ) as HTMLInputElement ;
225+ if ( input ) { input . click ( ) ; }
226+ } ) ;
227+ await this . page . waitForTimeout ( 500 ) ;
228+ }
201229 }
202230 } else {
203231 const plannings = await this . getAllPlannings ( 0 , false ) ;
@@ -437,8 +465,21 @@ export class PlanningRowObject {
437465 async clickOnCheckboxForMultipleDelete ( valueCheckbox = true ) {
438466 const isChecked = await this . checkboxDelete . locator ( 'input' ) . isChecked ( ) . catch ( ( ) => false ) ;
439467 if ( isChecked !== valueCheckbox ) {
440- await this . checkboxDelete . locator ( 'input' ) . evaluate ( ( el : HTMLInputElement ) => el . click ( ) ) ;
468+ const label = this . checkboxDelete . locator ( 'label' ) ;
469+ if ( ( await label . count ( ) ) > 0 ) {
470+ await label . click ( { force : true } ) ;
471+ } else {
472+ await this . checkboxDelete . click ( { force : true } ) ;
473+ }
441474 await this . page . waitForTimeout ( 500 ) ;
475+ const nowChecked = await this . checkboxDelete . locator ( 'input' ) . isChecked ( ) . catch ( ( ) => false ) ;
476+ if ( nowChecked === isChecked ) {
477+ await this . checkboxDelete . evaluate ( ( el : HTMLElement ) => {
478+ const input = el . querySelector ( 'input[type="checkbox"]' ) as HTMLInputElement ;
479+ if ( input ) { input . click ( ) ; }
480+ } ) ;
481+ await this . page . waitForTimeout ( 500 ) ;
482+ }
442483 }
443484 }
444485
0 commit comments