Add unit tests for skill capabilities, skill planner, and UV setup
- Implement tests for random ID generation, ensuring preference for crypto.randomUUID. - Create tests for runtime context capabilities, validating the injection of enabled skill capabilities. - Add tests for skill capability parsing, including classification and command example extraction. - Introduce tests for the skill planner, verifying tool call planning based on user requests and attachment requirements. - Establish tests for UV setup, ensuring proper handling of Python installation scenarios and environment checks.
This commit is contained in:
@@ -33,6 +33,7 @@ import { GatewayLifecycleController, LifecycleSupersededError } from '../electro
|
||||
import { GatewayConnectionMonitor } from '../electron/gateway/connection-monitor';
|
||||
import { GatewayRestartController } from '../electron/gateway/restart-controller';
|
||||
import { GatewayRestartGovernor } from '../electron/gateway/restart-governor';
|
||||
import { createRandomId } from '../electron/gateway/random-id';
|
||||
import {
|
||||
DEFAULT_GATEWAY_RELOAD_POLICY,
|
||||
parseGatewayReloadPolicy,
|
||||
@@ -69,6 +70,52 @@ describe('startup-stderr helpers', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('random-id helpers', () => {
|
||||
it('prefers crypto.randomUUID when available', () => {
|
||||
const originalCrypto = Object.getOwnPropertyDescriptor(globalThis, 'crypto');
|
||||
|
||||
try {
|
||||
Object.defineProperty(globalThis, 'crypto', {
|
||||
value: {
|
||||
randomUUID: () => 'uuid-from-crypto',
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
expect(createRandomId()).toBe('uuid-from-crypto');
|
||||
} finally {
|
||||
if (originalCrypto) {
|
||||
Object.defineProperty(globalThis, 'crypto', originalCrypto);
|
||||
} else {
|
||||
Reflect.deleteProperty(globalThis, 'crypto');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('falls back to a deterministic local id when crypto.randomUUID is unavailable', () => {
|
||||
const originalCrypto = Object.getOwnPropertyDescriptor(globalThis, 'crypto');
|
||||
const dateNowSpy = vi.spyOn(Date, 'now').mockReturnValue(1760000000000);
|
||||
const mathRandomSpy = vi.spyOn(Math, 'random').mockReturnValue(0.5);
|
||||
|
||||
try {
|
||||
Object.defineProperty(globalThis, 'crypto', {
|
||||
value: undefined,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
expect(createRandomId()).toMatch(/^id-1760000000000-/);
|
||||
} finally {
|
||||
dateNowSpy.mockRestore();
|
||||
mathRandomSpy.mockRestore();
|
||||
if (originalCrypto) {
|
||||
Object.defineProperty(globalThis, 'crypto', originalCrypto);
|
||||
} else {
|
||||
Reflect.deleteProperty(globalThis, 'crypto');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('startup-recovery helpers', () => {
|
||||
it('retries transient startup errors before max attempts', () => {
|
||||
expect(getGatewayStartupRecoveryAction({
|
||||
|
||||
Reference in New Issue
Block a user