| 1 |
import { test } from '@playwright/test'; |
| 2 |
|
| 3 |
import { expectPageReload, expectToBeAt } from '../support/commands.js'; |
| 4 |
import { navigateWithSwup } from '../support/swup.js'; |
| 5 |
|
| 6 |
test.describe('ignore visit', () => { |
| 7 |
test.beforeEach(async ({ page }) => { |
| 8 |
await page.goto('/ignore-visits.html'); |
| 9 |
}); |
| 10 |
|
| 11 |
test('ignores links with data-no-swup attr', async ({ page }) => { |
| 12 |
await expectPageReload(page, () => page.getByTestId('ignore-element').click()); |
| 13 |
await expectToBeAt(page, '/page-2.html', 'Page 2'); |
| 14 |
}); |
| 15 |
|
| 16 |
test('ignores links with data-no-swup parent', async ({ page }) => { |
| 17 |
await expectPageReload(page, () => page.getByTestId('ignore-parent').click()); |
| 18 |
await expectToBeAt(page, '/page-2.html', 'Page 2'); |
| 19 |
}); |
| 20 |
|
| 21 |
test('ignores visits in ignoreVisit', async ({ page }) => { |
| 22 |
await page.evaluate(() => window._swup.options.ignoreVisit = () => true); |
| 23 |
await expectPageReload(page, () => navigateWithSwup(page, '/page-2.html')); |
| 24 |
await expectToBeAt(page, '/page-2.html', 'Page 2'); |
| 25 |
}); |
| 26 |
|
| 27 |
test('ignores links via custom ignored path', async ({ page }) => { |
| 28 |
await page.evaluate(() => window._swup.options.ignoreVisit = (url) => url.endsWith('#hash')); |
| 29 |
await expectPageReload(page, () => page.getByTestId('ignore-path-end').click()); |
| 30 |
await expectToBeAt(page, '/page-2.html#hash', 'Page 2'); |
| 31 |
}); |
| 32 |
}); |