diff --git a/src/components/ContributionTable.tsx b/src/components/ContributionTable.tsx index 8b11a87..e793a9a 100644 --- a/src/components/ContributionTable.tsx +++ b/src/components/ContributionTable.tsx @@ -21,87 +21,82 @@ export function ContributionTable({ items }: ContributionTableProps) { } return ( -
- - - - - - - - - - - {items.map((item) => { - const isExpanded = expandedId === item.id; - const canExpand = item.type === "pr"; - const [owner, repo] = item.repoNameWithOwner.split("/"); +
+ {/* Header row */} +
+
+
Title
+
Repo
+
Status
+
Date
+
+
- return ( -
- - - ); - })} - -
- TitleRepoStatusDate -
-
{ + const isExpanded = expandedId === item.id; + const canExpand = item.type === "pr"; + const [owner, repo] = item.repoNameWithOwner.split("/"); + + return ( +
+
{ + if (canExpand) { + setExpandedId(isExpanded ? null : item.id); + } + }} + role={canExpand ? "button" : undefined} + aria-expanded={canExpand ? isExpanded : undefined} + > +
+ {canExpand && ( + { - if (canExpand) { - setExpandedId(isExpanded ? null : item.id); - } - }} - role={canExpand ? "button" : undefined} - aria-expanded={canExpand ? isExpanded : undefined} - > -
- {canExpand && ( - - )} -
-
- {item.title} -
-
- {item.repoNameWithOwner} -
-
- - {item.state} - -
-
- {formatDate(item.createdAt)} -
- e.stopPropagation()} - className="flex-shrink-0 text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200" - aria-label={`Open #${item.number} on GitHub`} - > - - -
- {isExpanded && canExpand && ( - - )} -
+ /> + )} +
+
+ {item.title} +
+
+ {item.repoNameWithOwner} +
+
+ + {item.state} + +
+
+ {formatDate(item.createdAt)} +
+ e.stopPropagation()} + className="flex-shrink-0 text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200" + aria-label={`Open #${item.number} on GitHub`} + > + + + + {isExpanded && canExpand && ( + + )} + + ); + })} ); } diff --git a/src/components/__tests__/ContributionTable.test.tsx b/src/components/__tests__/ContributionTable.test.tsx index 579ede7..7fac8e2 100644 --- a/src/components/__tests__/ContributionTable.test.tsx +++ b/src/components/__tests__/ContributionTable.test.tsx @@ -75,6 +75,32 @@ describe("ContributionTable", () => { expect(issueRow).not.toHaveAttribute("role", "button"); }); + it("renders column headers", () => { + render(); + + expect(screen.getByText("Title")).toBeInTheDocument(); + expect(screen.getByText("Repo")).toBeInTheDocument(); + expect(screen.getByText("Status")).toBeInTheDocument(); + expect(screen.getByText("Date")).toBeInTheDocument(); + }); + + it("renders repo name and date for each row", () => { + render(); + + expect(screen.getAllByText("bitcoin/bitcoin")).toHaveLength(2); + }); + + it("collapses expanded PR when clicked again", () => { + render(); + + const row = screen.getByText("Fix consensus bug").closest("[role='button']"); + fireEvent.click(row!); + expect(screen.getByTestId("pr-detail")).toBeInTheDocument(); + + fireEvent.click(row!); + expect(screen.queryByTestId("pr-detail")).not.toBeInTheDocument(); + }); + it("has external links to GitHub", () => { render();