@@ -268,7 +268,7 @@ describe('ProjectModals', () => {
268268 expect ( setModal ) . toHaveBeenCalledWith ( 'none' ) ;
269269 } ) ;
270270
271- it ( 'calls setModal with create and sets createSourceIsSelect when create new is clicked' , async ( ) => {
271+ it ( 'calls setModal with create when create new is clicked' , async ( ) => {
272272 const { setModal } = renderModals ( { modal : 'select' } ) ;
273273 await userEvent . click ( screen . getByTestId ( 'select-create-new' ) ) ;
274274 expect ( setModal ) . toHaveBeenCalledWith ( 'create' ) ;
@@ -282,19 +282,16 @@ describe('ProjectModals', () => {
282282 } ) ;
283283
284284 describe ( 'create modal' , ( ) => {
285- it ( 'calls setModal with none when create modal closes without a select source ' , async ( ) => {
285+ it ( 'calls setModal with none when create modal is closed ' , async ( ) => {
286286 const { setModal } = renderModals ( { modal : 'create' } ) ;
287287 await userEvent . click ( screen . getByTestId ( 'create-close' ) ) ;
288288 expect ( setModal ) . toHaveBeenCalledWith ( 'none' ) ;
289289 } ) ;
290290
291- it ( 'calls setModal with select on close when createSourceIsSelect is true' , async ( ) => {
292- // To set createSourceIsSelect, we must open create from the select modal.
293- // Render with select open first, then trigger create-new.
291+ it ( 'calls setModal with none when create modal is closed after opening from select' , async ( ) => {
294292 const setModal = jest . fn ( ) ;
295293 const state = makeWebViewState ( ) ;
296294
297- // Render with select modal so create-new can be clicked
298295 const { rerender } = render (
299296 < ProjectModals
300297 activeProject = { undefined }
@@ -305,7 +302,6 @@ describe('ProjectModals', () => {
305302 /> ,
306303 ) ;
307304 await userEvent . click ( screen . getByTestId ( 'select-create-new' ) ) ;
308- // setModal was called with 'create' — now re-render with modal='create'
309305 rerender (
310306 < ProjectModals
311307 activeProject = { undefined }
@@ -317,15 +313,14 @@ describe('ProjectModals', () => {
317313 ) ;
318314 setModal . mockClear ( ) ;
319315 await userEvent . click ( screen . getByTestId ( 'create-close' ) ) ;
320- expect ( setModal ) . toHaveBeenCalledWith ( 'select ' ) ;
316+ expect ( setModal ) . toHaveBeenCalledWith ( 'none ' ) ;
321317 } ) ;
322318
323- it ( 'keeps the create modal open and does not call setModal when a project is created' , async ( ) => {
319+ it ( 'selects the created project and calls setModal with none when a project is created' , async ( ) => {
324320 const state = makeWebViewState ( ) ;
325321 const { setModal } = renderModals ( { modal : 'create' , useWebViewState : state } ) ;
326322 await userEvent . click ( screen . getByTestId ( 'create-created' ) ) ;
327- expect ( screen . getByTestId ( 'create-modal' ) ) . toBeInTheDocument ( ) ;
328- expect ( setModal ) . not . toHaveBeenCalled ( ) ;
323+ expect ( setModal ) . toHaveBeenCalledWith ( 'none' ) ;
329324 } ) ;
330325 } ) ;
331326
0 commit comments