72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
|
|
|
import { RemoteIngressManager } from '../ts/remoteingress/index.js';
|
|
import { RemoteIngressHubSettingsDoc } from '../ts/db/index.js';
|
|
|
|
tap.test('RemoteIngressManager preserves omitted hub settings on partial update', async () => {
|
|
const originalLoad = RemoteIngressHubSettingsDoc.load;
|
|
const fakeDoc: any = {
|
|
settingsId: 'remote-ingress-hub-settings',
|
|
enabled: true,
|
|
tunnelPort: 29443,
|
|
hubDomain: 'ingress.example.com',
|
|
performance: {
|
|
totalWindowBudgetBytes: 134217728,
|
|
},
|
|
updatedAt: 1,
|
|
updatedBy: 'seed',
|
|
save: async () => undefined,
|
|
};
|
|
|
|
(RemoteIngressHubSettingsDoc as any).load = async () => fakeDoc;
|
|
try {
|
|
const manager = new RemoteIngressManager();
|
|
const settings = await manager.updateHubSettings({
|
|
performance: {
|
|
maxStreamsPerEdge: 10000,
|
|
},
|
|
}, 'test-user');
|
|
|
|
expect(settings.enabled).toEqual(true);
|
|
expect(settings.tunnelPort).toEqual(29443);
|
|
expect(settings.hubDomain).toEqual('ingress.example.com');
|
|
expect(settings.performance?.maxStreamsPerEdge).toEqual(10000);
|
|
} finally {
|
|
(RemoteIngressHubSettingsDoc as any).load = originalLoad;
|
|
}
|
|
});
|
|
|
|
tap.test('RemoteIngressManager clears optional hub settings explicitly', async () => {
|
|
const originalLoad = RemoteIngressHubSettingsDoc.load;
|
|
const fakeDoc: any = {
|
|
settingsId: 'remote-ingress-hub-settings',
|
|
enabled: true,
|
|
tunnelPort: 29443,
|
|
hubDomain: 'ingress.example.com',
|
|
performance: {
|
|
maxStreamsPerEdge: 10000,
|
|
},
|
|
updatedAt: 1,
|
|
updatedBy: 'seed',
|
|
save: async () => undefined,
|
|
};
|
|
|
|
(RemoteIngressHubSettingsDoc as any).load = async () => fakeDoc;
|
|
try {
|
|
const manager = new RemoteIngressManager();
|
|
const settings = await manager.updateHubSettings({
|
|
hubDomain: null,
|
|
performance: null,
|
|
}, 'test-user');
|
|
|
|
expect(settings.enabled).toEqual(true);
|
|
expect(settings.tunnelPort).toEqual(29443);
|
|
expect(settings.hubDomain).toBeUndefined();
|
|
expect(settings.performance).toBeUndefined();
|
|
} finally {
|
|
(RemoteIngressHubSettingsDoc as any).load = originalLoad;
|
|
}
|
|
});
|
|
|
|
export default tap.start();
|