Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: error messages from workspaceScheduleXService #3255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 28, 2022
Merged
Prev Previous commit
Format
  • Loading branch information
presleyp committed Jul 28, 2022
commit ad871dc684fbda1d76cdfd3a5f653917ff505bf8
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export default {
component: WorkspaceScheduleForm,
argTypes: {
onCancel: {
action: "onCancel"
action: "onCancel",
},
onSubmit: {
action: "onSubmit"
}
}
action: "onSubmit",
},
},
}

const Template: Story<WorkspaceScheduleFormProps> = (args) => <WorkspaceScheduleForm {...args} />
Expand Down Expand Up @@ -74,6 +74,6 @@ WithError.args = {
initialTouched: { ttl: true },
submitScheduleError: makeMockApiError({
message: "Something went wrong.",
validations: [{ field: "ttl_ms", detail: "Invalid time until shutdown." }]
})
validations: [{ field: "ttl_ms", detail: "Invalid time until shutdown." }],
}),
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
isLoading,
onCancel,
onSubmit,
initialTouched
initialTouched,
}) => {
const styles = useStyles()

const form = useFormik<WorkspaceScheduleFormValues>({
initialValues,
onSubmit,
validationSchema,
initialTouched
initialTouched,
})
const formHelpers = getFormHelpersWithError<WorkspaceScheduleFormValues>(
form,
Expand Down
28 changes: 17 additions & 11 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,21 @@ export const MockCancellationMessage = {
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const makeMockApiError = ({ message, detail, validations }: { message?: string, detail?: string, validations?: FieldError[] }) => (
{
response: {
data: {
message: message ?? "Something went wrong.",
detail: detail ?? undefined,
validations: validations ?? undefined,
},
export const makeMockApiError = ({
message,
detail,
validations,
}: {
message?: string
detail?: string
validations?: FieldError[]
}) => ({
response: {
data: {
message: message ?? "Something went wrong.",
detail: detail ?? undefined,
validations: validations ?? undefined,
},
isAxiosError: true,
}
)
},
isAxiosError: true,
})