LibreChat/client/test/turnServices.ts
Marco Beretta f7d95f0f1c
📮 refactor: Derive a Send's Code Decision Inside @librechat/chat (#17797)
* refactor: Derive a Send's Code Decision Inside @librechat/chat

TurnServices.resolveCode computed the code workspace and approval a send
carries in the app. It becomes readCodeInputs, a storage read of the raw values,
and the package derives the decision through resolveTurnCode. The read goes
through a ref updated each render, so a captured adapter still reads the newest
render's values.

* test: Close Mocked Readers Over Each Render in the Freshness Spec

* test: Close the Mobile Drawer Through the Race-Tolerant Helper in Two Agent Specs

Two specs closed the drawer after selecting an agent with a bare click on
Close sidebar. The drawer closes itself as the selection lands, so the click
waited on a button that stopped being visible and ran into the 120 s test
timeout on phones. closeMobileDrawer, which #17764 added for this, handles that
race and keeps the inert check.
2026-11-07 18:51:32 +01:00

28 lines
980 B
TypeScript

import type { TurnServices } from '@librechat/chat/react';
/** Turn services with no app behind them, for specs that mock `~/hooks/Chat/services` because
* they exercise the chat hooks without a router, query client or agent settings. */
export const createTestTurnServices = (): TurnServices => ({
logger: { log: jest.fn(), dir: jest.fn(), warn: jest.fn() },
isTemporary: false,
getEndpointsConfig: () => undefined,
getEphemeralAgent: () => null,
getUserKey: () => undefined,
getRouteProjectId: () => null,
readCodeInputs: () => ({
workspace: {
conversation: null,
canRunCode: false,
configurationLoaded: true,
recoveryPending: true,
replacingDecision: false,
statuses: {},
getPreferredWorkspace: () => undefined,
},
approval: { conversation: null, reachable: { agents: [], complete: true } },
latest: null,
}),
openNewChat: jest.fn(),
releaseFiles: jest.fn(),
clearFilesToDelete: jest.fn(),
});