Refactor VPN proxy client implementation
Build and Deploy Gateway / build-and-push (push) Failing after 2s
Build and Deploy Gateway / deploy (push) Has been skipped

This commit is contained in:
2026-08-09 00:41:52 +03:00
parent 32be4380a3
commit 34d8b681ad
190 changed files with 20064 additions and 9761 deletions
+37 -1
View File
@@ -5,7 +5,9 @@ import {
classifySyncError,
harborReducer,
initialHarborState,
} from '../../src/web/state/harborReducer.js';
} from '../../.test-dist/src/web/state/harborReducer.js';
import { parseHarborState } from '../../.test-dist/src/web/api/harborClient.js';
import { createStateSnapshot } from '../../.test-dist/src/shared/contracts/state.js';
const snapshot = (revision, desiredServerId = '', serverIds = ['one', 'two']) => ({
apiVersion: 1,
@@ -26,6 +28,40 @@ function deferred() {
return { promise, resolve };
}
test('typed Harbor client validates unknown state and isolates wire compatibility fields', () => {
const snapshot = createStateSnapshot({
storedState: {},
runtime: { running: false },
gatewayAuto: null,
appMode: 'client',
configExists: false,
subscriptionHost: '',
now: new Date('2026-07-11T12:00:00.000Z'),
});
const parsed = parseHarborState({
...snapshot,
proxyPort: 9082,
configExists: true,
gatewayAuto: { available: true },
});
assert.deepEqual(parsed.clientRuntime, {
proxyPort: 9082,
configured: true,
gatewayAvailable: true,
});
assert.equal(Object.hasOwn(parsed, 'proxyPort'), false);
let incompatible;
try {
parseHarborState({ ...snapshot, revision: -1 });
} catch (error) {
incompatible = error;
}
assert.equal(incompatible.code, 'INCOMPATIBLE_API');
const failed = harborReducer(initialHarborState, { type: 'sync-failed', error: incompatible });
assert.equal(failed.transport.bootStatus, 'incompatible-api');
});
test('data invariant: an older polling promise cannot replace a newer mutation snapshot', async () => {
let state = receive(initialHarborState, snapshot(1, 'one'));
const poll = deferred();