55
66import expect from '@osd/expect' ;
77import { WorkspaceAttribute } from 'opensearch-dashboards/server' ;
8- import { omit } from 'lodash' ;
98import { FtrProviderContext } from '../../ftr_provider_context' ;
109
10+ const omitId = < T extends { id ?: string } > ( object : T ) : Omit < T , 'id' > => {
11+ const { id, ...others } = object ;
12+ return others ;
13+ } ;
14+
1115const testWorkspace : WorkspaceAttribute = {
1216 id : 'fake_id' ,
1317 name : 'test_workspace' ,
@@ -47,7 +51,7 @@ export default function ({ getService }: FtrProviderContext) {
4751 const result : any = await supertest
4852 . post ( `/api/workspaces` )
4953 . send ( {
50- attributes : omit ( testWorkspace , 'id' ) ,
54+ attributes : omitId ( testWorkspace ) ,
5155 } )
5256 . set ( 'osd-xsrf' , 'opensearch-dashboards' )
5357 . expect ( 200 ) ;
@@ -59,7 +63,7 @@ export default function ({ getService }: FtrProviderContext) {
5963 const result = await supertest
6064 . post ( `/api/workspaces` )
6165 . send ( {
62- attributes : omit ( testWorkspace , 'id' ) ,
66+ attributes : omitId ( testWorkspace ) ,
6367 } )
6468 . set ( 'osd-xsrf' , 'opensearch-dashboards' )
6569 . expect ( 200 ) ;
@@ -71,7 +75,7 @@ export default function ({ getService }: FtrProviderContext) {
7175 const result : any = await supertest
7276 . post ( `/api/workspaces` )
7377 . send ( {
74- attributes : omit ( testWorkspace , 'id' ) ,
78+ attributes : omitId ( testWorkspace ) ,
7579 } )
7680 . set ( 'osd-xsrf' , 'opensearch-dashboards' )
7781 . expect ( 200 ) ;
@@ -80,7 +84,7 @@ export default function ({ getService }: FtrProviderContext) {
8084 . put ( `/api/workspaces/${ result . body . result . id } ` )
8185 . send ( {
8286 attributes : {
83- ...omit ( testWorkspace , 'id' ) ,
87+ ...omitId ( testWorkspace ) ,
8488 name : 'updated' ,
8589 } ,
8690 } )
@@ -96,7 +100,7 @@ export default function ({ getService }: FtrProviderContext) {
96100 const result : any = await supertest
97101 . post ( `/api/workspaces` )
98102 . send ( {
99- attributes : omit ( testWorkspace , 'id' ) ,
103+ attributes : omitId ( testWorkspace ) ,
100104 } )
101105 . set ( 'osd-xsrf' , 'opensearch-dashboards' )
102106 . expect ( 200 ) ;
@@ -114,7 +118,7 @@ export default function ({ getService }: FtrProviderContext) {
114118 await supertest
115119 . post ( `/api/workspaces` )
116120 . send ( {
117- attributes : omit ( testWorkspace , 'id' ) ,
121+ attributes : omitId ( testWorkspace ) ,
118122 } )
119123 . set ( 'osd-xsrf' , 'opensearch-dashboards' )
120124 . expect ( 200 ) ;
0 commit comments