mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
feat(gateway): grant scopes by verified identity (#121531)
* feat(gateway): grant scopes by verified identity * chore(plugin-sdk): refresh API baseline * test(agents): isolate transcript repair mocks
This commit is contained in:
committed by
GitHub
parent
e97c3450a2
commit
c6edd3e80f
@@ -247,6 +247,15 @@ beforeAll(async () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks();
|
||||
state.runAgentAttemptMock.mockReset();
|
||||
state.loadManifestModelCatalogMock.mockReset();
|
||||
state.normalizeProviderModelIdWithRuntimeMock.mockReset();
|
||||
state.runCliTurnCompactionLifecycleMock.mockReset();
|
||||
state.deliverAgentCommandResultMock.mockReset();
|
||||
state.emitAgentEventMock.mockReset();
|
||||
state.persistCliTurnTranscriptMock.mockReset();
|
||||
state.appendExactAssistantMessageMock.mockReset();
|
||||
state.persistSessionEntryMock.mockReset();
|
||||
state.loadManifestModelCatalogMock.mockReturnValue([]);
|
||||
state.normalizeProviderModelIdWithRuntimeMock.mockImplementation(() => undefined);
|
||||
state.runCliTurnCompactionLifecycleMock.mockImplementation(
|
||||
@@ -474,11 +483,24 @@ describe("assistant transcript repair", () => {
|
||||
);
|
||||
await agentCommand({ message: "user one", sessionId, sessionKey, cwd: state.workspaceDir });
|
||||
|
||||
state.persistSessionEntryMock.mockRejectedValueOnce(new Error("simulated cleanup failure"));
|
||||
let cleanupFailureInjected = false;
|
||||
state.persistSessionEntryMock.mockImplementation(async (...args) => {
|
||||
const [params] = args;
|
||||
if (
|
||||
!cleanupFailureInjected &&
|
||||
params.initialEntry.pendingTranscriptRepair?.length &&
|
||||
params.entry.pendingTranscriptRepair === undefined
|
||||
) {
|
||||
cleanupFailureInjected = true;
|
||||
throw new Error("simulated cleanup failure");
|
||||
}
|
||||
return state.persistSessionEntryReal?.(...args);
|
||||
});
|
||||
state.runAgentAttemptMock.mockResolvedValueOnce(
|
||||
makeResult({ sessionId, text: "assistant two", runner: "cli" }),
|
||||
);
|
||||
await agentCommand({ message: "user two", sessionId, sessionKey, cwd: state.workspaceDir });
|
||||
expect(cleanupFailureInjected).toBe(true);
|
||||
expect(findStoredSessionEntry(sessionKey)?.pendingTranscriptRepair).toHaveLength(1);
|
||||
|
||||
state.runAgentAttemptMock.mockResolvedValueOnce(
|
||||
|
||||
Reference in New Issue
Block a user