mirror of
https://github.com/k1tbyte/Wand-Enhancer.git
synced 2026-08-29 01:08:51 +00:00
a0b3968d33
Reorganize the panel around product capabilities and integrate the remote i18n feature from origin/master into the new structure. - Restructure src into capability features (app, trainer, library, remote-session, appearance, shared); move the bridge to bridge/src. - Add lingui-based UI localization and wrap remaining user-facing strings (Trans / msg macros); fix the 'END В·' mojibake. - Port WeMod cheat-metadata i18n: capture the access token from the snapshot's renderer in the bridge and fetch localized trainer_meta in remote-session.i18n; guarantee snapshot sync on token failure. - Wire vitest to the app's lingui/preact pipeline (mergeConfig).
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { validateClientMessage, validateSetValueTarget } from './protocol-router';
|
|
|
|
const snapshot = {
|
|
trainerMeta: {
|
|
trainer: { trainerId: 'active' },
|
|
schema: { cheats: [{ target: 'god', type: 'toggle' }] },
|
|
},
|
|
trainerValues: { values: { god: false } },
|
|
};
|
|
|
|
describe('bridge protocol router', () => {
|
|
it('requires a compatible hello before commands', () => {
|
|
const command = {
|
|
type: 'set_value',
|
|
version: 1,
|
|
requestId: 'set',
|
|
payload: { trainerId: 'active', target: 'god', value: true },
|
|
};
|
|
expect(validateClientMessage(command, false)).toMatchObject({
|
|
ok: false,
|
|
error: { code: 'handshake_required' },
|
|
});
|
|
expect(validateClientMessage({ ...command, version: 2 }, true)).toMatchObject({
|
|
ok: false,
|
|
error: { code: 'protocol_mismatch' },
|
|
});
|
|
});
|
|
|
|
it('validates trainer and target while normalizing toggle values', () => {
|
|
expect(validateSetValueTarget({
|
|
payload: { trainerId: 'other', target: 'god', value: 1 },
|
|
}, snapshot)).toMatchObject({ ok: false, error: { code: 'trainer_mismatch' } });
|
|
|
|
expect(validateSetValueTarget({
|
|
payload: { trainerId: 'active', target: 'god', value: 1 },
|
|
}, snapshot)).toMatchObject({ ok: true, value: true });
|
|
});
|
|
});
|