diff --git a/generators/entity-microfrontend/templates/ui/widgets/entity/detailsWidget/src/components/EntityDetailsContainer.js.ejs b/generators/entity-microfrontend/templates/ui/widgets/entity/detailsWidget/src/components/EntityDetailsContainer.js.ejs index 2a4b851a..fea88368 100644 --- a/generators/entity-microfrontend/templates/ui/widgets/entity/detailsWidget/src/components/EntityDetailsContainer.js.ejs +++ b/generators/entity-microfrontend/templates/ui/widgets/entity/detailsWidget/src/components/EntityDetailsContainer.js.ejs @@ -108,12 +108,12 @@ class <%= ComponentName %> extends React.Component { onError: PropTypes.func, t: PropTypes.func.isRequired, keycloak: keycloakType.isRequired, - config: PropTypes.func, + config: PropTypes.object, }; <%= ComponentName %>.defaultProps = { onError: () => {}, - config: () => {}, + config: {}, }; export default withKeycloak(withTranslation()(<%= ComponentName %>)); diff --git a/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/EntityAddFormContainer.js.ejs b/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/EntityAddFormContainer.js.ejs index 39b05623..ba664e94 100644 --- a/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/EntityAddFormContainer.js.ejs +++ b/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/EntityAddFormContainer.js.ejs @@ -88,14 +88,14 @@ class <%= entityClass %>AddFormContainer extends PureComponent { onCreate: PropTypes.func, t: PropTypes.func.isRequired, keycloak: keycloakType.isRequired, - config: PropTypes.func, + config: PropTypes.object, }; <%= entityClass %>AddFormContainer.defaultProps = { onError: () => {}, onCancelEditing: () => {}, onCreate: () => {}, - config: () => {}, + config: {}, }; export default withKeycloak(withTranslation()(<%= entityClass %>AddFormContainer)); diff --git a/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/EntityEditFormContainer.js.ejs b/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/EntityEditFormContainer.js.ejs index 9b601a4d..63d77dfd 100644 --- a/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/EntityEditFormContainer.js.ejs +++ b/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/EntityEditFormContainer.js.ejs @@ -174,7 +174,7 @@ class <%= entityClass %>EditFormContainer extends PureComponent { onDelete: PropTypes.func, t: PropTypes.func.isRequired, keycloak: keycloakType.isRequired, - config: PropTypes.func, + config: PropTypes.object, }; <%= entityClass %>EditFormContainer.defaultProps = { @@ -182,7 +182,7 @@ class <%= entityClass %>EditFormContainer extends PureComponent { onDelete: () => {}, onUpdate: () => {}, onError: () => {}, - config: () => {}, + config: {}, }; export default withKeycloak(withTranslation()(<%= entityClass %>EditFormContainer)); diff --git a/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/__tests__/EntityAddFormContainer.test.js.ejs b/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/__tests__/EntityAddFormContainer.test.js.ejs index d49620ec..614df7d5 100644 --- a/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/__tests__/EntityAddFormContainer.test.js.ejs +++ b/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/__tests__/EntityAddFormContainer.test.js.ejs @@ -6,6 +6,16 @@ import <%= entityClass %>AddFormContainer from 'components/<%= entityClass %>Add import 'i18n/__mocks__/i18nMock'; import { <%= entityInstance %>MockAdd as <%= entityInstance %>Mock } from 'components/__mocks__/<%= entityInstance %>Mocks'; +const configMock = { + systemParams: { + api: { + '<%= entityFileName %>-api': { + url: '', + }, + }, + }, +}; + jest.mock('api/<%= entityInstancePlural %>'); jest.mock('@material-ui/pickers', () => { // eslint-disable-next-line react/prop-types @@ -72,7 +82,7 @@ describe('<%= entityClass %>AddFormContainer', () => { api<%= entityClass %>Post.mockImplementation(data => Promise.resolve(data)); const { findByTestId, findByLabelText, queryByText, rerender } = render( - <<%= entityClass %>AddFormContainer onError={onErrorMock} onUpdate={onCreateMock} /> + <<%= entityClass %>AddFormContainer onError={onErrorMock} onUpdate={onCreateMock} config={configMock} /> ); <%_ @@ -97,7 +107,7 @@ describe('<%= entityClass %>AddFormContainer', () => { } }) _%> - rerender(<<%= entityClass %>AddFormContainer onError={onErrorMock} onUpdate={onCreateMock} />); + rerender(<<%= entityClass %>AddFormContainer onError={onErrorMock} onUpdate={onCreateMock} config={configMock} />); const saveButton = await findByTestId('submit-btn'); @@ -118,7 +128,7 @@ describe('<%= entityClass %>AddFormContainer', () => { api<%= entityClass %>Post.mockImplementation(() => Promise.reject()); const { findByTestId, findByLabelText, queryByText, rerender } = render( - <<%= entityClass %>AddFormContainer onError={onErrorMock} onUpdate={onCreateMock} /> + <<%= entityClass %>AddFormContainer onError={onErrorMock} onUpdate={onCreateMock} config={configMock} /> ); <%_ @@ -143,7 +153,7 @@ describe('<%= entityClass %>AddFormContainer', () => { } }) _%> - rerender(<<%= entityClass %>AddFormContainer onError={onErrorMock} onUpdate={onCreateMock} />); + rerender(<<%= entityClass %>AddFormContainer onError={onErrorMock} onUpdate={onCreateMock} config={configMock} />); const saveButton = await findByTestId('submit-btn'); diff --git a/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/__tests__/EntityEditFormContainer.test.js.ejs b/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/__tests__/EntityEditFormContainer.test.js.ejs index a982dd8b..692da05c 100644 --- a/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/__tests__/EntityEditFormContainer.test.js.ejs +++ b/generators/entity-microfrontend/templates/ui/widgets/entity/formWidget/src/components/__tests__/EntityEditFormContainer.test.js.ejs @@ -6,6 +6,16 @@ import <%= entityClass %>EditFormContainer from 'components/<%= entityClass %>Ed import 'i18n/__mocks__/i18nMock'; import { <%= entityInstance %>MockEdit as <%= entityInstance %>Mock } from 'components/__mocks__/<%= entityInstance %>Mocks'; +const configMock = { + systemParams: { + api: { + '<%= entityFileName %>-api': { + url: '', + }, + }, + }, +}; + jest.mock('api/<%= entityInstancePlural %>'); jest.mock('auth/withKeycloak', () => { @@ -38,7 +48,7 @@ describe('<%= entityClass %>EditFormContainer', () => { it('loads data', async () => { api<%= entityClass %>Get.mockImplementation(() => Promise.resolve(<%= entityInstance %>Mock)); const { queryByText } = render( - <<%= entityClass %>EditFormContainer id="1" onError={onErrorMock} onUpdate={onUpdateMock} /> + <<%= entityClass %>EditFormContainer id="1" onError={onErrorMock} onUpdate={onUpdateMock} config={configMock} /> ); await wait(() => { @@ -54,7 +64,7 @@ describe('<%= entityClass %>EditFormContainer', () => { api<%= entityClass %>Put.mockImplementation(() => Promise.resolve(<%= entityInstance %>Mock)); const { findByTestId, queryByText } = render( - <<%= entityClass %>EditFormContainer id="1" onError={onErrorMock} onUpdate={onUpdateMock} /> + <<%= entityClass %>EditFormContainer id="1" onError={onErrorMock} onUpdate={onUpdateMock} config={configMock} /> ); const saveButton = await findByTestId('submit-btn'); @@ -73,7 +83,7 @@ describe('<%= entityClass %>EditFormContainer', () => { it('shows an error if data is not successfully loaded', async () => { api<%= entityClass %>Get.mockImplementation(() => Promise.reject()); const { queryByText } = render( - <<%= entityClass %>EditFormContainer id="1" onError={onErrorMock} onUpdate={onUpdateMock} /> + <<%= entityClass %>EditFormContainer id="1" onError={onErrorMock} onUpdate={onUpdateMock} config={configMock} /> ); await wait(() => { @@ -89,7 +99,7 @@ describe('<%= entityClass %>EditFormContainer', () => { api<%= entityClass %>Get.mockImplementation(() => Promise.resolve(<%= entityInstance %>Mock)); api<%= entityClass %>Put.mockImplementation(() => Promise.reject()); const { findByTestId, getByText } = render( - <<%= entityClass %>EditFormContainer id="1" onError={onErrorMock} /> + <<%= entityClass %>EditFormContainer id="1" onError={onErrorMock} config={configMock} /> ); const saveButton = await findByTestId('submit-btn'); diff --git a/generators/entity-microfrontend/templates/ui/widgets/entity/tableWidget/src/components/EntityTableContainer.js.ejs b/generators/entity-microfrontend/templates/ui/widgets/entity/tableWidget/src/components/EntityTableContainer.js.ejs index 167b87cb..4a1dcfb6 100644 --- a/generators/entity-microfrontend/templates/ui/widgets/entity/tableWidget/src/components/EntityTableContainer.js.ejs +++ b/generators/entity-microfrontend/templates/ui/widgets/entity/tableWidget/src/components/EntityTableContainer.js.ejs @@ -265,7 +265,7 @@ class <%= ComponentName %> extends Component { currentPage: PropTypes.number, itemsPerPage: PropTypes.number, }), - config: PropTypes.func, + config: PropTypes.object, }; <%= ComponentName %>.defaultProps = { @@ -275,7 +275,7 @@ class <%= ComponentName %> extends Component { onSelect: () => {}, paginationMode: '', pagination: null, - config: () => {}, + config: {}, }; export default withKeycloak(