Skip to content

refactor(admin): the dashboard's tests split into one file per flow - #605

Merged
PiquelChips merged 2 commits into
mainfrom
refactor/544-admin-tests-split
Nov 21, 2026
Merged

PiquelChips merged 2 commits into
mainfrom
refactor/544-admin-tests-split

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Part of #544

apps/auth-service/src/web/admin/tests.rs was 2,406 lines, the largest hand-written file in the repository, and too long to read in one sitting. It is now a tests/ directory, as docs/dev/rust-conventions.md asks for a test file that outgrows one read. tests/mod.rs keeps the imports, the constants and the Harness, plus its actor_of, which tests in three files use. Each flow has its own file, with use super::* as admin/tests/ does:

  • sessions.rs: signing in through auth's handoff page, the dashboard's confirmation, and the admin listener.
  • frame.rs: what every page shares, such as the crumb, the top bar, the sidebar, the error page and the attention cache.
  • accounts.rs: an account's page, its changes and settings, granting rights, and messages.
  • clients.rs: clients and their approved origins.
  • operations.rs: audit, invitations, deliveries (with the Unsent channel), signing keys, handles and alerts.
  • announcements.rs: drafting and sending announcements.

This is a pure move, kept in its own pull request so the fixture clean-up that touches this file can rebase onto it. No test or fixture changed. The only edited line is tests/mod.rs's import of the dashboard, which now also names Attention and AttentionCache, so the attention-cache test's super::AttentionCache still resolves from its new file. A script checked that every non-blank line of the old file's body appears exactly once across the new files. The 39 tests keep their function names; only their module path gains the file's name, e.g. web::admin::tests::sessions::signing_in_asks_auth_for_a_passkey_once.

  • Tests merged or removed: none (39 before, 39 after).
  • Files edited outside the Admin area: none.
  • Proof that nothing else changed: the same 39 tests pass under just db test -E 'test(/^web::admin::/)'.

Checks: just fmt (no change to the moved code); cargo clippy -p auth-service --all-targets with and without --all-features (-D warnings); just db test -E 'test(/^web::admin::/)'.

Note

Written by Claude Opus 5.5 in Claude Code and reviewed by Claude Opus 5.5 (via T3 Code)

Scope: Test module layout (apps/auth-service/src/web/admin/)

  • Deletes tests.rs (-2425 lines). Its admin dashboard integration tests move to a tests/ directory.
  • Adds tests/mod.rs (+250). It keeps the shared imports, constants, Harness, and actor_of helper, and declares six flow modules. The only edit outside the moved code adds Attention and AttentionCache to the dashboard import, so super::AttentionCache still resolves.
  • Adds six flow modules:
    • sessions.rs (+443): handoff, sign-in/sign-out, session expiry, passkey confirmation, admin listener restrictions.
    • frame.rs (+168): error trace IDs, breadcrumbs, notification bell, search, AttentionCache.
    • accounts.rs (+773): account-page changes, recovery, grants, deletion, messages.
    • clients.rs (+308): origins and client lifecycle.
    • operations.rs (+325): audit, invitations, deliveries, signing keys, handles, alerts.
    • announcements.rs (+187): announcement drafting, confirmation, sending, inbox view.

Scope: Documentation (docs/dev/)

  • extending/account-setting.md: test location changes to web/admin/tests/accounts.rs (+1/-1).
  • extending/admin-operation.md: test location changes to web/admin/tests/ (+1/-1).
  • security/account-recovery.md: test name changes to accounts::an_accounts_page_names_no_passkey (+1/-1).

Totals

  • 11 files changed, +2457/-2428 lines.
  • The PR describes the change as a pure move. Test function names stay the same, and only module paths change.
  • The PR reports these checks: just fmt, cargo clippy -p auth-service --all-targets (with and without --all-features), and just db test -E 'test(/^web::admin::/)' with 39 passing tests. I did not run these checks or verify the 39-test count.

@PiquelChips PiquelChips added admin The admin dashboard at admin.sourceorigin.dev refactor No behviour changes tests Tests labels Nov 20, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The former admin dashboard test module was removed and replaced by a shared test harness and per-flow test modules for sessions, accounts, announcements, clients, operations, and dashboard framing. Developer documentation now points to the reorganized test paths. No production implementation changes are described.

Changes: Admin dashboard test reorganization

Layer / File(s) Summary
Shared test harness and module setup
apps/auth-service/src/web/admin/tests.rs, apps/auth-service/src/web/admin/tests/mod.rs
The former test module is removed. The new module provides shared database and browser setup, dashboard authentication helpers, event lookup, and declarations for per-flow test modules.
Dashboard authentication and session tests
apps/auth-service/src/web/admin/tests/sessions.rs
Tests cover handoff, passkey confirmation, session expiry and revocation, administrator-rights changes, and admin-listener restrictions.
Admin account tests
apps/auth-service/src/web/admin/tests/accounts.rs, docs/dev/extending/account-setting.md, docs/dev/security/account-recovery.md
Tests cover account changes, recovery, administrator grants, deletion and restoration, history, session revocation, and message preview and delivery. Documentation points to the account test module.
Announcement tests
apps/auth-service/src/web/admin/tests/announcements.rs
Tests cover recipient selection, draft revisions, confirmation before sending, and announcement display in a recipient inbox.
Client management tests
apps/auth-service/src/web/admin/tests/clients.rs
Tests cover client origins, registration and editing, secret operations, suspension, deletion, and client ID routing.
Admin operations tests
apps/auth-service/src/web/admin/tests/operations.rs, docs/dev/extending/admin-operation.md
Tests cover audit verification, invitation links, delivery operations, signing keys, handle reservations, and audit-chain alerts. Documentation points to the dashboard test directory.
Dashboard frame and search tests
apps/auth-service/src/web/admin/tests/frame.rs
Tests cover trace IDs, breadcrumbs, notifications, dashboard links, search suggestions, and AttentionCache behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Merge Risk: Minimal · up to b817c

This reorganizes admin dashboard tests into per-flow files and updates the developer documentation to match. It has no runtime effect on the service. The remaining risk is a test that was dropped or altered during the move, which the reported check of the 39 test names mitigates.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "refactor(admin): the dashboard's tests split into one file per flow" matches the change. The PR splits the 2,406-line admin dashboard test file into a tests/ directory with one file per flo…
Description check Passed The description follows the template's sections. The 'What and why' section explains the 2,406-line file, the reason for the split, and the file layout. It does not include a 'Closes #' issue referenc…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "refactor(admin): the dashboard's tests split into one file per flow" matches the change. The PR splits the 2,406-line admin dashboard test file into a tests/ directory with one file per flow, and the description and objectives confirm it is a pure move with no test changes. It is a conventional commit with a clear scope and a specific main change.

Full details: Description check

Explanation

The description follows the template's sections. The 'What and why' section explains the 2,406-line file, the reason for the split, and the file layout. It does not include a 'Closes #' issue reference; it says 'Part of #544' instead, which is acceptable for a partial change. The 'Testing' section lists the fmt, clippy, and db test commands and the 39-test parity check. It does not explicitly list what was not tested (such as real devices or live providers), which the template asks for, though that gap is minor for a pure move. The checklist from the template is missing. The author did not tick any boxes or state that the Generated files and the 'just validate' checks were addressed. The 'just validate' command and the 'every surface' item are not addressed, and the checklist is absent from the description.

Resolution

Optional: add the template Checklist, or state which items apply (for example, that 'just validate' passed and that no generated files changed). Optionally note what was not tested.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

I’m a rabbit with test paths to explore,
I hop through sessions, then accounts galore.
Drafts and clients line the trail,
Alerts and searches join the detail.
Fresh modules tucked safe in my burrow.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8fc9a1c5-cd16-4811-9f33-d01df8766e43
Commits

Reviewing files that changed from the base of the PR and between f675d8d and b817cb1.

Files selected for processing: 11

  • apps/auth-service/src/web/admin/tests.rs
  • apps/auth-service/src/web/admin/tests/accounts.rs
  • apps/auth-service/src/web/admin/tests/announcements.rs
  • apps/auth-service/src/web/admin/tests/clients.rs
  • apps/auth-service/src/web/admin/tests/frame.rs
  • apps/auth-service/src/web/admin/tests/mod.rs
  • apps/auth-service/src/web/admin/tests/operations.rs
  • apps/auth-service/src/web/admin/tests/sessions.rs
  • docs/dev/extending/account-setting.md
  • docs/dev/extending/admin-operation.md
  • docs/dev/security/account-recovery.md
Files with no reviewable changes: 1

  • apps/auth-service/src/web/admin/tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@PiquelChips
PiquelChips marked this pull request as ready for review November 20, 2026 10:14
@PiquelChips
PiquelChips marked this pull request as draft November 21, 2026 14:00
`web/admin/tests.rs` was 2,406 lines. It becomes `tests/`: `mod.rs` keeps the
imports, constants and the `Harness`, and sessions, the frame, accounts,
clients, the service's own lists and announcements each get a file. A pure
move: no test or fixture changed.
@PiquelChips
PiquelChips force-pushed the refactor/544-admin-tests-split branch from 16a7602 to b817cb1 Compare November 21, 2026 14:07
@PiquelChips
PiquelChips marked this pull request as ready for review November 21, 2026 14:08
@github-project-automation github-project-automation Bot moved this from Needs Triage to Ready in sourceorigin.dev Nov 21, 2026
@PiquelChips
PiquelChips added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 4440fbd Nov 21, 2026
14 checks passed
@PiquelChips
PiquelChips deleted the refactor/544-admin-tests-split branch November 21, 2026 14:45
@github-project-automation github-project-automation Bot moved this from Ready to Done in sourceorigin.dev Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

admin The admin dashboard at admin.sourceorigin.dev refactor No behviour changes tests Tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant