3x-ui/frontend/src/test/security.test.ts
MHSanaei 2176e816f0
test(frontend): broaden golden coverage to remaining inbounds + stream + security DUs
Round out Step 3b. Four more inbound fixtures complete the protocol set
(http with two accounts, mixed with socks-style auth, tunnel with a port
map, hysteria v1). Two parallel test files cover the other DUs:
stream.test.ts walks tcp/ws/grpc fixtures through NetworkSettingsSchema,
and security.test.ts walks none/tls/reality through SecuritySettingsSchema.

Snapshot count is now 16 across three test files. The reality fixture
locks in the array form of serverNames/shortIds (the panel class stores
them comma-joined internally but they ship as arrays on the wire). The
TLS fixture pins the file-vs-inline cert DU on the file branch.

Stream coverage for httpupgrade/xhttp/kcp and security mixed-with-stream
combos follow in the next turn, alongside the shadow harness.
2026-05-25 23:26:27 +02:00

26 lines
876 B
TypeScript

/// <reference types="vite/client" />
import { describe, expect, it } from 'vitest';
import { SecuritySettingsSchema } from '@/schemas/protocols';
const securityFixtures = import.meta.glob<unknown>(
'./golden/fixtures/security/*.json',
{ eager: true, import: 'default' },
);
function fixtureName(path: string): string {
const file = path.split('/').pop() ?? path;
return file.replace(/\.json$/, '');
}
describe('SecuritySettingsSchema fixtures', () => {
const entries = Object.entries(securityFixtures).sort(([a], [b]) => a.localeCompare(b));
expect(entries.length, 'expected at least one fixture under golden/fixtures/security').toBeGreaterThan(0);
for (const [path, raw] of entries) {
it(`parses ${fixtureName(path)} byte-stably`, () => {
const parsed = SecuritySettingsSchema.parse(raw);
expect(parsed).toMatchSnapshot();
});
}
});