@@ -225,6 +225,7 @@ export function workerProbe(
225225 import path from 'node:path';
226226 import { fileURLToPath } from 'node:url';
227227 import { DatabaseSync } from 'node:sqlite';
228+ import { Worker } from 'node:worker_threads';
228229 import { it, expect, vi, inject } from 'vitest';
229230 import {value} from '#fixture-value';
230231 import { runtimeProcessEntrypoints } from ${ JSON . stringify ( path . join ( root , "src/infra/runtime-process-entrypoints.ts" ) ) } ;
@@ -234,18 +235,23 @@ export function workerProbe(
234235 import { tuiPtyRuntimeEntrypoints } from ${ JSON . stringify ( path . join ( root , "src/tui/tui-pty-runtime-test-support.ts" ) ) } ;
235236 import { resolveRuntimeWorkerUrl } from ${ JSON . stringify ( path . join ( root , "src/infra/runtime-worker-url.ts" ) ) } ;
236237 import { prepareSqliteReadOnlyLocation } from ${ JSON . stringify ( path . join ( root , "src/infra/sqlite-readonly-location.ts" ) ) } ;
238+ import { runSqliteTranscriptArchivePublishWorker } from ${ JSON . stringify ( path . join ( root , "src/config/sessions/session-accessor.sqlite-archive.ts" ) ) } ;
237239 const tuiUrls = Object.values(tuiPtyRuntimeEntrypoints).map(entry => resolveRuntimeWorkerUrl(entry).href);
238240 // Import acquisition must finish during collection, before any fixture hook starts.
239241 const tuiPresentAtCollection = tuiUrls.every(url => fs.existsSync(new URL(url)));
240242 vi.mock('node:child_process', async (original) => {
241243 const actual = await original();
242244 return {...actual, execFile: vi.fn(actual.execFile)};
243245 });
246+ vi.mock('node:worker_threads', async (original) => {
247+ const actual = await original();
248+ return {...actual, Worker: vi.fn(function(...args) { return new actual.Worker(...args); })};
249+ });
244250 it('runs current SQLite code in the expected execution mode', async () => {
245251 const launcherArgv = inject('launcherArgv');
246252 expect(path.isAbsolute(launcherArgv[1])).toBe(true);
247253 expect(path.basename(launcherArgv[1])).toBe('vitest.mjs');
248- expect(Object.values(runtimeProcessBuildEntries)).toHaveLength(7 );
254+ expect(Object.values(runtimeProcessBuildEntries)).toHaveLength(9 );
249255 for (const source of Object.values(runtimeProcessBuildEntries)) {
250256 expect(source).not.toContain('/dist/');
251257 expect(source).toMatch(/\\.ts$/);
@@ -272,6 +278,10 @@ export function workerProbe(
272278 const args = cp.execFile.mock.calls[0][1];
273279 const generation = runtimeProcessEntrypoints.sqliteReadOnly.currentModuleUrl;
274280 const sourceMode = ${ mode === "auto" ? "generation.endsWith('.ts')" : mode === "source" } ;
281+ await expect(runSqliteTranscriptArchivePublishWorker([])).resolves.toEqual([]);
282+ const [archiveUrl] = Worker.mock.calls.at(-1);
283+ expect(archiveUrl.href.endsWith(sourceMode ? '.ts' : '.js')).toBe(true);
284+ if (!sourceMode) expect(fileURLToPath(archiveUrl).startsWith(fileURLToPath(new URL('../', generation)))).toBe(true);
275285 expect(tuiUrls).toHaveLength(4);
276286 for (const url of tuiUrls) {
277287 expect(url.endsWith(sourceMode ? '.ts' : '.js')).toBe(true);
0 commit comments