Skip to content

Commit

Permalink
Merge branch 'integrationTesting' into INT-B-21549
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljordan-caci authored Oct 16, 2024
2 parents 4c60aef + 8b7f600 commit 1ea87f0
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 90 deletions.
2 changes: 1 addition & 1 deletion config/env/loadtest.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DB_USER=crud
DEBUG_PPROF=false
DEVLOCAL_AUTH=true
DOD_CA_PACKAGE=/config/tls/api.loadtest.dp3.us.chain.der.p7b
DTOD_USE_MOCK=true
DTOD_USE_MOCK=false
EMAIL_BACKEND=ses
FEATURE_FLAG_SERVER_URL=http://flipt.svc-loadtest.local:8080
HEALTH_SERVER_ENABLED=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ const MobileHomeShipmentForm = ({ mtoShipment, onBack, onSubmit }) => {
Example
<ul>
<li>
Is there additional information you feel is pertinent to the processing of your mobile home
shipment?(e.g., &lsquo;wrecker service requested&rsquo; and &lsquo;crane service needed&rsquo;).
Dimensions of the mobile home on the trailer are significantly different than one would expect
given their individual dimensions
</li>
</ul>
</Callout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,35 @@ const ApprovedRequestedShipments = ({

return (
<div className={styles.RequestedShipments} data-testid="requested-shipments">
<h2>Approved Shipments</h2>
<div className={styles.dropdownButton}>
{!isMoveLocked && (
<Restricted to={permissionTypes.createTxoShipment}>
<ButtonDropdown
ariaLabel="Add a new shipment"
data-testid="addShipmentButton"
onChange={handleButtonDropdownChange}
>
<option value="" label="Add a new shipment">
Add a new shipment
</option>
<option data-testid="hhgOption" value={SHIPMENT_OPTIONS_URL.HHG}>
HHG
</option>
<option value={SHIPMENT_OPTIONS_URL.PPM}>PPM</option>
<option value={SHIPMENT_OPTIONS_URL.NTS}>NTS</option>
<option value={SHIPMENT_OPTIONS_URL.NTSrelease}>NTS-release</option>
<option data-testid="boatOption" value={SHIPMENT_OPTIONS_URL.BOAT}>
Boat
</option>
<option data-testid="mobileHomeOption" value={SHIPMENT_OPTIONS_URL.MOBILE_HOME}>
Mobile Home
</option>
</ButtonDropdown>
</Restricted>
)}
<div className={styles.sectionHeader}>
<h2>Approved Shipments</h2>
<div className={styles.buttonDropdown}>
{!isMoveLocked && (
<Restricted to={permissionTypes.createTxoShipment}>
<ButtonDropdown
ariaLabel="Add a new shipment"
data-testid="addShipmentButton"
onChange={handleButtonDropdownChange}
>
<option value="" label="Add a new shipment">
Add a new shipment
</option>
<option data-testid="hhgOption" value={SHIPMENT_OPTIONS_URL.HHG}>
HHG
</option>
<option value={SHIPMENT_OPTIONS_URL.PPM}>PPM</option>
<option value={SHIPMENT_OPTIONS_URL.NTS}>NTS</option>
<option value={SHIPMENT_OPTIONS_URL.NTSrelease}>NTS-release</option>
<option data-testid="boatOption" value={SHIPMENT_OPTIONS_URL.BOAT}>
Boat
</option>
<option data-testid="mobileHomeOption" value={SHIPMENT_OPTIONS_URL.MOBILE_HOME}>
Mobile Home
</option>
</ButtonDropdown>
</Restricted>
)}
</div>
</div>

<div className={shipmentCardsStyles.shipmentCards}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
@include u-padding-x(4);
@include u-padding-y(2);

.sectionHeader {
display: flex;
justify-content: center;
align-items: center;
h2 {
margin-right: auto;
}

.buttonDropdown {
margin-left: auto
}
}

h4 {
@include u-margin(0);
font-weight: bold;
Expand Down Expand Up @@ -55,7 +68,3 @@
.serviceCounselingCompleted {
@include u-margin-top(3);
}

.dropdownButton {
float: right;
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,33 +223,35 @@ const SubmittedRequestedShipments = ({
</div>

<form onSubmit={formik.handleSubmit}>
<h2>Requested shipments</h2>
<div className={styles.dropdownButton}>
{!isMoveLocked && (
<Restricted to={permissionTypes.createTxoShipment}>
<ButtonDropdown
ariaLabel="Add a new shipment"
data-testid="addShipmentButton"
onChange={handleButtonDropdownChange}
>
<option value="" label="Add a new shipment">
Add a new shipment
</option>
<option data-testid="hhgOption" value={SHIPMENT_OPTIONS_URL.HHG}>
HHG
</option>
<option value={SHIPMENT_OPTIONS_URL.PPM}>PPM</option>
<option value={SHIPMENT_OPTIONS_URL.NTS}>NTS</option>
<option value={SHIPMENT_OPTIONS_URL.NTSrelease}>NTS-release</option>
<option data-testid="boatOption" value={SHIPMENT_OPTIONS_URL.BOAT}>
Boat
</option>
<option data-testid="mobileHomeOption" value={SHIPMENT_OPTIONS_URL.MOBILE_HOME}>
Mobile Home
</option>
</ButtonDropdown>
</Restricted>
)}
<div className={styles.sectionHeader}>
<h2>Requested shipments</h2>
<div className={styles.buttonDropdown}>
{!isMoveLocked && (
<Restricted to={permissionTypes.createTxoShipment}>
<ButtonDropdown
ariaLabel="Add a new shipment"
data-testid="addShipmentButton"
onChange={handleButtonDropdownChange}
>
<option value="" label="Add a new shipment">
Add a new shipment
</option>
<option data-testid="hhgOption" value={SHIPMENT_OPTIONS_URL.HHG}>
HHG
</option>
<option value={SHIPMENT_OPTIONS_URL.PPM}>PPM</option>
<option value={SHIPMENT_OPTIONS_URL.NTS}>NTS</option>
<option value={SHIPMENT_OPTIONS_URL.NTSrelease}>NTS-release</option>
<option data-testid="boatOption" value={SHIPMENT_OPTIONS_URL.BOAT}>
Boat
</option>
<option data-testid="mobileHomeOption" value={SHIPMENT_OPTIONS_URL.MOBILE_HOME}>
Mobile Home
</option>
</ButtonDropdown>
</Restricted>
)}
</div>
</div>
<div className={shipmentCardsStyles.shipmentCards}>
{mtoShipments &&
Expand Down
61 changes: 32 additions & 29 deletions src/pages/PrimeUI/Shipment/PrimeUIShipmentCreate.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,37 +81,40 @@ describe('successful submission of form', () => {
});
});

describe('Create PPM', () => {
it('test destination address street 1 is OPTIONAL', async () => {
createPrimeMTOShipmentV3.mockReturnValue({});
describe('Error when submitting', () => {
it('Correctly displays the unexpected server error window when an unusuable api error response is returned', async () => {
createPrimeMTOShipmentV3.mockRejectedValue('malformed api error response');
render(mockedComponent);

waitFor(async () => {
await userEvent.selectOptions(screen.getByLabelText('Shipment type'), 'HHG');

const saveButton = await screen.getByRole('button', { name: 'Save' });

expect(saveButton).not.toBeDisabled();
await userEvent.click(saveButton);
expect(screen.getByText('Unexpected error')).toBeInTheDocument();
expect(
screen.getByText('An unknown error has occurred, please check the address values used'),
).toBeInTheDocument();
});
});

it('Correctly displays the invalid fields in the error window when an api error response is returned', async () => {
createPrimeMTOShipmentV3.mockRejectedValue({ body: { title: 'Error', invalidFields: { someField: true } } });
render(mockedComponent);

await userEvent.selectOptions(screen.getByLabelText('Shipment type'), 'PPM');

// Start controlled test case to verify everything is working.
let input = await document.querySelector('input[name="ppmShipment.pickupAddress.streetAddress1"]');
expect(input).toBeInTheDocument();
// enter required street 1 for pickup
await userEvent.type(input, '123 Street');
// clear
await userEvent.clear(input);
await userEvent.tab();
// verify Required alert is displayed
const requiredAlerts = screen.getByRole('alert');
expect(requiredAlerts).toHaveTextContent('Required');
// make valid again to clear alert
await userEvent.type(input, '123 Street');

// Verify destination address street 1 is OPTIONAL.
input = await document.querySelector('input[name="ppmShipment.destinationAddress.streetAddress1"]');
expect(input).toBeInTheDocument();
// enter something
await userEvent.type(input, '123 Street');
// clear
await userEvent.clear(input);
await userEvent.tab();
// verify no validation is displayed after clearing destination address street 1 because it's OPTIONAL
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
waitFor(async () => {
await userEvent.selectOptions(screen.getByLabelText('Shipment type'), 'HHG');

const saveButton = await screen.getByRole('button', { name: 'Save' });

expect(saveButton).not.toBeDisabled();
await userEvent.click(saveButton);
expect(screen.getByText('Prime API: Error')).toBeInTheDocument();
expect(
screen.getByText('An unknown error has occurred, please check the address values used'),
).toBeInTheDocument();
});
});
});

0 comments on commit 1ea87f0

Please sign in to comment.