-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Graph] Fix guidance panel appearing for a moment when saving Graph (#…
…141228) * [Discover] Fix issue where workspace switches to uninitialized briefly when saving as copy in Graph * [Graph] Add Jest tests for Graph workspace saving bug (cherry picked from commit b026d2c)
- Loading branch information
1 parent
f99ae3a
commit 28892bf
Showing
4 changed files
with
115 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
x-pack/plugins/graph/public/helpers/saved_workspace_utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { coreMock } from '@kbn/core/public/mocks'; | ||
import { GraphWorkspaceSavedObject } from '../types'; | ||
import { saveSavedWorkspace } from './saved_workspace_utils'; | ||
|
||
const core = coreMock.createStart(); | ||
|
||
describe('saved_workspace_utils', () => { | ||
describe('saveSavedWorkspace', () => { | ||
it('should delete the savedWorkspace id and set isSaving to true immediately when copyOnSave is true', async () => { | ||
const savedWorkspace = { | ||
id: '123', | ||
title: 'my workspace', | ||
lastSavedTitle: 'my workspace', | ||
migrationVersion: {}, | ||
wsState: '{ "indexPattern": "my-index-pattern" }', | ||
getEsType: () => 'graph-workspace', | ||
copyOnSave: true, | ||
isSaving: false, | ||
} as GraphWorkspaceSavedObject; | ||
const promise = saveSavedWorkspace( | ||
savedWorkspace, | ||
{}, | ||
{ | ||
savedObjectsClient: { | ||
...core.savedObjects.client, | ||
find: jest.fn().mockResolvedValue({ savedObjects: [] }), | ||
create: jest.fn().mockResolvedValue({ id: '456' }), | ||
}, | ||
overlays: core.overlays, | ||
} | ||
); | ||
expect(savedWorkspace.id).toBe(undefined); | ||
expect(savedWorkspace.isSaving).toBe(true); | ||
const id = await promise; | ||
expect(id).toBe('456'); | ||
expect(savedWorkspace.id).toBe('456'); | ||
expect(savedWorkspace.isSaving).toBe(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters