Skip to content

Commit b84cf5c

Browse files
committed
test(angular): adding more dedicated testing around swipe gesture property
1 parent f1d9d22 commit b84cf5c

File tree

7 files changed

+96
-16
lines changed

7 files changed

+96
-16
lines changed

packages/angular/test/base/e2e/src/lazy/routing.spec.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,6 @@ test.describe('Routing', () => {
1919
await expect(page.locator('app-router-link-page')).toHaveAttribute('class', 'ion-page can-go-back');
2020
});
2121

22-
test('should not swipe back when swipeGesture is false', async ({ page }) => {
23-
await page.locator('#routerLink').click();
24-
25-
await ionPageHidden(page, 'app-router-link');
26-
await ionPageVisible(page, 'app-router-link-page');
27-
28-
await page.locator('ion-router-outlet').evaluate((el: any) => {
29-
el.swipeGesture = false;
30-
});
31-
32-
await ionSwipeToGoBack(page, true);
33-
34-
await ionPageVisible(page, 'app-router-link-page');
35-
await ionPageHidden(page, 'app-router-link');
36-
});
37-
3822
test('should swipe and go back', async ({ page }) => {
3923
await page.locator('#routerLink').click();
4024

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { test } from '@playwright/test';
2+
import { ionSwipeToGoBack } from '../../utils/drag-utils';
3+
import { ionPageVisible, ionPageHidden } from '../../utils/test-utils';
4+
5+
test.describe('Swipe Gesture Disabled', () => {
6+
test.beforeEach(async ({ page }) => {
7+
await page.goto('/standalone/swipe-gesture-disabled?ionic:mode=ios');
8+
});
9+
10+
test('should not swipe back when swipeGesture is false', async ({ page }) => {
11+
await ionPageVisible(page, 'app-swipe-gesture-disabled-main');
12+
13+
await page.locator('#swipe-disabled-details').click();
14+
await ionPageVisible(page, 'app-swipe-gesture-disabled-details');
15+
await ionPageHidden(page, 'app-swipe-gesture-disabled-main');
16+
17+
await ionSwipeToGoBack(page, true);
18+
19+
await ionPageVisible(page, 'app-swipe-gesture-disabled-details');
20+
await ionPageHidden(page, 'app-swipe-gesture-disabled-main');
21+
});
22+
});

packages/angular/test/base/src/app/standalone/app-standalone/app.routes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ export const routes: Routes = [
5353
]
5454
},
5555
{ path: 'tabs-basic', loadComponent: () => import('../tabs-basic/tabs-basic.component').then(c => c.TabsBasicComponent) },
56+
{
57+
path: 'swipe-gesture-disabled',
58+
loadComponent: () => import('../swipe-gesture-disabled/swipe-gesture-disabled.component').then(c => c.SwipeGestureDisabledComponent),
59+
children: [
60+
{ path: '', loadComponent: () => import('../swipe-gesture-disabled/swipe-gesture-disabled-main.component').then(c => c.SwipeGestureDisabledMainComponent) },
61+
{ path: 'details', loadComponent: () => import('../swipe-gesture-disabled/swipe-gesture-disabled-details.component').then(c => c.SwipeGestureDisabledDetailsComponent) }
62+
]
63+
},
5664
{
5765
path: 'validation',
5866
children: [

packages/angular/test/base/src/app/standalone/home-page/home-page.component.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@
7474
Tabs Basic Test
7575
</ion-label>
7676
</ion-item>
77+
<ion-item routerLink="/standalone/swipe-gesture-disabled">
78+
<ion-label>
79+
Swipe Gesture Disabled Test
80+
</ion-label>
81+
</ion-item>
7782
</ion-list>
7883

7984
<ion-list>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Component } from '@angular/core';
2+
import { IonBackButton, IonButtons, IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/angular/standalone';
3+
4+
@Component({
5+
selector: 'app-swipe-gesture-disabled-details',
6+
template: `
7+
<ion-header>
8+
<ion-toolbar>
9+
<ion-buttons slot="start">
10+
<ion-back-button defaultHref="/standalone/swipe-gesture-disabled"></ion-back-button>
11+
</ion-buttons>
12+
<ion-title>Details</ion-title>
13+
</ion-toolbar>
14+
</ion-header>
15+
<ion-content>
16+
<div>Details (swipe disabled)</div>
17+
</ion-content>
18+
`,
19+
standalone: true,
20+
imports: [IonBackButton, IonButtons, IonContent, IonHeader, IonTitle, IonToolbar]
21+
})
22+
export class SwipeGestureDisabledDetailsComponent {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Component } from '@angular/core';
2+
import { RouterModule } from '@angular/router';
3+
import { IonContent, IonItem, IonLabel, IonRouterLink } from '@ionic/angular/standalone';
4+
5+
@Component({
6+
selector: 'app-swipe-gesture-disabled-main',
7+
template: `
8+
<ion-content>
9+
<ion-item routerLink="/standalone/swipe-gesture-disabled/details" id="swipe-disabled-details">
10+
<ion-label>Details</ion-label>
11+
</ion-item>
12+
</ion-content>
13+
`,
14+
standalone: true,
15+
imports: [IonContent, IonItem, IonLabel, IonRouterLink, RouterModule]
16+
})
17+
export class SwipeGestureDisabledMainComponent {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Component } from '@angular/core';
2+
import { IonBackButton, IonButtons, IonContent, IonHeader, IonRouterOutlet, IonTitle, IonToolbar } from '@ionic/angular/standalone';
3+
4+
@Component({
5+
selector: 'app-swipe-gesture-disabled',
6+
template: `
7+
<ion-header>
8+
<ion-toolbar>
9+
<ion-buttons slot="start">
10+
<ion-back-button defaultHref="/standalone"></ion-back-button>
11+
</ion-buttons>
12+
<ion-title>Swipe Gesture Disabled</ion-title>
13+
</ion-toolbar>
14+
</ion-header>
15+
<ion-content>
16+
<ion-router-outlet [swipeGesture]="false"></ion-router-outlet>
17+
</ion-content>
18+
`,
19+
standalone: true,
20+
imports: [IonBackButton, IonButtons, IonContent, IonHeader, IonRouterOutlet, IonTitle, IonToolbar]
21+
})
22+
export class SwipeGestureDisabledComponent {}

0 commit comments

Comments
 (0)