From 3a5c94e52da51e867df677a73a7a6fff7d73d3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=94=B7?= Date: Tue, 28 Apr 2026 10:20:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(e2e):=20=E6=9C=BA=E6=9E=84=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=A1=B5=E7=94=A8=20.main=20h4=20=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=20CI=20=E4=B8=8A=20getByText=20?= =?UTF-8?q?=E5=A4=B1=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- tests/org-data-isolation.spec.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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,