test: e2e 选择器迁移为角色定位

This commit is contained in:
2026-08-27 22:25:59 +08:00
parent 8c8924d652
commit 5569921df6
5 changed files with 30 additions and 30 deletions
+7 -7
View File
@@ -115,7 +115,7 @@ test.describe('StartTask - 暂停后继续', () => {
await expect(page.locator('.status-text')).toContainText('进行中');
// 点击暂停按钮
await page.locator('button', { hasText: '暂停' }).click();
await page.getByRole('button', { name: '暂停' }).click();
// 验证暂停 API 被调用
expect(apiCalls).toContain('pause');
@@ -124,7 +124,7 @@ test.describe('StartTask - 暂停后继续', () => {
await expect(page.locator('.status-text')).toContainText('已暂停');
// 点击开始按钮
await page.locator('button', { hasText: '开始' }).click();
await page.getByRole('button', { name: '开始' }).click();
// 验证 continue API 被调用
expect(apiCalls).toContain('continue');
@@ -159,7 +159,7 @@ test.describe('StartTask - 暂停后继续', () => {
await expect(page.locator('.status-text')).toContainText('进行中');
// ONGOING 状态下,开始按钮是 disabled 的,不应触发 continue
const startBtn = page.locator('button', { hasText: '开始' });
const startBtn = page.getByRole('button', { name: '开始' });
await expect(startBtn).toBeDisabled();
// continue API 不应被调用
@@ -187,18 +187,18 @@ test.describe('StartTask - 暂停后继续', () => {
await page.waitForSelector('.start-page', { timeout: 10_000 });
// 暂停
await page.locator('button', { hasText: '暂停' }).click();
await page.getByRole('button', { name: '暂停' }).click();
await expect(page.locator('.status-text')).toContainText('已暂停');
// 结束会话
await page.locator('button', { hasText: '结束会话' }).click();
await page.getByRole('button', { name: '结束会话' }).click();
// 在弹窗中输入总结内容
await page.locator('.el-dialog textarea').fill('测试总结');
await page.locator('.el-dialog button', { hasText: '确认结束' }).click();
await page.getByRole('dialog').getByRole('button', { name: '确认结束' }).click();
// 确认第二个弹窗("确定要结束本次学习会话吗?")
const confirmBtn = page.locator('.el-message-box__btns button', { hasText: '确定' });
const confirmBtn = page.getByRole('dialog').getByRole('button', { name: '确定' });
await confirmBtn.waitFor({ timeout: 5000 });
await confirmBtn.click();