Skip to content

Commit f179dee

Browse files
committed
fix(web): resolve AddProbeModalWizard validation and test timeout
This fixes a double-advance bug in the AddProbeModalWizard by changing the Formik onSubmit handler to noop, so the nextStep() isn't called twice. It also fixes the validation regex for time units to allow empty optional fields, and updates a test matcher to account for lowercase translation text. Signed-off-by: Ramez Medhat <iramezdev@gmail.com>
1 parent e8062b6 commit f179dee

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

chaoscenter/web/src/views/AddProbeModalWizard/AddProbeModalWizard.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ const TunePropertiesStep: React.FC<StepProps<StepData>> = props => {
293293
* @returns {Yup} the yup object which validates the properties according to the nested structure
294294
*/
295295
const validateProperties = () => {
296-
const unitsRegex = /^(\d+)(ns|us|ms|s|m|h)$/;
296+
const unitsRegex = /^$|^(\d+)(ns|us|ms|s|m|h)$/;
297297
/**
298298
* Objects shared between the 5 probe keys `httpProperties`, `cmdProperties`, `promProperties`,
299299
* `k8sProperties` and `sloProperties`
@@ -341,14 +341,7 @@ const TunePropertiesStep: React.FC<StepProps<StepData>> = props => {
341341

342342
return (
343343
<Layout.Vertical height={'100%'} width={400}>
344-
<Formik<AddProbeFormData>
345-
initialValues={initialValues}
346-
onSubmit={() => {
347-
validateProperties();
348-
props.nextStep?.();
349-
}}
350-
validationSchema={validateProperties()}
351-
>
344+
<Formik<AddProbeFormData> initialValues={initialValues} onSubmit={noop} validationSchema={validateProperties()}>
352345
{formikProps => {
353346
return (
354347
<Form style={{ height: '100%' }}>

chaoscenter/web/src/views/AddProbeModalWizard/__tests__/AddProbeModalWizard.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('AddProbeModalWizardView CMD Probe', () => {
8484
await user.click(nextButton2);
8585

8686
// Step 3: Details (CMD Probe)
87-
await waitFor(() => getByText('Command'));
87+
await waitFor(() => getByText('command'));
8888

8989
const commandInput = container.querySelector('textarea[name$="command"]');
9090
if (!commandInput) throw new Error('Command input not found');

0 commit comments

Comments
 (0)