import { test, expect } from './helpers/fixtures'; import { mock } from './helpers/mock'; test('default data-theme is dark', async ({ page }) => { await page.goto('/app/authorize'); await expect(page.locator('html')).toHaveAttribute('data-theme', 'dark'); }); test('theme cookie set to light makes data-theme light', async ({ page }) => { await page.context().addCookies([ { name: 'theme', value: 'light', domain: 'localhost', path: '/app', sameSite: 'Lax' } ]); await page.goto('/app/authorize'); await expect(page.locator('html')).toHaveAttribute('data-theme', 'light'); }); test('theme toggle button switches dark to light', async ({ page, loggedInUser }) => { void loggedInUser; await mock.override('GET', '/event/list', { status: 200, body: { status: 200, data: { items: [] } } }); await page.goto('/app/'); await page.waitForLoadState('networkidle'); await expect(page.locator('html')).toHaveAttribute('data-theme', 'dark'); await page.getByRole('button', { name: '切换主题' }).click(); await page.waitForLoadState('networkidle'); await expect(page.locator('html')).toHaveAttribute('data-theme', 'light'); });