diff --git a/tests/org-data-isolation.spec.ts b/tests/org-data-isolation.spec.ts index a1971e1..14d6ee7 100644 --- a/tests/org-data-isolation.spec.ts +++ b/tests/org-data-isolation.spec.ts @@ -221,18 +221,22 @@ test.describe('多机构数据隔离(会话与 token)', () => { test.skip(true, '打开机构页时会话已退回访客态'); } - // 线上壳层不一定是 .main>h4(路由/构建差异);任一就绪即可 - await Promise.race([ - page.locator('#app').getByText(/请选择机构/).first().waitFor({ - state: 'visible', - timeout: 90_000, - }), - page.getByText('暂无可用机构').waitFor({ state: 'visible', timeout: 90_000 }), - page - .locator('#app .van-cell-group .van-cell') - .first() - .waitFor({ state: 'visible', timeout: 90_000 }), - ]); + // 线上壳层可能存在结构差异;轮询任一机构页就绪信号,避免分支超时互相误杀 + await expect + .poll( + async () => + page.evaluate(() => { + const appRoot = document.querySelector('#app'); + if (!appRoot) return false; + const rootText = appRoot.textContent ?? ''; + const hasOrgTitle = /请选择机构/.test(rootText); + const hasEmptyHint = rootText.includes('暂无可用机构'); + const hasOrgCells = !!appRoot.querySelector('.van-cell-group .van-cell'); + return hasOrgTitle || hasEmptyHint || hasOrgCells; + }), + { timeout: 90_000, intervals: [500, 1000, 2000] } + ) + .toBeTruthy(); if ( await page.getByText('暂无可用机构').isVisible().catch(() => false)