47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { createAnalysisArtifactFixture } from "./analysis-document-fixtures";
|
|
import { createInitialWorkspaceContext, reduceWorkspaceContext } from "./workspace-context";
|
|
|
|
describe("workspace context", () => {
|
|
it("keeps operational time independent from artifact analytical time", () => {
|
|
const artifact = createAnalysisArtifactFixture(0, 0);
|
|
const withArtifact = reduceWorkspaceContext(createInitialWorkspaceContext(), {
|
|
type: "sync-artifact",
|
|
artifact
|
|
});
|
|
const selectedEvent = reduceWorkspaceContext(withArtifact, {
|
|
type: "select-operational-event",
|
|
eventId: "event-1",
|
|
cursorTime: "2026-08-19T10:30:00.000Z"
|
|
});
|
|
|
|
expect(selectedEvent.analytical.timeRange).toEqual(artifact.analyticalTimeRange);
|
|
expect(selectedEvent.operational.cursorTime).toBe("2026-08-19T10:30:00.000Z");
|
|
});
|
|
|
|
it("updates analytical context without moving the operational cursor", () => {
|
|
const initial = createInitialWorkspaceContext(new Date("2026-08-19T08:00:00.000Z"));
|
|
const cursorTime = initial.operational.cursorTime;
|
|
const withArtifact = reduceWorkspaceContext(initial, {
|
|
type: "sync-artifact",
|
|
artifact: createAnalysisArtifactFixture(1, 1)
|
|
});
|
|
|
|
expect(withArtifact.operational.cursorTime).toBe(cursorTime);
|
|
expect(withArtifact.analytical.artifactId).toBeTruthy();
|
|
});
|
|
|
|
it("clears selection while retaining cursor until returning to now", () => {
|
|
const initial = createInitialWorkspaceContext();
|
|
const selected = reduceWorkspaceContext(initial, {
|
|
type: "select-operational-event",
|
|
eventId: "event-2",
|
|
cursorTime: "2026-08-19T13:10:00.000Z"
|
|
});
|
|
const cleared = reduceWorkspaceContext(selected, { type: "clear-operational-event" });
|
|
|
|
expect(cleared.operational.selectedEventId).toBeNull();
|
|
expect(cleared.operational.cursorTime).toBe("2026-08-19T13:10:00.000Z");
|
|
});
|
|
});
|