Skip to content

test: add component tests for 6 untested components - #215

Merged
mankatcheung merged 1 commit into
mainfrom
feat/add-component-tests
Aug 4, 2026
Merged

mankatcheung merged 1 commit into
mainfrom
feat/add-component-tests

Conversation

@mankatcheung

@mankatcheung mankatcheung commented Aug 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds 64 new tests across 6 previously untested components, bringing total from 165 to 229.

New test files

Component Tests Coverage
ErrorState 8 Error message rendering (string, Error, GraphQL, TypeError), NOT_FOUND/FORBIDDEN overrides, retry button, icon
LogoMark 6 SVG rendering, default/custom size, className, aria-hidden, brand elements
NavigationProgressBar 3 Renders null, NProgress.done on unmount, no start when idle
OAuthButtons 4 "or" divider, Google/GitHub links with correct hrefs and labels
DocumentPreviewModal 10 Null doc, PDF iframe, PNG/JPEG img, unsupported fallback, close button, backdrop click, open-in-new-tab link
JdImportPanel 13 Toggle expand/collapse, text/URL mode switch, empty/filled input, auto-fill success/error, AI not configured, loading/filled states

Summary by CodeRabbit

  • Tests
    • Expanded coverage for document previews, including PDFs, images, downloads, and interactions.
    • Added validation for error messages, retry actions, and network-related failures.
    • Added coverage for job description import flows, loading states, successful parsing, and configuration errors.
    • Added checks for logo rendering, navigation progress behaviour, and OAuth sign-in links.
    • Improved confidence in component behaviour across common success, failure, and interaction scenarios.

…sBar, OAuthButtons, DocumentPreviewModal, JdImportPanel

Adds 64 new tests across 6 previously untested components (165 -> 229 total).

- ErrorState: error message rendering, retry button, GraphQL error codes
- LogoMark: SVG rendering, size/className props, accessibility
- NavigationProgressBar: renders null, NProgress.done on unmount
- OAuthButtons: Google/GitHub links, divider
- DocumentPreviewModal: PDF/image/unsupported rendering, close/backdrop, links
- JdImportPanel: expand/collapse, text/URL modes, auto-fill flow, error states
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Added frontend tests for six components. Coverage includes rendering, user interactions, asynchronous states, error handling, accessibility attributes, mocked integrations, and navigation lifecycle behaviour.

Changes

Frontend component tests

Layer / File(s) Summary
Document preview behaviour
apps/web/src/__tests__/components/DocumentPreviewModal.test.tsx
Tests cover supported MIME types, modal rendering, PDF and image previews, fallback downloads, close and backdrop callbacks, and opening documents in a new tab.
Error and import workflows
apps/web/src/__tests__/components/ErrorState.test.tsx, apps/web/src/__tests__/components/JdImportPanel.test.tsx
Tests cover error messages, GraphQL overrides, retry behaviour, import modes, validation, asynchronous parsing, loading states, and mutation errors.
Branding and authentication controls
apps/web/src/__tests__/components/LogoMark.test.tsx, apps/web/src/__tests__/components/OAuthButtons.test.tsx
Tests cover logo structure, sizing, classes, accessibility, OAuth links, labels, and the divider.
Navigation progress lifecycle
apps/web/src/__tests__/components/NavigationProgressBar.test.tsx
Tests cover mocked router status, null rendering, idle navigation, and NProgress completion on unmount.

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

Possibly related PRs

Poem

A rabbit checks each button twice,
Tests hop through errors, links, and types.
PDFs open, imports flow,
Progress bars start and stop just so.
Six components now have clearer sights.

🚥 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 clearly and concisely describes the addition of component tests for the six previously untested components.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-component-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.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/web/src/__tests__/components/NavigationProgressBar.test.tsx (1)

41-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the pending-to-idle transition.

These tests only verify idle navigation and unmount cleanup. They do not verify the main lifecycle in apps/web/src/components/NavigationProgressBar.tsx: NProgress.start() must run when the status changes from 'idle' to 'pending', and NProgress.done() must run when it changes back to 'idle'. Add a rerender test for both transitions and assert exact call counts.

Suggested test
+  it('starts and completes progress across navigation transitions', async () => {
+    const { rerender } = render(<NavigationProgressBar />);
+
+    mockStatus = 'pending';
+    await act(async () => {
+      rerender(<NavigationProgressBar />);
+    });
+    expect(mockStart).toHaveBeenCalledTimes(1);
+
+    mockStatus = 'idle';
+    await act(async () => {
+      rerender(<NavigationProgressBar />);
+    });
+    expect(mockDone).toHaveBeenCalledTimes(1);
+  });
🤖 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 `@apps/web/src/__tests__/components/NavigationProgressBar.test.tsx` around
lines 41 - 46, Extend the NavigationProgressBar test suite with a rerender
scenario that changes navigation status from idle to pending and back to idle.
Assert exact call counts showing NProgress.start is called once on the pending
transition and NProgress.done is called once when returning to idle, while
preserving the existing idle and unmount cleanup tests.
apps/web/src/__tests__/components/LogoMark.test.tsx (1)

38-43: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Strengthen the brand-rendering assertion.

The test title says that it checks the blue rectangles and the checkmark path. It only checks that three <rect> elements and a <path> exist. A colour or path-styling regression would pass. Assert the fill, opacity, and path stroke values defined by apps/web/src/components/LogoMark.tsx (Lines 12-34).

Suggested assertions
     const rects = container.querySelectorAll('rect');
-    expect(rects.length).toBe(3);
+    expect(rects).toHaveLength(3);
+    expect(Array.from(rects, (rect) => rect.getAttribute('fill'))).toEqual([
+      '`#1d4ed8`',
+      '`#1d4ed8`',
+      '`#1d4ed8`',
+    ]);
     const path = container.querySelector('path');
     expect(path).toBeInTheDocument();
+    expect(path).toHaveAttribute('stroke', '`#ffffff`');
🤖 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 `@apps/web/src/__tests__/components/LogoMark.test.tsx` around lines 38 - 43,
Strengthen the test named “contains the brand blue rectangles and checkmark
path” by asserting each rendered rectangle’s defined fill and opacity values,
and asserting the checkmark path’s defined stroke value from LogoMark. Keep the
existing element-count and presence assertions while validating the actual brand
styling.
🤖 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 `@apps/web/src/__tests__/components/DocumentPreviewModal.test.tsx`:
- Around line 95-100: Update the close button in DocumentPreviewModal to include
aria-label="Close preview", then replace the broad SVG-based button lookup in
the test with an accessible-name query for “Close preview” before clicking it
and asserting onClose is called.

---

Nitpick comments:
In `@apps/web/src/__tests__/components/LogoMark.test.tsx`:
- Around line 38-43: Strengthen the test named “contains the brand blue
rectangles and checkmark path” by asserting each rendered rectangle’s defined
fill and opacity values, and asserting the checkmark path’s defined stroke value
from LogoMark. Keep the existing element-count and presence assertions while
validating the actual brand styling.

In `@apps/web/src/__tests__/components/NavigationProgressBar.test.tsx`:
- Around line 41-46: Extend the NavigationProgressBar test suite with a rerender
scenario that changes navigation status from idle to pending and back to idle.
Assert exact call counts showing NProgress.start is called once on the pending
transition and NProgress.done is called once when returning to idle, while
preserving the existing idle and unmount cleanup tests.
🪄 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: CHILL

Plan: Pro Plus

Run ID: 60e78dec-8185-4ea1-9c37-463064695e7e

📥 Commits

Reviewing files that changed from the base of the PR and between 54fe11b and a458d0c.

📒 Files selected for processing (6)
  • apps/web/src/__tests__/components/DocumentPreviewModal.test.tsx
  • apps/web/src/__tests__/components/ErrorState.test.tsx
  • apps/web/src/__tests__/components/JdImportPanel.test.tsx
  • apps/web/src/__tests__/components/LogoMark.test.tsx
  • apps/web/src/__tests__/components/NavigationProgressBar.test.tsx
  • apps/web/src/__tests__/components/OAuthButtons.test.tsx

Comment on lines +95 to +100
// The X button
const buttons = screen.getAllByRole('button');
const closeButton = buttons.find((b) => b.querySelector('svg'));
expect(closeButton).toBeDefined();
fireEvent.click(closeButton!);
expect(onClose).toHaveBeenCalledOnce();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add an accessible name to the close button.

DocumentPreviewModal renders the close button with only XIcon. The button has no accessible name. This test selects any button containing an SVG, so it passes without verifying accessible operation.

Add aria-label="Close preview" to the component button. Query that name in this test.

Proposed fix
- const buttons = screen.getAllByRole('button');
- const closeButton = buttons.find((b) => b.querySelector('svg'));
- expect(closeButton).toBeDefined();
- fireEvent.click(closeButton!);
+ fireEvent.click(screen.getByRole('button', { name: 'Close preview' }));
- <button type="button" onClick={onClose} className="p-1.5 ...">
+ <button type="button" aria-label="Close preview" onClick={onClose} className="p-1.5 ...">
🤖 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 `@apps/web/src/__tests__/components/DocumentPreviewModal.test.tsx` around lines
95 - 100, Update the close button in DocumentPreviewModal to include
aria-label="Close preview", then replace the broad SVG-based button lookup in
the test with an accessible-name query for “Close preview” before clicking it
and asserting onClose is called.

@mankatcheung
mankatcheung merged commit b798c2a into main Aug 4, 2026
11 checks passed
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