From 038107c4084f2cc2d7efc600db8fbdfcb8d7c936 Mon Sep 17 00:00:00 2001 From: omar-sarfraz Date: Fri, 31 Jan 2025 19:12:21 +0500 Subject: [PATCH] feat: Add Include Date option in reporting configuration form --- .../ReportingConfig/ReportingConfigForm.jsx | 28 +++++++++++++++++++ .../ReportingConfigForm.test.jsx | 25 +++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/components/ReportingConfig/ReportingConfigForm.jsx b/src/components/ReportingConfig/ReportingConfigForm.jsx index 3552862661..1770d781ee 100644 --- a/src/components/ReportingConfig/ReportingConfigForm.jsx +++ b/src/components/ReportingConfig/ReportingConfigForm.jsx @@ -51,6 +51,7 @@ class ReportingConfigForm extends React.Component { active: this.props.config ? this.props.config.active : false, enableCompression: this.props.config ? this.props.config.enableCompression : true, submitState: SUBMIT_STATES.DEFAULT, + includeDate: this.props.config ? this.props.config.includeDate : false, }; /** @@ -127,6 +128,7 @@ class ReportingConfigForm extends React.Component { let requiredFields = []; formData.append('active', this.state.active); formData.append('enableCompression', this.state.enableCompression); + formData.append('includeDate', this.state.includeDate); if (formData.get('deliveryMethod') === 'email') { requiredFields = config ? [...REQUIRED_EMAIL_FIELDS] : [...REQUIRED_NEW_EMAIL_FIELDS]; // transform email field to match what the api is looking for @@ -257,6 +259,7 @@ class ReportingConfigForm extends React.Component { active, enableCompression, submitState, + includeDate, } = this.state; const selectedCatalogs = (config?.enterpriseCustomerCatalogs || []).map(item => item.uuid); const dataTypesOptions = reportingConfigTypes.dataType.map((item, index) => ({ @@ -515,6 +518,30 @@ class ReportingConfigForm extends React.Component { +
+ + + + + this.setState(prevState => ({ includeDate: !prevState.includeDate }))} + /> + + + + +
', () => { instance.handleAPIErrorResponse(null); expect(mock).not.toHaveBeenCalled(); }); + it("should update the includeDate state when the 'Include Date' checkbox is clicked", async () => { + const wrapper = mount(( + + + + )); + + const instance = wrapper.find('ReportingConfigForm').instance(); + expect(instance.state.includeDate).toBeFalsy(); + + await act(async () => { + wrapper.find('[data-testid="includeDateCheckbox"]').first().prop('onChange')(); + }); + + wrapper.update(); + expect(instance.state.includeDate).toBeTruthy(); + }); });