diff --git a/x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.test.tsx b/x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.test.tsx index afd80f9e9c9a8..ad5517313024c 100644 --- a/x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.test.tsx +++ b/x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.test.tsx @@ -340,6 +340,46 @@ describe('EditSpaceSettings', () => { expect(navigateSpy).toHaveBeenCalledTimes(1); }); + it('navigates away when cancel is clicked after changing the solution view', async () => { + const spaceToUpdate = { + id: 'existing-space', + name: 'Existing Space', + description: 'hey an existing space', + color: '#aabbcc', + initials: 'AB', + disabledFeatures: [], + solution: undefined, + }; + + render( + + + + ); + + // update the space solution view + const solutionViewPicker = screen.getByTestId('solutionViewSelect'); + await userEvent.click(solutionViewPicker); + + const esSolutionOption = await screen.findByTestId('solutionViewEsOption'); + await userEvent.click(esSolutionOption); + + expect(screen.getByTestId('space-edit-page-user-impact-warning')).toBeInTheDocument(); + + // click cancel - should navigate back to spaces list without saving + const cancelButton = screen.getByTestId('cancel-space-button'); + await userEvent.click(cancelButton); + + expect(navigateSpy).toHaveBeenCalledWith('/'); + }); + it('warns when updating features in the active space', async () => { const features = [ new KibanaFeature({ diff --git a/x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.tsx b/x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.tsx index a55df3a18c110..bc6d2e0ec394a 100644 --- a/x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.tsx +++ b/x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.tsx @@ -173,6 +173,7 @@ export const EditSpaceSettingsTab: React.FC = ({ space, features, history const onClickCancel = useCallback(() => { setShowAlteringActiveSpaceDialog(false); setShowUserImpactWarning(false); + setIsDirty(false); backToSpacesList(); }, [backToSpacesList]);