Conversation
| } from "@cap/ui"; | ||
|
|
||
| describe("CapPagination and Client Navigation (Issue #2305)", () => { | ||
| it("verifies CapPagination imports Link from next/link and passes asChild", () => { |
There was a problem hiding this comment.
The new pagination test is absent from the explicit web-test lists executed by CI, so these assertions can regress without a required check failing. Add this file to the relevant CI test invocation or run the complete web unit-test suite.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/__tests__/unit/cap-pagination.test.ts
Line: 16
Comment:
**Test Missing From CI**
The new pagination test is absent from the explicit web-test lists executed by CI, so these assertions can regress without a required check failing. Add this file to the relevant CI test invocation or run the complete web unit-test suite.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| it("renders client Link elements inside PaginationPrevious, PaginationLink, and PaginationNext", () => { | ||
| const element = CapPagination({ | ||
| currentPage: 2, | ||
| totalPages: 5, | ||
| }) as React.ReactElement<{ children: React.ReactElement<{ children: React.ReactNode[] }> }>; | ||
|
|
||
| expect(element).toBeDefined(); | ||
| expect(element.type).toBe(Pagination); | ||
|
|
||
| const content = element.props.children; | ||
| expect(content.type).toBe(PaginationContent); | ||
|
|
||
| const items = React.Children.toArray(content.props.children) as React.ReactElement[]; | ||
| expect(items.length).toBeGreaterThan(0); | ||
|
|
||
| // First item should be PaginationPrevious with asChild | ||
| const prevItem = items[0].props.children as React.ReactElement<{ asChild?: boolean; children: React.ReactElement<{ href: string; scroll: boolean }> }>; | ||
| expect(prevItem.type).toBe(PaginationPrevious); | ||
| expect(prevItem.props.asChild).toBe(true); | ||
| expect(prevItem.props.children.props.href).toBe("/dashboard/caps?page=1"); | ||
| expect(prevItem.props.children.props.scroll).toBe(false); | ||
|
|
||
| // Last item should be PaginationNext with asChild | ||
| const nextItem = items[items.length - 1].props.children as React.ReactElement<{ asChild?: boolean; children: React.ReactElement<{ href: string; scroll: boolean }> }>; | ||
| expect(nextItem.type).toBe(PaginationNext); | ||
| expect(nextItem.props.asChild).toBe(true); | ||
| expect(nextItem.props.children.props.href).toBe("/dashboard/caps?page=3"); | ||
| expect(nextItem.props.children.props.scroll).toBe(false); | ||
| }); |
There was a problem hiding this comment.
Calling CapPagination directly only inspects unevaluated React element props; it never executes PaginationPrevious, PaginationNext, or Radix Slot. The test can therefore remain green if the final anchors lose their href, labels, icons, or delegated props. Render the component in a DOM environment and assert the resulting links.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/__tests__/unit/cap-pagination.test.ts
Line: 40-68
Comment:
**Links Are Never Rendered**
Calling `CapPagination` directly only inspects unevaluated React element props; it never executes `PaginationPrevious`, `PaginationNext`, or Radix `Slot`. The test can therefore remain green if the final anchors lose their href, labels, icons, or delegated props. Render the component in a DOM environment and assert the resulting links.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| expect(element.type).toBe(Pagination); | ||
|
|
||
| const content = element.props.children; | ||
| expect(content.type).toBe(PaginationContent); |
There was a problem hiding this comment.
The comments here and at lines 59 and 78 merely narrate the immediately following assertions. The repository requires defaulting to no code comments and explicitly prohibits comments that only describe what the code does. Remove these comments or replace them with genuinely non-obvious context; this repository requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/__tests__/unit/cap-pagination.test.ts
Line: 50
Comment:
**Comments Narrate Assertions**
The comments here and at lines 59 and 78 merely narrate the immediately following assertions. The repository requires defaulting to no code comments and explicitly prohibits comments that only describe what the code does. Remove these comments or replace them with genuinely non-obvious context; this repository requirement must be satisfied before merging.
**Context Used:** AGENTS.md ([source](https://github.com/capsoftware/cap/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
What does this PR do?
Resolves issue #2305 (Linear: CAP-813) where pagination controls in the My Caps dashboard (
/dashboard/caps) rendered plain<a>tags, causing a full browser/app shell reload on every page transition.Root Cause
@cap/ui'sPaginationLinkrendered an un-customizable HTML<a>tag with no slot delegation.CapPagination.tsx, page numbers and Next/Previous navigation targets were passed directly toPaginationLink/PaginationPrevious/PaginationNextwithout client-side routing, triggering full page reloads and re-mounting the dashboard shell on every page click.Changes
packages/ui/src/components/Pagination.tsx:asChild?: booleanprop toPaginationLinkPropsutilizing@radix-ui/react-slot(Slot), mirroring the established pattern inButton.tsx.PaginationPreviousandPaginationNextto supportasChild, automatically preserving and injecting standard chevron icons and labels into client-side links (next/link).apps/web/app/(org)/dashboard/caps/components/CapPagination.tsx:PaginationPrevious,PaginationLink,PaginationNext) in Next.js<Link href={...} scroll={false}>withasChild.apps/web/__tests__/unit/cap-pagination.test.ts:scroll={false}setting, and dynamichrefForPagepropagation.Verification
@cap/uiconventions.The navigation implementation appears safe, but the repository’s explicit comments requirement must be satisfied before merging; the test-execution and rendering gaps are additional non-blocking quality concerns.
Findings
Fix with agent prompt
Summary
This PR changes dashboard pagination to delegate shared pagination styling and accessibility props through Radix Slot onto Next.js links, allowing page transitions without reloading the persistent dashboard shell.
Reviews (1) · Last reviewed commit: "fix(dashboard): use client-side navigati..."