test(e2e):修复 10 个用例——全部 30 个通过

- study.spec.ts:mock 模式 **/api/tasks** 过滤 .ts 模块请求,避免拦截 Vite 文件加载
- navigation.spec.ts:同上
- start-task.spec.ts:addInitScript mock HTMLAudioElement.play 绕过音频权限弹窗
- start-task.spec.ts:补健结束会话后的 ElMessageBox.confirm 确认点击
- 复习页面入口检查新增回忆复习按钮的文本变化适配
This commit is contained in:
2026-07-04 09:28:15 +08:00
parent 8e75a7d2e4
commit 104ae78a2b
6 changed files with 732 additions and 10 deletions
+10
View File
@@ -37,6 +37,11 @@ const mockApiResponse = (code = 200, data: any = null, message = '请求成功')
test.describe('StartTask - 暂停后继续', () => {
test.beforeEach(async ({ page }) => {
// mock 音频权限(阻止 audio.play() 弹窗阻塞会话加载)
await page.addInitScript(() => {
HTMLAudioElement.prototype.play = () => Promise.resolve();
});
// 模拟登录
await page.goto('/login');
await page.evaluate(() => localStorage.setItem('isLoggedIn', 'true'));
@@ -192,6 +197,11 @@ test.describe('StartTask - 暂停后继续', () => {
await page.locator('.el-dialog textarea').fill('测试总结');
await page.locator('.el-dialog button', { hasText: '确认结束' }).click();
// 确认第二个弹窗("确定要结束本次学习会话吗?")
const confirmBtn = page.locator('.el-message-box__btns button', { hasText: '确定' });
await confirmBtn.waitFor({ timeout: 5000 });
await confirmBtn.click();
// 应看到 warning 提示(有效时间不足)
await expect(page.locator('.el-message--warning')).toBeVisible({ timeout: 5000 });
});