mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 00:03:13 +03:00
test(cli-rs): press each key sequence once per keymap setup
Aliases and overlapping commands sent identical bytes to the same registered layer. Deduplicate before dispatch, keeping the command in the key for isolated layers. The regenerated oracle contains all 1,906 distinct cases from the 3,743 recordings in their original order. oracle_key_sequences_run_the_commands_typescript_runs still compares every distinct result, including focused input, overridden bindings, leader timeouts and Windows suspend. No parity scenario disappears.
This commit is contained in:
@@ -40,7 +40,9 @@ fn oracle_key_sequences_run_the_commands_typescript_runs() {
|
||||
let _all = (!isolated).then(|| recorder(&names));
|
||||
let mut parser = Parser::standalone().unwrap();
|
||||
let mut now = Instant::now();
|
||||
for case in scenario["cases"].as_array().unwrap() {
|
||||
let cases = scenario["cases"].as_array().unwrap();
|
||||
assert!(!cases.is_empty(), "no sequences for {}", scenario["name"]);
|
||||
for case in cases {
|
||||
total += 1;
|
||||
let _layer = case["command"].as_str().map(|command| recorder(&[command]));
|
||||
tui.keymap().clear_pending_sequence();
|
||||
@@ -78,7 +80,6 @@ fn oracle_key_sequences_run_the_commands_typescript_runs() {
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(total > 2000, "the fixture has {total} cases");
|
||||
assert!(failures.is_empty(), "{} of {total} cases differ:\n{}", failures.len(), failures.join("\n"));
|
||||
}
|
||||
|
||||
|
||||
+4
-1841
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,6 @@ const { testRender } = await import(Bun.resolveSync("@opentui/solid", tui))
|
||||
const { createComponent, createSignal } = await import(Bun.resolveSync("solid-js", tui))
|
||||
|
||||
const names = Object.keys(TuiKeybind.Definitions).filter((name) => name !== "leader")
|
||||
const kitty = (stroke: Stroke) => encode(stroke, true)
|
||||
const escape = "\x1b[27u"
|
||||
const backspace = "\x1b[127u"
|
||||
|
||||
@@ -237,7 +236,11 @@ async function run(scenario: Scenario): Promise<Case[]> {
|
||||
})),
|
||||
)
|
||||
const cases: Case[] = []
|
||||
const seen = new Set<string>()
|
||||
const press = async (keys: Step[], command?: string) => {
|
||||
const id = JSON.stringify([command, keys])
|
||||
if (seen.has(id)) return
|
||||
seen.add(id)
|
||||
raw.clearPendingSequence()
|
||||
calls.length = 0
|
||||
for (const key of keys) {
|
||||
@@ -248,13 +251,10 @@ async function run(scenario: Scenario): Promise<Case[]> {
|
||||
}
|
||||
for (const sequence of sequences) {
|
||||
if (scenario.layout === "isolated") setRegistered([sequence.command])
|
||||
const encodings = [sequence.strokes.map(kitty), sequence.strokes.map((stroke) => encode(stroke, false))]
|
||||
const unique = encodings.filter(
|
||||
(keys, index) =>
|
||||
keys.every((key) => key !== undefined) &&
|
||||
encodings.findIndex((other) => JSON.stringify(other) === JSON.stringify(keys)) === index,
|
||||
) as string[][]
|
||||
for (const keys of unique) await press(keys, scenario.layout === "isolated" ? sequence.command : undefined)
|
||||
for (const csi of [true, false]) {
|
||||
const keys = sequence.strokes.map((stroke) => encode(stroke, csi))
|
||||
if (keys.every((key) => key !== undefined)) await press(keys, scenario.layout === "isolated" ? sequence.command : undefined)
|
||||
}
|
||||
}
|
||||
if (scenario.layout === "all") for (const keys of scenario.extra ?? []) await press(keys)
|
||||
return cases
|
||||
|
||||
Reference in New Issue
Block a user