Skip to content
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

INT-B-21974 hide additional pickup and delivery options for nts and ntsr #14587

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
271 changes: 140 additions & 131 deletions src/pages/PrimeUI/Shipment/PrimeUIShipmentCreateForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,89 +426,93 @@ const PrimeUIShipmentCreateForm = ({ enableBoat, enableMobileHome }) => {
render={(fields) => (
<>
{fields}
<h4>Second Pickup Address</h4>
<FormGroup>
<p>
Will the movers pick up any belongings from a second address? (Must be near the pickup address.
Subject to approval.)
</p>
<div className={formStyles.radioGroup}>
<Field
as={Radio}
id="has-secondary-pickup"
data-testid="has-secondary-pickup"
label="Yes"
name="hasSecondaryPickupAddress"
value="true"
title="Yes, there is a second pickup address"
checked={hasSecondaryPickupAddress === 'true'}
/>
<Field
as={Radio}
id="no-secondary-pickup"
data-testid="no-secondary-pickup"
label="No"
name="hasSecondaryPickupAddress"
value="false"
title="No, there is not a second pickup address"
checked={hasSecondaryPickupAddress !== 'true' && hasTertiaryPickupAddress !== 'true'}
/>
</div>
</FormGroup>
{hasSecondaryPickupAddress === 'true' && (
{shipmentType !== SHIPMENT_TYPES.NTSR && (
<>
<h5 className={styles.sectionHeader}>Second Pickup Address</h5>
<AddressFields
name="secondaryPickupAddress"
locationLookup
formikProps={{
setFieldTouched,
setFieldValue,
}}
/>

<h4>Third Pickup Address</h4>
<h4>Second Pickup Address</h4>
<FormGroup>
<p>
Will the movers pick up any belongings from a third address? (Must be near the pickup address.
Will the movers pick up any belongings from a second address? (Must be near the pickup address.
Subject to approval.)
</p>
<div className={formStyles.radioGroup}>
<Field
as={Radio}
id="has-tertiary-pickup"
data-testid="has-tertiary-pickup"
id="has-secondary-pickup"
data-testid="has-secondary-pickup"
label="Yes"
name="hasTertiaryPickupAddress"
name="hasSecondaryPickupAddress"
value="true"
title="Yes, there is a tertiary pickup address"
checked={hasTertiaryPickupAddress === 'true'}
title="Yes, there is a second pickup address"
checked={hasSecondaryPickupAddress === 'true' && hasTertiaryPickupAddress !== 'true'}
/>
<Field
as={Radio}
id="no-tertiary-pickup"
data-testid="no-tertiary-pickup"
id="no-secondary-pickup"
data-testid="no-secondary-pickup"
label="No"
name="hasTertiaryPickupAddress"
name="hasSecondaryPickupAddress"
value="false"
title="No, there is not a tertiary pickup address"
checked={hasTertiaryPickupAddress !== 'true'}
title="No, there is not a second pickup address"
checked={hasSecondaryPickupAddress !== 'true'}
/>
</div>
</FormGroup>
</>
)}
{hasTertiaryPickupAddress === 'true' && hasSecondaryPickupAddress === 'true' && (
<>
<h5 className={styles.sectionHeader}>Third Pickup Address</h5>
<AddressFields
name="tertiaryPickupAddress"
locationLookup
formikProps={{
setFieldTouched,
setFieldValue,
}}
/>
{hasSecondaryPickupAddress === 'true' && (
<>
<h5 className={styles.sectionHeader}>Second Pickup Address</h5>
<AddressFields
name="secondaryPickupAddress"
locationLookup
formikProps={{
setFieldTouched,
setFieldValue,
}}
/>

<h4>Third Pickup Address</h4>
<FormGroup>
<p>
Will the movers pick up any belongings from a third address? (Must be near the pickup
address. Subject to approval.)
</p>
<div className={formStyles.radioGroup}>
<Field
as={Radio}
id="has-tertiary-pickup"
data-testid="has-tertiary-pickup"
label="Yes"
name="hasTertiaryPickupAddress"
value="true"
title="Yes, there is a tertiary pickup address"
checked={hasTertiaryPickupAddress === 'true'}
/>
<Field
as={Radio}
id="no-tertiary-pickup"
data-testid="no-tertiary-pickup"
label="No"
name="hasTertiaryPickupAddress"
value="false"
title="No, there is not a tertiary pickup address"
checked={hasTertiaryPickupAddress !== 'true'}
/>
</div>
</FormGroup>
</>
)}
{hasTertiaryPickupAddress === 'true' && hasSecondaryPickupAddress === 'true' && (
<>
<h5 className={styles.sectionHeader}>Third Pickup Address</h5>
<AddressFields
name="tertiaryPickupAddress"
locationLookup
formikProps={{
setFieldTouched,
setFieldValue,
}}
/>
</>
)}
</>
)}
</>
Expand All @@ -527,90 +531,95 @@ const PrimeUIShipmentCreateForm = ({ enableBoat, enableMobileHome }) => {
render={(fields) => (
<>
{fields}

<h4>Second Delivery Address</h4>
<FormGroup>
<p>
Will the movers pick up any belongings from a second address? (Must be near the pickup address.
Subject to approval.)
</p>
<div className={formStyles.radioGroup}>
<Field
as={Radio}
id="has-secondary-destination"
data-testid="has-secondary-destination"
label="Yes"
name="hasSecondaryDestinationAddress"
value="true"
title="Yes, there is a second delivery address"
checked={hasSecondaryDestinationAddress === 'true'}
/>
<Field
as={Radio}
id="no-secondary-destination"
data-testid="no-secondary-destination"
label="No"
name="hasSecondaryDestinationAddress"
value="false"
title="No, there is not a second delivery address"
checked={hasSecondaryDestinationAddress !== 'true' && hasTertiaryDestinationAddress !== 'true'}
/>
</div>
</FormGroup>
{hasSecondaryDestinationAddress === 'true' && (
{shipmentType !== SHIPMENT_TYPES.NTS && (
<>
<h5 className={styles.sectionHeader}>Second Delivery Address</h5>
<AddressFields
name="secondaryDestinationAddress"
locationLookup
formikProps={{
setFieldTouched,
setFieldValue,
}}
/>

<h4>Third Delivery Address</h4>
<h4>Second Delivery Address</h4>
<FormGroup>
<p>
Will the movers pick up any belongings from a third address? (Must be near the pickup address.
Will the movers pick up any belongings from a second address? (Must be near the pickup address.
Subject to approval.)
</p>
<div className={formStyles.radioGroup}>
<Field
as={Radio}
id="has-tertiary-destination"
data-testid="has-tertiary-destination"
id="has-secondary-destination"
data-testid="has-secondary-destination"
label="Yes"
name="hasTertiaryDestinationAddress"
name="hasSecondaryDestinationAddress"
value="true"
title="Yes, there is a third delivery address"
checked={hasTertiaryDestinationAddress === 'true'}
title="Yes, there is a second delivery address"
checked={
hasSecondaryDestinationAddress === 'true' && hasTertiaryDestinationAddress !== 'true'
}
/>
<Field
as={Radio}
id="no-tertiary-destination"
data-testid="no-tertiary-destination"
id="no-secondary-destination"
data-testid="no-secondary-destination"
label="No"
name="hasTertiaryDestinationAddress"
name="hasSecondaryDestinationAddress"
value="false"
title="No, there is not a third delivery address"
checked={hasTertiaryDestinationAddress !== 'true'}
title="No, there is not a second delivery address"
checked={hasSecondaryDestinationAddress !== 'true'}
/>
</div>
</FormGroup>
</>
)}
{hasTertiaryDestinationAddress === 'true' && hasSecondaryDestinationAddress === 'true' && (
<>
<h5 className={styles.sectionHeader}>Third Delivery Address</h5>
<AddressFields
name="tertiaryDestinationAddress"
locationLookup
formikProps={{
setFieldTouched,
setFieldValue,
}}
/>
{hasSecondaryDestinationAddress === 'true' && (
<>
<h5 className={styles.sectionHeader}>Second Delivery Address</h5>
<AddressFields
name="secondaryDestinationAddress"
locationLookup
formikProps={{
setFieldTouched,
setFieldValue,
}}
/>

<h4>Third Delivery Address</h4>
<FormGroup>
<p>
Will the movers pick up any belongings from a third address? (Must be near the pickup
address. Subject to approval.)
</p>
<div className={formStyles.radioGroup}>
<Field
as={Radio}
id="has-tertiary-destination"
data-testid="has-tertiary-destination"
label="Yes"
name="hasTertiaryDestinationAddress"
value="true"
title="Yes, there is a third delivery address"
checked={hasTertiaryDestinationAddress === 'true'}
/>
<Field
as={Radio}
id="no-tertiary-destination"
data-testid="no-tertiary-destination"
label="No"
name="hasTertiaryDestinationAddress"
value="false"
title="No, there is not a third delivery address"
checked={hasTertiaryDestinationAddress !== 'true'}
/>
</div>
</FormGroup>
</>
)}
{hasTertiaryDestinationAddress === 'true' && hasSecondaryDestinationAddress === 'true' && (
<>
<h5 className={styles.sectionHeader}>Third Delivery Address</h5>
<AddressFields
name="tertiaryDestinationAddress"
locationLookup
formikProps={{
setFieldTouched,
setFieldValue,
}}
/>
</>
)}
</>
)}
</>
Expand Down
52 changes: 52 additions & 0 deletions src/pages/PrimeUI/Shipment/PrimeUIShipmentCreateForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,58 @@ describe('PrimeUIShipmentCreateForm', () => {
expect(screen.getAllByLabelText('Address 1')[5]).toHaveValue('');
});

it('does not render secondary pickup address question for HHG_OUTOF_NTS', async () => {
renderShipmentCreateForm();

const shipmentTypeInput = await screen.findByLabelText('Shipment type');
expect(shipmentTypeInput).toBeInTheDocument();

// Select the shipment type
await userEvent.selectOptions(shipmentTypeInput, 'HHG_OUTOF_NTS');

const hasSecondaryPickup = screen.queryByTestId('has-secondary-pickup');
expect(hasSecondaryPickup).not.toBeInTheDocument();
});

it('renders secondary destination address question for HHG_OUTOF_NTS', async () => {
renderShipmentCreateForm();

const shipmentTypeInput = await screen.findByLabelText('Shipment type');
expect(shipmentTypeInput).toBeInTheDocument();

// Select the shipment type
await userEvent.selectOptions(shipmentTypeInput, 'HHG_OUTOF_NTS');

const hasSecondaryDestination = screen.queryByTestId('has-secondary-destination');
expect(hasSecondaryDestination).toBeInTheDocument();
});

it('does not render secondary destination address question for HHG_INTO_NTS', async () => {
renderShipmentCreateForm();

const shipmentTypeInput = await screen.findByLabelText('Shipment type');
expect(shipmentTypeInput).toBeInTheDocument();

// Select the shipment type
await userEvent.selectOptions(shipmentTypeInput, 'HHG_INTO_NTS');

const hasSecondaryDestination = screen.queryByTestId('has-secondary-destination');
expect(hasSecondaryDestination).not.toBeInTheDocument();
});

it('renders secondary pickup address question for HHG_INTO_NTS', async () => {
renderShipmentCreateForm();

const shipmentTypeInput = await screen.findByLabelText('Shipment type');
expect(shipmentTypeInput).toBeInTheDocument();

// Select the shipment type
await userEvent.selectOptions(shipmentTypeInput, 'HHG_INTO_NTS');

const hasSecondaryPickup = screen.queryByTestId('has-secondary-pickup');
expect(hasSecondaryPickup).toBeInTheDocument();
});

it('renders the HHG form and displays the shipment id text input when diversion box is checked', async () => {
isBooleanFlagEnabled.mockResolvedValue(false);
expect(await screen.queryByText('BOAT_HAUL_AWAY')).not.toBeInTheDocument();
Expand Down
Loading