Skip to content

test(webui): rework brittle source-grepping and daisyUI-class tests - #1179

Open
jatmn wants to merge 3 commits into
mainfrom
test/rework-brittle-tests-1139
Open

jatmn wants to merge 3 commits into
mainfrom
test/rework-brittle-tests-1139

Conversation

@jatmn

@jatmn jatmn commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Closes #1139

Summary

  • Part A (Rust source-grepping tests):
    • crates/bot/src/member_rejoin/tests.rs: Replaced fixed-window include_str! checks with async behavioral tests (maybe_emit_defers_rejoin_enrichment_to_log_admission, rejected_departure_keeps_rejoin_delivery_guard, concurrent_guild_member_addition_does_not_double_post_rejoin_note) against StartupProbe, Handler, and a local hyper fixture.
    • crates/bot/src/member_directory.rs + crates/bot/src/discord.rs + ban callers (automod.rs, spam_actions.rs, commands/behaviors.rs, commands/plans.rs): Replaced source-file grepping with a compile-time BanAttemptToken witness required on discord::automod_ban / discord::ban_with_reason plus an async start_paused = true deadline test for reserve_ban_marker.
    • crates/runtime/src/cgroup.rs: Replaced include_str!("cgroup.rs") grep with behavioral temp /proc + cgroup fixture coverage proving host /proc/meminfo and /proc/stat never synthesize cgroup counters and host_total is consulted only for numeric v1 limits.
    • crates/api/src/web/mod.rs, recovery.rs, enrollment_tests.rs: Replaced include_str! .route( string splitting with a zero-overhead RouteBuilder wrapper that collects registered &'static str paths under #[cfg(test)].
  • Part B (Frontend daisyUI-class selectors): Added semantic data-testid hooks on dashboard stats (frontend/app.js) and reworked the coupled tests in scripts/frontend-state-test.mjs off .stat*/.badge/.card/.hero onto semantic role/label/data-testid selectors.
  • Part C (CSS-parsing contrast tests): Removed file-layout (analytics/database usage comment-banner) and obsolete-scale regex checks from scripts/frontend-contrast-test.mjs while keeping all WCAG contrast, focus-ring, scale, and responsive layout assertions.
  • Part D (Platform analytics legacy fallback): Removed the legacy single-endpoint API fallback in frontend/app.js and its test in scripts/frontend-state-test.mjs (current only, per test(webui): rework tests that pin source text and daisyUI-era classes #1139 / chore: master plan and merge order for the Dec 2026 backlog #1151 decision).

Validation

  • Reviewed SHA: db3e6ad4d940e32a50614a11a9eb6a99fdc71462
  • bash scripts/ci-preflight.sh --only frontend — PASS (frontend-state-test.mjs 634/634, frontend-contrast-test.mjs 39/39, frontend-warmup-test.mjs 13/13, frontend-sr-only-test.mjs 1/1, package-webui-test.mjs 4/4, administration-state-test.mjs 42/42, ESLint + flake 10/10)
  • cargo test --locked -p jmodguard-runtime — PASS (77/77)
  • cargo test --locked -p jmodguard-bot member_rejoin — PASS (32/32)
  • cargo test --locked -p jmodguard-bot member_directory — PASS (12/12)
  • cargo test --locked -p jmodguard-api owner_routes — PASS (2/2 default, 2/2 --no-default-features)
  • cargo fmt --check and cargo clippy --locked -p <pkg> --all-targets -- -D warnings (all 3 crates, API both feature modes) — PASS
  • git diff --check — PASS
  • Simulated boundaries: Local SQLite, loopback hyper fixtures, temp /proc/cgroup fixtures, and JSDOM + headless Firefox browser tests; no live Discord/Bunny/remote libSQL calls.

Summary by Sourcery

Replace brittle source- and style-based checks with behavior-focused coverage, and remove the obsolete platform analytics API fallback.

Bug Fixes:

  • Remove the platform analytics fallback to the legacy combined endpoint, keeping the split history and member-directory API as the supported path.

Enhancements:

  • Replace brittle source-text assertions with behavioral tests for member rejoin delivery, ban-marker deadlines, cgroup readings, and API route registration.
  • Use semantic dashboard test hooks and accessible selectors in frontend state tests instead of styling-class selectors.
  • Retain contrast, focus-ring, scale, and responsive-layout assertions while dropping CSS comment-layout and obsolete-scale checks.

Tests:

  • Add async coverage for rejoin admission, rejected departures, and concurrent joins to verify enrichment and delivery behavior.

@jatmn
jatmn marked this pull request as ready for review December 4, 2026 07:42
@sourcery-ai

sourcery-ai Bot commented Dec 4, 2026

Copy link
Copy Markdown

Sorry @jatmn, this account has used its review budget of 1,500,000 diff characters for the last 7 days.

You can request another review in 12 hours and 57 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new rejoin concurrency test can hang the bot test job if the first handler exits before posting.

Approach The behavioral fixtures and semantic selectors fit #1139. The current-only analytics calls match the decision in #1151.

Reviewed changes

  • Bot. Rejoin tests exercise log admission, stale departures, and concurrent joins. The four permanent-ban callers pass a marker-attempt token, and a paused-time test checks the reservation deadline.
  • API and runtime. The owner denial test reads paths from the sessioned router builder. The cgroup fixture tests exercise host metric isolation and v1 memory-limit handling.
  • WebUI. Dashboard state tests use stable stat hooks, contrast checks drop stylesheet comment boundaries, and Platform Analytics uses the split endpoints.

Local validation covered JavaScript syntax checks and Rust source tracing. The full suites were not rerun for this review.

Non-blocking

  • The owner-route inventory omits the outer router. The previous scan covered registrations anywhere in mod.rs, while registered_sessioned_routes sees only the sessioned builder. A future owner-prefixed route added directly to the outer router would escape the denial-test inventory. Include both routers in the recorded paths. Inventory assertion and Outer router.
  • The Members import tests still depend on wrapper markup. Adding a semantic section around Members would fail both the finished and never-run cases even if the summary, order, and controls stayed the same. The existing summary, order, and disclosure assertions can carry those checks without the Mantine-class and ancestor-tag assertions. Finished case and never-run case.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol | 𝕏

Comment thread crates/bot/src/member_rejoin/tests.rs Resolved
pullfrog[bot]
pullfrog Bot previously approved these changes Dec 4, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed d974011, the follow-up to db3e6ad.

  • Bounded the initial rejoin wait. The concurrency test now fails when the first handler exits before posting or when the loopback request fails to arrive within five seconds.
  • Included outer routes in the owner-route inventory. The denial test now collects paths from both builders used by the live router.
  • Removed wrapper assertions from the Members import tests. The tests still check the summary, the collapsed history disclosure after a completed run, and the absence of import details before the first run.

Both targeted Members state tests passed in JSDOM. Rust formatting and delta whitespace checks passed. The Rust test paths were reviewed in source, and the bot and API CI jobs were still running. CI run

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed d974011 through 138f615.

  • Replaced the explicit sleep with tokio::time::timeout. The rejoin test still races the first loopback request against early handler exit, and it fails after five seconds if neither happens. This removes the explicit sleep that the prior Dylint run flagged.
  • Rebased the WebUI changes onto the updated card and modal components. The dashboard keeps its stat hooks, and the Members and known-spam tests keep their summary, disclosure, and alert assertions.

Rust formatting, JavaScript syntax, whitespace, and the test timing policy check passed locally. The bot test suite and Dylint were still running in CI for 138f615.

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

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.

test(webui): rework tests that pin source text and daisyUI-era classes

1 participant