Skip to content

Commit 90d1cdb

Browse files
authored
Restore the REPL wheel burst refusal fixture (#1345)
1 parent b7d8fe2 commit 90d1cdb

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

‎packages/cli/tests/repl-wheel-burst.test.ts‎

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { expect } from "@executablemd/test-support/expect";
33
import { scoped, sleep } from "effection";
44
import type { Operation } from "effection";
55
import { useReplPage } from "./support/repl-page.ts";
6-
import type { ReplPage, ScreenCell } from "./support/repl-page.ts";
7-
import { composerHolds, intoComposer, paneLines } from "./support/screen-journeys.ts";
6+
import type { ReplPage, ScreenCell, ScreenReading } from "./support/repl-page.ts";
7+
import { draftHolds, intoComposer, intoDraft, paneLines } from "./support/screen-journeys.ts";
88
import { generateTypingHistory } from "./support/typing-history.ts";
99

1010
const SIZE = { columns: 160, rows: 36 };
@@ -52,6 +52,13 @@ function chatRows(page: ReplPage): number[] {
5252
return shown;
5353
}
5454

55+
// The generated TAIL lines the Sidekick chat shows, right of the Draft pane.
56+
function tailLines(reading: ScreenReading): string[] {
57+
return paneLines(reading).flatMap(
58+
(row) => row.slice(row.lastIndexOf("│") + 1).match(/TAIL-(?:LINE|END)-\d+/g) ?? [],
59+
);
60+
}
61+
5562
// A labelled turn row left of the Sidekick pane.
5663
function transcriptCell(page: ReplPage): ScreenCell {
5764
const rows = page.screen().rows;
@@ -130,28 +137,35 @@ describe("wheel bursts in one input chunk", () => {
130137
});
131138

132139
it("a tick that clears a staged refusal moves the next one within the freed capacity", function* () {
133-
const reason =
134-
"Permission to start was declined because the chosen fixture rejected this request. ";
135-
const request = "Please refuse this request";
136-
const footer = "! Permission to start was declined";
140+
// Each dotted segment is one probed path segment, so each stays within a file name.
141+
const name = ["Unknown", "Missing", "Absent"].map((at) => at + "Component".repeat(27));
142+
const request = `<${name.join(".")} />`;
143+
const footer = "! this entry cannot run here: Cannot resolve component:";
137144
const cell = { column: 140, row: 13 };
138145

139146
function* endpoints(move: typeof burst) {
140147
return yield* scoped(function* () {
141148
const page = yield* useReplPage({ size: SIZE });
142149
yield* generateTypingHistory(page, 2, 80);
143-
yield* intoComposer(page);
144-
// The staged refusal frees more rows than one tick moves when it clears.
145-
page.repl.fake.script({ reply: "", failure: reason.repeat(8) });
150+
// The name alone wraps the staged refusal past the searched paths, which
151+
// vary by platform, so clearing it frees more rows than one tick moves.
152+
yield* intoDraft(page);
146153
yield* page.type(request);
147-
yield* page.until("the request in Message", (one) => composerHolds(one, request));
154+
const drafted = yield* page.until("the unknown component in Draft", (one) =>
155+
draftHolds(one, "/>"),
156+
);
157+
const before = tailLines(drafted);
148158
yield* page.key("Enter");
149-
yield* page.until("the staged refusal", (one) => one.shows(footer));
150-
const start = paneLines(page.screen());
159+
const refused = yield* page.until("the staged refusal", (one) => one.shows(footer));
160+
const start = tailLines(refused);
161+
expect(start.length + 3).toBeLessThan(before.length);
151162

152163
yield* move(page, "up", cell, 2);
153164
expect(page.screen().shows(footer)).toBe(false);
154-
return { start, end: paneLines(page.screen()) };
165+
const end = tailLines(page.screen());
166+
expect(end.length).toBeGreaterThan(start.length);
167+
expect(end[0]).not.toBe(start[0]);
168+
return { start, end };
155169
});
156170
}
157171

0 commit comments

Comments
 (0)