|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import { ionPageVisible, withTestingMode } from './utils/test-utils'; |
| 3 | + |
| 4 | +test.describe('Nested Params', () => { |
| 5 | + |
| 6 | + /** |
| 7 | + * Regression: navigating to a parameterized route, back to landing, |
| 8 | + * then to a different param, back, and to the same param again caused |
| 9 | + * an infinite loop that locked up the browser. |
| 10 | + * |
| 11 | + * Steps: user 99 -> landing -> user 42 -> landing -> user 42 (loop) |
| 12 | + */ |
| 13 | + test('should not infinite loop when revisiting a parameterized route after visiting a different param', async ({ page }) => { |
| 14 | + // Use a tight timeout -- if the infinite loop fires, the browser locks up |
| 15 | + // and this test would hang forever without it. |
| 16 | + test.setTimeout(15_000); |
| 17 | + |
| 18 | + await page.goto(withTestingMode('/nested-params')); |
| 19 | + await ionPageVisible(page, 'nested-params-landing'); |
| 20 | + |
| 21 | + // Step 1: Navigate to user 99 details |
| 22 | + await page.locator('#go-to-user-99').click(); |
| 23 | + await expect(page.getByText('Details view user: 99')).toBeVisible(); |
| 24 | + |
| 25 | + // Step 2: Back to landing via routerLink (push). |
| 26 | + // Use .first() because the hidden user 99 details page stays in the DOM, |
| 27 | + // leaving a duplicate #back-to-landing button. |
| 28 | + await page.locator('#back-to-landing').first().click(); |
| 29 | + await ionPageVisible(page, 'nested-params-landing'); |
| 30 | + |
| 31 | + // Step 3: Navigate to user 42 details |
| 32 | + await page.locator('#go-to-user-42').click(); |
| 33 | + await expect(page.getByText('Details view user: 42')).toBeVisible(); |
| 34 | + |
| 35 | + // Step 4: Back to landing via routerLink (push) |
| 36 | + await page.locator('#back-to-landing').first().click(); |
| 37 | + await ionPageVisible(page, 'nested-params-landing'); |
| 38 | + |
| 39 | + // Step 5: Navigate to user 42 details AGAIN -- this triggered the infinite loop |
| 40 | + await page.locator('#go-to-user-42').click(); |
| 41 | + await expect(page.getByText('Details view user: 42')).toBeVisible(); |
| 42 | + await expect(page.getByText('Layout sees user: 42')).toBeVisible(); |
| 43 | + }); |
| 44 | + |
| 45 | +}); |
0 commit comments