@@ -3,13 +3,25 @@ import { render, screen, cleanup, fireEvent } from "@testing-library/react";
33import { ContributionTable } from "@/components/ContributionTable" ;
44import type { ContributionDetail } from "@/lib/types" ;
55
6- // Mock the ExpandedPRDetail since it uses SWR
6+ // Mock the ExpandedPRDetail and ExpandedIssueDetail since they use SWR
77vi . mock ( "@/components/ExpandedPRDetail" , ( ) => ( {
88 ExpandedPRDetail : ( { number } : { number : number } ) => (
99 < div data-testid = "pr-detail" > PR Detail #{ number } </ div >
1010 ) ,
1111} ) ) ;
1212
13+ vi . mock ( "@/components/ExpandedReviewDetail" , ( ) => ( {
14+ ExpandedReviewDetail : ( { number } : { number : number } ) => (
15+ < div data-testid = "review-detail" > Review Detail #{ number } </ div >
16+ ) ,
17+ } ) ) ;
18+
19+ vi . mock ( "@/components/ExpandedIssueDetail" , ( ) => ( {
20+ ExpandedIssueDetail : ( { number } : { number : number } ) => (
21+ < div data-testid = "issue-detail" > Issue Detail #{ number } </ div >
22+ ) ,
23+ } ) ) ;
24+
1325import { vi } from "vitest" ;
1426
1527afterEach ( cleanup ) ;
@@ -68,11 +80,14 @@ describe("ContributionTable", () => {
6880 expect ( screen . getByTestId ( "pr-detail" ) ) . toBeInTheDocument ( ) ;
6981 } ) ;
7082
71- it ( "does not expand issue rows " , ( ) => {
83+ it ( "expands issue row on click " , ( ) => {
7284 render ( < ContributionTable items = { items } /> ) ;
7385
74- const issueRow = screen . getByText ( "Add docs" ) . closest ( "div" ) ;
75- expect ( issueRow ) . not . toHaveAttribute ( "role" , "button" ) ;
86+ const row = screen . getByText ( "Add docs" ) . closest ( "[role='button']" ) ;
87+ expect ( row ) . toBeInTheDocument ( ) ;
88+
89+ fireEvent . click ( row ! ) ;
90+ expect ( screen . getByTestId ( "issue-detail" ) ) . toBeInTheDocument ( ) ;
7691 } ) ;
7792
7893 it ( "renders column headers" , ( ) => {
0 commit comments