Files
qwerty-learner/tests/e2e/theme.spec.ts
rubickecho b47fd0a8c2 test: Add e2e tests with playwright for website (#736)
* docs: update README, add deploy to vercel

* docs: update README

* feat: add e2e tests

* feat: add main feature e2e tests with playwright

* fix: ci env value and update gitignore

* fix: ci job conditions for execution

* chore: merge from main

---------

Co-authored-by: KaiyiWing <Zhang.kaiyi42@gmail.com>
2024-02-17 16:04:59 +08:00

25 lines
762 B
TypeScript

import { test, expect } from '@playwright/test'
test.describe('Theme switch', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/')
await page.getByLabel('关闭提示').click()
})
test('Has theme switch button', async ({ page }) => {
await expect(await page.getByLabel('开关深色模式').isVisible()).toBeTruthy()
})
test('Theme mode switch', async ({ page }) => {
// light to dark
await page.getByLabel('开关深色模式').click()
await expect(await page.locator('html').getAttribute('class')).toBe('dark')
await page.waitForTimeout(500)
// dark to light
await page.getByLabel('开关深色模式').click()
await expect(await page.locator('html').getAttribute('class')).toBe('')
})
})