Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workspace routes integration failed #251

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/plugins/workspace/server/integration_tests/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const testWorkspace: WorkspaceAttribute = {
describe('workspace service', () => {
let root: ReturnType<typeof osdTestServer.createRoot>;
let opensearchServer: osdTestServer.TestOpenSearchUtils;
let osd: osdTestServer.TestOpenSearchDashboardsUtils;
beforeAll(async () => {
const { startOpenSearch, startOpenSearchDashboards } = osdTestServer.createTestServers({
adjustTimeout: (t: number) => jest.setTimeout(t),
Expand All @@ -34,8 +35,8 @@ describe('workspace service', () => {
},
});
opensearchServer = await startOpenSearch();
const startOSDResp = await startOpenSearchDashboards();
root = startOSDResp.root;
osd = await startOpenSearchDashboards();
root = osd.root;
});
afterAll(async () => {
await root.shutdown();
Expand All @@ -49,14 +50,17 @@ describe('workspace service', () => {
page: 1,
})
.expect(200);
await Promise.all(
listResult.body.result.workspaces.map((item: WorkspaceAttribute) =>
// this will delete reserved workspace
osdTestServer.request
.delete(root, `/api/saved_objects/${WORKSPACE_TYPE}/${item.id}`)
.expect(200)
const savedObjectsRepository = osd.coreStart.savedObjects.createInternalRepository([
WORKSPACE_TYPE,
]);
await expect(
Promise.all(
listResult.body.result.workspaces.map((item: WorkspaceAttribute) =>
// this will delete reserved workspace
savedObjectsRepository.delete(WORKSPACE_TYPE, item.id)
)
)
);
).resolves.toBeInstanceOf(Array);
});
it('create', async () => {
await osdTestServer.request
Expand Down Expand Up @@ -192,7 +196,8 @@ describe('workspace service', () => {
page: 1,
})
.expect(200);
expect(listResult.body.result.total).toEqual(2);
// Global and Management workspace will be created by default after workspace list API called.
expect(listResult.body.result.total).toEqual(4);
});
it('unable to perform operations on workspace by calling saved objects APIs', async () => {
const result = await osdTestServer.request
Expand Down Expand Up @@ -254,7 +259,8 @@ describe('workspace service', () => {
})
.expect(200);
expect(findResult.body.total).toEqual(0);
expect(listResult.body.result.total).toEqual(1);
// Global and Management workspace will be created by default after workspace list API called.
expect(listResult.body.result.total).toEqual(3);
});
});
});
Loading