feat: add session-scoped workflow approval gate commands
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
import { createContextCommand, createElevateCommand, createModelCommand, createQueueCommand, createResearchCommand, createTransferCommand } from './index.js';
|
||||
import { createApproveCommand, createApprovalsCommand, createContextCommand, createDenyCommand, createElevateCommand, createModelCommand, createQueueCommand, createResearchCommand, createTransferCommand } from './index.js';
|
||||
|
||||
describe('builtin /model command', () => {
|
||||
it('passes through the full argument string', async () => {
|
||||
@@ -197,3 +197,47 @@ describe('builtin /transfer command', () => {
|
||||
expect(result).toEqual({ handled: true, text: 'Transfer command is not available in this session.' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('builtin approval commands', () => {
|
||||
it('calls getApprovals for /approvals', async () => {
|
||||
const cmd = createApprovalsCommand();
|
||||
const getApprovals = vi.fn(() => '1 pending');
|
||||
const result = await cmd.execute([], {
|
||||
channel: 'test',
|
||||
senderId: 'user',
|
||||
sessionId: 's1',
|
||||
rawInput: '/approvals',
|
||||
services: { getApprovals },
|
||||
});
|
||||
expect(getApprovals).toHaveBeenCalledOnce();
|
||||
expect(result).toEqual({ handled: true, text: '1 pending' });
|
||||
});
|
||||
|
||||
it('passes raw input to approvePending for /approve', async () => {
|
||||
const cmd = createApproveCommand();
|
||||
const approvePending = vi.fn(() => 'approved');
|
||||
const result = await cmd.execute(['abc-123'], {
|
||||
channel: 'test',
|
||||
senderId: 'user',
|
||||
sessionId: 's1',
|
||||
rawInput: '/approve abc-123',
|
||||
services: { approvePending },
|
||||
});
|
||||
expect(approvePending).toHaveBeenCalledWith('abc-123');
|
||||
expect(result).toEqual({ handled: true, text: 'approved' });
|
||||
});
|
||||
|
||||
it('passes raw input to denyPending for /deny', async () => {
|
||||
const cmd = createDenyCommand();
|
||||
const denyPending = vi.fn(() => 'denied');
|
||||
const result = await cmd.execute(['abc-123', 'too', 'risky'], {
|
||||
channel: 'test',
|
||||
senderId: 'user',
|
||||
sessionId: 's1',
|
||||
rawInput: '/deny abc-123 too risky',
|
||||
services: { denyPending },
|
||||
});
|
||||
expect(denyPending).toHaveBeenCalledWith('abc-123 too risky');
|
||||
expect(result).toEqual({ handled: true, text: 'denied' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user