test(e2e): add org multi-tenant entry coverage
Add a moicen Playwright scenario that verifies logged-in users can access org selection flow without falling back to guest placeholder, to protect tenant-entry behavior in production. Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
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 });
|
||||
await expect(
|
||||
page.getByText('请返回微信小程序完成登录')
|
||||
).not.toBeVisible({ timeout: 60_000 });
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user