|
| 1 | +import { test } from '@playwright/test'; |
| 2 | +import { ionPageVisible, ionPageDoesNotExist, withTestingMode } from './utils/test-utils'; |
| 3 | + |
| 4 | +/** |
| 5 | + * Tests for issue #26394: |
| 6 | + * routerLink on IonItem (and other routing components) should allow modifier key |
| 7 | + * clicks (ctrl/cmd/shift+click) to open in a new tab without triggering SPA |
| 8 | + * navigation on the current page. |
| 9 | + */ |
| 10 | +test.describe('Router Link Modifier Click', () => { |
| 11 | + test('normal click should trigger SPA navigation', async ({ page }) => { |
| 12 | + await page.goto(withTestingMode('/router-link-modifier-click')); |
| 13 | + await ionPageVisible(page, 'router-link-modifier-click'); |
| 14 | + |
| 15 | + await page.locator('#nav-to-target').click(); |
| 16 | + |
| 17 | + await ionPageVisible(page, 'router-link-modifier-click-target'); |
| 18 | + }); |
| 19 | + |
| 20 | + test('meta+click should not trigger SPA navigation on the current page', async ({ page }) => { |
| 21 | + await page.goto(withTestingMode('/router-link-modifier-click')); |
| 22 | + await ionPageVisible(page, 'router-link-modifier-click'); |
| 23 | + |
| 24 | + await page.locator('#nav-to-target').click({ modifiers: ['Meta'] }); |
| 25 | + await page.waitForTimeout(500); |
| 26 | + |
| 27 | + // The current page should NOT have navigated to the target via SPA |
| 28 | + await ionPageVisible(page, 'router-link-modifier-click'); |
| 29 | + await ionPageDoesNotExist(page, 'router-link-modifier-click-target'); |
| 30 | + }); |
| 31 | + |
| 32 | + test('shift+click should not trigger SPA navigation on the current page', async ({ page }) => { |
| 33 | + await page.goto(withTestingMode('/router-link-modifier-click')); |
| 34 | + await ionPageVisible(page, 'router-link-modifier-click'); |
| 35 | + |
| 36 | + await page.locator('#nav-to-target').click({ modifiers: ['Shift'] }); |
| 37 | + await page.waitForTimeout(500); |
| 38 | + |
| 39 | + // The current page should NOT have navigated to the target via SPA |
| 40 | + await ionPageVisible(page, 'router-link-modifier-click'); |
| 41 | + await ionPageDoesNotExist(page, 'router-link-modifier-click-target'); |
| 42 | + }); |
| 43 | +}); |
0 commit comments