08ea5fbe98
添加用户管理视图、API和状态管理文件
135 lines
5.9 KiB
TypeScript
135 lines
5.9 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-003: 黄历查询功能', () => {
|
|
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-003-01: 查询单日黄历', async ({ page }) => {
|
|
const testDate = '2024-01-01';
|
|
|
|
await test.step('Given 用户已登录系统', async () => {
|
|
await expect(page).toHaveURL(/.*dashboard/);
|
|
});
|
|
|
|
await test.step('When 用户导航到黄历页面并选择日期', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/almanac`);
|
|
await page.fill('[data-testid="date-picker"]', testDate);
|
|
await page.click('[data-testid="query-button"]');
|
|
});
|
|
|
|
await test.step('Then 系统应显示黄历信息', async () => {
|
|
await expect(page.locator('[data-testid="almanac-result"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="suitable-activities"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="unsuitable-activities"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="god-direction"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="fortune-direction"]')).toBeVisible();
|
|
});
|
|
});
|
|
|
|
uatTest('UAT-003-02: 查看宜忌事项', async ({ page }) => {
|
|
await test.step('Given 用户已查询黄历', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/almanac`);
|
|
await page.fill('[data-testid="date-picker"]', '2024-01-01');
|
|
await page.click('[data-testid="query-button"]');
|
|
await expect(page.locator('[data-testid="almanac-result"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('When 用户查看宜忌事项', async () => {
|
|
await expect(page.locator('[data-testid="suitable-activities"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="unsuitable-activities"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('Then 宜忌事项应正确显示', async () => {
|
|
const suitableText = await page.locator('[data-testid="suitable-activities"]').textContent();
|
|
const unsuitableText = await page.locator('[data-testid="unsuitable-activities"]').textContent();
|
|
|
|
expect(suitableText).toBeTruthy();
|
|
expect(suitableText!.length).toBeGreaterThan(0);
|
|
expect(unsuitableText).toBeTruthy();
|
|
expect(unsuitableText!.length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
|
|
uatTest('UAT-003-03: 查看吉凶方位', async ({ page }) => {
|
|
await test.step('Given 用户已查询黄历', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/almanac`);
|
|
await page.fill('[data-testid="date-picker"]', '2024-01-01');
|
|
await page.click('[data-testid="query-button"]');
|
|
await expect(page.locator('[data-testid="almanac-result"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('When 用户查看吉凶方位', async () => {
|
|
await expect(page.locator('[data-testid="god-direction"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="joy-direction"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="fortune-direction"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="noble-direction"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('Then 方位信息应正确显示', async () => {
|
|
const godDirection = await page.locator('[data-testid="god-direction"]').textContent();
|
|
const fortuneDirection = await page.locator('[data-testid="fortune-direction"]').textContent();
|
|
|
|
expect(godDirection).toBeTruthy();
|
|
expect(godDirection!.length).toBeGreaterThan(0);
|
|
expect(fortuneDirection).toBeTruthy();
|
|
expect(fortuneDirection!.length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
|
|
uatTest('UAT-003-04: 查看冲煞信息', async ({ page }) => {
|
|
await test.step('Given 用户已查询黄历', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/almanac`);
|
|
await page.fill('[data-testid="date-picker"]', '2024-01-01');
|
|
await page.click('[data-testid="query-button"]');
|
|
await expect(page.locator('[data-testid="almanac-result"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('When 用户查看冲煞信息', async () => {
|
|
await expect(page.locator('[data-testid="clash-info"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="evil-direction"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('Then 冲煞信息应正确显示', async () => {
|
|
const clashInfo = await page.locator('[data-testid="clash-info"]').textContent();
|
|
const evilDirection = await page.locator('[data-testid="evil-direction"]').textContent();
|
|
|
|
expect(clashInfo).toBeTruthy();
|
|
expect(clashInfo!.length).toBeGreaterThan(0);
|
|
expect(evilDirection).toBeTruthy();
|
|
expect(evilDirection!.length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
|
|
uatTest('UAT-003-05: 查看建除十二神', async ({ page }) => {
|
|
await test.step('Given 用户已查询黄历', async () => {
|
|
await page.goto(`${testConfig.getBaseURL()}/almanac`);
|
|
await page.fill('[data-testid="date-picker"]', '2024-01-01');
|
|
await page.click('[data-testid="query-button"]');
|
|
await expect(page.locator('[data-testid="almanac-result"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('When 用户查看建除十二神', async () => {
|
|
await expect(page.locator('[data-testid="jian-chu"]')).toBeVisible();
|
|
});
|
|
|
|
await test.step('Then 建除十二神应正确显示', async () => {
|
|
const jianChu = await page.locator('[data-testid="jian-chu"]').textContent();
|
|
|
|
expect(jianChu).toBeTruthy();
|
|
expect(jianChu!.length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
}); |