Skip to content
65 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { BEAT, CHECKS, LOOP_MS, PILLS, STEPS, 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: Code 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", "chat", "agents", "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", () => {
31 assert.equal(frameAt(BEAT.merged - 1).cursorShown, false);
32 assert.equal(frameAt(BEAT.railChatClick).cursor, "rail-chat");
33 assert.equal(frameAt(BEAT.railChatClick).click, true);
34});
35
36test("Otto's work is done before the story opens", () => {
37 for (const t of [0, BEAT.chat, BEAT.agents]) assert.equal(frameAt(t).steps, STEPS.length);
38});
39
40test("the loop wraps", () => {
41 assert.ok(sameFrame(frameAt(LOOP_MS + 1234), frameAt(1234)));
42 assert.ok(sameFrame(frameAt(-1), frameAt(LOOP_MS - 1)));
43});
44
45test("pills start where their scene does, and progress runs 0 to 1", () => {
46 assert.equal(PILLS[0].scene, "code");
47 PILLS.forEach((pill, index) => {
48 assert.equal(frameAt(pill.start + 1).scene, pill.scene);
49 assert.equal(pillAt(pill.start + 1), index);
50 });
51 assert.ok(pillProgress(PILLS[1].start) < 0.01);
52 assert.ok(pillProgress(PILLS[2].start - 1) > 0.99);
53});
54
55test("each still shows its step's point", () => {
56 assert.equal(frameAt(STILLS.code).approved, true);
57 assert.equal(frameAt(STILLS.chat).izzy, true);
58 assert.equal(frameAt(STILLS.agents).scene, "agents");
59 assert.equal(frameAt(STILLS.docs).docUpdated, true);
60});
61
62test("Izzy tells #support after g1t says it shipped", () => {
63 assert.equal(frameAt(BEAT.izzy - 1).izzy, false);
64 assert.equal(frameAt(BEAT.izzy).shipped, true);
65});