Skip to content
74 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { ASK, BEAT, CHECKS, LOOP_MS, PILLS, STEPS, STILLS, frameAt, pillAt, pillProgress, sameFrame } from "./tour.ts";
5
6test("the first frame is the empty channel, the same on the server and the client", () => {
7 const frame = frameAt(0);
8 assert.equal(frame.scene, "chat");
9 assert.equal(frame.typed, 0);
10 assert.equal(frame.sent, false);
11 assert.equal(frame.cursorShown, false);
12 assert.ok(sameFrame(frame, frameAt(0)));
13});
14
15test("the message is typed in full before it is sent, then the composer empties", () => {
16 assert.equal(frameAt(BEAT.typed).typed, ASK.length);
17 assert.equal(frameAt(BEAT.typed - 1).typed, ASK.length - 1);
18 const sent = frameAt(BEAT.sent);
19 assert.equal(sent.sent, true);
20 assert.equal(sent.typed, 0);
21});
22
23test("typing only ever moves forward", () => {
24 let last = 0;
25 for (let t = 0; t <= BEAT.typed; t += 17) {
26 const typed = frameAt(t).typed;
27 assert.ok(typed >= last);
28 last = typed;
29 }
30});
31
32test("the scenes come in the story's order", () => {
33 const order: string[] = [];
34 for (let t = 0; t < LOOP_MS; t += 100) {
35 const scene = frameAt(t).scene;
36 if (order[order.length - 1] !== scene) order.push(scene);
37 }
38 assert.deepEqual(order, ["chat", "agents", "code", "chat", "docs"]);
39});
40
41test("steps and checks finish before the cursor leaves them", () => {
42 assert.equal(frameAt(BEAT.pullClick).steps, STEPS.length);
43 assert.equal(frameAt(BEAT.approved).checks, CHECKS.length);
44 assert.equal(frameAt(BEAT.pullClick).cursor, "task-pull");
45});
46
47test("the loop wraps", () => {
48 assert.ok(sameFrame(frameAt(LOOP_MS + 1234), frameAt(1234)));
49 assert.ok(sameFrame(frameAt(-1), frameAt(LOOP_MS - 1)));
50});
51
52test("pills start where their scene does, and progress runs 0 to 1", () => {
53 PILLS.forEach((pill, index) => {
54 assert.equal(frameAt(pill.start + 1).scene, pill.scene);
55 assert.equal(pillAt(pill.start + 1), index);
56 });
57 assert.equal(pillAt(BEAT.chatAgain + 10), 2);
58 assert.ok(pillProgress(PILLS[1].start) < 0.01);
59 assert.ok(pillProgress(PILLS[2].start - 1) > 0.99);
60});
61
62test("each still shows its step's point", () => {
63 assert.equal(frameAt(STILLS.chat).handoff, true);
64 assert.equal(frameAt(STILLS.agents).steps, STEPS.length);
65 assert.equal(frameAt(STILLS.code).approved, true);
66 assert.equal(frameAt(STILLS.docs).docUpdated, true);
67});
68
69test("Izzy tells #support after g1t says it shipped, and the consult shows while Otto works", () => {
70 assert.equal(frameAt(BEAT.izzy - 1).izzy, false);
71 assert.equal(frameAt(BEAT.izzy).shipped, true);
72 assert.equal(frameAt(BEAT.agents).consult, false);
73 assert.equal(frameAt(BEAT.pullClick).consult, true);
74});