| 1 |
import { test } from '@playwright/test'; |
| 2 |
|
| 3 |
import { expectH1, expectH2, expectPageReload, expectToBeAt } from '../support/commands.js'; |
| 4 |
import { navigateWithSwup } from '../support/swup.js'; |
| 5 |
|
| 6 |
test.describe('containers', () => { |
| 7 |
test.beforeEach(async ({ page }) => { |
| 8 |
await page.goto('/containers-1.html'); |
| 9 |
}); |
| 10 |
|
| 11 |
test('can be customized from visit object', async ({ page }) => { |
| 12 |
await page.evaluate(() => { |
| 13 |
window._swup.hooks.on('visit:start', (visit) => visit.containers = ['#aside']); |
| 14 |
}); |
| 15 |
await navigateWithSwup(page, '/containers-2.html'); |
| 16 |
await expectH1(page, 'Containers 1'); |
| 17 |
await expectH2(page, 'Heading 2'); |
| 18 |
}); |
| 19 |
|
| 20 |
test('forces reload on container mismatch', async ({ page }) => { |
| 21 |
await expectPageReload(page, () => navigateWithSwup(page, '/containers-missing.html')); |
| 22 |
await expectToBeAt(page, '/containers-missing.html'); |
| 23 |
}); |
| 24 |
}); |