import { test, expect } from '@playwright/test';

test.describe('暗黑模式切换', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/');
  });

  test('主题切换按钮存在', async ({ page }) => {
    const toggleBtn = page.locator('button').filter({ has: page.locator('svg') }).first();
    await expect(toggleBtn).toBeVisible();
  });

  test('点击主题切换按钮无错误', async ({ page }) => {
    const toggleBtn = page.locator('button').filter({ has: page.locator('svg') }).first();
    await expect(toggleBtn).toBeEnabled();
    await toggleBtn.click();
    await page.waitForTimeout(500);
    await expect(page.locator('html')).toBeAttached();
  });
});
