style: 全站接入深色主题,按新规则整改界面取值
This commit is contained in:
+49
-5
@@ -37,6 +37,9 @@ const mockApiResponse = (code = 200, data: any = null, message = '请求成功')
|
||||
|
||||
test.describe('StartTask - 暂停后继续', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// Match business endpoints only, never Vite's /src/api/*.ts modules.
|
||||
await page.route(url => url.pathname.startsWith('/api/'), route => route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockApiResponse()) }));
|
||||
await page.route('**/api/study-sessions/SESSION_001', route => route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockSessionPaused) }));
|
||||
// mock 音频权限(阻止 audio.play() 弹窗阻塞会话加载)
|
||||
await page.addInitScript(() => {
|
||||
HTMLAudioElement.prototype.play = () => Promise.resolve();
|
||||
@@ -83,6 +86,26 @@ test.describe('StartTask - 暂停后继续', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('记录知识碎片一次保存,结束总结前暂停,取消恢复原进行中状态', async ({ page }) => {
|
||||
const calls: string[] = [];
|
||||
await page.route('**/api/report-fragments', route => { calls.push('record'); return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockApiResponse()) }); });
|
||||
await page.route('**/api/study-sessions/SESSION_001/study-sessions/pause', route => { calls.push('pause'); return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockApiResponse()) }); });
|
||||
await page.route('**/api/study-sessions/SESSION_001/study-sessions/continue', route => { calls.push('continue'); return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockApiResponse()) }); });
|
||||
await page.goto('/start-task/T001');
|
||||
await expect(page.locator('.task-info-bar')).toContainText('学习 Vue3');
|
||||
await page.getByRole('button', { name: '记录知识碎片', exact: true }).click();
|
||||
await page.getByRole('dialog').locator('textarea').fill('整体提交或回滚');
|
||||
await page.getByRole('button', { name: '保存记录', exact: true }).click();
|
||||
await expect.poll(() => calls.filter(call => call === 'record').length).toBe(1);
|
||||
await expect(page.getByRole('dialog')).toHaveCount(0);
|
||||
await page.getByRole('button', { name: '结束会话', exact: true }).click();
|
||||
await expect(page.getByRole('dialog', { name: '结束会话总结' })).toBeVisible();
|
||||
expect(calls).toContain('pause');
|
||||
await expect(page.locator('.status-text')).toContainText('已暂停');
|
||||
await page.getByRole('button', { name: '取消并继续学习' }).click();
|
||||
await expect.poll(() => calls.includes('continue')).toBe(true);
|
||||
});
|
||||
|
||||
test('暂停后点击开始,应触发 continue API', async ({ page }) => {
|
||||
// 记录 API 调用
|
||||
const apiCalls: string[] = [];
|
||||
@@ -194,15 +217,36 @@ test.describe('StartTask - 暂停后继续', () => {
|
||||
await page.getByRole('button', { name: '结束会话' }).click();
|
||||
|
||||
// 在弹窗中输入总结内容
|
||||
await page.locator('.el-dialog textarea').fill('测试总结');
|
||||
await page.getByRole('dialog').locator('textarea').first().fill('测试总结');
|
||||
await page.getByRole('dialog').getByRole('button', { name: '确认结束' }).click();
|
||||
|
||||
// 确认第二个弹窗("确定要结束本次学习会话吗?")
|
||||
const confirmBtn = page.getByRole('dialog').getByRole('button', { name: '确定' });
|
||||
await confirmBtn.waitFor({ timeout: 5000 });
|
||||
await confirmBtn.click();
|
||||
await expect(page.getByText('确定要结束本次学习会话吗?')).toHaveCount(0);
|
||||
|
||||
// 应看到 warning 提示(有效时间不足)
|
||||
await expect(page.locator('.el-message--warning')).toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
test('旧标准图原生编辑Enter后可连续Tab/Enter新增并以原outline契约保存', async ({ page }) => {
|
||||
let savedOutline = '';
|
||||
await page.route('**/api/review/standard-mind-map/T001', async route => {
|
||||
if (route.request().method() === 'PUT') savedOutline = (route.request().postDataJSON() as { outline: string }).outline;
|
||||
await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockApiResponse(200, null)) });
|
||||
});
|
||||
await page.goto('/start-task/T001');
|
||||
await expect(page.locator('.task-info-bar')).toContainText('学习 Vue3');
|
||||
const card = page.locator('.mindmap-card');
|
||||
await card.getByRole('button', { name: '新建导图', exact: true }).click();
|
||||
await card.locator('me-root > me-tpc').click();
|
||||
await card.locator('.map-container').press('F2');
|
||||
await card.locator('#input-box').fill('标准根修改'); await card.locator('#input-box').press('Enter');
|
||||
await expect(card.locator('me-tpc.selected')).toHaveCount(1);
|
||||
await card.locator('.map-container').press('Tab'); await expect(card.locator('#input-box')).toHaveText('New Node');
|
||||
await card.locator('#input-box').fill('第一个子节点'); await card.locator('#input-box').press('Enter');
|
||||
await card.locator('.map-container').press('Enter');
|
||||
await card.locator('#input-box').fill('第二个子节点'); await card.locator('#input-box').press('Enter');
|
||||
await card.locator('.map-container').press('Tab');
|
||||
await card.locator('#input-box').fill('下一级'); await card.locator('#input-box').press('Enter');
|
||||
await card.getByRole('button', { name: '保存', exact: true }).click();
|
||||
await expect.poll(() => savedOutline).toBe('标准根修改\n - 第一个子节点\n - 第二个子节点\n - 下一级');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user