[SecuritySolution] It should return to the origin app and path after editing markdown from the dashboard (#167927)

## Summary

issue:
https://github.com/elastic/kibana/issues/167786


In this PR:



a35bd617-5805-4e60-a1e6-7ba559756ef0



### Checklist

Delete any items that are not applicable to this PR.


- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
Angela Chuang 2023-10-04 09:58:29 +01:00 committed by GitHub
parent a69957e0fc
commit dfd35c6361
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions

View file

@ -224,6 +224,49 @@ describe('getTopNavConfig', () => {
]
`);
});
test('navigates to origin app and path on cancel', async () => {
const vis = {
savedVis: {
id: 'test',
sharingSavedObjectProps: {
outcome: 'conflict',
aliasTargetId: 'alias_id',
},
},
vis: {
type: {
title: 'TSVB',
},
},
} as VisualizeEditorVisInstance;
const mockNavigateToApp = jest.fn();
const topNavLinks = getTopNavConfig(
{
hasUnsavedChanges: false,
setHasUnsavedChanges: jest.fn(),
hasUnappliedChanges: false,
onOpenInspector: jest.fn(),
originatingApp: 'testApp',
originatingPath: '/testPath',
setOriginatingApp: jest.fn(),
visInstance: vis,
stateContainer,
visualizationIdFromUrl: undefined,
stateTransfer: createEmbeddableStateTransferMock(),
} as unknown as TopNavConfigParams,
{
...services,
application: { navigateToApp: mockNavigateToApp },
} as unknown as VisualizeServices
);
const executionFunction = topNavLinks.find(({ id }) => id === 'cancel')?.run;
const mockAnchorElement = document.createElement('div');
await executionFunction?.(mockAnchorElement);
expect(mockNavigateToApp).toHaveBeenCalledWith('testApp', { path: '/testPath' });
});
test('returns correct links for by reference visualization', () => {
const vis = {
savedVis: {

View file

@ -258,7 +258,7 @@ export const getTopNavConfig = (
const navigateToOriginatingApp = () => {
if (originatingApp) {
application.navigateToApp(originatingApp);
application.navigateToApp(originatingApp, { path: originatingPath });
}
};