@@ -133,15 +133,22 @@ describe("TaskHeader", () => {
133133 expect ( screen . queryByText ( / \$ / ) ) . not . toBeInTheDocument ( )
134134 } )
135135
136+ it ( "should render the condense context button in the collapsed state" , ( ) => {
137+ renderTaskHeader ( )
138+ // Button is visible without expanding the task header
139+ const buttons = screen . getAllByRole ( "button" )
140+ const condenseButton = buttons . find ( ( button ) => button . querySelector ( "svg.lucide-list-chevrons-down-up" ) )
141+ expect ( condenseButton ) . toBeDefined ( )
142+ expect ( condenseButton ?. querySelector ( "svg" ) ) . toBeInTheDocument ( )
143+ } )
144+
136145 it ( "should render the condense context button when expanded" , ( ) => {
137146 renderTaskHeader ( )
138- // First click to expand the task header
139147 const taskHeader = screen . getByText ( "Test task" )
140148 fireEvent . click ( taskHeader )
141149
142- // Now find the condense button in the expanded state
143150 const buttons = screen . getAllByRole ( "button" )
144- const condenseButton = buttons . find ( ( button ) => button . querySelector ( "svg.lucide-fold-vertical " ) )
151+ const condenseButton = buttons . find ( ( button ) => button . querySelector ( "svg.lucide-list-chevrons-down-up " ) )
145152 expect ( condenseButton ) . toBeDefined ( )
146153 expect ( condenseButton ?. querySelector ( "svg" ) ) . toBeInTheDocument ( )
147154 } )
@@ -150,29 +157,24 @@ describe("TaskHeader", () => {
150157 const handleCondenseContext = vi . fn ( )
151158 renderTaskHeader ( { handleCondenseContext } )
152159
153- // First click to expand the task header
154- const taskHeader = screen . getByText ( "Test task" )
155- fireEvent . click ( taskHeader )
156-
157- // Find the button that contains the FoldVertical icon
160+ // Button is clickable in collapsed state without expanding first
158161 const buttons = screen . getAllByRole ( "button" )
159- const condenseButton = buttons . find ( ( button ) => button . querySelector ( "svg.lucide-fold-vertical " ) )
162+ const condenseButton = buttons . find ( ( button ) => button . querySelector ( "svg.lucide-list-chevrons-down-up " ) )
160163 expect ( condenseButton ) . toBeDefined ( )
161164 fireEvent . click ( condenseButton ! )
162165 expect ( handleCondenseContext ) . toHaveBeenCalledWith ( "test-task-id" )
166+ // Clicking the condense button must not expand the header (stopPropagation guard).
167+ // The expanded state renders the "chat:task.title" label, which stays absent while collapsed.
168+ expect ( screen . queryByText ( "chat:task.title" ) ) . not . toBeInTheDocument ( )
163169 } )
164170
165171 it ( "should disable the condense context button when buttonsDisabled is true" , ( ) => {
166172 const handleCondenseContext = vi . fn ( )
167173 renderTaskHeader ( { buttonsDisabled : true , handleCondenseContext } )
168174
169- // First click to expand the task header
170- const taskHeader = screen . getByText ( "Test task" )
171- fireEvent . click ( taskHeader )
172-
173- // Find the button that contains the FoldVertical icon
175+ // Button is disabled in collapsed state without expanding first
174176 const buttons = screen . getAllByRole ( "button" )
175- const condenseButton = buttons . find ( ( button ) => button . querySelector ( "svg.lucide-fold-vertical " ) )
177+ const condenseButton = buttons . find ( ( button ) => button . querySelector ( "svg.lucide-list-chevrons-down-up " ) )
176178 expect ( condenseButton ) . toBeDefined ( )
177179 expect ( condenseButton ) . toBeDisabled ( )
178180 fireEvent . click ( condenseButton ! )
0 commit comments