From 39bb304f9d3499a306f4b981b644c32dcf8292b2 Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Wed, 17 Apr 2024 17:54:26 +0800 Subject: [PATCH] fix: unit test Signed-off-by: SuZhou-Joe --- ...apper_for_check_workspace_conflict.test.ts | 25 +++++++++++-------- ...ts_wrapper_for_check_workspace_conflict.ts | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.test.ts b/src/plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.test.ts index 2cbfb951bbee..c6efcb832221 100644 --- a/src/plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.test.ts +++ b/src/plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.test.ts @@ -326,16 +326,21 @@ describe('WorkspaceConflictSavedObjectsClientWrapper', () => { }); it(`Should return error when trying to create disallowed types within a workspace`, async () => { mockedClient.bulkCreate.mockResolvedValueOnce({ saved_objects: [] }); - const result = await wrapperClient.bulkCreate([ - getSavedObject({ - type: 'config', - id: 'foo', - }), - getSavedObject({ - type: DATA_SOURCE_SAVED_OBJECT_TYPE, - id: 'foo', - }), - ]); + const result = await wrapperClient.bulkCreate( + [ + getSavedObject({ + type: 'config', + id: 'foo', + }), + getSavedObject({ + type: DATA_SOURCE_SAVED_OBJECT_TYPE, + id: 'foo', + }), + ], + { + workspaces: ['foo'], + } + ); expect(mockedClient.bulkCreate).toBeCalledWith([], { workspaces: ['foo'], diff --git a/src/plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts b/src/plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts index 46ad3cf2ec97..8d57226e71ab 100644 --- a/src/plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts +++ b/src/plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts @@ -219,7 +219,7 @@ export class WorkspaceConflictSavedObjectsClientWrapper { /** * Get all the objects that do not conflict on workspaces */ - const objectsNoWorkspaceConflictError = objects.filter( + const objectsNoWorkspaceConflictError = allowedSavedObjects.filter( (item) => !objectsConflictWithWorkspace.find( (errorItems) =>