Skip to content

Conversation

@JanZachmann
Copy link
Contributor

Summary

Adds comprehensive unit tests for all authentication flows in the Crux Core, following the testing strategy defined in FRONTEND_TEST_CONCEPT.md (Phase 1.1).

Changes

Test Coverage

  • Login flow: 4 tests covering loading state, success/failure responses, error clearing
  • Logout flow: 3 tests covering session cleanup and error handling
  • Set password: 3 tests for initial password setup flow
  • Update password: 3 tests for password change with validation
  • Check requires password: 4 tests for password requirement state management

Architecture

  • Tests are colocated with code in src/app/src/update/auth.rs following Rust conventions
  • Uses crux_core::testing::AppTester for deterministic state testing
  • Organized into nested modules by domain (login, logout, etc.)

Cleanup

  • Removed old src/app/src/tests.rs (tests now live next to the code they test)
  • Removed test module reference from lib.rs

Test Results

running 17 tests
test result: ok. 17 passed; 0 failed; 0 ignored

All tests pass with no warnings from clippy.

Signed-off-by: Jan Zachmann 50990105+JanZachmann@users.noreply.github.com

Add unit tests for all authentication flows in the Core:
- Login: loading state, success/failure handling, error clearing
- Logout: session cleanup, error handling
- Set password: initial password setup flow
- Update password: password change with validation
- Check requires password: state management

Tests are colocated with the auth handler code following Rust conventions.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Update FRONTEND_TEST_CONCEPT.md to reflect:

Phase 1 Complete (92 tests):
- PR omnect#77: Authentication Tests (17 tests)
- PR omnect#78: Device Tests (27 tests)
- PR omnect#79: Network Tests (21 tests)
- PR omnect#80: Reconnection Tests (27 tests)

Phase 2 Skipped:
- Effect emission testing deemed low-value after Phase 1 implementation
- Effects are auto-generated and handled by well-tested macros
- Testing implementation details (how Core communicates) vs behavior (what it does)
- Response handling tests in Phase 1 already validate request/response cycles

Lessons Learned:
- Colocated tests improve maintainability
- Domain organization mirrors code structure
- Response-focused testing validates behavior without coupling
- Avoid testing auto-generated types and macro usage

Key Patterns:
- Use `let _ = app.update(...)` for unused results
- Test response events not request events
- Organize with nested modules
- Use helper functions for test data

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
@JanZachmann JanZachmann changed the title test: add comprehensive authentication state tests test: add comprehensive authentication state tests (PR 1.1) Dec 19, 2025
Update FRONTEND_TEST_CONCEPT.md to accurately reflect that this branch
(test/core-auth) only contains the authentication tests from PR 1.1.
The document previously indicated all of Phase 1 was complete (92 tests
across 4 PRs), but this branch only has 17 authentication tests.

Changes:
- Update Phase 1 status from "Complete (92 tests)" to "In Progress (17 tests)"
- Mark PR omnect#77 (Authentication Tests) as complete for this branch
- Mark PR omnect#78-80 as pending (not in this branch)
- Update ROI Summary table to show correct progress (17/92 tests)
- Fix markdown formatting issues (blank lines around lists/headings)

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
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