|
| 1 | +import { expect, test } from '@playwright/test'; |
| 2 | + |
| 3 | +/** |
| 4 | + * Tests for INLINE sheet modals in child routes with showBackdrop=false. |
| 5 | + * |
| 6 | + * Related issue: https://github.com/ionic-team/ionic-framework/issues/30700 |
| 7 | + * |
| 8 | + * This test mimics the EXACT structure from the issue reproduction: |
| 9 | + * - PARENT component has interactive content (buttons) AND a nested ion-router-outlet |
| 10 | + * - CHILD route (rendered in that nested outlet) contains ONLY the modal |
| 11 | + * - The modal has showBackdrop=false |
| 12 | + * |
| 13 | + * The bug: when the modal opens in the child route, the buttons in the PARENT |
| 14 | + * become non-interactive even though showBackdrop=false should allow interaction. |
| 15 | + * |
| 16 | + * DOM structure: |
| 17 | + * - ion-app > ion-router-outlet (root) > PARENT (buttons + nested outlet) > ion-router-outlet > CHILD (modal only) |
| 18 | + */ |
| 19 | +test.describe('Modals: Inline Sheet in Child Route (standalone)', () => { |
| 20 | + test.beforeEach(async ({ page }) => { |
| 21 | + // Navigate to the child route - this will: |
| 22 | + // 1. Render the parent with buttons |
| 23 | + // 2. Render the child in the nested outlet, which immediately opens the modal |
| 24 | + await page.goto('/standalone/modal-child-route/child'); |
| 25 | + }); |
| 26 | + |
| 27 | + test('should render parent content and child modal', async ({ page }) => { |
| 28 | + // Verify the PARENT content is visible (buttons are in parent, not child) |
| 29 | + await expect(page.locator('#increment-btn')).toBeVisible(); |
| 30 | + await expect(page.locator('#decrement-btn')).toBeVisible(); |
| 31 | + await expect(page.locator('#background-action-count')).toHaveText('0'); |
| 32 | + |
| 33 | + // Verify the modal from CHILD route is visible (opens immediately with isOpen=true) |
| 34 | + await expect(page.locator('ion-modal.show-modal')).toBeVisible(); |
| 35 | + await expect(page.locator('#modal-content-loaded')).toBeVisible(); |
| 36 | + }); |
| 37 | + |
| 38 | + test('should allow interacting with PARENT content while modal (showBackdrop: false) is open in CHILD route', async ({ page }) => { |
| 39 | + // Modal should already be open (isOpen=true in child component) |
| 40 | + await expect(page.locator('ion-modal.show-modal')).toBeVisible(); |
| 41 | + await expect(page.locator('#modal-content-loaded')).toBeVisible(); |
| 42 | + |
| 43 | + // Click the increment button in the PARENT - this should work with showBackdrop=false |
| 44 | + // This is the KEY test - it FAILS due to issue #30700 |
| 45 | + await page.locator('#increment-btn').click(); |
| 46 | + |
| 47 | + // Verify the click was registered |
| 48 | + await expect(page.locator('#background-action-count')).toHaveText('1'); |
| 49 | + }); |
| 50 | + |
| 51 | + test('should allow multiple interactions with PARENT content while modal is open', async ({ page }) => { |
| 52 | + // Modal should already be open |
| 53 | + await expect(page.locator('ion-modal.show-modal')).toBeVisible(); |
| 54 | + |
| 55 | + // Click increment multiple times |
| 56 | + await page.locator('#increment-btn').click(); |
| 57 | + await page.locator('#increment-btn').click(); |
| 58 | + await expect(page.locator('#background-action-count')).toHaveText('2'); |
| 59 | + |
| 60 | + // Click decrement |
| 61 | + await page.locator('#decrement-btn').click(); |
| 62 | + await expect(page.locator('#background-action-count')).toHaveText('1'); |
| 63 | + }); |
| 64 | +}); |
0 commit comments