Files
everything-is-suitable/everything-is-suitable-admin/e2e/uat/uat-005-ziwei.spec.ts
T
张翔 08ea5fbe98 feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
2026-03-28 14:37:29 +08:00

146 lines
6.3 KiB
TypeScript

import { test } from '@playwright/test';
import { test as uatTest } from './uat-base';
import { LoginPage } from '../pages/login-page';
import { DashboardPage } from '../pages/dashboard-page';
import { testConfig } from '../core/test-config';
uatTest.describe('UAT-005: 紫微斗数功能', () => {
let loginPage: LoginPage;
let dashboardPage: DashboardPage;
test.beforeEach(async ({ page, uatLogin, uatDashboard }) => {
loginPage = uatLogin;
dashboardPage = uatDashboard;
await page.goto(testConfig.getBaseURL());
await loginPage.login('admin', 'admin123');
await expect(page).toHaveURL(/.*dashboard/);
});
uatTest('UAT-005-01: 生成紫微斗数命盘', async ({ page }) => {
const birthDate = '1990-05-15';
const birthTime = '08:30';
await test.step('Given 用户已登录系统', async () => {
await expect(page).toHaveURL(/.*dashboard/);
});
await test.step('When 用户导航到紫微斗数页面并输入出生信息', async () => {
await page.goto(`${testConfig.getBaseURL()}/ziwei`);
await page.fill('[data-testid="birth-date"]', birthDate);
await page.fill('[data-testid="birth-time"]', birthTime);
await page.click('[data-testid="gender-male"]');
await page.click('[data-testid="generate-chart-button"]');
});
await test.step('Then 系统应生成紫微斗数命盘', async () => {
await expect(page.locator('[data-testid="ziwei-chart"]')).toBeVisible();
await expect(page.locator('[data-testid="palace-grid"]')).toBeVisible();
await expect(page.locator('[data-testid="ming-gong"]')).toBeVisible();
await expect(page.locator('[data-testid="shen-gong"]')).toBeVisible();
});
});
uatTest('UAT-005-02: 查看十二宫位', async ({ page }) => {
await test.step('Given 用户已生成紫微斗数命盘', async () => {
await page.goto(`${testConfig.getBaseURL()}/ziwei`);
await page.fill('[data-testid="birth-date"]', '1990-05-15');
await page.fill('[data-testid="birth-time"]', '08:30');
await page.click('[data-testid="gender-male"]');
await page.click('[data-testid="generate-chart-button"]');
await expect(page.locator('[data-testid="ziwei-chart"]')).toBeVisible();
});
await test.step('When 用户查看十二宫位', async () => {
await expect(page.locator('[data-testid="palace-grid"]')).toBeVisible();
});
await test.step('Then 十二宫位应正确显示', async () => {
const palaceCount = await page.locator('[data-testid^="palace-"]').count();
expect(palaceCount).toBe(12);
});
});
uatTest('UAT-005-03: 查看主星排列', async ({ page }) => {
await test.step('Given 用户已生成紫微斗数命盘', async () => {
await page.goto(`${testConfig.getBaseURL()}/ziwei`);
await page.fill('[data-testid="birth-date"]', '1990-05-15');
await page.fill('[data-testid="birth-time"]', '08:30');
await page.click('[data-testid="gender-male"]');
await page.click('[data-testid="generate-chart-button"]');
await expect(page.locator('[data-testid="ziwei-chart"]')).toBeVisible();
});
await test.step('When 用户查看主星排列', async () => {
await expect(page.locator('[data-testid="major-stars"]')).toBeVisible();
});
await test.step('Then 主星应正确显示', async () => {
const majorStars = await page.locator('[data-testid^="major-star-"]').count();
expect(majorStars).toBeGreaterThan(0);
});
});
uatTest('UAT-005-04: 查看四化飞星', async ({ page }) => {
await test.step('Given 用户已生成紫微斗数命盘', async () => {
await page.goto(`${testConfig.getBaseURL()}/ziwei`);
await page.fill('[data-testid="birth-date"]', '1990-05-15');
await page.fill('[data-testid="birth-time"]', '08:30');
await page.click('[data-testid="gender-male"]');
await page.click('[data-testid="generate-chart-button"]');
await expect(page.locator('[data-testid="ziwei-chart"]')).toBeVisible();
});
await test.step('When 用户查看四化飞星', async () => {
await expect(page.locator('[data-testid="transformations"]')).toBeVisible();
});
await test.step('Then 四化飞星应正确显示', async () => {
await expect(page.locator('[data-testid="hua-lu"]')).toBeVisible();
await expect(page.locator('[data-testid="hua-quan"]')).toBeVisible();
await expect(page.locator('[data-testid="hua-ke"]')).toBeVisible();
await expect(page.locator('[data-testid="hua-ji"]')).toBeVisible();
});
});
uatTest('UAT-005-05: 查看命盘分析', async ({ page }) => {
await test.step('Given 用户已生成紫微斗数命盘', async () => {
await page.goto(`${testConfig.getBaseURL()}/ziwei`);
await page.fill('[data-testid="birth-date"]', '1990-05-15');
await page.fill('[data-testid="birth-time"]', '08:30');
await page.click('[data-testid="gender-male"]');
await page.click('[data-testid="generate-chart-button"]');
await expect(page.locator('[data-testid="ziwei-chart"]')).toBeVisible();
});
await test.step('When 用户查看命盘分析', async () => {
await expect(page.locator('[data-testid="chart-analysis"]')).toBeVisible();
});
await test.step('Then 命盘分析应正确显示', async () => {
const analysisText = await page.locator('[data-testid="chart-analysis"]').textContent();
expect(analysisText).toBeTruthy();
expect(analysisText!.length).toBeGreaterThan(0);
});
});
uatTest('UAT-005-06: 保存命盘', async ({ page }) => {
await test.step('Given 用户已生成紫微斗数命盘', async () => {
await page.goto(`${testConfig.getBaseURL()}/ziwei`);
await page.fill('[data-testid="birth-date"]', '1990-05-15');
await page.fill('[data-testid="birth-time"]', '08:30');
await page.click('[data-testid="gender-male"]');
await page.click('[data-testid="generate-chart-button"]');
await expect(page.locator('[data-testid="ziwei-chart"]')).toBeVisible();
});
await test.step('When 用户点击保存命盘按钮', async () => {
await page.click('[data-testid="save-chart-button"]');
});
await test.step('Then 命盘应保存成功', async () => {
await expect(page.locator('.ant-message-success')).toBeVisible();
await expect(page.locator('.ant-message-success')).toContainText('命盘保存成功');
});
});
});