@@ -24,13 +24,14 @@ describe('<FooterConfigDialog />', () => {
2424
2525 it ( 'renders correctly with default settings' , async ( ) => {
2626 const settings = createMockSettings ( ) ;
27- const { lastFrame , waitUntilReady } = renderWithProviders (
27+ const renderResult = renderWithProviders (
2828 < FooterConfigDialog onClose = { mockOnClose } /> ,
2929 { settings } ,
3030 ) ;
3131
32- await waitUntilReady ( ) ;
33- expect ( lastFrame ( ) ) . toMatchSnapshot ( ) ;
32+ await renderResult . waitUntilReady ( ) ;
33+ expect ( renderResult . lastFrame ( ) ) . toMatchSnapshot ( ) ;
34+ await expect ( renderResult ) . toMatchSvgSnapshot ( ) ;
3435 } ) ;
3536
3637 it ( 'toggles an item when enter is pressed' , async ( ) => {
@@ -66,7 +67,7 @@ describe('<FooterConfigDialog />', () => {
6667 ) ;
6768
6869 await waitUntilReady ( ) ;
69- // Initial order: workspace, branch, ...
70+ // Initial order: workspace, git- branch, ...
7071 const output = lastFrame ( ) ;
7172 const cwdIdx = output . indexOf ( '] workspace' ) ;
7273 const branchIdx = output . indexOf ( '] git-branch' ) ;
@@ -108,22 +109,40 @@ describe('<FooterConfigDialog />', () => {
108109
109110 it ( 'highlights the active item in the preview' , async ( ) => {
110111 const settings = createMockSettings ( ) ;
111- const { lastFrame , stdin , waitUntilReady } = renderWithProviders (
112+ const renderResult = renderWithProviders (
112113 < FooterConfigDialog onClose = { mockOnClose } /> ,
113114 { settings } ,
114115 ) ;
115116
117+ const { lastFrame, stdin, waitUntilReady } = renderResult ;
118+
116119 await waitUntilReady ( ) ;
117120 expect ( lastFrame ( ) ) . toContain ( '~/project/path' ) ;
118121
119- // Move focus down to 'git-branch'
122+ // Move focus down to 'code-changes' (which has colored elements)
123+ for ( let i = 0 ; i < 8 ; i ++ ) {
124+ act ( ( ) => {
125+ stdin . write ( '\u001b[B' ) ; // Down arrow
126+ } ) ;
127+ }
128+
129+ await waitFor ( ( ) => {
130+ // The selected indicator should be next to 'code-changes'
131+ expect ( lastFrame ( ) ) . toMatch ( / > \[ \] c o d e - c h a n g e s / ) ;
132+ } ) ;
133+
134+ // Toggle it on
120135 act ( ( ) => {
121- stdin . write ( '\u001b[B ' ) ; // Down arrow
136+ stdin . write ( '\r ' ) ;
122137 } ) ;
123138
124139 await waitFor ( ( ) => {
125- expect ( lastFrame ( ) ) . toContain ( 'main' ) ;
140+ // It should now be checked and appear in the preview
141+ expect ( lastFrame ( ) ) . toMatch ( / > \[ ✓ \] c o d e - c h a n g e s / ) ;
142+ expect ( lastFrame ( ) ) . toContain ( '+12 -4' ) ;
126143 } ) ;
144+
145+ await expect ( renderResult ) . toMatchSvgSnapshot ( ) ;
127146 } ) ;
128147
129148 it ( 'shows an empty preview when all items are deselected' , async ( ) => {
@@ -134,20 +153,64 @@ describe('<FooterConfigDialog />', () => {
134153 ) ;
135154
136155 await waitUntilReady ( ) ;
137- for ( let i = 0 ; i < 10 ; i ++ ) {
156+
157+ // Default items are the first 5. We toggle them off.
158+ for ( let i = 0 ; i < 5 ; i ++ ) {
159+ act ( ( ) => {
160+ stdin . write ( '\r' ) ; // Toggle off
161+ } ) ;
138162 act ( ( ) => {
139- stdin . write ( '\r' ) ; // Toggle (deselect)
140163 stdin . write ( '\u001b[B' ) ; // Down arrow
141164 } ) ;
142165 }
143166
167+ await waitFor (
168+ ( ) => {
169+ const output = lastFrame ( ) ;
170+ expect ( output ) . toContain ( 'Preview:' ) ;
171+ expect ( output ) . not . toContain ( '~/project/path' ) ;
172+ expect ( output ) . not . toContain ( 'docker' ) ;
173+ } ,
174+ { timeout : 2000 } ,
175+ ) ;
176+ } ) ;
177+
178+ it ( 'moves item correctly after trying to move up at the top' , async ( ) => {
179+ const settings = createMockSettings ( ) ;
180+ const { lastFrame, stdin, waitUntilReady } = renderWithProviders (
181+ < FooterConfigDialog onClose = { mockOnClose } /> ,
182+ { settings } ,
183+ ) ;
184+ await waitUntilReady ( ) ;
185+
186+ // Default initial items in mock settings are 'git-branch', 'workspace', ...
144187 await waitFor ( ( ) => {
145188 const output = lastFrame ( ) ;
146- expect ( output ) . toContain ( 'Preview:' ) ;
147- expect ( output ) . not . toContain ( '~/project/path' ) ;
148- expect ( output ) . not . toContain ( 'docker' ) ;
149- expect ( output ) . not . toContain ( 'gemini-2.5-pro' ) ;
150- expect ( output ) . not . toContain ( '1.2k left' ) ;
189+ expect ( output ) . toContain ( '] git-branch' ) ;
190+ expect ( output ) . toContain ( '] workspace' ) ;
191+ } ) ;
192+
193+ const output = lastFrame ( ) ;
194+ const branchIdx = output . indexOf ( '] git-branch' ) ;
195+ const workspaceIdx = output . indexOf ( '] workspace' ) ;
196+ expect ( workspaceIdx ) . toBeLessThan ( branchIdx ) ;
197+
198+ // Try to move workspace up (left arrow) while it's at the top
199+ act ( ( ) => {
200+ stdin . write ( '\u001b[D' ) ; // Left arrow
201+ } ) ;
202+
203+ // Move workspace down (right arrow)
204+ act ( ( ) => {
205+ stdin . write ( '\u001b[C' ) ; // Right arrow
206+ } ) ;
207+
208+ await waitFor ( ( ) => {
209+ const outputAfter = lastFrame ( ) ;
210+ const bIdxAfter = outputAfter . indexOf ( '] git-branch' ) ;
211+ const wIdxAfter = outputAfter . indexOf ( '] workspace' ) ;
212+ // workspace should now be after git-branch
213+ expect ( bIdxAfter ) . toBeLessThan ( wIdxAfter ) ;
151214 } ) ;
152215 } ) ;
153216} ) ;
0 commit comments