3x-ui/frontend/src/test/__snapshots__/inbound-defaults.test.ts.snap
MHSanaei 8d5d11cafc
refactor(frontend): extract createDefault*Client factories to lib/xray
Next Step 3d slice. Five plain-object factories — Vless, Vmess, Trojan,
Shadowsocks, Hysteria — replace the legacy
`new Inbound.<Protocol>Settings.<Protocol>(...)` constructor chain and the
ClientBase XrayCommonClass machinery. Each factory takes an optional
seed; missing random fields (id, password, auth, email, subId) fall
through to RandomUtil at call time. Forms can hand-pick a UUID; tests
pass deterministic seeds so the suite never touches window.crypto.

Tests double-verify each factory: a snapshot locks the exact shape, and
the matching Zod ClientSchema.parse(out) must equal `out` — no missing
defaults, no stray fields, type-narrowed end-to-end.

Discovered: VmessClientSchema and VlessClientSchema enforce z.uuid()
format, so the test seeds use real-shape UUIDs.

Suite: 49 tests across 6 files; typecheck + lint clean. Outbound and
inbound-settings factories follow in subsequent turns alongside the
toShareLink extraction.
2026-05-25 23:42:30 +02:00

79 lines
1.6 KiB
Text

// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`createDefaultHysteriaClient > produces a Zod-valid client 1`] = `
{
"auth": "fixed-hyst-auth",
"comment": "",
"email": "fixture@example.test",
"enable": true,
"expiryTime": 0,
"limitIp": 0,
"reset": 0,
"subId": "fixed-sub-id-1234",
"tgId": 0,
"totalGB": 0,
}
`;
exports[`createDefaultShadowsocksClient > produces a Zod-valid client 1`] = `
{
"comment": "",
"email": "fixture@example.test",
"enable": true,
"expiryTime": 0,
"limitIp": 0,
"method": "",
"password": "ZmFrZS1zcy1wYXNzd29yZA==",
"reset": 0,
"subId": "fixed-sub-id-1234",
"tgId": 0,
"totalGB": 0,
}
`;
exports[`createDefaultTrojanClient > produces a Zod-valid client 1`] = `
{
"comment": "",
"email": "fixture@example.test",
"enable": true,
"expiryTime": 0,
"limitIp": 0,
"password": "fixed-trojan-pw",
"reset": 0,
"subId": "fixed-sub-id-1234",
"tgId": 0,
"totalGB": 0,
}
`;
exports[`createDefaultVlessClient > produces a Zod-valid client 1`] = `
{
"comment": "",
"email": "fixture@example.test",
"enable": true,
"expiryTime": 0,
"flow": "",
"id": "11111111-2222-4333-8444-555555555555",
"limitIp": 0,
"reset": 0,
"subId": "fixed-sub-id-1234",
"tgId": 0,
"totalGB": 0,
}
`;
exports[`createDefaultVmessClient > produces a Zod-valid client 1`] = `
{
"comment": "",
"email": "fixture@example.test",
"enable": true,
"expiryTime": 0,
"id": "aaaaaaaa-bbbb-4ccc-9ddd-eeeeeeeeeeee",
"limitIp": 0,
"reset": 0,
"security": "auto",
"subId": "fixed-sub-id-1234",
"tgId": 0,
"totalGB": 0,
}
`;