Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2645 +/- ##
==========================================
- Coverage 78.29% 78.28% -0.01%
==========================================
Files 281 281
Lines 20611 20603 -8
Branches 2102 2103 +1
==========================================
- Hits 16137 16129 -8
Misses 4426 4426
Partials 48 48
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4173447 to
64b5298
Compare
|
@MomoRazor good catch for the unexpected test passing! |
There was a problem hiding this comment.
Pull request overview
This PR improves client-side validation for Box Create and transfer-related forms by updating Zod schemas so missing single-select values produce the intended “Please select …” errors, and adjusts tests to assert against actual rendered error messages (not matching placeholder text).
Changes:
- Update Zod form schemas for single-select fields (BoxCreate, CreateShipment, CreateTransferAgreement) to provide custom required-field errors.
- Refine form validation tests to target Chakra form error messages specifically, avoiding false positives from placeholder text.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| front/src/views/Transfers/CreateTransferAgreement/components/CreateTransferAgreement.tsx | Adjusts select option schema usage and required partner organisation validation messaging. |
| front/src/views/Transfers/CreateShipment/components/CreateShipment.tsx | Updates shipment form validation for organisation/base selects with custom required errors. |
| front/src/views/Transfers/CreateShipment/CreateShipmentView.test.tsx | Makes validation assertions target Chakra error messages instead of placeholder text. |
| front/src/views/BoxCreate/components/BoxCreate.tsx | Updates BoxCreate select validations and number field error messaging. |
| front/src/views/BoxCreate/BoxCreateView.test.tsx | Makes validation assertions target Chakra error messages instead of placeholder text. |
| export const ShipmentFormSchema = z.object({ | ||
| shipmentTarget: shipmentTargetSchema, | ||
| receivingOrganisation: singleSelectOptionSchema | ||
| .nullable() | ||
| .refine(Boolean, { error: "Please select an organisation" }) | ||
| .transform((selectedOption) => selectedOption || { label: "", value: "" }), | ||
| receivingBase: singleSelectOptionSchema | ||
| .nullable() | ||
| .refine(Boolean, { error: "Please select a base" }) | ||
| .transform((selectedOption) => selectedOption || { label: "", value: "" }), | ||
| receivingOrganisation: z.object(singleSelectOptionSchema, { | ||
| error: (iss) => (iss.input === undefined ? "Please select an organisation" : "Invalid input."), | ||
| }), | ||
| receivingBase: z.object(singleSelectOptionSchema, { | ||
| error: (iss) => (iss.input === undefined ? "Please select a base" : "Invalid input."), | ||
| }), |
There was a problem hiding this comment.
ShipmentFormSchema now makes receivingOrganisation required for all cases, but the intra-org tab doesn’t render an organisation field and relies on programmatic setValueIntraOrg to satisfy validation. Consider modeling this as a discriminated union by shipmentTarget (partners: require organisation+base; currentOrg: require base only) or provide defaultValues for receivingOrganisation (set once in an effect) to avoid render-time setValue workarounds.
This fixes the errors for the Box Create Form, and also includes fixes for the test that checks for them, that was passing unexpectedly due to placeholder texts, rather then what the errors should have been