Skip to content

Commit 65ef41d

Browse files
committed
add correct max value
1 parent f174311 commit 65ef41d

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

x-pack/platform/plugins/shared/cases/public/components/system_actions/cases/cases_params.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ describe('CasesParamsFields renders', () => {
113113
expect(await screen.findByTestId('time-window-unit-select')).toBeInTheDocument();
114114
expect(await screen.findByTestId('create-case-template-select')).toBeInTheDocument();
115115
expect(await screen.findByTestId('reopen-case')).toBeInTheDocument();
116+
expect(await screen.findByTestId('maximum-case-to-open-input')).toBeInTheDocument();
116117
});
117118

118119
it('renders loading state of grouping by fields correctly', async () => {
@@ -167,6 +168,22 @@ describe('CasesParamsFields renders', () => {
167168
expect(await screen.findByText('error')).toBeInTheDocument();
168169
});
169170

171+
it('renders the default maximum amount of cases correctly', async () => {
172+
render(<CasesParamsFields {...defaultProps} />);
173+
174+
const maximumCasesInput = await screen.findByTestId('maximum-case-to-open-input');
175+
expect(maximumCasesInput).toHaveValue(5);
176+
177+
// set to the maximum
178+
fireEvent.change(maximumCasesInput, { target: { value: '20' } });
179+
expect(editAction.mock.calls[0][1].maximumCasesToOpen).toEqual(20);
180+
expect(maximumCasesInput).toBeValid();
181+
182+
// set to an invalid value
183+
fireEvent.change(maximumCasesInput, { target: { value: '22' } });
184+
expect(maximumCasesInput).toBeInvalid();
185+
});
186+
170187
describe('UI updates', () => {
171188
it('renders grouping by field options', async () => {
172189
render(<CasesParamsFields {...defaultProps} />);

x-pack/platform/plugins/shared/cases/public/components/system_actions/cases/cases_params.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ import { ATTACK_DISCOVERY_SCHEDULES_ALERT_TYPE_ID } from '@kbn/elastic-assistant
2626
import type { ServerlessProjectType } from '../../../../common/constants/types';
2727
import * as i18n from './translations';
2828
import type { CasesActionParams } from './types';
29-
import { CASES_CONNECTOR_SUB_ACTION, DEFAULT_MAX_OPEN_CASES } from '../../../../common/constants';
29+
import {
30+
CASES_CONNECTOR_SUB_ACTION,
31+
DEFAULT_MAX_OPEN_CASES,
32+
MAX_OPEN_CASES,
33+
} from '../../../../common/constants';
3034
import { DEFAULT_TIME_WINDOW, TIME_UNITS } from './constants';
3135
import { getTimeUnitOptions } from './utils';
3236
import { useKibana } from '../../../common/lib/kibana';
@@ -309,10 +313,12 @@ export const CasesParamsFieldsComponent: React.FunctionComponent<
309313
<EuiFieldNumber
310314
fullWidth
311315
min={1}
312-
max={DEFAULT_MAX_OPEN_CASES}
316+
max={MAX_OPEN_CASES}
313317
step={1}
314-
defaultValue={actionParams.subActionParams?.maximumCasesToOpen ?? 5}
315-
data-test-subj="max-case-to-open-input"
318+
defaultValue={
319+
actionParams.subActionParams?.maximumCasesToOpen ?? DEFAULT_MAX_OPEN_CASES
320+
}
321+
data-test-subj="maximum-case-to-open-input"
316322
onChange={onChangeMaxCasesToOpend}
317323
/>
318324
</EuiFormRow>

0 commit comments

Comments
 (0)