mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 08:25:23 +02:00
test: add coverage for non-OAuth fallback oauthRequired handler
Verify that MCPConnectionFactory registers a fallback handler on non-OAuth connections that emits oauthFailed when oauthRequired fires.
This commit is contained in:
parent
0922db9db2
commit
aa97376c05
1 changed files with 29 additions and 0 deletions
|
|
@ -93,6 +93,35 @@ describe('MCPConnectionFactory', () => {
|
|||
expect(mockConnectionInstance.connect).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should register fallback oauthRequired handler for non-OAuth connections', async () => {
|
||||
const basicOptions = {
|
||||
serverName: 'test-server',
|
||||
serverConfig: mockServerConfig,
|
||||
};
|
||||
|
||||
mockConnectionInstance.isConnected.mockResolvedValue(true);
|
||||
|
||||
await MCPConnectionFactory.create(basicOptions);
|
||||
|
||||
expect(mockConnectionInstance.once).toHaveBeenCalledWith(
|
||||
'oauthRequired',
|
||||
expect.any(Function),
|
||||
);
|
||||
|
||||
const onceCall = (mockConnectionInstance.once as jest.Mock).mock.calls.find(
|
||||
([event]: [string]) => event === 'oauthRequired',
|
||||
);
|
||||
expect(onceCall).toBeDefined();
|
||||
|
||||
const handler = onceCall![1] as () => void;
|
||||
handler();
|
||||
|
||||
expect(mockConnectionInstance.emit).toHaveBeenCalledWith(
|
||||
'oauthFailed',
|
||||
expect.objectContaining({ message: 'Server does not use OAuth' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('should create a connection with OAuth', async () => {
|
||||
const basicOptions = {
|
||||
serverName: 'test-server',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue