diff --git a/tests/course-package-store.spec.ts b/tests/course-package-store.spec.ts index b44a598..174bb09 100644 --- a/tests/course-package-store.spec.ts +++ b/tests/course-package-store.spec.ts @@ -255,10 +255,13 @@ async function loginAsStudent(page: any, moicenUnionid: string) { if (await page.locator('.course-package-store').isVisible().catch(() => false)) { return false; // session not usable } - const orgCell = page.locator('#app .van-cell-group .van-cell').first(); - if (await orgCell.isVisible({ timeout: 5000 }).catch(() => false)) { - await orgCell.click(); - await page.waitForTimeout(2000); + const firstOrgCell = page.locator('#app .van-cell-group .van-cell').first(); + if (await firstOrgCell.isVisible({ timeout: 10_000 }).catch(() => false)) { + await firstOrgCell.click(); + // Navigate to a known student page to settle SPA state after org switch + await page.waitForURL(/\/student\/|\//, { timeout: 15_000 }); + await page.goto('/student/profile', { waitUntil: 'domcontentloaded', timeout: 60_000 }); + await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 }); } } return true;