fix(clazz-dual-view): handle org/select redirect in loginAsTeacher, increase CI timeout
music-room Playwright (Gitea Actions) / playwright (push) Failing after 20m39s
music-room Playwright (Gitea Actions) / playwright (push) Failing after 20m39s
loginAsTeacher 之前只处理了角色选择页,没处理机构选择页(/org/select), CI 环境下多角色用户经常卡在机构选择环节导致 2m 超时。 改用逐层循环处理,和 supervisor-features 的 loginAndSelectRole 一致。 同时将文件级超时从 120s 放宽到 240s,应对 CI 环境启动慢的问题。 Run 62: 65 passed, 5 failed — 这 5 个全是 clazz-dual-view 超时。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -8,23 +8,35 @@ async function loginAsTeacher(page: any) {
|
||||
await page.goto(`/?${q.toString()}`, { waitUntil: 'domcontentloaded', timeout: 120_000 });
|
||||
await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 });
|
||||
|
||||
// Wait up to 15s for role selection dialog (may not appear if already logged in)
|
||||
const rs = page.getByText('请选择您的登录身份');
|
||||
try {
|
||||
await rs.waitFor({ state: 'visible', timeout: 15_000 });
|
||||
const items = page.locator('.van-grid-item');
|
||||
const count = await items.count();
|
||||
if (count >= 3) {
|
||||
await items.nth(2).click(); // TEACHER role
|
||||
// 逐层处理选择页:机构选择 → 角色选择(可能有 0~n 层)
|
||||
const teacherRoleText = '教师';
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const path = await page.evaluate(() => window.location.pathname);
|
||||
|
||||
if (path === '/org/select') {
|
||||
await page.locator('.van-cell').first().click();
|
||||
await page.waitForTimeout(3_000);
|
||||
} else if (path === '/') {
|
||||
const rs = page.getByText('请选择您的登录身份');
|
||||
try {
|
||||
await rs.waitFor({ state: 'visible', timeout: 10_000 });
|
||||
await page.locator('.van-grid-item').filter({ hasText: teacherRoleText }).click();
|
||||
await page.waitForTimeout(3_000);
|
||||
return;
|
||||
} catch {
|
||||
// 无角色选择器 → 角色已自动选中,继续
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
await items.first().click();
|
||||
// 已在目标页面
|
||||
break;
|
||||
}
|
||||
await page.waitForTimeout(3000);
|
||||
} catch {
|
||||
// No role dialog — proceed with default role
|
||||
}
|
||||
}
|
||||
|
||||
// CI 环境下 /clazz 页加载较慢,给予更宽松的超时
|
||||
test.setTimeout(240_000);
|
||||
|
||||
test.describe('排课双视图切换(阿难账号)', () => {
|
||||
|
||||
test('教师端排课页显示视图切换按钮', async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user