Skip to content

Commit b14d273

Browse files
committed
fix: [AB#17110] allow navigation on profile save: fixes industry saving bug
1 parent a074228 commit b14d273

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

web/src/pages/profile.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
})

web/test/pages/profile/profile-shared.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff 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 });

0 commit comments

Comments
 (0)