26 lines
841 B
TypeScript
Executable File
26 lines
841 B
TypeScript
Executable File
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Theme switching', () => {
|
|
test('toggling the switch changes the body theme attribute', async ({ page }) => {
|
|
await page.goto('/');
|
|
const body = page.locator('body');
|
|
const initial = await body.getAttribute('data-theme');
|
|
|
|
await page.getByRole('switch').click();
|
|
|
|
await expect(async () => {
|
|
const updated = await body.getAttribute('data-theme');
|
|
expect(updated).not.toBe(initial);
|
|
}).toPass();
|
|
});
|
|
|
|
test('theme preference persists across a reload', async ({ page }) => {
|
|
await page.goto('/');
|
|
await page.getByRole('switch').click();
|
|
const chosen = await page.locator('body').getAttribute('data-theme');
|
|
|
|
await page.reload();
|
|
await expect(page.locator('body')).toHaveAttribute('data-theme', chosen || '');
|
|
});
|
|
});
|