Skip to content

Conversation

@JanZachmann
Copy link
Contributor

Summary

Adds comprehensive unit tests for device operations and WebSocket updates in the Crux Core, implementing Phase 1.2 of the testing strategy.

Changes

WebSocket Tests (13 tests)

  • System info: Updates and replacements via WebSocket (2 tests)
  • Online status: Online/offline transitions (3 tests)
  • Factory reset: Status updates (1 test)
  • Update validation: Validation status updates (1 test)
  • Timeouts: Timeout configuration updates (1 test)
  • Connection: Connected/disconnected state (2 tests)

Device Operation Tests (14 tests)

  • Reboot: Success, network errors, permission errors (3 tests)
  • Factory reset: Invalid mode, success, network errors (3 tests)
  • Firmware upload: Start, progress, completion, failure (4 tests)
  • Load update: Success with manifest, failure (2 tests)
  • Run update: Success, network error handling (2 tests)

Test Organization

  • Tests colocated with handlers in src/app/src/update/websocket.rs and src/app/src/update/device/mod.rs
  • Uses crux_core::testing::AppTester for deterministic state testing
  • Organized into nested modules by domain

Test Results

running 27 tests
test result: ok. 27 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 device operations and WebSocket updates:
- System info: updates and replacements via WebSocket
- Online status: online/offline transitions
- Factory reset: state machine and network error handling
- Reboot: state transitions and error handling
- Firmware upload: progress tracking, success/failure
- Update operations: load and run update flows

Tests are colocated with handlers in websocket.rs and device/mod.rs.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
JanZachmann added a commit to JanZachmann/omnect-ui that referenced this pull request Dec 18, 2025
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 device operation state tests test: add device operation state tests (PR 1.2) Dec 19, 2025
JanZachmann added a commit to JanZachmann/omnect-ui that referenced this pull request 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