Skip to content

Add admin frontend tests#980

Merged
bootjp merged 2 commits into
mainfrom
admin-frontend-tests
Jun 25, 2026
Merged

Add admin frontend tests#980
bootjp merged 2 commits into
mainfrom
admin-frontend-tests

Conversation

@bootjp

@bootjp bootjp commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a dedicated Vitest setup for the admin React frontend and wires it into CI.

  • Adds Vitest, jsdom, and Testing Library dependencies and npm scripts.
  • Covers the admin API client contracts for URL construction, CSRF headers, JSON errors, and DynamoDB item-key encoding.
  • Covers app routing/login flows and authenticated dashboard rendering with mocked backend responses.
  • Adds an Admin Frontend GitHub Actions workflow that runs npm ci, TypeScript lint, Vitest, and production build.

Validation

  • cd web/admin && npm run test:run
  • cd web/admin && npm run lint
  • cd web/admin && npm run build -- --outDir ../../.cache/admin-dist-test
  • git diff --check

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@bootjp, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 51 minutes and 34 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: abb5bf00-e521-49d7-b5f6-861c0623b7fb

📥 Commits

Reviewing files that changed from the base of the PR and between 239ba8d and 93af4ce.

⛔ Files ignored due to path filters (1)
  • web/admin/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • .github/workflows/admin-frontend.yml
  • web/admin/package.json
  • web/admin/src/App.test.tsx
  • web/admin/src/api/client.test.ts
  • web/admin/src/test/setup.ts
  • web/admin/tsconfig.node.json
  • web/admin/vitest.config.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch admin-frontend-tests

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

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

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a testing framework to the web admin frontend by adding Vitest, React Testing Library, and JSDOM, along with test suites for application routing, login functionality, and the API client. The review feedback highlights two key issues: a potential race condition in App.test.tsx caused by typing a newline character immediately before clicking the submit button, and the exclusion of test files from tsconfig.app.json, which prevents them from being type-checked during CI runs.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread web/admin/src/App.test.tsx Outdated
Comment on lines +128 to +129
await user.type(screen.getByLabelText("Secret key"), " SECRET_TEST\n");
await user.click(screen.getByRole("button", { name: "Sign in" }));

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.

medium

Typing \n at the end of the secret key triggers an implicit form submission (Enter key press) in HTML forms. Immediately following this with user.click on the submit button can lead to a race condition:

  1. If the first submission starts and disables the button asynchronously, user.click might throw an error or be ignored depending on timing.
  2. If the button is not yet disabled when clicked, the form will be submitted a second time, triggering a duplicate API call. Since fetchMock is only mocked once, the second call will resolve to undefined and cause unexpected test failures or unhandled rejections.

To prevent this flakiness, remove the trailing \n from the typed secret key.

Suggested change
await user.type(screen.getByLabelText("Secret key"), " SECRET_TEST\n");
await user.click(screen.getByRole("button", { name: "Sign in" }));
await user.type(screen.getByLabelText("Secret key"), " SECRET_TEST ");
await user.click(screen.getByRole("button", { name: "Sign in" }));

Comment thread web/admin/tsconfig.app.json Outdated
Comment on lines +21 to +22
"include": ["src"],
"exclude": ["src/**/*.test.ts", "src/**/*.test.tsx", "src/test/**"]

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.

medium

Excluding test files from tsconfig.app.json without referencing them in another TypeScript configuration means they will be completely skipped during type-checking (e.g., when running npm run lint, which executes tsc -b --noEmit). This can allow type errors in test files to go unnoticed in CI.

Since Vite's production build only bundles files reachable from the entry point anyway, it is safe and recommended to keep test files included in tsconfig.app.json so they are properly type-checked.

  "include": ["src"]

@bootjp

bootjp commented Jun 25, 2026

Copy link
Copy Markdown
Owner Author

Addressed the stale Gemini findings on the latest pushed head.

  • Removed the trailing Enter from the login test secret-key input to avoid implicit form submission before the explicit click.
  • Kept test files included in tsconfig.app.json so npm run lint / tsc -b type-checks the Vitest suites.

Validation:

  • cd web/admin && npm run test:run
  • cd web/admin && npm run lint
  • cd web/admin && npm run build -- --outDir ../../.cache/admin-dist-test
  • git diff --check

@codex review

@bootjp bootjp marked this pull request as ready for review June 25, 2026 15:29
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 93af4ce457

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

@bootjp bootjp merged commit 8ce61e0 into main Jun 25, 2026
11 checks passed
@bootjp bootjp deleted the admin-frontend-tests branch June 25, 2026 15:45
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