-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Include Date option in reporting configuration form
- Loading branch information
1 parent
519feab
commit a70b8a3
Showing
2 changed files
with
130 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ import ReportingConfigForm from './ReportingConfigForm'; | |
const defaultConfig = { | ||
enterpriseCustomerId: 'test-customer-uuid', | ||
active: true, | ||
enableCompression: true, | ||
includeDate: false, | ||
deliveryMethod: 'email', | ||
email: ['[email protected]'], | ||
emailRaw: '[email protected]', | ||
|
@@ -362,6 +364,7 @@ describe('<ReportingConfigForm />', () => { | |
const errorResponse = { | ||
data: { | ||
pgp_encryption_key: ['Please enter a valid PGP encryption key.'], | ||
enableCompression: ['Test Compression Error'], | ||
}, | ||
}; | ||
await act(async () => { | ||
|
@@ -377,4 +380,52 @@ describe('<ReportingConfigForm />', () => { | |
instance.handleAPIErrorResponse(null); | ||
expect(mock).not.toHaveBeenCalled(); | ||
}); | ||
it("should update the includeDate state when the 'Include Date' checkbox is clicked", async () => { | ||
const wrapper = mount(( | ||
<IntlProvider locale="en"> | ||
<ReportingConfigForm | ||
config={defaultConfig} | ||
createConfig={createConfig} | ||
updateConfig={updateConfig} | ||
availableCatalogs={availableCatalogs} | ||
reportingConfigTypes={reportingConfigTypes} | ||
enterpriseCustomerUuid={enterpriseCustomerUuid} | ||
/> | ||
</IntlProvider> | ||
)); | ||
|
||
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(); | ||
}); | ||
it("should update enableCompression state when the 'Enable Compression' checkbox is clicked", async () => { | ||
const wrapper = mount(( | ||
<IntlProvider locale="en"> | ||
<ReportingConfigForm | ||
config={defaultConfig} | ||
createConfig={createConfig} | ||
updateConfig={updateConfig} | ||
availableCatalogs={availableCatalogs} | ||
reportingConfigTypes={reportingConfigTypes} | ||
enterpriseCustomerUuid={enterpriseCustomerUuid} | ||
/> | ||
</IntlProvider> | ||
)); | ||
|
||
const instance = wrapper.find('ReportingConfigForm').instance(); | ||
expect(instance.state.enableCompression).toBeTruthy(); | ||
|
||
await act(async () => { | ||
wrapper.find('[data-testid="compressionCheckbox"]').first().prop('onChange')(); | ||
}); | ||
|
||
wrapper.update(); | ||
expect(instance.state.enableCompression).toBeFalsy(); | ||
}); | ||
}); |