File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -299,6 +299,7 @@ const ProfilePage = (props: Props): ReactElement => {
299299 await router ?. push ( postSaveRedirectUrl ) ;
300300 setPostSaveRedirectUrl ( null ) ;
301301 } else {
302+ allowNavigation ( ) ;
302303 await redirect ( { success : true } ) ;
303304 }
304305 } )
Original file line number Diff line number Diff line change @@ -361,6 +361,42 @@ describe("profile - shared", () => {
361361 } ) ;
362362 } ;
363363
364+ it ( "does not show escape modal when saving changes" , async ( ) => {
365+ const initialIndustry = filterRandomIndustry ( ( ) => true ) ;
366+ const updatedIndustry = filterRandomIndustry (
367+ ( industry : Industry ) => industry . id !== initialIndustry . id ,
368+ ) ;
369+
370+ mockRouter . mockPush . mockImplementation ( async ( url : string ) => {
371+ try {
372+ mockRouterEvents . emit ( "routeChangeStart" , url ) ;
373+ } catch {
374+ // expected when navigation is blocked
375+ }
376+ return { } ;
377+ } ) ;
378+
379+ const business = generateBusinessForProfile ( {
380+ profileData : generateProfileData ( {
381+ businessPersona : "STARTING" ,
382+ industryId : initialIndustry . id ,
383+ } ) ,
384+ } ) ;
385+
386+ renderPage ( { business } ) ;
387+
388+ selectByText ( "Industry" , updatedIndustry . name ) ;
389+ clickSave ( ) ;
390+
391+ await waitFor ( ( ) => {
392+ expect ( mockRouter . mockPush ) . toHaveBeenCalledWith ( "/dashboard?success=true" ) ;
393+ } ) ;
394+
395+ expect (
396+ screen . queryByText ( Config . profileDefaults . default . escapeModalReturn ) ,
397+ ) . not . toBeInTheDocument ( ) ;
398+ } ) ;
399+
364400 it ( "shows escape modal when navigation is intercepted by unsaved changes guard" , async ( ) => {
365401 const business = makeBusiness ( ) ;
366402 renderPage ( { business } ) ;
You can’t perform that action at this time.
0 commit comments