mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-25 12:34:38 -07:00
test: add Object.create context regression test and tool confirmation integration test (#22356)
This commit is contained in:
@@ -676,6 +676,43 @@ describe('policy.ts', () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should work when context is created via Object.create (prototype chain)', async () => {
|
||||
const mockConfig = {
|
||||
setApprovalMode: vi.fn(),
|
||||
} as unknown as Mocked<Config>;
|
||||
const mockMessageBus = {
|
||||
publish: vi.fn(),
|
||||
} as unknown as Mocked<MessageBus>;
|
||||
|
||||
const baseContext = {
|
||||
config: mockConfig,
|
||||
messageBus: mockMessageBus,
|
||||
};
|
||||
const protoContext: AgentLoopContext = Object.create(baseContext);
|
||||
|
||||
expect(Object.keys(protoContext)).toHaveLength(0);
|
||||
expect(protoContext.config).toBe(mockConfig);
|
||||
expect(protoContext.messageBus).toBe(mockMessageBus);
|
||||
|
||||
const tool = { name: 'test-tool' } as AnyDeclarativeTool;
|
||||
|
||||
await updatePolicy(
|
||||
tool,
|
||||
ToolConfirmationOutcome.ProceedAlways,
|
||||
undefined,
|
||||
protoContext,
|
||||
mockMessageBus,
|
||||
);
|
||||
|
||||
expect(mockMessageBus.publish).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
type: MessageBusType.UPDATE_POLICY,
|
||||
toolName: 'test-tool',
|
||||
persist: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPolicyDenialError', () => {
|
||||
|
||||
Reference in New Issue
Block a user