Commit 94f8de45 authored by Illya Klymov's avatar Illya Klymov

Support legacy format response in importGroup

* normalize response to simplify deployment
parent 3fa034df
......@@ -142,7 +142,7 @@ export function createResolvers({ endpoints }) {
};
});
const { data: responses } = await axios.post(endpoints.createBulkImport, {
const { data: originalResponse } = await axios.post(endpoints.createBulkImport, {
bulk_import: importOperations.map((op) => ({
source_type: 'group_entity',
source_full_path: op.group.fullPath,
......@@ -151,6 +151,10 @@ export function createResolvers({ endpoints }) {
})),
});
const responses = Array.isArray(originalResponse)
? originalResponse
: [{ success: true, id: originalResponse.id }];
return importOperations.map((op, idx) => {
const response = responses[idx];
const lastImportTarget = {
......
......@@ -188,6 +188,26 @@ describe('Bulk import resolvers', () => {
expect(results[0].progress.status).toBe(STATUSES.CREATED);
});
it('sets import status to CREATED for successful groups when request completes with legacy response', async () => {
axiosMockAdapter.onPost(FAKE_ENDPOINTS.createBulkImport).reply(httpStatus.OK, { id: 1 });
await client.mutate({
mutation: importGroupsMutation,
variables: {
importRequests: [
{
sourceGroupId: statusEndpointFixture.importable_data[0].id,
newName: 'test',
targetNamespace: 'root',
},
],
},
});
await axios.waitForAll();
expect(results[0].progress.status).toBe(STATUSES.CREATED);
});
it('sets import status to FAILED and sets progress message for failed groups when request completes', async () => {
const FAKE_ERROR_MESSAGE = 'foo';
axiosMockAdapter
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment