Files
openclaw/extensions/codex/src/session-upstream-marker.test.ts
T
Peter Steinberger b080dd1e76 refactor: consolidate coercion contracts (#122458)
* refactor: consolidate coercion contracts

Centralize exact string, record, numeric, date, Boolean, argument, and structured-error coercions while preserving call-site semantics.

Migrate canonical-name collisions and deprecated internal SDK bypasses, deleting 55 net production/tooling lines. Expand declaration ownership enforcement to 101 allowed helpers and add a narrow export-completeness audit.

* fix: preserve standalone script coercions

Keep copied Control UI tooling self-contained and retain the trusted release harness module-relative source seam when the harness runs against an old target cwd.
2026-08-11 23:26:37 -07:00

43 lines
1.5 KiB
TypeScript

import { readNonEmptyStringPreservingWhitespace as normalizeTurnId } from "openclaw/plugin-sdk/string-coerce-runtime";
import { describe, expect, it } from "vitest";
import type { CodexThread } from "./app-server/protocol.js";
import { codexUpstreamBaseline } from "./session-upstream-marker.js";
describe("codexUpstreamBaseline", () => {
it("baselines an active adoption-time turn including its current user items", () => {
const thread = {
id: "thread-1",
turns: [
{
id: "turn-done",
status: "completed",
items: [{ type: "userMessage", text: "old prompt" }],
},
{
id: "turn-active",
status: "inProgress",
items: [
{ type: "userMessage", text: "current prompt" },
{ type: "userMessage", text: "steer before adoption" },
],
},
],
} as unknown as CodexThread;
// Skipping to the last terminal turn would replay the active turn's existing
// user items as external activity once it completes.
expect(codexUpstreamBaseline(thread, normalizeTurnId)).toEqual({
turnId: "turn-active",
userMessageCount: 2,
});
});
it("falls back to the newest identifiable turn and null on empty threads", () => {
const empty = { id: "thread-2", turns: [] } as unknown as CodexThread;
expect(codexUpstreamBaseline(empty, normalizeTurnId)).toEqual({
turnId: null,
userMessageCount: 0,
});
});
});