Skip to content

Commit 85f2372

Browse files
committed
test(react-router): add regression test for catch-all redirect with no ionPageElement
1 parent b166c89 commit 85f2372

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

packages/react-router/test/base/src/pages/redirect-params/RedirectParams.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* Verifies that useParams() returns correct values after a Navigate
3-
* (catch-all redirect) fires inside IonRouterOutlet.
4-
*/
5-
61
import {
72
IonTabs,
83
IonRouterOutlet,
@@ -23,11 +18,6 @@ import { Route, Navigate, useParams } from 'react-router-dom';
2318

2419
/**
2520
* Scenario 1: Tabs with catch-all Navigate redirect
26-
*
27-
* Structure:
28-
* /redirect-params/tabs → redirects to /redirect-params/tabs/tab2
29-
* /redirect-params/tabs/tab1/:id → Tab1 with param
30-
* /redirect-params/tabs/tab2 → Tab2
3121
*/
3222
const TabsWithRedirect: React.FC = () => {
3323
return (
@@ -88,11 +78,6 @@ const Tab2Page: React.FC = () => {
8878

8979
/**
9080
* Scenario 2: Flat outlet with catch-all Navigate redirect
91-
*
92-
* Structure:
93-
* /redirect-params/flat → redirects to /redirect-params/flat/home
94-
* /redirect-params/flat/home → Home page
95-
* /redirect-params/flat/details/:id → Details with param
9681
*/
9782
const FlatOutletWithRedirect: React.FC = () => {
9883
return (
@@ -120,6 +105,9 @@ const HomePage: React.FC = () => {
120105
<IonButton routerLink="/redirect-params/flat/details/99" id="go-to-details-99">
121106
Go to Details 99
122107
</IonButton>
108+
<IonButton routerLink="/redirect-params/flat/this-route-does-not-exist" id="go-to-non-existing">
109+
Go to Non-Existing Route
110+
</IonButton>
123111
</IonContent>
124112
</IonPage>
125113
);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { test, expect } from '@playwright/test';
2+
import { ionPageVisible, withTestingMode } from './utils/test-utils';
3+
4+
test.describe('Redirect Params', () => {
5+
6+
test.describe('Flat outlet with catch-all Navigate redirect', () => {
7+
8+
test('should redirect to home when navigating to a non-existing route covered by catch-all', async ({ page }, testInfo) => {
9+
testInfo.annotations.push({
10+
type: 'issue',
11+
description: 'https://github.com/ionic-team/ionic-framework/issues/30081',
12+
});
13+
14+
// 1. Navigate to flat outlet — catch-all redirects to /flat/home
15+
await page.goto(withTestingMode('/redirect-params/flat'));
16+
await ionPageVisible(page, 'home-page');
17+
await expect(page).toHaveURL(/\/redirect-params\/flat\/home/);
18+
19+
// 2. Click a link to a non-existing route — catch-all fires, leaving view has no ionPageElement
20+
await page.locator('#go-to-non-existing').click();
21+
22+
// 3. Should redirect back to home without crashing
23+
await expect(page).toHaveURL(/\/redirect-params\/flat\/home/);
24+
await ionPageVisible(page, 'home-page');
25+
});
26+
27+
});
28+
29+
});

0 commit comments

Comments
 (0)