diff --git a/tests/org-data-isolation.spec.ts b/tests/org-data-isolation.spec.ts index 55a130a..b3473be 100644 --- a/tests/org-data-isolation.spec.ts +++ b/tests/org-data-isolation.spec.ts @@ -209,16 +209,23 @@ test.describe('多机构数据隔离(会话与 token)', () => { await resolveOrgContextForCoursePage(page); await page.goto('/org/select', { - waitUntil: 'domcontentloaded', - timeout: 60_000, + waitUntil: 'load', + timeout: 90_000, }); - await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 }); - await page.waitForURL(/\/org\/select/, { timeout: 60_000 }); - await expect(page.getByText(/请选择机构|选择机构/)).toBeVisible({ - timeout: 60_000, + await expect(page.locator('#app')).toBeVisible({ timeout: 90_000 }); + await page.waitForURL(/\/org\/select/, { timeout: 90_000 }); + // 与 `org/select.vue` 根节点一致;避免 getByText 在 Vant/拆行下偶发匹配不到 + await expect(page.locator('.main')).toBeVisible({ timeout: 90_000 }); + if ( + await page.getByText('暂无可用机构').isVisible().catch(() => false) + ) { + test.skip(true, '机构接口无数据,跳过多机构切换断言'); + } + await expect(page.locator('.main h4')).toContainText(/请选择机构/, { + timeout: 90_000, }); - const orgCells = page.locator('#app .van-cell-group .van-cell'); + const orgCells = page.locator('.main .van-cell-group .van-cell'); const count = await orgCells.count(); test.skip( count < 2,