26312055c5
* fix(schema): Add union with undefined to the tool permission props. * fix(schema): Add union with undefined to the tool permission props. * Add CI tests. * fix: reduced nesting in tests. * Add project-based config for vitest to run all tests by a single command.
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { Inputs } from './payload.ts';
|
|
|
|
describe('Inputs schema', () => {
|
|
it('only prompt is required', () => {
|
|
const result = Inputs.assert({prompt: 'test prompt'});
|
|
expect(result).toEqual({prompt: 'test prompt'});
|
|
expect(() => Inputs.assert({})).toThrow();
|
|
});
|
|
|
|
it.each([
|
|
['web', 'enabled'],
|
|
['web', 'disabled'],
|
|
['web', undefined],
|
|
['search', 'enabled'],
|
|
['search', 'disabled'],
|
|
['search', undefined],
|
|
['write', 'enabled'],
|
|
['write', 'disabled'],
|
|
['write', undefined],
|
|
['bash', 'enabled'],
|
|
['bash', 'restricted'],
|
|
['bash', 'disabled'],
|
|
['bash', undefined],
|
|
['effort', 'mini'],
|
|
['effort', 'auto'],
|
|
['effort', 'max'],
|
|
['agent', 'claude'],
|
|
['agent', 'codex'],
|
|
['agent', 'cursor'],
|
|
['agent', 'gemini'],
|
|
['agent', 'opencode'],
|
|
['agent', null],
|
|
] as const)('should accept %s for %s', (prop, value) => {
|
|
const input = {prompt: 'test', [prop]: value};
|
|
expect(() => Inputs.assert(input)).not.toThrow();
|
|
});
|
|
|
|
|
|
it.each([
|
|
['web'],
|
|
['search'],
|
|
['write'],
|
|
['bash'],
|
|
['effort'],
|
|
['agent'],
|
|
] as const)('should reject invalid %s values', (prop) => {
|
|
const input = {prompt: 'test', [prop]: 'invalid' as any};
|
|
expect(() => Inputs.assert(input)).toThrow();
|
|
});
|
|
|
|
});
|