test: replace flaky login assertions with localStorage JWT check

loginAndGetJwt / loginAsStudent no longer wait 120s for text patterns
that may not appear. Instead they wait for Authorization in localStorage,
which is faster and more reliable.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 16:15:54 +08:00
parent 90f3bbf442
commit 2f73bea4b6
2 changed files with 19 additions and 37 deletions
+5 -3
View File
@@ -48,9 +48,11 @@ async function loginAndGetJwt(page: any): Promise<string> {
) {
await page.locator('.van-grid-item').first().click();
}
await expect(
page.getByText(/请选择您的登录身份|欢迎回来|进入工作台/),
).toBeVisible({ timeout: 120_000 });
// Wait for JWT to appear in localStorage (login completed)
await page.waitForFunction(
() => !!window.localStorage.getItem('Authorization'),
{ timeout: 90_000 },
);
if (
await page.getByText('请返回微信小程序完成登录').isVisible().catch(() => false)