|
@@ -1,5 +1,6 @@
|
|
|
import { TIMEOUTS } from '../../utils/timeouts';
|
|
import { TIMEOUTS } from '../../utils/timeouts';
|
|
|
import { test, expect } from '../../utils/test-setup';
|
|
import { test, expect } from '../../utils/test-setup';
|
|
|
|
|
+import type { Page } from '@playwright/test';
|
|
|
import { AdminLoginPage } from '../../pages/admin/login.page';
|
|
import { AdminLoginPage } from '../../pages/admin/login.page';
|
|
|
import { TalentMiniPage } from '../../pages/mini/talent-mini.page';
|
|
import { TalentMiniPage } from '../../pages/mini/talent-mini.page';
|
|
|
import type { TalentOrderData, TalentOrderDetailData } from '../../pages/mini/talent-mini.page';
|
|
import type { TalentOrderData, TalentOrderDetailData } from '../../pages/mini/talent-mini.page';
|
|
@@ -41,7 +42,7 @@ const TALENT_LOGIN_PASSWORD = 'password123'; // 默认测试密码
|
|
|
/**
|
|
/**
|
|
|
* 后台登录辅助函数
|
|
* 后台登录辅助函数
|
|
|
*/
|
|
*/
|
|
|
-async function loginAdmin(page: any, testUsers: any) {
|
|
|
|
|
|
|
+async function loginAdmin(page: Page, testUsers: { admin: { username: string; password: string } }) {
|
|
|
const adminLoginPage = new AdminLoginPage(page);
|
|
const adminLoginPage = new AdminLoginPage(page);
|
|
|
await adminLoginPage.goto();
|
|
await adminLoginPage.goto();
|
|
|
await adminLoginPage.page.getByPlaceholder('请输入用户名').fill(testUsers.admin.username);
|
|
await adminLoginPage.page.getByPlaceholder('请输入用户名').fill(testUsers.admin.username);
|
|
@@ -54,7 +55,7 @@ async function loginAdmin(page: any, testUsers: any) {
|
|
|
/**
|
|
/**
|
|
|
* 人才小程序登录辅助函数
|
|
* 人才小程序登录辅助函数
|
|
|
*/
|
|
*/
|
|
|
-async function loginTalentMini(page: any) {
|
|
|
|
|
|
|
+async function loginTalentMini(page: Page) {
|
|
|
const talentMiniPage = new TalentMiniPage(page);
|
|
const talentMiniPage = new TalentMiniPage(page);
|
|
|
await talentMiniPage.goto();
|
|
await talentMiniPage.goto();
|
|
|
await talentMiniPage.login(TALENT_LOGIN_PHONE, TALENT_LOGIN_PASSWORD);
|
|
await talentMiniPage.login(TALENT_LOGIN_PHONE, TALENT_LOGIN_PASSWORD);
|
|
@@ -86,7 +87,7 @@ test.describe('跨端数据同步测试 - 后台添加人员到人才小程序',
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
test.describe.serial('后台添加人员', () => {
|
|
test.describe.serial('后台添加人员', () => {
|
|
|
- test('应该成功打开订单详情并添加残疾人', async ({ page: adminPage, testUsers }) => {
|
|
|
|
|
|
|
+ test('应该成功打开订单详情并添加残疾人', async ({ adminPage, testUsers }) => {
|
|
|
// 记录开始时间
|
|
// 记录开始时间
|
|
|
const startTime = Date.now();
|
|
const startTime = Date.now();
|
|
|
|
|
|
|
@@ -166,20 +167,23 @@ test.describe('跨端数据同步测试 - 后台添加人员到人才小程序',
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
test.describe.serial('人才小程序验证', () => {
|
|
test.describe.serial('人才小程序验证', () => {
|
|
|
- test('应该在小程序中显示关联的订单', async ({ page: talentMiniPage }) => {
|
|
|
|
|
|
|
+ test('应该在小程序中显示关联的订单', async ({ talentMiniPage: page }) => {
|
|
|
|
|
+ // 创建 TalentMiniPage 对象
|
|
|
|
|
+ const talentMini = new TalentMiniPage(page);
|
|
|
|
|
+
|
|
|
// 1. 人才小程序登录
|
|
// 1. 人才小程序登录
|
|
|
- await loginTalentMini(talentMiniPage);
|
|
|
|
|
|
|
+ await loginTalentMini(page);
|
|
|
|
|
|
|
|
// 2. 记录同步开始时间
|
|
// 2. 记录同步开始时间
|
|
|
const syncStartTime = Date.now();
|
|
const syncStartTime = Date.now();
|
|
|
|
|
|
|
|
// 3. 导航到"我的订单"页面
|
|
// 3. 导航到"我的订单"页面
|
|
|
- await talentMiniPage.navigateToMyOrders();
|
|
|
|
|
|
|
+ await talentMini.navigateToMyOrders();
|
|
|
console.debug('[人才小程序] 已导航到我的订单页面');
|
|
console.debug('[人才小程序] 已导航到我的订单页面');
|
|
|
|
|
|
|
|
// 4. 验证订单显示(使用轮询等待)
|
|
// 4. 验证订单显示(使用轮询等待)
|
|
|
// 由于数据同步可能有延迟,使用轮询检查
|
|
// 由于数据同步可能有延迟,使用轮询检查
|
|
|
- const orderFound = await talentMiniPage.waitForOrderToAppear(TEST_ORDER_NAME, TEST_SYNC_TIMEOUT);
|
|
|
|
|
|
|
+ const orderFound = await talentMini.waitForOrderToAppear(TEST_ORDER_NAME, TEST_SYNC_TIMEOUT);
|
|
|
|
|
|
|
|
const syncEndTime = Date.now();
|
|
const syncEndTime = Date.now();
|
|
|
testState.syncTime = syncEndTime - syncStartTime;
|
|
testState.syncTime = syncEndTime - syncStartTime;
|
|
@@ -193,25 +197,28 @@ test.describe('跨端数据同步测试 - 后台添加人员到人才小程序',
|
|
|
console.debug(`[验证] 数据同步时间 ${testState.syncTime}ms 符合要求(≤ ${TEST_SYNC_TIMEOUT}ms)`);
|
|
console.debug(`[验证] 数据同步时间 ${testState.syncTime}ms 符合要求(≤ ${TEST_SYNC_TIMEOUT}ms)`);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- test('应该在小程序订单详情中显示完整信息', async ({ page: talentMiniPage }) => {
|
|
|
|
|
|
|
+ test('应该在小程序订单详情中显示完整信息', async ({ talentMiniPage: page }) => {
|
|
|
|
|
+ // 创建 TalentMiniPage 对象
|
|
|
|
|
+ const talentMini = new TalentMiniPage(page);
|
|
|
|
|
+
|
|
|
// 前置条件:已登录并在我的订单页面
|
|
// 前置条件:已登录并在我的订单页面
|
|
|
- await loginTalentMini(talentMiniPage);
|
|
|
|
|
- await talentMiniPage.navigateToMyOrders();
|
|
|
|
|
|
|
+ await loginTalentMini(page);
|
|
|
|
|
+ await talentMini.navigateToMyOrders();
|
|
|
|
|
|
|
|
// 1. 导航到"我的订单"并找到测试订单
|
|
// 1. 导航到"我的订单"并找到测试订单
|
|
|
- const orders: TalentOrderData[] = await (talentMiniPage as unknown as TalentMiniPage).getMyOrders();
|
|
|
|
|
|
|
+ const orders: TalentOrderData[] = await talentMini.getMyOrders();
|
|
|
const testOrder = orders.find(order => order.name === TEST_ORDER_NAME);
|
|
const testOrder = orders.find(order => order.name === TEST_ORDER_NAME);
|
|
|
|
|
|
|
|
expect(testOrder, `应该找到订单 "${TEST_ORDER_NAME}"`).toBeDefined();
|
|
expect(testOrder, `应该找到订单 "${TEST_ORDER_NAME}"`).toBeDefined();
|
|
|
console.debug(`[人才小程序] 找到订单: ${testOrder?.name}`);
|
|
console.debug(`[人才小程序] 找到订单: ${testOrder?.name}`);
|
|
|
|
|
|
|
|
// 2. 点击订单详情
|
|
// 2. 点击订单详情
|
|
|
- const orderId = await talentMiniPage.openOrderDetail(TEST_ORDER_NAME);
|
|
|
|
|
|
|
+ const orderId = await talentMini.openOrderDetail(TEST_ORDER_NAME);
|
|
|
expect(orderId).toBeTruthy();
|
|
expect(orderId).toBeTruthy();
|
|
|
console.debug(`[人才小程序] 已打开订单详情: ${orderId}`);
|
|
console.debug(`[人才小程序] 已打开订单详情: ${orderId}`);
|
|
|
|
|
|
|
|
// 3. 验证订单信息完整性
|
|
// 3. 验证订单信息完整性
|
|
|
- const detail: TalentOrderDetailData = await (talentMiniPage as unknown as TalentMiniPage).getOrderDetail();
|
|
|
|
|
|
|
+ const detail: TalentOrderDetailData = await talentMini.getOrderDetail();
|
|
|
|
|
|
|
|
// 验证订单名称
|
|
// 验证订单名称
|
|
|
expect(detail.name).toBe(TEST_ORDER_NAME);
|
|
expect(detail.name).toBe(TEST_ORDER_NAME);
|
|
@@ -230,7 +237,7 @@ test.describe('跨端数据同步测试 - 后台添加人员到人才小程序',
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
test.describe.serial('数据同步时效性验证', () => {
|
|
test.describe.serial('数据同步时效性验证', () => {
|
|
|
- test('应该在合理时间内完成数据同步(≤ 10 秒)', async ({ page: _adminPage, page: _talentMiniPage, testUsers: _testUsers }) => {
|
|
|
|
|
|
|
+ test('应该在合理时间内完成数据同步(≤ 10 秒)', async () => {
|
|
|
// 此测试专门验证数据同步时效性
|
|
// 此测试专门验证数据同步时效性
|
|
|
// AC6: 数据应在 5 秒内同步,最多等待 10 秒
|
|
// AC6: 数据应在 5 秒内同步,最多等待 10 秒
|
|
|
|
|
|
|
@@ -249,7 +256,7 @@ test.describe('跨端数据同步测试 - 后台添加人员到人才小程序',
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
test.describe.serial('多人员添加同步验证', () => {
|
|
test.describe.serial('多人员添加同步验证', () => {
|
|
|
- test('应该支持批量添加多个残疾人', async ({ page: adminPage, testUsers }) => {
|
|
|
|
|
|
|
+ test('应该支持批量添加多个残疾人', async ({ adminPage, testUsers }) => {
|
|
|
// AC3: 多人员添加同步验证
|
|
// AC3: 多人员添加同步验证
|
|
|
// 此测试验证添加多个残疾人后小程序的同步情况
|
|
// 此测试验证添加多个残疾人后小程序的同步情况
|
|
|
|
|
|