test(state): table tests for pure action handlers + join_flow decisions (R26)#105
Merged
Conversation
…ns (R26) The mode-transition handlers in `settings_actions.rs`, `credential_actions.rs`, and `relationship_actions.rs` are pure functions of `&mut State` but had no direct tests. Add table tests (following the `setup_flow/navigation.rs` pattern) covering each handler's mode transitions — 17 tests in total across the three modules. For `join_flow.rs`, peel three pure decisions out of the existing call sites into free functions (no client trait / mock introduced) and test them: `validate_join_input`, `is_duplicate_membership`, `build_pending_record`. The call sites now delegate to these — behavior is unchanged. Handlers that do I/O (token/keyring/filesystem, network) are intentionally left out of the pure table tests; the network ones are already covered by the existing `*Outcome::apply` tests. `main/mod.rs` is untouched (its key-handler tests are a later slice). Gate: cargo fmt --all, clippy --workspace --all-targets -D warnings, cargo test -p openvtc (113 passed) — all green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A first slice of R26 (tests are ongoing, landed in slices). Adds direct tests for the pure mode-transition handlers that previously had none, and peels
join_flow.rs's pure decisions into testable free functions.Tests added (17)
Following the
setup_flow/navigation.rstable-test pattern:handle_start_editindex→mode map (incl. View fallback + input seeding),handle_field_update,handle_change_protection+ sub-field handlers, export/import form field + tab-switch,handle_wipe_start/handle_wipe_input,handle_select.NewRequest).join_flow.rs extraction (mechanical, behavior-neutral)
No client trait or mock introduced. Three pure decisions peeled out of the existing call sites, which now delegate to them:
validate_join_input— the trim + empty-reject from the submit arm.is_duplicate_membership— wraps the step-1 idempotency check.build_pending_record— wraps the step-9CommunityRecord::new_pending.Scope
main/mod.rsis untouched (its key-handler tests are a later slice). Handlers that do I/O (token/keyring/filesystem, network) are left out of the pure table tests; the network ones are already covered by existing*Outcome::applytests.Gate
Rebased onto current
main;cargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,cargo test -p openvtc(113 passed) — all green.🤖 Generated with Claude Code