feat: expose stable journey intent signals

This commit is contained in:
2026-09-04 15:25:35 +03:00
parent c73410a956
commit 7632c8b9c0
12 changed files with 197 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import {
activationLineDocumentY,
deriveSectionActivationSnapshot,
deriveSectionState,
isAtDocumentEnd,
selectActiveSection,
@@ -109,6 +110,41 @@ describe("active section selection", () => {
).toBe("profile");
});
it("derives responsive heading offsets from the same activation-line geometry", () => {
expect(deriveSectionActivationSnapshot({
headings: [
{ id: "start", top: 100 },
{ id: "profile", top: 420 },
{ id: "experience", top: 1_120 },
],
activeSectionId: "profile",
activationY: 500,
viewportHeight: 800,
layoutRevision: 7,
})).toEqual({
layoutRevision: 7,
activeHeadingOffsetVh: -0.1,
nextHeadingOffsetVh: 0.775,
});
});
it("returns no following-heading offset for the final active heading", () => {
expect(deriveSectionActivationSnapshot({
headings: [
{ id: "start", top: 100 },
{ id: "profile", top: 420 },
],
activeSectionId: "profile",
activationY: 500,
viewportHeight: 800,
layoutRevision: 8,
})).toEqual({
layoutRevision: 8,
activeHeadingOffsetVh: -0.1,
nextHeadingOffsetVh: null,
});
});
it("maps every canonical section to its chapter and arrival state", () => {
expect([
deriveSectionState("start"),