tui-tests

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗

Use when adding or modifying tests for one of GitButler's Ratatui TUIs

.agents/skills/tui-tests/SKILL.md

Download bundle ↓
master · 1f5041d1 bundle fileScanned 2026-09-14

SKILL.md

692 tokens · o200k_base · 3,004 bytes

Source excerpt starting at line 1.
---name: tui-testsdescription: Use when adding or modifying tests for one of GitButler's Ratatui TUIs--- ## Where tests live - Main TUI tests: `crates/but/src/command/legacy/status/tui/tests/`- Test harness/helpers: `crates/but/src/tui/test_utils.rs` and `crates/but/src/command/legacy/status/tui/tests/utils.rs`- Snapshots: `crates/but/src/command/legacy/status/tui/tests/snapshots/` ## Basic pattern ```rust#[test]fn describes_behavior_under_test() {    let env = Sandbox::init_scenario_with_target_and_default_settings("one-stack").unwrap();    env.setup_metadata(&["A"]).unwrap();     let mut tui = test_status_tui(env);     tui.input_then_render(KeyCode::Down)        .assert_rendered_term_svg_eq(file!["snapshots/describes_behavior_under_test_001.svg"]);}``` ## Driving the TUI Useful input examples: ```rusttui.input_then_render(None);                                       // render without inputstui.input_then_render('j');                                        // single char inputtui.input_then_render(KeyCode::Down);                              // special keytui.input_then_render(Shift('j'));                                 // keys with shifttui.input_then_render(Control('j'));                               // keys with controltui.input_then_render([KeyCode::Down, KeyCode::Down]);             // multiple keys from arraytui.input_then_render("commit message text");                      // multiple keys from stringtui.reload();                                                      // reload state after making external changes``` ## Assertions Generally prefer - `assert_current_line_eq(str![...])` for cursor/selection behavior.- `assert_rendered_term_svg_eq(file!["snapshots/test_function_name_001.svg"])`  for everything else. Generally you should include one `assert_rendered_term_svg_eq` per logicalgroup of inputs, to catch bad states early. Be careful using `assert_rendered_contains` and `assert_rendered_not_contains`since they might lead to false positives. They're intended to use whileiterating on a test where snapshots would cause too much churn. Read `crates/but/src/tui/test_utils.rs` and`crates/but/src/command/legacy/status/tui/tests/utils.rs` for more specializedassertions. You're not allowed to add new kinds of assertions to `crates/but/src/tui/test_utils.rs` or`crates/but/src/command/legacy/status/tui/tests/utils.rs`. Rely entirely on theexisting assertions. Don't reuse snapshots from other tests. Give each test its own snapshots. Avoid using `tui.env().invoke_git("...")`. Prefer performing operations via the TUI. ## Running tests - `cargo test -p but <test-name>` to run one test.- `SNAPSHOTS=overwrite cargo test -p but <test-name>` to run and update  snapshots.- `cargo test -p but tui` to run all tui tests. Do this after changing  things. If a test fails the output will include the rendered state of the test backend.This can be used when iterating on a test as a way of inspecting the state. 
Discovery context

Discovered by repository scan. No exact path reference found in the snapshot’s root AGENTS.md.