Files
everything-is-suitable/everything-is-suitable-uniapp/e2e/fortune.spec.ts
T
张翔 0761ecffd3 ci: 添加 E2E 测试与 CI/CD 配置
- Playwright E2E 测试(运势页、紫微斗数页)
- Playwright 配置文件
- Jenkinsfile 流水线定义
- 构建/部署脚本
2026-04-29 21:16:34 +08:00

96 lines
3.3 KiB
TypeScript

import { test, expect } from '@playwright/test'
test.describe('运势分析功能E2E测试', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/#/pages/fortune/index')
await page.waitForLoadState('networkidle')
})
test.describe('TC-FORTUNE-001: 运势页面结构', () => {
test('应该显示运势标签页', async ({ page }) => {
const tabs = page.locator('[data-test="fortune-tabs"]')
await expect(tabs).toBeVisible()
})
test('应该显示日运和月运标签', async ({ page }) => {
const dailyTab = page.locator('.tab:has-text("日运")')
const monthlyTab = page.locator('.tab:has-text("月运")')
await expect(dailyTab).toBeVisible()
await expect(monthlyTab).toBeVisible()
})
test('默认应该选中日运标签', async ({ page }) => {
const dailyTab = page.locator('.tab:has-text("日运")')
await expect(dailyTab).toHaveClass(/active/)
})
})
test.describe('TC-FORTUNE-002: 标签切换', () => {
test('应该能够切换到月运', async ({ page }) => {
const monthlyTab = page.locator('.tab:has-text("月运")')
await monthlyTab.click()
await expect(monthlyTab).toHaveClass(/active/)
const dailyTab = page.locator('.tab:has-text("日运")')
await expect(dailyTab).not.toHaveClass(/active/)
})
test('应该能够切换回日运', async ({ page }) => {
const monthlyTab = page.locator('.tab:has-text("月运")')
await monthlyTab.click()
await expect(monthlyTab).toHaveClass(/active/)
const dailyTab = page.locator('.tab:has-text("日运")')
await dailyTab.click()
await expect(dailyTab).toHaveClass(/active/)
})
})
test.describe('TC-FORTUNE-003: 无排盘数据提示', () => {
test('未排盘时应该显示提示信息', async ({ page }) => {
const hint = page.locator('.no-chart-hint')
const isVisible = await hint.isVisible().catch(() => false)
if (isVisible) {
await expect(hint).toBeVisible()
const hintText = page.locator('.hint-text')
await expect(hintText).toContainText('排盘')
}
})
})
test.describe('TC-FORTUNE-004: 日期选择', () => {
test('日运页面应该显示日期选择器', async ({ page }) => {
const datePicker = page.locator('.date-picker').first()
await expect(datePicker).toBeVisible()
})
test('月运页面应该显示月份选择器', async ({ page }) => {
const monthlyTab = page.locator('.tab:has-text("月运")')
await monthlyTab.click()
const monthPicker = page.locator('.date-picker').first()
await expect(monthPicker).toBeVisible()
})
})
test.describe('TC-FORTUNE-005: 响应式设计', () => {
test('移动端应该正常显示', async ({ page }) => {
await page.setViewportSize({ width: 375, height: 667 })
await page.reload()
await page.waitForLoadState('networkidle')
const tabs = page.locator('[data-test="fortune-tabs"]')
await expect(tabs).toBeVisible()
})
test('桌面端应该正常显示', async ({ page }) => {
await page.setViewportSize({ width: 1920, height: 1080 })
await page.reload()
await page.waitForLoadState('networkidle')
const tabs = page.locator('[data-test="fortune-tabs"]')
await expect(tabs).toBeVisible()
})
})
})