Skip to content
69 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { BEAT, CHECKS, LOOP_MS, PILLS, SESSION, STILLS, frameAt, pillAt, pillProgress, sameFrame } from "./tour.ts";
5
6test("the first frame is the pull request before its checks, the same on the server and the client", () => {
7 const frame = frameAt(0);
8 assert.equal(frame.scene, "code");
9 assert.equal(frame.checks, 0);
10 assert.equal(frame.merged, false);
11 assert.equal(frame.cursorShown, false);
12 assert.ok(sameFrame(frame, frameAt(0)));
13});
14
15test("the scenes come in the story's order: the pull request first", () => {
16 const order: string[] = [];
17 for (let t = 0; t < LOOP_MS; t += 100) {
18 const scene = frameAt(t).scene;
19 if (order[order.length - 1] !== scene) order.push(scene);
20 }
21 assert.deepEqual(order, ["code", "session", "chat", "docs"]);
22});
23
24test("checks pass before review, and the queue merges only after approval", () => {
25 assert.equal(frameAt(BEAT.approved).checks, CHECKS.length);
26 assert.equal(frameAt(BEAT.merged - 1).merged, false);
27 assert.equal(frameAt(BEAT.merged).approved, true);
28});
29
30test("the cursor leaves the code only once it has merged, for the Session tab", () => {
31 assert.equal(frameAt(BEAT.merged - 1).cursorShown, false);
32 assert.equal(frameAt(BEAT.sessionClick).cursor, "pr-session");
33 assert.equal(frameAt(BEAT.sessionClick).click, true);
34 assert.equal(frameAt(BEAT.railChatClick).cursor, "rail-chat");
35 assert.equal(frameAt(BEAT.railChatClick).click, true);
36});
37
38test("the session plays back in full before the tour moves on to chat", () => {
39 assert.equal(frameAt(BEAT.session - 1).entries, 0);
40 assert.equal(frameAt(BEAT.railChatClick - 1).entries, SESSION.length);
41 assert.equal(SESSION[0].kind, "prompt");
42});
43
44test("the loop wraps", () => {
45 assert.ok(sameFrame(frameAt(LOOP_MS + 1234), frameAt(1234)));
46 assert.ok(sameFrame(frameAt(-1), frameAt(LOOP_MS - 1)));
47});
48
49test("pills start where their scene does, and progress runs 0 to 1", () => {
50 assert.equal(PILLS[0].scene, "code");
51 PILLS.forEach((pill, index) => {
52 assert.equal(frameAt(pill.start + 1).scene, pill.scene);
53 assert.equal(pillAt(pill.start + 1), index);
54 });
55 assert.ok(pillProgress(PILLS[1].start) < 0.01);
56 assert.ok(pillProgress(PILLS[2].start - 1) > 0.99);
57});
58
59test("each still shows its step's point", () => {
60 assert.equal(frameAt(STILLS.code).approved, true);
61 assert.equal(frameAt(STILLS.session).entries, SESSION.length);
62 assert.equal(frameAt(STILLS.chat).told, true);
63 assert.equal(frameAt(STILLS.docs).docUpdated, true);
64});
65
66test("Dana tells support only after Priya says it shipped", () => {
67 assert.equal(frameAt(BEAT.told - 1).told, false);
68 assert.equal(frameAt(BEAT.told).shipped, true);
69});