diff --git a/src/components/ReportingConfig/ReportingConfigForm.jsx b/src/components/ReportingConfig/ReportingConfigForm.jsx
index a3025ae83a..90023ef45c 100644
--- a/src/components/ReportingConfig/ReportingConfigForm.jsx
+++ b/src/components/ReportingConfig/ReportingConfigForm.jsx
@@ -141,7 +141,9 @@ class ReportingConfigForm extends React.Component {
submitState,
} = this.state;
const selectedCatalogs = (config?.enterpriseCustomerCatalogs || []).map(item => item.uuid);
- const dataTypesOptions = reportingConfigTypes.dataType.map(item => ({ label: item[1], value: item[0] }));
+ const dataTypesOptions = reportingConfigTypes.dataType.map((item, index) => ({
+ key: index, label: item[1], value: item[0],
+ }));
const dataTypesOptionsValues = dataTypesOptions.map(item => item.value);
const selectedDataTypesOption = config ? [{ label: config.dataType, value: config.dataType, hidden: true }] : [];
return (
@@ -404,7 +406,16 @@ ReportingConfigForm.propTypes = {
uuid: PropTypes.string,
title: PropTypes.string,
})).isRequired,
- reportingConfigTypes: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)).isRequired,
+ reportingConfigTypes: PropTypes.shape({
+ dataType: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
+ reportType: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
+ deliveryMethod: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
+ dayOfWeek: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number,
+ ]))),
+ frequency: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
+ }).isRequired,
createConfig: PropTypes.func.isRequired,
updateConfig: PropTypes.func,
deleteConfig: PropTypes.func,
diff --git a/src/components/ReportingConfig/ReportingConfigForm.test.jsx b/src/components/ReportingConfig/ReportingConfigForm.test.jsx
index 7fa7d38ddb..32b228ff8f 100644
--- a/src/components/ReportingConfig/ReportingConfigForm.test.jsx
+++ b/src/components/ReportingConfig/ReportingConfigForm.test.jsx
@@ -114,6 +114,23 @@ const createConfig = () => { };
const updateConfig = () => { };
describe('', () => {
+ it('properly handles deletion of configs', () => {
+ const mock = jest.fn();
+ const wrapper = mount((
+
+ ));
+ // It's finding three buttons for some reason??
+ wrapper.find('.btn-outline-danger').at(0).simulate('click');
+ expect(mock).toHaveBeenCalled();
+ });
+
it('renders the proper fields when changing the delivery method', () => {
const wrapper = mount((
', () => {
/>
));
expect(
- wrapper.find('select#enterpriseCustomerCatalogs').instance().value = ['test-enterprise-customer-catalog'],
- );
+ wrapper.find('select#enterpriseCustomerCatalogs').instance().value,
+ ).toEqual('test-enterprise-customer-catalog');
});
});
diff --git a/src/components/ReportingConfig/index.jsx b/src/components/ReportingConfig/index.jsx
index c0852d777f..e63d52655e 100644
--- a/src/components/ReportingConfig/index.jsx
+++ b/src/components/ReportingConfig/index.jsx
@@ -73,7 +73,10 @@ class ReportingConfig extends React.Component {
.findIndex(config => config.uuid === uuid);
this.setState((state) => {
- const newReportingConfig = { ...state.reportingConfigs }.splice(deletedIndex, 1);
+ // Copy the existing, needs to be updated, list of reporting configs
+ const newReportingConfig = [...state.reportingConfigs];
+ // Splice out the one that's being deleted
+ newReportingConfig.splice(deletedIndex, 1);
return {
reportingConfigs: newReportingConfig,
};
diff --git a/src/components/ReportingConfig/index.test.jsx b/src/components/ReportingConfig/index.test.jsx
new file mode 100644
index 0000000000..4f77bed91e
--- /dev/null
+++ b/src/components/ReportingConfig/index.test.jsx
@@ -0,0 +1,30 @@
+import React from 'react';
+import { mount } from 'enzyme';
+import ReportingConfig from './index';
+
+const defaultProps = {
+ location: {
+ state: { hasRequestedCodes: true },
+ },
+ match: { path: 'foobar' },
+ history: { replace: jest.fn() },
+ enterpriseId: 'enterpriseFoobar',
+};
+
+describe(' ', () => {
+ it('properly removes forms on delete', () => {
+ const wrapper = mount();
+ const configUuidToDelete = 'fake enterprise uuid';
+ wrapper.setState(
+ {
+ reportingConfigs: [
+ { uuid: configUuidToDelete },
+ { uuid: 'foo' },
+ { uuid: 'bar' },
+ ],
+ },
+ );
+ // Make sure deleteConfig doesn't blow things up
+ wrapper.instance().deleteConfig(configUuidToDelete);
+ });
+});