fix(e2e): 机构页就绪判断改为统一轮询
避免 Promise.race 分支 waitFor 超时直接失败,改为 #app 文本与机构 cell 的组合条件轮询。 Made-with: Cursor
This commit is contained in:
@@ -221,18 +221,22 @@ test.describe('多机构数据隔离(会话与 token)', () => {
|
|||||||
test.skip(true, '打开机构页时会话已退回访客态');
|
test.skip(true, '打开机构页时会话已退回访客态');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 线上壳层不一定是 .main>h4(路由/构建差异);任一就绪即可
|
// 线上壳层可能存在结构差异;轮询任一机构页就绪信号,避免分支超时互相误杀
|
||||||
await Promise.race([
|
await expect
|
||||||
page.locator('#app').getByText(/请选择机构/).first().waitFor({
|
.poll(
|
||||||
state: 'visible',
|
async () =>
|
||||||
timeout: 90_000,
|
page.evaluate(() => {
|
||||||
}),
|
const appRoot = document.querySelector('#app');
|
||||||
page.getByText('暂无可用机构').waitFor({ state: 'visible', timeout: 90_000 }),
|
if (!appRoot) return false;
|
||||||
page
|
const rootText = appRoot.textContent ?? '';
|
||||||
.locator('#app .van-cell-group .van-cell')
|
const hasOrgTitle = /请选择机构/.test(rootText);
|
||||||
.first()
|
const hasEmptyHint = rootText.includes('暂无可用机构');
|
||||||
.waitFor({ state: 'visible', timeout: 90_000 }),
|
const hasOrgCells = !!appRoot.querySelector('.van-cell-group .van-cell');
|
||||||
]);
|
return hasOrgTitle || hasEmptyHint || hasOrgCells;
|
||||||
|
}),
|
||||||
|
{ timeout: 90_000, intervals: [500, 1000, 2000] }
|
||||||
|
)
|
||||||
|
.toBeTruthy();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
await page.getByText('暂无可用机构').isVisible().catch(() => false)
|
await page.getByText('暂无可用机构').isVisible().catch(() => false)
|
||||||
|
|||||||
Reference in New Issue
Block a user