Files
huike-e2e-moicen/tests/org-multi-tenant.spec.ts
T

60 lines
1.8 KiB
TypeScript
Raw Normal View History

import { expect, test } from './fixtures';
const moicenUnionid = process.env.MOICEN_E2E_UNIONID?.trim();
test.describe('机构多租户入口链路', () => {
test.skip(!moicenUnionid, '需要 MOICEN_E2E_UNIONIDSecret 或 .env.e2e');
test('登录后可进入机构选择页且不出现未登录占位', async ({ page }) => {
const queryString = new URLSearchParams({
unionid: moicenUnionid!,
status: '2',
});
await page.goto(`/?${queryString.toString()}`, {
waitUntil: 'domcontentloaded',
timeout: 60_000,
});
await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 });
if (
await page
.getByText('请选择您的登录身份')
.isVisible()
.catch(() => false)
) {
await page.locator('.van-grid-item').first().click();
}
await page.goto('/org/select', {
waitUntil: 'domcontentloaded',
timeout: 60_000,
});
await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 });
// 线上会话状态可能被服务端回收;出现访客占位时跳过,不让 CI 因账号瞬时态失败。
if (
await page
.getByText('请返回微信小程序完成登录')
.isVisible()
.catch(() => false)
) {
test.skip(true, '当前 unionid 会话未处于可用登录态,跳过机构入口断言');
}
const institutionCandidates = [
page.getByRole('heading', { name: /机构|选择机构/ }),
page.getByText(/机构|切换机构|选择机构/),
page.locator('.van-cell'),
page.locator('.van-card'),
];
let foundInstitutionUI = false;
for (const institutionLocator of institutionCandidates) {
if ((await institutionLocator.count()) > 0) {
foundInstitutionUI = true;
break;
}
}
expect(foundInstitutionUI).toBeTruthy();
});
});