@lvce-editor/test-worker 14.9.0 → 14.10.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 CHANGED
@@ -86,6 +86,12 @@ export interface DroppedFileHandle {
86
86
  readonly id: number;
87
87
  }
88
88
 
89
+ export interface MockErrorResponse {
90
+ readonly code: string;
91
+ readonly error: string;
92
+ readonly statusCode: number;
93
+ }
94
+
89
95
  export interface MockResponseOptions {
90
96
  readonly text: string;
91
97
  }
@@ -128,6 +134,12 @@ export interface Dirent {
128
134
  readonly type: number;
129
135
  }
130
136
 
137
+ export interface LayoutExpectation extends LayoutExpectationObject {
138
+ readonly activeGroupIndex?: number;
139
+ readonly direction?: LayoutDirection;
140
+ readonly groups?: readonly LayoutExpectationObject[];
141
+ }
142
+
131
143
  export interface SelectItem2Options {
132
144
  readonly callbackCommand: string;
133
145
  readonly label: string;
@@ -137,6 +149,29 @@ export type ChatDebugInputName = "closeDetails" | "eventCategoryFilter" | "filte
137
149
 
138
150
  export type TokenRow = readonly string[];
139
151
 
152
+ export type LayoutDirection = "horizontal" | "vertical" | number;
153
+
154
+ export type LayoutExpectationValue = string | number | boolean | RegExp | null | readonly LayoutExpectationValue[] | LayoutExpectationObject;
155
+
156
+ export type LayoutExpectationObject = {
157
+ readonly [key: string]: LayoutExpectationValue | undefined;
158
+ };
159
+
160
+ export type LayoutGroupState = {
161
+ readonly id?: number | string;
162
+ readonly [key: string]: unknown;
163
+ };
164
+
165
+ export type LayoutState = {
166
+ readonly activeGroupId?: number | string;
167
+ readonly groups?: readonly LayoutGroupState[];
168
+ readonly [key: string]: unknown;
169
+ };
170
+
171
+ export type SavedState = {
172
+ readonly layout?: LayoutState;
173
+ };
174
+
140
175
  export type SearchInputType = "SearchValue" | "ReplaceValue" | "IncludeValue" | "ExcludeValue";
141
176
 
142
177
  interface Workspace {
@@ -210,6 +245,7 @@ interface Chat {
210
245
  readonly handleProjectListContextMenu: (id: number, x: number, y: number) => Promise<void>;
211
246
  readonly handleSubmit: () => Promise<void>;
212
247
  readonly mockBackendAuthResponse: (response: any) => Promise<void>;
248
+ readonly mockBackendSetHttpErrorResponse: (response: MockErrorResponse) => Promise<void>;
213
249
  readonly mockOpenAiResponse: (options: MockOpenAiResponseOptions) => Promise<void>;
214
250
  readonly mockOpenApiRequestGetAll: () => Promise<readonly any[]>;
215
251
  readonly mockOpenApiRequestReset: () => Promise<void>;
@@ -217,6 +253,7 @@ interface Chat {
217
253
  readonly mockOpenApiStreamPushChunk: (chunk: string) => Promise<void>;
218
254
  readonly mockOpenApiStreamReset: () => Promise<void>;
219
255
  readonly openAgentModePicker: () => Promise<void>;
256
+ readonly openDebugView: () => Promise<void>;
220
257
  readonly openGitBranchPicker: () => Promise<void>;
221
258
  readonly openMockSession: (sessionId: string, messages: readonly any[]) => Promise<void>;
222
259
  readonly openModelPicker: () => Promise<void>;
@@ -236,6 +273,7 @@ interface Chat {
236
273
  readonly setSearchEnabled: (enabled: boolean) => Promise<void>;
237
274
  readonly setShowChatListTime: (showTime: boolean) => Promise<any>;
238
275
  readonly setStreamingEnabled: (enabled: boolean) => Promise<void>;
276
+ readonly setUseOwnBackend: (enabled: boolean) => Promise<void>;
239
277
  readonly shouldHaveComposerSelection: (start: number, end: number) => Promise<void>;
240
278
  readonly show: () => Promise<void>;
241
279
  readonly showComposerAttachmentPreviewOverlay: (attachmentId: string) => Promise<void>;
@@ -627,8 +665,9 @@ interface Main {
627
665
  readonly openUri: (uri: string) => Promise<void>;
628
666
  readonly save: () => Promise<void>;
629
667
  readonly saveAll: () => Promise<void>;
630
- readonly saveState: (uid: number) => Promise<any>;
668
+ readonly saveState: (uid: number) => Promise<SavedState>;
631
669
  readonly selectTab: (groupIndex: number, tabIndex: number) => Promise<void>;
670
+ readonly shouldHaveLayout: (expectedLayout: LayoutExpectation, uid?: number) => Promise<void>;
632
671
  readonly splitDown: () => Promise<void>;
633
672
  readonly splitRight: () => Promise<void>;
634
673
  }
@@ -1864,6 +1864,9 @@ const handleChatListContextMenu = async (eventX, eventY) => {
1864
1864
  const setBackendUrl = async url => {
1865
1865
  await invoke('Chat.setBackendUrl', url);
1866
1866
  };
1867
+ const setUseOwnBackend = async enabled => {
1868
+ await invoke('Chat.setUseOwnBackend', enabled);
1869
+ };
1867
1870
  const handleClickBack = async () => {
1868
1871
  await invoke('Chat.handleClickBack');
1869
1872
  };
@@ -1937,6 +1940,9 @@ const mockOpenApiStreamPushChunk = async chunk => {
1937
1940
  const openMockSession = async (sessionId, messages) => {
1938
1941
  await invoke('Chat.openMockSession', sessionId, messages);
1939
1942
  };
1943
+ const mockBackendSetHttpErrorResponse = async response => {
1944
+ await invoke('Chat.mockBackendSetHttpErrorResponse', response.statusCode, response);
1945
+ };
1940
1946
  const registerMockResponse = async options => {
1941
1947
  await invoke('Chat.registerMockResponse', options);
1942
1948
  };
@@ -2024,6 +2030,9 @@ const mockOpenAiResponse = async options => {
2024
2030
  const handleInputFocus = async () => {
2025
2031
  return execute$1('Chat.handleInputFocus', 'chat-list');
2026
2032
  };
2033
+ const openDebugView = async () => {
2034
+ return execute$1('Chat.openDebugViw');
2035
+ };
2027
2036
  const chatListFocusPrevious = async () => {
2028
2037
  return execute$1('Chat.chatListFocusPrevious');
2029
2038
  };
@@ -2084,6 +2093,7 @@ const Chat = {
2084
2093
  handleProjectListContextMenu,
2085
2094
  handleSubmit,
2086
2095
  mockBackendAuthResponse,
2096
+ mockBackendSetHttpErrorResponse,
2087
2097
  mockOpenAiResponse,
2088
2098
  mockOpenApiRequestGetAll,
2089
2099
  mockOpenApiRequestReset,
@@ -2091,6 +2101,7 @@ const Chat = {
2091
2101
  mockOpenApiStreamPushChunk,
2092
2102
  mockOpenApiStreamReset,
2093
2103
  openAgentModePicker,
2104
+ openDebugView,
2094
2105
  openGitBranchPicker,
2095
2106
  openMockSession,
2096
2107
  openModelPicker,
@@ -2110,6 +2121,7 @@ const Chat = {
2110
2121
  setSearchEnabled,
2111
2122
  setShowChatListTime,
2112
2123
  setStreamingEnabled,
2124
+ setUseOwnBackend,
2113
2125
  shouldHaveComposerSelection,
2114
2126
  show: show$7,
2115
2127
  showComposerAttachmentPreviewOverlay,
@@ -2344,12 +2356,92 @@ const Dialog = {
2344
2356
  showSaveFilePicker
2345
2357
  };
2346
2358
 
2359
+ const defaultMainAreaUid = 2;
2360
+ const directionMap = {
2361
+ horizontal: 1,
2362
+ vertical: 2
2363
+ };
2364
+ const isObject$1 = value => {
2365
+ return typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof RegExp);
2366
+ };
2367
+ const matchesExpectedArray = (actual, expected) => {
2368
+ if (!Array.isArray(actual) || actual.length !== expected.length) {
2369
+ return false;
2370
+ }
2371
+ for (let i = 0; i < expected.length; i++) {
2372
+ if (!matchesExpected(actual[i], expected[i])) {
2373
+ return false;
2374
+ }
2375
+ }
2376
+ return true;
2377
+ };
2378
+ const matchesExpectedObject = (actual, expected) => {
2379
+ if (!isObject$1(actual)) {
2380
+ return false;
2381
+ }
2382
+ for (const [childKey, childExpectedValue] of Object.entries(expected)) {
2383
+ if (childExpectedValue === undefined) {
2384
+ continue;
2385
+ }
2386
+ if (!matchesExpected(actual[childKey], childExpectedValue, childKey)) {
2387
+ return false;
2388
+ }
2389
+ }
2390
+ return true;
2391
+ };
2392
+ const matchesExpected = (actual, expected, key = '') => {
2393
+ if (key === 'direction' && typeof expected === 'string' && expected in directionMap) {
2394
+ return Object.is(actual, directionMap[expected]);
2395
+ }
2396
+ if (expected instanceof RegExp) {
2397
+ return typeof actual === 'string' && expected.test(actual);
2398
+ }
2399
+ if (Array.isArray(expected)) {
2400
+ return matchesExpectedArray(actual, expected);
2401
+ }
2402
+ if (isObject$1(expected)) {
2403
+ return matchesExpectedObject(actual, expected);
2404
+ }
2405
+ return Object.is(actual, expected);
2406
+ };
2407
+ const matchesActiveGroupIndex = (layout, activeGroupIndex) => {
2408
+ const groups = layout.groups || [];
2409
+ const group = groups[activeGroupIndex];
2410
+ if (!group) {
2411
+ return false;
2412
+ }
2413
+ return layout.activeGroupId === group.id;
2414
+ };
2415
+ const serializeForError = value => {
2416
+ return JSON.stringify(value, (_key, currentValue) => {
2417
+ if (currentValue instanceof RegExp) {
2418
+ return currentValue.toString();
2419
+ }
2420
+ return currentValue;
2421
+ });
2422
+ };
2347
2423
  const openUri = async uri => {
2348
2424
  await invoke('Main.openUri', uri);
2349
2425
  };
2350
2426
  const saveState = async uid => {
2351
2427
  return invoke('Main.saveState', uid);
2352
2428
  };
2429
+ const shouldHaveLayout = async (expectedLayout, uid = defaultMainAreaUid) => {
2430
+ const state = await saveState(uid);
2431
+ const actualLayout = state.layout;
2432
+ if (!actualLayout) {
2433
+ throw new AssertionError(`expected main layout to exist but state was ${serializeForError(state)}`);
2434
+ }
2435
+ const {
2436
+ activeGroupIndex,
2437
+ ...partialExpectedLayout
2438
+ } = expectedLayout;
2439
+ const matchesLayout = matchesExpected(actualLayout, partialExpectedLayout);
2440
+ const matchesActiveGroup = activeGroupIndex === undefined || matchesActiveGroupIndex(actualLayout, activeGroupIndex);
2441
+ if (!matchesLayout || !matchesActiveGroup) {
2442
+ throw new AssertionError(`expected main layout to match ${serializeForError(expectedLayout)} but was ${serializeForError(actualLayout)}`);
2443
+ }
2444
+ };
2353
2445
  const splitRight = async () => {
2354
2446
  await invoke('Main.splitRight');
2355
2447
  };
@@ -2440,6 +2532,7 @@ const Main = {
2440
2532
  saveAll,
2441
2533
  saveState,
2442
2534
  selectTab: selectTab$2,
2535
+ shouldHaveLayout,
2443
2536
  splitDown,
2444
2537
  splitRight
2445
2538
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "14.9.0",
3
+ "version": "14.10.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",