08ea5fbe98
添加用户管理视图、API和状态管理文件
125 lines
5.6 KiB
TypeScript
125 lines
5.6 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-004: 运势分析功能', () => {
|
|
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-004-01: 查看每日运势', async ({ page }) => {
|
|
const testDate = '2024-01-15';
|
|
|
|
await test.step('Given 用户已登录系统', async () => {
|
|
await expect(page).toHaveURL(/.*dashboard/);
|
|
});
|
|
|
|
await test.step('When 用户导航到运势页面并选择日期', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/fortune`);
|
|
await page.fill('[data-testid="fortune-date"]', testDate);
|
|
await page.click('[data-testid="query-fortune-button"]');
|
|
});
|
|
|
|
await test.step('Then 系统应显示每日运势', async () => {
|
|
await expect(page.locator('[data-testid="daily-fortune"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="overall-luck"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="career-advice"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="wealth-advice"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="relationship-advice"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="health-advice"]')).toBeVisible();
|
|
});
|
|
});
|
|
|
|
uatTest('UAT-004-02: 查看每月运势', async ({ page }) => {
|
|
await test.step('Given 用户已登录系统', async () => {
|
|
await expect(page).toHaveURL(/.*dashboard/);
|
|
});
|
|
|
|
await test.step('When 用户导航到运势页面并切换到每月运势', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/fortune`);
|
|
await page.click('[data-testid="monthly-fortune-tab"]');
|
|
});
|
|
|
|
await test.step('Then 系统应显示每月运势', async () => {
|
|
await expect(page.locator('[data-testid="monthly-fortune"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="monthly-overall-luck"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="monthly-key-focus"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="monthly-caution-advice"]')).toBeVisible();
|
|
});
|
|
});
|
|
|
|
uatTest('UAT-004-03: 查看每年运势', async ({ page }) => {
|
|
await test.step('Given 用户已登录系统', async () => {
|
|
await expect(page).toHaveURL(/.*dashboard/);
|
|
});
|
|
|
|
await test.step('When 用户导航到运势页面并切换到每年运势', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/fortune`);
|
|
await page.click('[data-testid="yearly-fortune-tab"]');
|
|
});
|
|
|
|
await test.step('Then 系统应显示每年运势', async () => {
|
|
await expect(page.locator('[data-testid="yearly-fortune"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="yearly-overall-luck"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="yearly-theme"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="yearly-major-opportunity"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="yearly-major-challenge"]')).toBeVisible();
|
|
});
|
|
});
|
|
|
|
uatTest('UAT-004-04: 查看宫位运势', async ({ page }) => {
|
|
await test.step('Given 用户已查看每日运势', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/fortune`);
|
|
await page.fill('[data-testid="fortune-date"]', '2024-01-15');
|
|
await page.click('[data-testid="query-fortune-button"]');
|
|
await expect(page.locator('[data-testid="daily-fortune"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('When 用户查看宫位运势', async () => {
|
|
await expect(page.locator('[data-testid="palace-fortunes"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('Then 宫位运势应正确显示', async () => {
|
|
const palaceCount = await page.locator('[data-testid^="palace-"]').count();
|
|
expect(palaceCount).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
|
|
uatTest('UAT-004-05: 查看幸运信息', async ({ page }) => {
|
|
await test.step('Given 用户已查看每日运势', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/fortune`);
|
|
await page.fill('[data-testid="fortune-date"]', '2024-01-15');
|
|
await page.click('[data-testid="query-fortune-button"]');
|
|
await expect(page.locator('[data-testid="daily-fortune"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('When 用户查看幸运信息', async () => {
|
|
await expect(page.locator('[data-testid="lucky-color"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="lucky-number"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="lucky-direction"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('Then 幸运信息应正确显示', async () => {
|
|
const luckyColor = await page.locator('[data-testid="lucky-color"]').textContent();
|
|
const luckyNumber = await page.locator('[data-testid="lucky-number"]').textContent();
|
|
const luckyDirection = await page.locator('[data-testid="lucky-direction"]').textContent();
|
|
|
|
expect(luckyColor).toBeTruthy();
|
|
expect(luckyColor!.length).toBeGreaterThan(0);
|
|
expect(luckyNumber).toBeTruthy();
|
|
expect(luckyNumber!.length).toBeGreaterThan(0);
|
|
expect(luckyDirection).toBeTruthy();
|
|
expect(luckyDirection!.length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
}); |