Repository navigation
dash-tui: replace inline AppState::new(...) literals with st() fixture across app/ tests - #670
Conversation
app/mod.rs, app/actions.rs, and app/scrollbar.rs each wrote
AppState::new("t".into(), "default-dark".into()) inline at every test
call site instead of using the st() fixture that app/test_support.rs
already provides. Switch all 57 call sites to st(), adding the import
where it was missing. No behavior change.
Closes ROCm#639.
Signed-off-by: Jussi Elo <jussi.elo@amd.com>
There was a problem hiding this comment.
🟢 Approval recommended
All replacements are behaviorally equivalent and correctly scoped to tests.
0 open findings
What changed in this PR
Deduplicates test setup by consistently using the shared st() fixture without changing behavior.
Changes:
- Replaces matching inline
AppState::new(...)calls withst(). - Adds the required fixture imports.
| File | Description |
|---|---|
app/mod.rs |
Uses the existing fixture in tests. |
app/actions.rs |
Imports and uses st(). |
app/scrollbar.rs |
Imports and uses st(). |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
juhovainio
left a comment
There was a problem hiding this comment.
Reviewed this (mechanical test-only refactor closing #639) with a fan-out correctness pass plus a separate Standards/Spec pass. The substitution itself checks out completely: I independently recounted 57 replaced call sites across the 3 touched files (actions.rs 23, mod.rs 17, scrollbar.rs 17), confirmed st() is byte-for-byte identical to the literal it replaces, verified imports and mutability are handled correctly at every site, and confirmed the 6 intentionally-different literals in mod.rs are correctly left untouched. No production code touched, no scope creep.
Two non-blocking notes:
- The PR description says "60" replacements; the actual count (and issue #639 itself) says 57. Cosmetic only - the diff itself is complete and correct.
- Minor: the commit/PR title uses a bare
dash-tui:scope with no Conventional Commits type prefix (repo precedent is typicallytest(dash-tui):or similar). Worth tightening for consistency, not blocking.
One CI item for awareness: the E2E tests check is failing on scenario chat-tool-definitions-accepted, which doesn't match the known-flaky patterns I check for - but this PR only touches unit tests in an unrelated crate, so there's no plausible causal link. Worth confirming it's pre-existing/unrelated, not something to hold this PR on.
Approving - nothing here blocks merge.
rominf
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · 9529d42
This automation never files a GitHub approval, so no approving review will
appear here whatever the outcome — the merge decision stays with a human
reviewer.
Review — no blocking findings
Full review of the whole change.
Closes #639 and fully does what it asks: all 57 AppState::new("t".into(), "default-dark".into()) calls in app/mod.rs (17), app/actions.rs (23) and app/scrollbar.rs (17) now use st(). The description matches the diff.
Blocking
None
Non-blocking
None
Decisions for the author
None
Positive signals
- The sweep stays inside
app/, wherest()is visible (it ispub(super)). It leaves alone the same literal inui/and theAppState::new("test".into(), …)calls inapp/mod.rsthat pass different arguments. That keeps the change at exactly the scope #639 sets.
Deployment notes
None
What this covered
- What was read: the whole diff
666cb34a…9529d421, plusapp/test_support.rs, theuselines of each touched test module, and the history ofst()(#635) and the earlierpress()dedup (#586). - Replacements are identical: every removed line exactly matches the body of
st().letversuslet mutis unchanged at every site. - Nothing missed: a grep found no remaining matching literal under
app/other thanst()'s own body. - Test verdicts: the change adds no tests and changes no production code. Each changed test swaps an inline constructor for an identical fixture, so "passes with the production change reverted" has nothing to revert against. No branch is introduced.
- What was run:
cargo test -p rocm-dash-tui --lib, using the checkout's owntarget/with noRUSTC_WRAPPER: 815 passed, 3 failed. The 177 tests in the touchedapp::test modules all passed.- The 3 failures are in
agent::clients::tests, a file this change does not touch. They fail withcannot create token cache dir: Permission denied, which comes from this environment. CI reports all checks green on this head. cargo clippy -p rocm-dash-tui --all-targets -- -D warningsexited 0.
- How it was split: the change is small, so one fan-out worker took the code pass, agent-instruction adherence and history together, and the driver ran tests and the intent check.
- Did not run: the prior-changes pass, because this review must not read earlier PR comments or reviews.
- Not reconciled against any discussion here.
Why
The
st()test fixture (app/test_support.rs) wrapsAppState::new("t".into(), "default-dark".into())soapp/'s test modules don't each redefine or repeat the same construction call. Despite that, three of those modules still spell out the literal at every call site instead of invokingst():crates/rocm-dash-tui/src/app/mod.rscrates/rocm-dash-tui/src/app/actions.rscrates/rocm-dash-tui/src/app/scrollbar.rsThis predates both the ROCMAI-84 test split and
st()'s introduction —mod.rsitself still carried its own copies.What changes
Every exact-literal call site (60 across the three files) now calls
st().actions.rsandscrollbar.rsgain the missinguse ...test_support::st;import (folded into the existingpressimport inactions.rs);mod.rsalready importedst. No production code changes, no behavior change — this is pure test-code deduplication.Scope
A handful of differently-themed literals in
mod.rs—AppState::new("test".into(), "dracula".into())andAppState::new("test".into(), "nope".into())— are notst()'s signature and are left untouched. The relatedui/fn key()duplication is a separate, already-tracked backlog item (ROCMAI-200) and is out of scope here.Closes #639.
Verification
cargo test -p rocm-dash-tui --all-targets— all existing tests pass unchanged.cargo clippy -p rocm-dash-tui --all-targets -- -D warnings— clean.cargo fmt -p rocm-dash-tui -- --check— clean.