Files
im_webapp/web/tests/fixed-tenant.test.mjs
T

25 lines
979 B
JavaScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import test from 'node:test';
const source = (path) => readFile(new URL(`../${path}`, import.meta.url), 'utf8');
test('tenant entry is permanently fixed to default', async () => {
const config = await source('src/lib/config.ts');
const entry = await source('src/features/auth/TenantEntryPage.tsx');
assert.match(config, /FIXED_TENANT_CODE = 'default'/);
assert.match(entry, /value=\{FIXED_TENANT_CODE\}/);
assert.match(entry, /readOnly/);
assert.match(entry, /resolveTenant\(FIXED_TENANT_CODE\)/);
assert.doesNotMatch(entry, /setCode/);
});
test('login page exposes no tenant switch and rejects stale tenant state', async () => {
const login = await source('src/features/auth/LoginPage.tsx');
assert.match(login, /tenant\.code !== FIXED_TENANT_CODE/);
assert.match(login, /企业码:\{FIXED_TENANT_CODE\}/);
assert.doesNotMatch(login, />\s*切换企业\s*</);
});