| 1 |
import { test } from '@playwright/test'; |
| 2 |
|
| 3 |
import { expectSwupAnimationDuration, waitForSwup } from '../support/swup.js'; |
| 4 |
import { expectNotToHaveClass, expectToHaveClass } from '../support/commands.js'; |
| 5 |
|
| 6 |
test.describe('native mode', () => { |
| 7 |
test('adds swup-native class if supported', async ({ page }) => { |
| 8 |
await page.goto('/animation-native.html'); |
| 9 |
await waitForSwup(page); |
| 10 |
const supported = await page.evaluate(() => !!document.startViewTransition); |
| 11 |
if (supported) { |
| 12 |
await expectToHaveClass(page.locator('html'), 'swup-native'); |
| 13 |
} else { |
| 14 |
await expectNotToHaveClass(page.locator('html'), 'swup-native'); |
| 15 |
} |
| 16 |
}); |
| 17 |
test('does not add swup-native class if not enabled', async ({ page }) => { |
| 18 |
await page.goto('/page-1.html'); |
| 19 |
await waitForSwup(page); |
| 20 |
await expectNotToHaveClass(page.locator('html'), 'swup-native'); |
| 21 |
}); |
| 22 |
test('awaits native view transitions', async ({ page }) => { |
| 23 |
await page.goto('/animation-native.html'); |
| 24 |
const supported = await page.evaluate(() => !!document.startViewTransition); |
| 25 |
await expectSwupAnimationDuration(page, { total: supported ? 500 : 800 }); |
| 26 |
}); |
| 27 |
}); |