Skip to content

test(ui): main-page key-handler tests, one per panel (R26 slice 2)#109

Merged
stormer78 merged 3 commits into
mainfrom
r26-keyhandler-tests
Jun 12, 2026
Merged

test(ui): main-page key-handler tests, one per panel (R26 slice 2)#109
stormer78 merged 3 commits into
mainfrom
r26-keyhandler-tests

Conversation

@stormer78

Copy link
Copy Markdown
Contributor

What

Completes R26 — slice 1 (#105) added table tests for the pure
*_actions.rs mode handlers but deferred the main-page key-handler tests
(they touched main/mod.rs, which was in flight for R23). This adds them.

Each test constructs a MainPage over a State, feeds a KeyEvent through the
public handle_key_event entry point, and asserts on the Action(s) emitted on
the channel. At least one test per content panel:

  • Communities, VTA-DID — confirmation commit (y/Enter) + cancel.
  • Inboxd/c arm the dismiss / clear-all confirmation (R25); a pending
    confirmation commits on y/Enter, cancels otherwise.
  • Relationships, Credentialsd in the detail view arms the removal (R25),
    and a pending confirmation commits the Remove.
  • Settings (Down moves selection), Logs, Help (Esc returns to
    the menu).

Action and its sub-enums derive neither PartialEq nor Debug, so the tests
pattern-match the expected variant rather than assert_eq!.

Stacking

Based on r25-destructive-confirms (#108), not main — the destructive-
confirm routing these tests exercise is introduced there. Review/merge #108
first, then this retargets to main automatically.

Gate

cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings,
cargo test --workspace — all green (openvtc lib 113 → 122 tests).

🤖 Generated with Claude Code

stormer78 and others added 2 commits June 12, 2026 14:36
Communities and VTA-DID deletes already require a y/Enter confirmation, but
`d` in Relationship detail, `d` in Credential detail, and `d`/`c` in the Inbox
deleted or dismissed instantly. This applies the existing
`confirm_delete: Option<…>` arm pattern to those three unguarded panels so
every destructive action behaves the same way.

- State (content.rs): add `RelationshipsState.confirm_delete: Option<String>`
  (remote_p_did), `CredentialsState.confirm_delete: Option<String>` (vrc_id),
  and `InboxState.confirm: Option<InboxConfirm>` where `InboxConfirm` is
  `Dismiss { task_id } | ClearAll` (covers both the single-dismiss and
  clear-all destructive paths).
- Actions: new pure arming/cancel variants — `RelationshipAction::{ConfirmRemove,
  CancelRemove}`, `CredentialAction::{ConfirmRemove, CancelRemove}`, and
  `InboxAction::{ConfirmDismiss, ConfirmClearAll, CancelConfirm}`. Handled as
  pure state mutations in the respective `*_actions.rs` dispatchers (never
  network); the commit handlers (`prepare_remove`, `handle_remove`,
  `handle_dismiss_task`, `handle_clear_all`) clear the flag as the existing
  community/VTA-DID commits do.
- Key handlers (main/mod.rs): the destructive keys now arm the confirmation;
  while one is pending, y/Enter commits and any other key cancels (Esc
  included), mirroring `handle_communities_key`/`handle_vta_key`.
- Render: each panel footer shows the "… ?  y: confirm  n: cancel" prompt
  (orange/bold) while a confirmation is pending, matching the Communities panel.

The confirm fields live on the panel state and survive `sync_from_config`
(which updates the inner data vectors, not the whole struct) — the same
mechanism the existing communities `confirm_delete` relies on.

Test coverage for the key handlers lands in R26 slice 2 (stacked next), per the
task's verification note.

Gate: cargo fmt, clippy -D warnings, test --workspace all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
Slice 1 (#105) added table tests for the pure `*_actions.rs` mode handlers but
deferred the main-page key-handler tests (they touched `main/mod.rs`, in flight
for R23). This adds them now that R23/R25 have settled the file.

Each test constructs a `MainPage` over a `State`, feeds a `KeyEvent` through the
public `handle_key_event` entry point, and asserts on the `Action`(s) emitted on
the channel. There is at least one test per content panel:

- Communities, VTA-DID: confirmation commit (y/Enter) + cancel.
- Inbox: `d`/`c` arm the dismiss / clear-all confirmation (R25), and a pending
  confirmation commits on y/Enter, cancels otherwise.
- Relationships, Credentials: `d` in the detail view arms the removal (R25),
  and a pending confirmation commits the Remove.
- Settings (Down moves selection), Logs, Help (Esc returns to the menu).

`Action` and its sub-enums derive neither `PartialEq` nor `Debug`, so the tests
pattern-match the expected variant. Stacked on R25 (#108) so the new
destructive-confirm routing is exercised end-to-end.

Gate: cargo fmt, clippy -D warnings, test --workspace all green (openvtc lib
113 -> 122 tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
@stormer78 stormer78 requested a review from a team as a code owner June 12, 2026 07:42
Base automatically changed from r25-destructive-confirms to main June 12, 2026 07:52
@stormer78 stormer78 merged commit 7295b37 into main Jun 12, 2026
11 of 13 checks passed
@stormer78 stormer78 deleted the r26-keyhandler-tests branch June 12, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant