41 lines · 1.6 KB · TypeScript
RawDownload
import { assert, it, vi } from "@effect/vitest";import {  CheckpointScopeId,  RunId,  ThreadId,  type OrchestrationV2ThreadProjection,} from "@t3tools/contracts";import * as Effect from "effect/Effect";import * as Layer from "effect/Layer"; import * as CheckpointCapture from "./CheckpointCaptureService.ts";import * as ProjectionStore from "./ProjectionStore.ts";import * as RunFinalization from "./RunFinalizationService.ts"; it.effect("captures the root checkpoint and refreshes workspace state", () => {  const threadId = ThreadId.make("thread_finalize");  const runId = RunId.make("run_finalize");  const scopeId = CheckpointScopeId.make("scope_finalize");  const capture = vi.fn(() => Effect.void);  const refresh = vi.fn(() => Effect.void);  const projection = {    checkpointScopes: [{ id: scopeId, cwd: "/repo" }],  } as unknown as OrchestrationV2ThreadProjection;  const layer = RunFinalization.layer.pipe(    Layer.provide(      Layer.mergeAll(        Layer.mock(CheckpointCapture.CheckpointCaptureServiceV2)({ execute: capture }),        Layer.mock(ProjectionStore.ProjectionStoreV2)({          getThreadProjection: () => Effect.succeed(projection),        }),        Layer.succeed(RunFinalization.RunFinalizationObserver, { refresh }),      ),    ),  );  return Effect.gen(function* () {    const service = yield* RunFinalization.RunFinalizationService;    yield* service.finalize({ threadId, runId, scopeId });    assert.equal(capture.mock.calls.length, 1);    assert.deepEqual(refresh.mock.calls[0], ["/repo"]);  }).pipe(Effect.provide(layer));});

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t