playwright/tests/e2e/menu.spec.js
2025-03-07 14:52:52 +08:00

34 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 加载环境变量
require('../../config/env');
const { test } = require('@playwright/test');
const TestController = require('../../src/controllers/LongiTestController');
test.describe('测试所有隆基需求计划是否可用', () => {
let controller;
test.beforeAll(async () => {
controller = new TestController();
});
test('获取最新菜单数据', async () => {
const menuData = await controller.fetchAndSaveMenuData();
test.expect(menuData.length).toBeGreaterThan(0);
console.log(`✓ 成功收集 ${menuData.length} 个菜单项`);
});
test('访问并点击所有页面', async () => {
// 执行所有测试
await controller.runAllTests();
// 验证测试结果
const progress = controller.getTestProgress();
test.expect(progress.completed).toBe(progress.total);
// 输出测试统计
console.log('\n测试完成');
console.log(`✓ 总计测试: ${progress.total} 个菜单`);
console.log(`✓ 成功完成: ${progress.completed} 个菜单`);
console.log(`✓ 成功率: ${((progress.completed / progress.total) * 100).toFixed(2)}%`);
});
});