forked from farhoodlabs/paperclip
Speed up issue-to-issue navigation
This commit is contained in:
@@ -7,10 +7,17 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { IssueRow } from "./IssueRow";
|
||||
|
||||
vi.mock("@/lib/router", () => ({
|
||||
Link: ({ children, className, disableIssueQuicklook: _disableIssueQuicklook, ...props }: React.ComponentProps<"a"> & { disableIssueQuicklook?: boolean }) => (
|
||||
Link: ({
|
||||
children,
|
||||
className,
|
||||
disableIssueQuicklook: _disableIssueQuicklook,
|
||||
issuePrefetch,
|
||||
...props
|
||||
}: React.ComponentProps<"a"> & { disableIssueQuicklook?: boolean; issuePrefetch?: Issue | null }) => (
|
||||
<a
|
||||
className={className}
|
||||
data-disable-issue-quicklook={_disableIssueQuicklook ? "true" : undefined}
|
||||
data-issue-prefetch-id={issuePrefetch?.id}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
@@ -157,6 +164,21 @@ describe("IssueRow", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("passes the visible row issue into the navigation prefetch path", () => {
|
||||
const root = createRoot(container);
|
||||
|
||||
act(() => {
|
||||
root.render(<IssueRow issue={createIssue()} />);
|
||||
});
|
||||
|
||||
const link = container.querySelector("[data-inbox-issue-link]") as HTMLAnchorElement | null;
|
||||
expect(link?.getAttribute("data-issue-prefetch-id")).toBe("issue-1");
|
||||
|
||||
act(() => {
|
||||
root.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders titleSuffix inline after the issue title", () => {
|
||||
const root = createRoot(container);
|
||||
const issue = createIssue({ title: "Parent task" });
|
||||
|
||||
Reference in New Issue
Block a user