Skip to content

Move admin debug tests and add a template rendering test - #1875

Merged
stefan-burke merged 5 commits into
mainfrom
work/move-debug-tests
Jul 21, 2026
Merged

stefan-burke merged 5 commits into
mainfrom
work/move-debug-tests

Conversation

@stefan-burke

@stefan-burke stefan-burke commented Jul 21, 2026

Copy link
Copy Markdown
Member

This is a test-only change. It does not touch src/ or any user-facing copy.

What changed

  • Moved test/lib/server-debug.test.ts to test/features/admin/debug/server.test.ts and extracted the local makeDebugState helper plus the owner session into a shared test/test-utils/debug.ts. The moved server test now imports these shared exports and still keeps its existing "Database pruning section" test.
  • Moved test/lib/server-debug-sentry.test.ts byte-for-byte to test/features/admin/debug/sentry.test.ts.
  • Added test/ui/templates/admin/debug/rendering.test.tsx that renders the admin debug template directly and asserts the navigation/section structure, missing and supplied values, badge variants for site/database/availability/storage, overridden limits, and the stable SENTRY_TEST_FORM_ID.
  • Recorded two out-of-scope CodeRabbit suggestions in TODO.md under "Admin debug test coverage follow-ups" — both are valid observations about the future follow-up work (inspect the Sentry envelope body, not just the request count; assert semantic section headings rather than CSS-class counts), kept here so the suggestions are not lost between this PR and whoever picks them up. No production code is touched.

Why

These tests had outlived their home under test/lib/. They now sit alongside the rest of the admin feature tests under test/features/admin/debug/, and the shared makeDebugState/debugOwnerSession helpers are reusable for the new direct-rendering test.

Current-main contracts

Because this targets current main, the prune state stays at Never across addresses, logins, payments, sessions, and strings, and the debug page still renders its prune section. The new rendering test asserts the matching counts for current main: 3 class="prose" and 13 class="table-scroll".

Verification

nix develop -c deno task test:files \
  test/features/admin/debug/server.test.ts \
  test/features/admin/debug/sentry.test.ts \
  test/ui/templates/admin/debug/rendering.test.tsx
# PASS 95 passed

nix develop -c deno task precommit
# precommit passed

The diff contains the two moves, the new test/test-utils/debug.ts and test/ui/templates/admin/debug/rendering.test.tsx, plus a TODO.md section recording two out-of-scope review suggestions for the future follow-up work they describe.

- Move test/lib/server-debug.test.ts to test/features/admin/debug/server.test.ts,
  extracting makeDebugState and the owner session into test/test-utils/debug.ts.
- Move test/lib/server-debug-sentry.test.ts unchanged to
  test/features/admin/debug/sentry.test.ts.
- Add test/ui/templates/admin/debug/rendering.test.tsx covering the
  navigation/section structure, missing and supplied values, badge variants
  for site/database/availability/storage, overridden limits, and the
  SENTRY_TEST_FORM_ID constant.

This targets current main, so the prune state stays at Never across all
fields and the existing Database pruning section test in the server test is
preserved unchanged.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 34177429-17de-4eef-8681-132c2790c313

📥 Commits

Reviewing files that changed from the base of the PR and between 2497d17 and fa2c37c.

📒 Files selected for processing (1)
  • TODO.md

📝 Walkthrough

Walkthrough

Adds shared admin debug test utilities and expands coverage for debug-page rendering and Sentry endpoint behavior, including configuration states, submission outcomes, read-only mode, request counts, and manager authorization. It also documents checkout-stage and debug-test follow-ups.

Changes

Admin debug testing

Layer / File(s) Summary
Shared debug test utilities
test/test-utils/debug.ts, test/features/admin/debug/server.test.ts
Adds reusable debug state and owner-session helpers, then updates server tests to use them.
Debug template rendering coverage
test/ui/templates/admin/debug/rendering.test.tsx
Tests debug-page structure, missing and configured values, badges, availability, storage, limits, and Sentry form markup.
Sentry debug endpoint coverage
test/features/admin/debug/sentry.test.ts
Tests Sentry form visibility, successful and failed submissions, read-only mode, request counts, configuration errors, and manager authorization.
Admin debug coverage follow-ups
TODO.md
Documents follow-up assertions for Sentry envelope contents and semantic debug-page structure.

Checkout stage deletion follow-ups

Layer / File(s) Summary
Checkout stage lifecycle requirements
TODO.md
Documents requirements for handling checkout_stages during attendee deletion, purge, and merge operations, including conflict handling.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: moving admin debug tests and adding a template rendering test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch work/move-debug-tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/features/admin/debug/sentry.test.ts`:
- Around line 63-68: Strengthen the “sends a tagged test error and confirms
delivery” test by replacing the shared request-count-only stub with a local
fetch recorder, then inspect the captured Sentry envelope to assert the expected
test-error message and tags source=admin-debug and test=true. Retain the
request-count assertion and existing redirect/flash checks, using the recorder
to validate the emitted request body details.

In `@test/ui/templates/admin/debug/rendering.test.tsx`:
- Around line 38-40: Update the assertions in the debug rendering test around
the href check to validate semantic debug section headings or table labels
instead of counting “prose” and “table-scroll” CSS-class occurrences. Remove the
hard-coded class-count expectations while preserving the existing admin debug
link assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7a642699-17c9-427c-a5ec-72e2adf89c47

📥 Commits

Reviewing files that changed from the base of the PR and between d0df2d7 and 2d99eaf.

📒 Files selected for processing (4)
  • test/features/admin/debug/sentry.test.ts
  • test/features/admin/debug/server.test.ts
  • test/test-utils/debug.ts
  • test/ui/templates/admin/debug/rendering.test.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/features/admin/debug/sentry.test.ts`:
- Around line 63-68: Strengthen the “sends a tagged test error and confirms
delivery” test by replacing the shared request-count-only stub with a local
fetch recorder, then inspect the captured Sentry envelope to assert the expected
test-error message and tags source=admin-debug and test=true. Retain the
request-count assertion and existing redirect/flash checks, using the recorder
to validate the emitted request body details.

In `@test/ui/templates/admin/debug/rendering.test.tsx`:
- Around line 38-40: Update the assertions in the debug rendering test around
the href check to validate semantic debug section headings or table labels
instead of counting “prose” and “table-scroll” CSS-class occurrences. Remove the
hard-coded class-count expectations while preserving the existing admin debug
link assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7a642699-17c9-427c-a5ec-72e2adf89c47

📥 Commits

Reviewing files that changed from the base of the PR and between d0df2d7 and 2d99eaf.

📒 Files selected for processing (4)
  • test/features/admin/debug/sentry.test.ts
  • test/features/admin/debug/server.test.ts
  • test/test-utils/debug.ts
  • test/ui/templates/admin/debug/rendering.test.tsx
🛑 Comments failed to post (2)
test/features/admin/debug/sentry.test.ts (1)

63-68: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Verify the diagnostic payload, not only its request count.

This test does not prove that the emitted event is tagged or even that it is the intended test error. Use a local fetch recorder to assert the Sentry envelope contains the expected message and source=admin-debug / test=true tags; the shared stub is only appropriate for call-count checks.

As per coding guidelines, tests must use strong mutation-resistant assertions. Based on learnings, retain/create a local fetch mock when per-request URL, method, or body details must be asserted.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/features/admin/debug/sentry.test.ts` around lines 63 - 68, Strengthen
the “sends a tagged test error and confirms delivery” test by replacing the
shared request-count-only stub with a local fetch recorder, then inspect the
captured Sentry envelope to assert the expected test-error message and tags
source=admin-debug and test=true. Retain the request-count assertion and
existing redirect/flash checks, using the recorder to validate the emitted
request body details.

Sources: Coding guidelines, Learnings

test/ui/templates/admin/debug/rendering.test.tsx (1)

38-40: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Assert semantic debug sections instead of CSS-class counts.

Lines 39-40 couple this test to presentation classes and hard-coded wrapper totals; adding/removing a layout wrapper can fail it without changing page behavior. Assert the expected section headings or table labels instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/ui/templates/admin/debug/rendering.test.tsx` around lines 38 - 40,
Update the assertions in the debug rendering test around the href check to
validate semantic debug section headings or table labels instead of counting
“prose” and “table-scroll” CSS-class occurrences. Remove the hard-coded
class-count expectations while preserving the existing admin debug link
assertion.

Source: Coding guidelines

@stefan-burke

Copy link
Copy Markdown
Member Author

Thanks for the review. Both findings are valid observations but are out of scope for this PR's brief, so I've recorded them in TODO.md (commit 0235d0a) for a follow-up rather than actioning them here:

  • test/features/admin/debug/sentry.test.ts:63-68 ("Verify the diagnostic payload, not only its request count"). Agreed — the test only asserts one request was made, not that the envelope carries the expected message and source=admin-debug / test=true tags. This PR's brief required sentry.test.ts to be moved unchanged from test/lib/server-debug-sentry.test.ts and listed "no Sentry SDK tests" as a hard exclusion, so strengthening the envelope assertions is deferred. Tracked under "Admin debug test coverage follow-ups" in TODO.md with a starting point (read the POST /admin/debug/sentry handler in src/features/admin/debug.ts to find where the envelope is built, then replace the shared stubFetch with a local recorder for that one test).

  • test/ui/templates/admin/debug/rendering.test.tsx:38-40 ("Assert semantic debug sections instead of CSS-class counts"). Agreed the counts couple the test to presentation wrappers. This PR's brief explicitly dictated these counts as the current-main contract (3 class="prose" and 13 class="table-scroll"), so removing them here would directly contradict the brief. Tracked in the same TODO.md section, with a starting point of deriving the expected section-title set from DEBUG_SECTIONS in src/ui/templates/admin/debug.tsx so the test fails only when a section is added, removed, or renamed. The existing href="/admin/debug" link assertion stays.

deno task precommit passes (commit 0235d0a). Happy to action either as a separate follow-up PR if you'd prefer that to the TODO queue.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0235d0ae34

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread test/ui/templates/admin/debug/rendering.test.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
TODO.md (2)

1330-1341: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the exact Sentry assertion values.

Specify the literal expected message and tag values so the follow-up cannot be implemented with weaker or incorrect assertions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@TODO.md` around lines 1330 - 1341, Update the TODO guidance for the “sends a
tagged test error and confirms delivery” test to require literal assertions for
the envelope message emitted by the POST /admin/debug/sentry handler, plus
source=admin-debug and test=true; derive the exact message literal from that
handler rather than describing it generically, while retaining request-count,
redirect, and flash assertions.

1342-1355: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the semantic test oracle independent of DEBUG_SECTIONS.

Deriving expected headings from the production list can allow a missing or renamed rendered section to pass if the list changes with it. Use an explicit expected heading set or separately maintained fixture, while retaining the /admin/debug link assertion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@TODO.md` around lines 1342 - 1355, Update the “keeps the debug navigation and
section structure” test to assert an explicitly maintained set of expected debug
section headings, independent of DEBUG_SECTIONS or production rendering data.
Keep the /admin/debug link assertion and ensure the test detects added, removed,
or renamed rendered sections without relying on CSS-class counts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@TODO.md`:
- Around line 1330-1341: Update the TODO guidance for the “sends a tagged test
error and confirms delivery” test to require literal assertions for the envelope
message emitted by the POST /admin/debug/sentry handler, plus source=admin-debug
and test=true; derive the exact message literal from that handler rather than
describing it generically, while retaining request-count, redirect, and flash
assertions.
- Around line 1342-1355: Update the “keeps the debug navigation and section
structure” test to assert an explicitly maintained set of expected debug section
headings, independent of DEBUG_SECTIONS or production rendering data. Keep the
/admin/debug link assertion and ensure the test detects added, removed, or
renamed rendered sections without relying on CSS-class counts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 04f01d30-0fb1-4f97-b6b4-6a28ba036753

📥 Commits

Reviewing files that changed from the base of the PR and between 0235d0a and 6ff3285.

📒 Files selected for processing (1)
  • TODO.md

Codex review of PR #1875 pointed out that "runtime-marker" is not a member of
the RuntimeInfo.runtime union ("bunny" | "deno" | "node" | "unknown"). The
test nonetheless passed because test/**/*.tsx is outside the typecheck glob
and the suite runs with --no-check, so an invalid literal could slip through
and would resurface as a real type error the moment TSX tests were added to
the typecheck. Use "bunny" instead.
CodeRabbit's 13:58 review on PR #1875 left two advisory comments on the
TODO.md section that records the deferred follow-ups. Both are good points
about the future follow-up's quality:

- The Sentry-envelope follow-up should name the literal expected message and
  tag values ("Test Sentry notification from the admin debug page." and
  source=admin-debug / test=true) so it cannot be implemented with weaker
  assertions than intended. Incorporated by reading sendSentryTest in
  src/shared/sentry.ts and pinning the literal values into the TODO.
- The semantic-sections follow-up should maintain the expected heading set as
  an explicit literal list inside the test, not derive it from DEBUG_SECTIONS:
  deriving the oracle from the same source list the template renders against
  lets a removed or renamed section pass undetected when both the rendering
  and the oracle shift in lockstep. The guidance now says so explicitly.
@stefan-burke

Copy link
Copy Markdown
Member Author

Addressed both advisory comments from CodeRabbit's 13:58 review (the ones flagged as outside-diff-range on TODO.md, so they post as review-body text rather than inline threads):

  • TODO.md:1330-1341 ("Document the exact Sentry assertion values"). Done in commit fa2c37c — the TODO entry now names the literal expected message "Test Sentry notification from the admin debug page." and the literal source=admin-debug / test=true tag values (verified against sendSentryTest in src/shared/sentry.ts:74-101), with a note to re-sync them with that source when the follow-up lands. This stops a future implementer substituting weaker or different assertions.

  • TODO.md:1342-1355 ("Keep the semantic test oracle independent of DEBUG_SECTIONS"). Done in the same commit — the TODO entry now explicitly tells the follow-up to maintain the expected heading set as a literal list inside the test, and explains why not derive it from DEBUG_SECTIONS: deriving the oracle from the same source list the template renders against lets a removed/renamed section pass undetected when both the rendering and the oracle shift in lockstep. An independent literal list makes any section addition/removal/rename a deliberate test review, which is the failure mode the test is meant to catch.

These are guidance improvements for the future follow-up PR; the current PR's code is unchanged. deno task precommit passes (commit fa2c37c).

@stefan-burke
stefan-burke added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit 857cbf7 Jul 21, 2026
3 checks passed
@stefan-burke
stefan-burke deleted the work/move-debug-tests branch July 21, 2026 15:19
stefan-burke added a commit that referenced this pull request Jul 21, 2026
Resolved conflicts in 10 files:
- TODO.md: kept both entries (PR #1872 extraction deferral and PR #1875
  admin debug follow-ups).
- e2e-payments/src/providers/stripe.ts: kept main's restructured imports
  and our per-endpoint try/catch in the cleanup loop.
- test/integration/code-quality.test.ts: combined main's #test/ alias
  imports with our detectRelativeImport import from relative-import.ts.
- test/integration/server-balance-webhook.test.ts,
  test/integration/server/public/ticket-csrf-and-capacity.test.ts,
  test/integration/server/reservation-edge-cases.test.ts,
  test/integration/server/reservation-no-provider.test.ts,
  test/integration/server/webhooks/can-pay-more-multi-ticket.test.ts,
  test/integration/stripe-mock-ports.test.ts,
  test/integration/webhook-price-signature-trusted-and-mismatch.test.ts:
  took main's versions — Stripe SDK replacement dropped resetStripeClient
  imports, file moves changed #test/lib/ aliases to relative paths.
stefan-burke pushed a commit that referenced this pull request Aug 4, 2026
Two test-only follow-ups from the PR #1875 review:

The admin Sentry test now records the envelope the page actually sends
and checks the test message and its source/test tags, instead of only
counting that one request happened.

The debug page structure test now asserts the exact ordered list of
section headings — an independent literal list, so a dropped, renamed,
or added section is a conscious test edit — instead of counting
presentation classes. Writing that list surfaced the Email section the
class counts said nothing about.

Closes the "Admin debug test coverage follow-ups" TODO section.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ehWXhDVAmSZFkKWVo4grA
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