2026-04-28 08:45:12 +08:00
|
|
|
|
import { expect, test } from './fixtures';
|
2026-04-27 20:11:48 +08:00
|
|
|
|
|
|
|
|
|
|
const moicenUnionid = process.env.MOICEN_E2E_UNIONID?.trim();
|
|
|
|
|
|
|
|
|
|
|
|
test.describe('机构多租户入口链路', () => {
|
|
|
|
|
|
test.skip(!moicenUnionid, '需要 MOICEN_E2E_UNIONID(Secret 或 .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 });
|
2026-04-27 20:37:18 +08:00
|
|
|
|
|
2026-05-01 10:37:48 +08:00
|
|
|
|
// 线上会话状态可能被服务端回收;出现访客课包商店时跳过,不让 CI 因账号瞬时态失败。
|
2026-04-27 20:37:18 +08:00
|
|
|
|
if (
|
|
|
|
|
|
await page
|
2026-05-01 10:37:48 +08:00
|
|
|
|
.locator('.course-package-store')
|
2026-04-27 20:37:18 +08:00
|
|
|
|
.isVisible()
|
|
|
|
|
|
.catch(() => false)
|
|
|
|
|
|
) {
|
|
|
|
|
|
test.skip(true, '当前 unionid 会话未处于可用登录态,跳过机构入口断言');
|
|
|
|
|
|
}
|
2026-04-27 20:11:48 +08:00
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|