From fb2b21e92bda9eec68fc2834873e56aff98554d3 Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Tue, 19 Sep 2023 18:14:35 +0800 Subject: [PATCH] temp: add unit test Signed-off-by: SuZhou-Joe --- test/api_integration/apis/workspace/index.ts | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/api_integration/apis/workspace/index.ts diff --git a/test/api_integration/apis/workspace/index.ts b/test/api_integration/apis/workspace/index.ts new file mode 100644 index 000000000000..18b0f9b7f511 --- /dev/null +++ b/test/api_integration/apis/workspace/index.ts @@ -0,0 +1,39 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import expect from '@osd/expect'; +import { WorkspaceAttribute } from 'opensearch-dashboards/server'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +const testWorkspace: WorkspaceAttribute = { + id: 'fake_id', + name: 'test_workspace', + description: 'test_workspace_description', +}; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const opensearch = getService('legacyOpenSearch'); + + const MILLISECOND_IN_WEEK = 1000 * 60 * 60 * 24 * 7; + + describe('Workspace CRUD apis', () => { + it('basic CRUD', async () => { + const resp = await supertest + .post(`/api/workspaces`) + .set('osd-xsrf', 'opensearch-dashboards') + .send( + JSON.stringify({ + attributes: testWorkspace, + }) + ) + .expect(200); + + expect(resp.body).to.be.an('array'); + expect(resp.body.length).to.be.above(0); + expect(resp.body[0].status).to.be('not_installed'); + }); + }); +}