Skip to content

Commit

Permalink
[SecuritySolution] It should return to the origin app and path after …
Browse files Browse the repository at this point in the history
…editing markdown from the dashboard (#167927)

## Summary

issue:
#167786


In this PR:



https://github.com/elastic/kibana/assets/6295984/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 <[email protected]>
  • Loading branch information
angorayc and stratoula authored Oct 4, 2023
1 parent a69957e commit dfd35c6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const getTopNavConfig = (

const navigateToOriginatingApp = () => {
if (originatingApp) {
application.navigateToApp(originatingApp);
application.navigateToApp(originatingApp, { path: originatingPath });
}
};

Expand Down

0 comments on commit dfd35c6

Please sign in to comment.