Skip to content

Commit

Permalink
ENG-11111 fix mfe api failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ichalagashvili committed May 2, 2024
1 parent 4f5253e commit f6c33d4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/api/mfe.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { makeRequest, METHODS } from '@entando/apimanager';
import { LIST_MFE_RESPONSE_OK } from 'test/mocks/mfe';
import { makeMockRequest, METHODS } from '@entando/apimanager';
import { LIST_MFE_MENU } from 'test/mocks/mfe';

// eslint-disable-next-line import/prefer-default-export
export const getMfeConfigList = (params = '') => (
makeRequest({
makeMockRequest({
uri: `/bundles/all/widgets?filters[0].value=app-builder&filters[0].attribute=widgetType&filters[0].operator=eq${params}`,
domain: '/digital-exchange',
method: METHODS.GET,
mockResponse: LIST_MFE_RESPONSE_OK,
mockResponse: LIST_MFE_MENU,
useAuthentication: true,
})
);
10 changes: 5 additions & 5 deletions test/api/mfe.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'test/enzyme-init';
import { getMfeConfigList } from 'api/mfe';
import { makeRequest, METHODS } from '@entando/apimanager';
import { LIST_MFE_RESPONSE_OK } from 'test/mocks/mfe';
import { makeMockRequest, METHODS } from '@entando/apimanager';
import { LIST_MFE_MENU } from 'test/mocks/mfe';

jest.mock('@entando/apimanager', () => ({
makeRequest: jest.fn(() => new Promise(resolve => resolve({}))),
makeMockRequest: jest.fn(() => new Promise(resolve => resolve({}))),
METHODS: require.requireActual('@entando/apimanager').METHODS,
}));

Expand All @@ -20,11 +20,11 @@ describe('api/mfe', () => {

it('makes the correct request', () => {
getMfeConfigList();
expect(makeRequest).toHaveBeenCalledWith({
expect(makeMockRequest).toHaveBeenCalledWith({
uri: '/bundles/all/widgets?filters[0].value=app-builder&filters[0].attribute=widgetType&filters[0].operator=eq',
domain: '/digital-exchange',
method: METHODS.GET,
mockResponse: LIST_MFE_RESPONSE_OK,
mockResponse: LIST_MFE_MENU,
useAuthentication: true,
});
});
Expand Down
25 changes: 25 additions & 0 deletions test/test/mocks/mfe.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,28 @@ export const UPDATE_MFE_OK = {
},
},
};

export const LIST_MFE_MENU = [
{
id: '9e343527-37bf-472e-aadc-a780613ceb88',
bundleId: '64c57c33',
bundleCode: 'layout-core-bundle-id',
bundleGroup: 'layout-core-bundle',
widgetName: 'app-builder-menu',
widgetCode: '6e3e752a-f796-11ec-b939-0242ac120002',
assets: ['http://localhost:4173/app-builder-menu.umd.js'],
customElement: 'app-builder-menu',
descriptorExt: {
slot: 'primary-menu',
nav: [],
paths: [],
},
systemParams: {
api: {
navigation: {
url: 'http://localhost:8080',
},
},
},
},
];

0 comments on commit f6c33d4

Please sign in to comment.