diff --git a/src/plugins/workspace/server/saved_objects/integration_tests/workspace_id_consumer_wrapper.test.ts b/src/plugins/workspace/server/saved_objects/integration_tests/workspace_id_consumer_wrapper.test.ts index f597dd369272..eca47fbb5b72 100644 --- a/src/plugins/workspace/server/saved_objects/integration_tests/workspace_id_consumer_wrapper.test.ts +++ b/src/plugins/workspace/server/saved_objects/integration_tests/workspace_id_consumer_wrapper.test.ts @@ -485,9 +485,7 @@ describe('workspace_id_consumer integration test', () => { ]); expect(bulkGetResultWithWorkspace.body.saved_objects[0]?.error).toBeUndefined(); expect(bulkGetResultWithWorkspace.body.saved_objects[1].id).toEqual('bar'); - expect(bulkGetResultWithWorkspace.body.saved_objects[1].workspaces).toEqual([ - createdBarWorkspace.id, - ]); + expect(bulkGetResultWithWorkspace.body.saved_objects[1].workspaces).toBeUndefined(); expect(bulkGetResultWithWorkspace.body.saved_objects[1]?.error).toMatchInlineSnapshot(` Object { "error": "Forbidden", diff --git a/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.test.ts b/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.test.ts index fcef67870523..5d9a4094336e 100644 --- a/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.test.ts +++ b/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.test.ts @@ -432,8 +432,8 @@ describe('WorkspaceIdConsumerWrapper', () => { { type: 'dashboard', id: 'dashboard_id', - attributes: {}, - references: [], + attributes: { description: 'description' }, + references: ['reference_id'], workspaces: ['foo'], }, { @@ -450,8 +450,8 @@ describe('WorkspaceIdConsumerWrapper', () => { { type: 'visualization', id: 'visualization_id', - attributes: {}, - references: [], + attributes: { description: 'description' }, + references: ['reference_id'], workspaces: ['bar'], }, { @@ -493,9 +493,13 @@ describe('WorkspaceIdConsumerWrapper', () => { Object { "saved_objects": Array [ Object { - "attributes": Object {}, + "attributes": Object { + "description": "description", + }, "id": "dashboard_id", - "references": Array [], + "references": Array [ + "reference_id", + ], "type": "dashboard", "workspaces": Array [ "foo", @@ -522,9 +526,6 @@ describe('WorkspaceIdConsumerWrapper', () => { "id": "visualization_id", "references": Array [], "type": "visualization", - "workspaces": Array [ - "bar", - ], }, Object { "attributes": Object {}, @@ -571,9 +572,13 @@ describe('WorkspaceIdConsumerWrapper', () => { Object { "saved_objects": Array [ Object { - "attributes": Object {}, + "attributes": Object { + "description": "description", + }, "id": "dashboard_id", - "references": Array [], + "references": Array [ + "reference_id", + ], "type": "dashboard", "workspaces": Array [ "foo", @@ -600,9 +605,6 @@ describe('WorkspaceIdConsumerWrapper', () => { "id": "visualization_id", "references": Array [], "type": "visualization", - "workspaces": Array [ - "bar", - ], }, Object { "attributes": Object {}, @@ -688,9 +690,13 @@ describe('WorkspaceIdConsumerWrapper', () => { Object { "saved_objects": Array [ Object { - "attributes": Object {}, + "attributes": Object { + "description": "description", + }, "id": "dashboard_id", - "references": Array [], + "references": Array [ + "reference_id", + ], "type": "dashboard", "workspaces": Array [ "foo", @@ -717,9 +723,6 @@ describe('WorkspaceIdConsumerWrapper', () => { "id": "visualization_id", "references": Array [], "type": "visualization", - "workspaces": Array [ - "bar", - ], }, Object { "attributes": Object {}, diff --git a/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.ts b/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.ts index f6efb690c5cd..b9edaecd2c9d 100644 --- a/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.ts +++ b/src/plugins/workspace/server/saved_objects/workspace_id_consumer_wrapper.ts @@ -195,7 +195,10 @@ export class WorkspaceIdConsumerWrapper { return this.validateObjectInAWorkspace(object, workspaces[0], wrapperOptions.request) ? object : { - ...object, + id: object.id, + type: object.type, + attributes: {} as T, + references: [], error: { ...generateSavedObjectsForbiddenError().output.payload, },