38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
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*</);
|
|
});
|
|
|
|
test('websocket fallback uses the current browser host', async () => {
|
|
const config = await source('src/lib/config.ts');
|
|
|
|
assert.match(config, /window\.location\.host/);
|
|
assert.doesNotMatch(config, /web\.118im\.com/);
|
|
});
|
|
|
|
test('local development proxies the same-origin websocket path', async () => {
|
|
const vite = await source('vite.config.ts');
|
|
|
|
assert.match(vite, /['"]\/v0\/channels['"]\s*:\s*\{[^}]*ws:\s*true/);
|
|
});
|