Skip to content

Move eleven more misplaced unit tests to their source mirror paths - #1769

Merged
stefan-burke merged 1 commit into
mainfrom
claude/unit-tests-easy-wins-xlyi1a
Jul 11, 2026
Merged

Move eleven more misplaced unit tests to their source mirror paths#1769
stefan-burke merged 1 commit into
mainfrom
claude/unit-tests-easy-wins-xlyi1a

Conversation

@stefan-burke

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

Copy link
Copy Markdown
Member

What changed

A second batch of the same low-risk cleanup as #1765. Eleven unit-test files each check a single piece of code in src/, but sat under test/lib/ (or another folder that mirrors nothing), so the coverage report treated those pieces of source as having no test at all — even though a working test existed.

Each test moves to sit alongside the code it checks:

Test file Now lives at
admin-image-upload.test.ts test/features/admin/image-upload.test.ts
question-forms.test.ts test/features/admin/questions.test.ts
payment-processing/packages.test.ts test/features/api/payment-processing/package-pricing.test.ts
payment-processing/pair-entries-by-listing.test.ts test/features/api/payment-processing/create.test.ts
server-listings/with-cookie.test.ts test/features/response.test.ts
column-order/columns.test.ts test/shared/columns/listing-columns.test.ts
csv/generate.test.ts test/shared/csv/index.test.ts
server-settings/payment-provider.test.ts test/features/admin/settings-general/payment-provider.test.ts
render-date-selector.test.ts test/ui/templates/public/reservations/controls.test.ts
reservation-rows.test.ts test/ui/templates/public/reservations/listing-rows.test.ts
reservations/og.test.ts test/ui/templates/public/reservations/og-tags.test.ts

Why it's safe

Every one of these files imports its code through project aliases (#shared/..., #routes/...), not relative paths, so moving the file changes nothing about how it runs — they are pure renames with no edits to any test code.

A note on the payment-provider suite

The automated misplaced-test report flagged payment-provider.test.ts against src/shared/demo/mode.ts, because that's the only source it imports. But that import (setDemoModeForTest) is used only for afterEach teardown — every assertion drives POST /admin/settings/payment-provider, whose handler lives in src/features/admin/settings-general.ts. Filing it at demo-mode's mirror would have mis-credited demo-mode coverage to a route test and skewed that file's mutation bookkeeping. It's therefore placed at the settings-general handler's mirror instead, which is the source it actually exercises. Thanks to the Codex reviewer for catching this.

Result

The unit-test report now recognises eleven more sources as having a mirrored test (316 → 327), and eleven fewer as untested. All eleven moved tests were run in their new locations and pass (0 failures); typecheck and lint are clean.

As with the first batch, these are the safe subset of the deno task unit-tests-report misplaced-tests list — each carries no shared fixtures, isn't imported by any other test, and lands on a free mirror path. Tests that share fixtures or use relative imports (e.g. the booking/model and stripe groups) were left out of this round.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q8LbdSHz7eSXyqY3GBSAgw

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (11)
  • test/features/admin/image-upload.test.ts
  • test/features/admin/questions.test.ts
  • test/features/admin/settings-general/payment-provider.test.ts
  • test/features/api/payment-processing/create.test.ts
  • test/features/api/payment-processing/package-pricing.test.ts
  • test/features/response.test.ts
  • test/shared/columns/listing-columns.test.ts
  • test/shared/csv/index.test.ts
  • test/ui/templates/public/reservations/controls.test.ts
  • test/ui/templates/public/reservations/listing-rows.test.ts
  • test/ui/templates/public/reservations/og-tags.test.ts
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bcd8d801-e04b-4478-950c-234baa9a0f31

📥 Commits

Reviewing files that changed from the base of the PR and between 9c67da9 and e66a4b7.

📒 Files selected for processing (11)
  • test/features/admin/image-upload.test.ts
  • test/features/admin/questions.test.ts
  • test/features/admin/settings-general/payment-provider.test.ts
  • test/features/api/payment-processing/create.test.ts
  • test/features/api/payment-processing/package-pricing.test.ts
  • test/features/response.test.ts
  • test/shared/columns/listing-columns.test.ts
  • test/shared/csv/index.test.ts
  • test/ui/templates/public/reservations/controls.test.ts
  • test/ui/templates/public/reservations/listing-rows.test.ts
  • test/ui/templates/public/reservations/og-tags.test.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/unit-tests-easy-wins-xlyi1a

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

@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

import { setDemoModeForTest } from "#shared/demo/mode.ts";

P2 Badge Keep payment-provider tests out of demo mode's mirror

This suite was moved to test/shared/demo/mode.test.ts because it imports setDemoModeForTest, but that import is only used for teardown while every assertion exercises POST /admin/settings/payment-provider. With the file at the direct mirror for src/shared/demo/mode.ts, the unit-test report now credits demo-mode code to payment-provider route tests, and a mutation run for demo mode would not run the real demo-mode assertions that still live elsewhere. Move these cases under the settings handler's mirror (or split actual mode assertions into this file) so the source-to-test bookkeeping stays accurate.

ℹ️ 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".

A second batch of the same low-risk cleanup: eleven test files each
exercise exactly one source but lived under test/lib or another folder
that mirrors nothing, so the coverage report counted their sources as
untested. Moving each to its source's mirror location lines the test
tree up with src/ and flips eleven sources from untested to mirrored
(316 -> 327). All imports are alias-based, so the moves are pure renames
with no code changes:

  admin-image-upload.test.ts        -> test/features/admin/image-upload.test.ts
  question-forms.test.ts            -> test/features/admin/questions.test.ts
  packages.test.ts                  -> test/features/api/payment-processing/package-pricing.test.ts
  pair-entries-by-listing.test.ts   -> test/features/api/payment-processing/create.test.ts
  server-listings/with-cookie...    -> test/features/response.test.ts
  column-order/columns.test.ts      -> test/shared/columns/listing-columns.test.ts
  csv/generate.test.ts              -> test/shared/csv/index.test.ts
  server-settings/payment-provider  -> test/features/admin/settings-general/payment-provider.test.ts
  render-date-selector.test.ts      -> test/ui/templates/public/reservations/controls.test.ts
  reservation-rows.test.ts          -> test/ui/templates/public/reservations/listing-rows.test.ts
  reservations/og.test.ts           -> test/ui/templates/public/reservations/og-tags.test.ts

The payment-provider suite imports demo/mode only for afterEach teardown
while every assertion drives POST /admin/settings/payment-provider, so it
belongs at the settings-general handler's mirror, not demo/mode's.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q8LbdSHz7eSXyqY3GBSAgw
@stefan-burke
stefan-burke force-pushed the claude/unit-tests-easy-wins-xlyi1a branch from cbc2a48 to e66a4b7 Compare July 11, 2026 20:20

Copy link
Copy Markdown
Member Author

@codex Good catch — fixed in e66a4b7.

You're right that this suite only imports setDemoModeForTest for afterEach teardown while every assertion drives POST /admin/settings/payment-provider, so filing it at test/shared/demo/mode.test.ts mis-credited demo-mode coverage. I've moved it to test/features/admin/settings-general/payment-provider.test.ts, the mirror of src/features/admin/settings-general.ts — the handler it actually exercises. The report now credits settings-general.ts (previously untested) and no longer touches demo/mode.ts's bookkeeping; the mirrored count is unchanged at 327.


Generated by Claude Code

@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

import { setDemoModeForTest } from "#shared/demo/mode.ts";

P2 Badge Move the demo-mode test to its actual mirror

This file still imports exactly one source, #shared/demo/mode.ts, but it was moved under test/features/admin/settings-general/ even though there is no matching src/features/admin/settings-general/payment-provider.ts. Under the repo's mirror rule, src/shared/demo/mode.ts maps to test/shared/demo/mode.test.ts or a file inside test/shared/demo/mode/, so the unit-test report will continue to count this as a misplaced orphan and will not credit the demo-mode source as intended.

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Testing

  • ⚠️ mise exec -- deno task test:files test/features/admin/settings-general/payment-provider.test.ts — blocked while caching npm dependencies because the npm registry TLS certificate was reported as UnknownIssuer.
  • git status --short
  • git show --name-status --find-renames --summary e66a4b7
  • rg --files test | rg '(^|/)mode\\.test\\.ts$|payment-provider\\.test\\.ts$'

View task →

Copy link
Copy Markdown
Member Author

@codex Thanks — and agreed with your follow-up summary that no further change is needed. To close the loop on the intermediate P2 ("will not credit the demo-mode source"):

The placement is correct, and I verified it against the actual report. There are two independent mechanisms in play:

  • Coverage/mutation credit is path-based (unit-tests-report-lib.ts, directory-suite convention): a file inside test/features/admin/settings-general/ credits src/features/admin/settings-general.ts. deno task unit-tests-report confirms settings-general.ts is now tested=true with this file, and demo/mode.ts is back in the untested list — which is the intended outcome. Crediting demo/mode.ts was never the goal; that was the mis-attribution we removed.
  • The import-based "misplaced" worklist (unit-tests-report-imports.ts) still lists this file, because it imports exactly one source (demo/mode.ts, for afterEach teardown) and doesn't sit at that source's mirror. That's an inherent false positive for any handler test driven over HTTP via adminFormPost — it exercises POST /admin/settings/payment-provider (handled in settings-general.ts) without importing that source directly, so no import-based heuristic can attribute it correctly. It's cosmetic and doesn't affect the path-based credit or which tests a mutation run selects (mutation takes explicit source/test globs, and the settings-general glob picks this file up).

So the source-to-test bookkeeping is accurate where it matters. Leaving as placed.


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Testing

  • git status --short
  • ⚠️ mise exec -- deno task unit-tests-report | rg 'settings-general|demo/mode|payment-provider' — first attempt was blocked by an npm TLS UnknownIssuer certificate error while caching dependencies.
  • DENO_TLS_CA_STORE=system mise exec -- deno task unit-tests-report | rg 'settings-general|demo/mode|payment-provider' — confirmed src/features/admin/settings-general.ts is credited with test/features/admin/settings-general/payment-provider.test.ts, while the import-based misplaced list still reports the expected cosmetic demo/mode.ts false positive.

View task →

@stefan-burke
stefan-burke added this pull request to the merge queue Jul 11, 2026
Merged via the queue into main with commit 7c07e59 Jul 11, 2026
3 checks passed
@stefan-burke
stefan-burke deleted the claude/unit-tests-easy-wins-xlyi1a branch July 11, 2026 23:43
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.

2 participants