Skip to content

Fixes for Errors on BoxCreate#2645

Merged
pylipp merged 8 commits intomasterfrom
box-create-error
Mar 30, 2026
Merged

Fixes for Errors on BoxCreate#2645
pylipp merged 8 commits intomasterfrom
box-create-error

Conversation

@MomoRazor
Copy link
Copy Markdown
Contributor

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

@sentry
Copy link
Copy Markdown

sentry bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.28%. Comparing base (3f33296) to head (7fb86c2).

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              
Flag Coverage Δ
backend 99.50% <ø> (ø)
frontend 70.55% <ø> (-0.02%) ⬇️
sharedComponents 68.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pylipp
Copy link
Copy Markdown
Contributor

pylipp commented Mar 30, 2026

@pylipp pylipp force-pushed the box-create-error branch from 4173447 to 64b5298 Compare March 30, 2026 10:46
@pylipp
Copy link
Copy Markdown
Contributor

pylipp commented Mar 30, 2026

@MomoRazor good catch for the unexpected test passing!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 54 to +61
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."),
}),
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@pylipp pylipp merged commit 8bcdee7 into master Mar 30, 2026
14 checks passed
@pylipp pylipp deleted the box-create-error branch March 30, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants