@@ -243,21 +243,50 @@ describe("web project actions", () => {
243243
244244 it . effect ( "applies a selected project through the project apply endpoint" , ( ) =>
245245 Effect . gen ( function * ( _ ) {
246+ const confirmMock = vi . fn ( ( ) => true )
247+ vi . stubGlobal ( "confirm" , confirmMock )
246248 applyProjectMock . mockImplementation ( ( ) => Effect . succeed ( project ) )
247- const { context, reloadDashboard, setMessage } = makeBrowserActionContext ( )
249+ const { context, reloadDashboard, setMessage } = makeBrowserActionContext ( {
250+ selectedProjectId : "project-1" ,
251+ selectedProjectName : "octocat/hello-world"
252+ } )
248253
249254 applyProjectById ( "project-1" , context )
250255
251256 yield * _ ( waitForAssertion ( ( ) => {
252257 expect ( applyProjectMock ) . toHaveBeenCalledWith ( "project-1" )
253258 } ) )
254259
260+ expect ( confirmMock ) . toHaveBeenCalledWith (
261+ "Apply docker-git config to octocat/hello-world? "
262+ + "This restarts the container and ends active SSH sessions and in-container browsers."
263+ )
255264 expect ( context . setSelectedProjectId ) . toHaveBeenCalledWith ( "project-1" )
256265 expect ( context . setSelectedProject ) . toHaveBeenCalledWith ( project )
257266 expect ( reloadDashboard ) . toHaveBeenCalledTimes ( 1 )
258267 expect ( setMessage ) . toHaveBeenLastCalledWith ( "Applied octocat/hello-world." )
259268 } ) )
260269
270+ it ( "does not apply a project when the user declines confirmation" , ( ) => {
271+ const confirmMock = vi . fn ( ( ) => false )
272+ vi . stubGlobal ( "confirm" , confirmMock )
273+ applyProjectMock . mockImplementation ( ( ) => Effect . succeed ( project ) )
274+ const { context, reloadDashboard } = makeBrowserActionContext ( {
275+ selectedProjectId : "project-1" ,
276+ selectedProjectName : "octocat/hello-world"
277+ } )
278+
279+ applyProjectById ( "project-1" , context )
280+
281+ expect ( confirmMock ) . toHaveBeenCalledWith (
282+ "Apply docker-git config to octocat/hello-world? "
283+ + "This restarts the container and ends active SSH sessions and in-container browsers."
284+ )
285+ expect ( applyProjectMock ) . not . toHaveBeenCalled ( )
286+ expect ( context . setSelectedProjectId ) . not . toHaveBeenCalled ( )
287+ expect ( reloadDashboard ) . not . toHaveBeenCalled ( )
288+ } )
289+
261290 it . effect ( "confirms and applies all projects" , ( ) =>
262291 Effect . gen ( function * ( _ ) {
263292 const confirmMock = vi . fn ( ( ) => true )
0 commit comments