@@ -33,6 +33,14 @@ function makeFile(overrides: Partial<DiffReviewFile> = {}): DiffReviewFile {
3333 } ;
3434}
3535
36+ function getLineContents ( text : string ) : HTMLElement [ ] {
37+ return screen . getAllByText ( ( _ , node ) => (
38+ node instanceof HTMLElement &&
39+ node . className . includes ( 'lineContent' ) &&
40+ node . textContent === text
41+ ) ) ;
42+ }
43+
3644describe ( 'DiffReviewPanel' , ( ) => {
3745 // ── Test 1: Renders empty state when no files ──────────────────────────
3846 it ( 'renders empty state when there are no files' , ( ) => {
@@ -61,15 +69,15 @@ describe('DiffReviewPanel', () => {
6169 render ( < DiffReviewPanel files = { files } /> ) ;
6270
6371 // Context lines appear in both left and right columns
64- const contextLines = screen . getAllByText ( 'import React from "react";' ) ;
72+ const contextLines = getLineContents ( 'import React from "react";' ) ;
6573 expect ( contextLines . length ) . toBe ( 2 ) ; // one in each column
66- expect ( screen . getAllByText ( 'export default App;' ) . length ) . toBe ( 2 ) ;
74+ expect ( getLineContents ( 'export default App;' ) . length ) . toBe ( 2 ) ;
6775
6876 // Deleted line (old) should be visible in left column
69- expect ( screen . getByText ( 'const x = 1;' ) ) . toBeInTheDocument ( ) ;
77+ expect ( getLineContents ( 'const x = 1;' ) [ 0 ] ) . toBeInTheDocument ( ) ;
7078
7179 // Added line (new) should be visible in right column
72- expect ( screen . getByText ( 'const x = 2;' ) ) . toBeInTheDocument ( ) ;
80+ expect ( getLineContents ( 'const x = 2;' ) [ 0 ] ) . toBeInTheDocument ( ) ;
7381 } ) ;
7482
7583 // ── Test 4: Renders the Accept All and Reject All toolbar buttons ───────
@@ -160,7 +168,7 @@ describe('DiffReviewPanel', () => {
160168 expect ( firstTab ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
161169
162170 // The second file's content should be visible
163- expect ( screen . getByText ( 'new file content' ) ) . toBeInTheDocument ( ) ;
171+ expect ( getLineContents ( 'new file content' ) [ 0 ] ) . toBeInTheDocument ( ) ;
164172 } ) ;
165173
166174 // ── Test 10: Accepting a line dims it and highlights the accept button ──
0 commit comments