From 90a47b24416f75929ff83e30d0d1e43ff03c16c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= <crazyserver@gmail.com> Date: Tue, 9 Jan 2024 14:38:17 +0100 Subject: [PATCH] MOBILE-3947 behat: Fix ion-toggle press --- .../messages/tests/behat/basic_usage.feature | 1 - .../core-context-menu-popover.html | 21 ++++++++++++------- src/testing/services/behat-dom.ts | 4 +++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/addons/messages/tests/behat/basic_usage.feature b/src/addons/messages/tests/behat/basic_usage.feature index b09b72646..eb3621b0f 100755 --- a/src/addons/messages/tests/behat/basic_usage.feature +++ b/src/addons/messages/tests/behat/basic_usage.feature @@ -346,7 +346,6 @@ Feature: Test basic usage of messages in app Then I should find "test message" in the app And I should find "Muted conversation" in the app - @ionic7_failure Scenario: Self conversations Given I entered the app as "student1" When I press "Messages" in the app diff --git a/src/core/components/context-menu/core-context-menu-popover.html b/src/core/components/context-menu/core-context-menu-popover.html index 1e2accd45..9e844194a 100644 --- a/src/core/components/context-menu/core-context-menu-popover.html +++ b/src/core/components/context-menu/core-context-menu-popover.html @@ -7,17 +7,22 @@ [href]="item.href" (click)="itemClicked($event, item)" [attr.aria-label]="item.ariaAction" [hidden]="item.hidden" [detail]="!!(item.href && !item.iconAction)" role="menuitem" [button]="!!(item.href && !item.iconAction)" [showBrowserWarning]="item.showBrowserWarning"> - <ion-label> + <ion-toggle *ngIf="item.iconAction === 'toggle'" [(ngModel)]="item.toggle" (ionChange)="item.toggleChanged($event)"> <p class="item-heading"> <core-format-text [clean]="true" [text]="item.content" [filter]="false" /> </p> - </ion-label> - <ng-container *ngIf="(item.href || item.action) && item.iconAction"> - <ion-icon *ngIf="item.iconAction !== 'spinner' && item.iconAction !== 'toggle'" [name]="item.iconAction" - [class.icon-slash]="item.iconSlash" slot="end" aria-hidden="true" /> - <ion-spinner *ngIf="item.iconAction === 'spinner'" slot="end" [attr.aria-label]="'core.loading' | translate" /> - <ion-toggle *ngIf="item.iconAction === 'toggle'" [(ngModel)]="item.toggle" (ionChange)="item.toggleChanged($event)" - slot="end" /> + </ion-toggle> + <ng-container *ngIf="item.iconAction !== 'toggle'"> + <ion-label> + <p class="item-heading"> + <core-format-text [clean]="true" [text]="item.content" [filter]="false" /> + </p> + </ion-label> + <ng-container *ngIf="(item.href || item.action) && item.iconAction"> + <ion-icon *ngIf="item.iconAction !== 'spinner'" [name]="item.iconAction" [class.icon-slash]="item.iconSlash" slot="end" + aria-hidden="true" /> + <ion-spinner *ngIf="item.iconAction === 'spinner'" slot="end" [attr.aria-label]="'core.loading' | translate" /> + </ng-container> </ng-container> <ion-badge class="{{item.badgeClass}}" slot="end" *ngIf="item.badge"> <span [attr.ara-hidden]="!!item.badgeA11yText">{{item.badge}}</span> diff --git a/src/testing/services/behat-dom.ts b/src/testing/services/behat-dom.ts index 7d988d3ab..a7fb274f1 100644 --- a/src/testing/services/behat-dom.ts +++ b/src/testing/services/behat-dom.ts @@ -612,8 +612,10 @@ export class TestingBehatDomUtilsService { // may not work without doing this. const parentElement = this.getParentElement(element); - if (parentElement && parentElement.matches('ion-button, ion-back-button')) { + if (parentElement?.matches('ion-button, ion-back-button')) { element = parentElement; + } else if (parentElement?.tagName === 'ION-ITEM' && parentElement?.classList.contains('clickable')) { + element = parentElement.querySelector<HTMLElement>('ion-toggle') || element; } const rect = await this.ensureElementVisible(element);