Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaweiWu committed Nov 1, 2023
1 parent dd553df commit 5b23cae
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,43 @@ describe('CreateMaintenanceWindowForm', () => {
expect(managementInput).toBeChecked();
});

it('should initialize MWs with selected category ids properly', async () => {
const result = appMockRenderer.render(
<CreateMaintenanceWindowForm
{...formProps}
initialValue={{
title: 'test',
startDate: '2023-03-24',
endDate: '2023-03-26',
timezone: ['America/Los_Angeles'],
recurring: true,
categoryIds: ['observability', 'management'],
}}
maintenanceWindowId="test"
/>
);

await waitFor(() => {
expect(
result.queryByTestId('maintenanceWindowCategorySelectionLoading')
).not.toBeInTheDocument();
});

const observabilityInput = within(
result.getByTestId('maintenanceWindowCategorySelection')
).getByTestId('checkbox-observability');
const securityInput = within(
result.getByTestId('maintenanceWindowCategorySelection')
).getByTestId('checkbox-securitySolution');
const managementInput = within(
result.getByTestId('maintenanceWindowCategorySelection')
).getByTestId('checkbox-management');

expect(observabilityInput).toBeChecked();
expect(managementInput).toBeChecked();
expect(securityInput).not.toBeChecked();
});

it('can select category IDs', async () => {
const result = appMockRenderer.render(<CreateMaintenanceWindowForm {...formProps} />);

Expand Down

0 comments on commit 5b23cae

Please sign in to comment.