@@ -215,6 +215,35 @@ describe('renderBrewing phase controls', () => {
215215 expect ( ctx . timerController . cancelRun ) . not . toHaveBeenCalled ( ) ;
216216 } ) ;
217217
218+ it ( 'finishing without a recorded profile keeps focus on brewing and expands saving' , async ( ) => {
219+ const container = createContainer ( ) ;
220+ const flowState = makeFlowState ( 'filter' ) ;
221+ flowState . beginBrewingRun ( ) ;
222+ const { ctx } = makeContext ( flowState , [ ] , 'disconnected' ) ;
223+ renderBrewing ( container , ctx ) ;
224+ ( container . querySelector ( '.brew-flow-stop-btn' ) as HTMLButtonElement ) . click ( ) ;
225+ await vi . waitFor ( ( ) => expect ( ctx . renderContent ) . toHaveBeenCalledWith ( 'brewing' , 'saving' ) ) ;
226+ expect ( ctx . flowState . step ) . toBe ( 'saving' ) ;
227+ } ) ;
228+
229+ it ( 'espresso done keeps focus on brewing and expands saving' , ( ) => {
230+ const container = createContainer ( ) ;
231+ const { ctx } = makeContext ( makeFlowState ( 'espresso' ) ) ;
232+ renderBrewing ( container , ctx ) ;
233+ ( container . querySelector ( '.brew-flow-stop-btn' ) as HTMLButtonElement ) . click ( ) ;
234+ expect ( ctx . renderContent ) . toHaveBeenCalledWith ( 'brewing' , 'saving' ) ;
235+ expect ( ctx . flowState . step ) . toBe ( 'saving' ) ;
236+ } ) ;
237+
238+ it ( 'finishing with a recorded profile focuses saving as before' , async ( ) => {
239+ const container = createContainer ( ) ;
240+ const ctx = makeRunningContext ( ) ;
241+ renderBrewing ( container , ctx ) ;
242+ ( container . querySelector ( '.brew-flow-stop-btn' ) as HTMLButtonElement ) . click ( ) ;
243+ await vi . waitFor ( ( ) => expect ( ctx . renderContent ) . toHaveBeenCalledWith ( ) ) ;
244+ expect ( ctx . flowState . step ) . toBe ( 'saving' ) ;
245+ } ) ;
246+
218247 it ( 'cancel rejection still re-renders a coherent armed brewing state' , async ( ) => {
219248 const container = createContainer ( ) ;
220249 const ctx = makeRunningContext ( ) ;
0 commit comments