@lvce-editor/test-worker 14.14.0 → 14.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +15 -0
- package/dist/testWorkerMain.js +45 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -101,6 +101,17 @@ export interface MockOpenAiResponseOptions {
|
|
|
101
101
|
readonly value: any;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
export interface ToolCallItem {
|
|
105
|
+
readonly toolCall: {
|
|
106
|
+
readonly arguments: any;
|
|
107
|
+
readonly name: "list_files";
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface TextItem {
|
|
112
|
+
readonly text: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
104
115
|
export interface ChatDebugEvent {
|
|
105
116
|
readonly [key: string]: unknown;
|
|
106
117
|
}
|
|
@@ -145,6 +156,8 @@ export interface SelectItem2Options {
|
|
|
145
156
|
readonly label: string;
|
|
146
157
|
}
|
|
147
158
|
|
|
159
|
+
export type MockRequestInput = ToolCallItem | TextItem;
|
|
160
|
+
|
|
148
161
|
export type ChatDebugInputName = "closeDetails" | "eventCategoryFilter" | "filter" | "showEventStreamFinishedEvents" | "showInputEvents" | "showResponsePartEvents" | "timelineRangePreset" | "useDevtoolsLayout";
|
|
149
162
|
|
|
150
163
|
export type TokenRow = readonly string[];
|
|
@@ -250,6 +263,7 @@ interface Chat {
|
|
|
250
263
|
readonly mockOpenAiResponse: (options: MockOpenAiResponseOptions) => Promise<void>;
|
|
251
264
|
readonly mockOpenApiRequestGetAll: () => Promise<readonly any[]>;
|
|
252
265
|
readonly mockOpenApiRequestReset: () => Promise<void>;
|
|
266
|
+
readonly mockOpenApiSetResponse: (items: readonly MockRequestInput[]) => Promise<void>;
|
|
253
267
|
readonly mockOpenApiStreamFinish: () => Promise<void>;
|
|
254
268
|
readonly mockOpenApiStreamPushChunk: (chunk: string) => Promise<void>;
|
|
255
269
|
readonly mockOpenApiStreamReset: () => Promise<void>;
|
|
@@ -315,6 +329,7 @@ interface ChatDebug {
|
|
|
315
329
|
readonly setShowInputEvents: (enabled: boolean) => Promise<void>;
|
|
316
330
|
readonly setShowResponsePartEvents: (enabled: boolean) => Promise<void>;
|
|
317
331
|
readonly setTimelineRangePreset: (value: string) => Promise<void>;
|
|
332
|
+
readonly shouldHavePayload: (expectedPayload: any) => Promise<void>;
|
|
318
333
|
readonly toggleHeadersSection: (sectionId: string) => Promise<void>;
|
|
319
334
|
readonly useDevtoolsLayout: () => Promise<void>;
|
|
320
335
|
}
|
package/dist/testWorkerMain.js
CHANGED
|
@@ -2060,6 +2060,9 @@ const setShowChatListTime = async showTime => {
|
|
|
2060
2060
|
const handleAgentModeChange = async newAgentMode => {
|
|
2061
2061
|
return invoke('Chat.handleAgentModeChange', newAgentMode);
|
|
2062
2062
|
};
|
|
2063
|
+
const mockOpenApiSetResponse = async items => {
|
|
2064
|
+
return invoke('Chat.mockOpenApiSetResponse', items);
|
|
2065
|
+
};
|
|
2063
2066
|
|
|
2064
2067
|
const Chat = {
|
|
2065
2068
|
chatListFocusFirst,
|
|
@@ -2101,6 +2104,7 @@ const Chat = {
|
|
|
2101
2104
|
mockOpenAiResponse,
|
|
2102
2105
|
mockOpenApiRequestGetAll,
|
|
2103
2106
|
mockOpenApiRequestReset,
|
|
2107
|
+
mockOpenApiSetResponse,
|
|
2104
2108
|
mockOpenApiStreamFinish,
|
|
2105
2109
|
mockOpenApiStreamPushChunk,
|
|
2106
2110
|
mockOpenApiStreamReset,
|
|
@@ -2132,6 +2136,26 @@ const Chat = {
|
|
|
2132
2136
|
useMockApi
|
|
2133
2137
|
};
|
|
2134
2138
|
|
|
2139
|
+
const defaultMessage = 'ChatDebug.shouldHavePayload assertion failed';
|
|
2140
|
+
const getMessage = cause => {
|
|
2141
|
+
if (!cause || typeof cause !== 'object') {
|
|
2142
|
+
return defaultMessage;
|
|
2143
|
+
}
|
|
2144
|
+
if ('message' in cause && typeof cause.message === 'string' && cause.message) {
|
|
2145
|
+
return cause.message;
|
|
2146
|
+
}
|
|
2147
|
+
return defaultMessage;
|
|
2148
|
+
};
|
|
2149
|
+
class ChatDebugShouldHavePayloadError extends Error {
|
|
2150
|
+
constructor(expectedPayload, actualPayload, cause) {
|
|
2151
|
+
super(getMessage(cause));
|
|
2152
|
+
this.name = 'ChatDebugShouldHavePayloadError';
|
|
2153
|
+
this.code = 'chat-debug.should-have-payload';
|
|
2154
|
+
this.expectedPayload = expectedPayload;
|
|
2155
|
+
this.actualPayload = actualPayload;
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2135
2159
|
const open$a = async sessionId => {
|
|
2136
2160
|
await invoke('Main.openUri', `chat-debug://${sessionId}`);
|
|
2137
2161
|
};
|
|
@@ -2169,6 +2193,26 @@ const resetIndexedDbSupportForTest = async () => {
|
|
|
2169
2193
|
const selectEventRow = async index => {
|
|
2170
2194
|
await invoke('ChatDebug.handleEventRowClick', String(index));
|
|
2171
2195
|
};
|
|
2196
|
+
const getActualPayload = error => {
|
|
2197
|
+
if (!error || typeof error !== 'object') {
|
|
2198
|
+
return undefined;
|
|
2199
|
+
}
|
|
2200
|
+
if ('actualPayload' in error) {
|
|
2201
|
+
return error.actualPayload;
|
|
2202
|
+
}
|
|
2203
|
+
if ('actual' in error) {
|
|
2204
|
+
return error.actual;
|
|
2205
|
+
}
|
|
2206
|
+
return undefined;
|
|
2207
|
+
};
|
|
2208
|
+
const shouldHavePayload = async expectedPayload => {
|
|
2209
|
+
try {
|
|
2210
|
+
await invoke('ChatDebug.shouldHavePayload', expectedPayload);
|
|
2211
|
+
} catch (error) {
|
|
2212
|
+
const actualPayload = getActualPayload(error);
|
|
2213
|
+
throw new ChatDebugShouldHavePayloadError(expectedPayload, actualPayload, error);
|
|
2214
|
+
}
|
|
2215
|
+
};
|
|
2172
2216
|
const handleInput$7 = async (name, value, checked) => {
|
|
2173
2217
|
await invoke('ChatDebug.handleInput', name, value, checked);
|
|
2174
2218
|
};
|
|
@@ -2282,6 +2326,7 @@ const ChatDebug = {
|
|
|
2282
2326
|
setShowInputEvents,
|
|
2283
2327
|
setShowResponsePartEvents,
|
|
2284
2328
|
setTimelineRangePreset,
|
|
2329
|
+
shouldHavePayload,
|
|
2285
2330
|
toggleHeadersSection,
|
|
2286
2331
|
useDevtoolsLayout
|
|
2287
2332
|
};
|