@@ -92,6 +92,97 @@ describe('views', () => {
9292 expect ( drawn ) . toContain ( '\u2191/\u2193 to scroll \u00b7 Esc to back' )
9393 } )
9494
95+ test ( 'inline, a file edited before the session opens too' , async ( $ , on ) => {
96+ const world = Fixtures . inRepository ( on , Fixtures . MOVED_IN )
97+
98+ on ( 'session.usage' , ( ) => ( { value : Fixtures . usageAt ( Fixtures . SETTLE_MS ) } ) )
99+ Fixtures . oldFiles ( on )
100+
101+ await $ . session . start ( Fixtures . SESSION )
102+ await $ . command . run ( Fixtures . DIALOG_DIFF )
103+ await world . clock . advance ( Fixtures . SETTLE_MS )
104+
105+ expect (
106+ Fixtures . textOf ( await $ . ui . render ( Fixtures . INLINE_PANE ) ) ,
107+ "the dialog lists it beside the session's file" ,
108+ ) . toContain ( 'old.ts' )
109+
110+ expect ( await $ . ui . press ( { plugin : 'diff' , key : 'file:old.ts' } ) ) . toEqual ( {
111+ element : 'file:old.ts' ,
112+ } )
113+
114+ await world . clock . advance ( Fixtures . SETTLE_MS )
115+
116+ const drawn = Fixtures . textOf ( await $ . ui . render ( Fixtures . INLINE_PANE ) )
117+
118+ expect (
119+ drawn ,
120+ 'a listed row can be pressed, so its hunks were read' ,
121+ ) . not . toContain ( 'Loading diff' )
122+
123+ expect ( drawn ) . toContain ( '+b' )
124+ expect ( drawn ) . not . toContain ( '+d' )
125+ } )
126+
127+ test ( 'inline, a file the docked pane hides opens too' , async ( $ , on ) => {
128+ const world = Fixtures . inRepository ( on , Fixtures . WITH_LOCKFILE )
129+
130+ await $ . session . start ( Fixtures . SESSION )
131+ await $ . command . run ( Fixtures . DIALOG_DIFF )
132+ await world . clock . advance ( Fixtures . SETTLE_MS )
133+ await $ . ui . render ( Fixtures . INLINE_PANE )
134+
135+ expect ( await $ . ui . press ( { plugin : 'diff' , key : 'file:bun.lock' } ) ) . toEqual ( {
136+ element : 'file:bun.lock' ,
137+ } )
138+
139+ await world . clock . advance ( Fixtures . SETTLE_MS )
140+
141+ const drawn = Fixtures . textOf ( await $ . ui . render ( Fixtures . INLINE_PANE ) )
142+
143+ expect ( drawn , 'generated, and still a listed row' ) . not . toContain (
144+ 'Loading diff' ,
145+ )
146+
147+ expect ( drawn ) . toContain ( '+"left": "1.0.1"' )
148+ } )
149+
150+ test ( 'inline, a window that moves reads only its new rows' , async ( $ , on ) => {
151+ const world = Fixtures . inRepository ( on , Fixtures . MANY_FILES )
152+
153+ on ( 'session.usage' , ( ) => ( { value : Fixtures . usageAt ( Fixtures . SETTLE_MS ) } ) )
154+
155+ Fixtures . oldFiles (
156+ on ,
157+ Array . from (
158+ { length : Fixtures . MANY_FILE_COUNT } ,
159+ ( _ , at ) => `file${ at } .ts` ,
160+ ) ,
161+ )
162+
163+ await $ . session . start ( Fixtures . SESSION )
164+ await $ . command . run ( Fixtures . DIALOG_DIFF )
165+ await world . clock . advance ( Fixtures . SETTLE_MS )
166+ await $ . ui . render ( Fixtures . INLINE_PANE )
167+ await world . clock . advance ( Fixtures . SETTLE_MS )
168+ await $ . ui . focus ( Fixtures . ringOnto ( 'file:file3.ts' ) )
169+ await world . clock . advance ( Fixtures . SETTLE_MS )
170+ await $ . ui . render ( Fixtures . INLINE_PANE )
171+ await $ . ui . press ( { plugin : 'diff' , key : 'file:file5.ts' } )
172+ await world . clock . advance ( Fixtures . SETTLE_MS )
173+
174+ expect (
175+ world . runs
176+ . filter ( run => run . argv . includes ( '--raw' ) )
177+ . map ( run => run . argv . slice ( run . argv . indexOf ( '--' ) + 1 ) . join ( ' ' ) ) ,
178+ 'the first five, the one the walk brought in, the two the press did' ,
179+ ) . toEqual ( [
180+ 'file0.ts file1.ts file2.ts file3.ts file4.ts' ,
181+ 'file5.ts' ,
182+ 'file6.ts file7.ts' ,
183+ ] )
184+ } )
185+
95186 test ( 'docked, a wheel tick moves the body, not the list' , async ( $ , on ) => {
96187 const world = Fixtures . inRepository ( on , Fixtures . MANY_FILES )
97188
0 commit comments