Skip to content

Commit

Permalink
Merge pull request #14100 from transcom/MAIN-B-21376
Browse files Browse the repository at this point in the history
MAIN B-21376
  • Loading branch information
deandreJones authored Dec 11, 2024
2 parents d2fa895 + 6be5bd4 commit bb9cced
Show file tree
Hide file tree
Showing 17 changed files with 394 additions and 10 deletions.
20 changes: 20 additions & 0 deletions pkg/gen/ghcapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/gen/ghcmessages/counseling_update_allowance_payload.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/gen/ghcmessages/update_allowance_payload.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions pkg/handlers/internalapi/orders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,28 @@ func (suite *HandlerSuite) TestShowOrder() {
suite.Assertions.Equal(order.SpouseHasProGear, *okResponse.Payload.SpouseHasProGear)
}

func (suite *HandlerSuite) TestPayloadForOrdersModel() {
dutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{
{
Model: factory.BuildAddress(suite.DB(), nil, []factory.Trait{factory.GetTraitAddress2}),
LinkOnly: true,
},
}, nil)
order := factory.BuildOrder(suite.DB(), []factory.Customization{
{
Model: dutyLocation,
LinkOnly: true,
Type: &factory.DutyLocations.OriginDutyLocation,
},
}, nil)

fakeS3 := storageTest.NewFakeS3Storage(true)

payload, err := payloadForOrdersModel(fakeS3, order)
suite.NoError(err)
suite.NotNil(payload)
}

func setUpMockOrders() models.Order {
orders := factory.BuildOrderWithoutDefaults(nil, nil, nil)

Expand Down
6 changes: 4 additions & 2 deletions src/components/Customer/MtoShipmentForm/MtoShipmentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { AddressShape, SimpleAddressShape } from 'types/address';
import { OrdersShape } from 'types/customerShapes';
import { ShipmentShape } from 'types/shipment';
import { formatMtoShipmentForAPI, formatMtoShipmentForDisplay } from 'utils/formatMtoShipment';
import { formatWeight } from 'utils/formatters';
import { formatUBAllowanceWeight, formatWeight } from 'utils/formatters';
import { validateDate } from 'utils/validation';
import withRouter from 'utils/routing';
import { ORDERS_TYPE } from 'constants/orders';
Expand Down Expand Up @@ -316,7 +316,9 @@ class MtoShipmentForm extends Component {
<Alert headingLevel="h4" type="info" noIcon>
Remember: You can move
{isUB
? ` up to your UB allowance for this move`
? ` up to ${formatUBAllowanceWeight(
orders?.entitlement?.ub_allowance,
)} for this UB shipment. The weight of your UB is part of your authorized weight allowance`
: ` ${formatWeight(orders.authorizedWeight)} total`}
. You’ll be billed for any excess weight you move.
</Alert>
Expand Down
18 changes: 18 additions & 0 deletions src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ const ubProps = {
orders: {
orders_type: ORDERS_TYPE.PERMANENT_CHANGE_OF_STATION,
has_dependents: false,
entitlement: {
ub_allowance: 600,
},
},
shipmentType: SHIPMENT_OPTIONS.UNACCOMPANIED_BAGGAGE,
};
Expand Down Expand Up @@ -1057,6 +1060,12 @@ describe('MtoShipmentForm component', () => {

expect(await screen.findByText('UB')).toHaveClass('usa-tag');

expect(
screen.queryByText(
'Remember: You can move up to 600 lbs for this UB shipment. The weight of your UB is part of your authorized weight allowance. You’ll be billed for any excess weight you move.',
),
).toBeInTheDocument();

expect(screen.getAllByText('Date')[0]).toBeInstanceOf(HTMLLegendElement);
expect(screen.getByLabelText(/Preferred pickup date/)).toBeInstanceOf(HTMLInputElement);
expect(screen.getByRole('heading', { level: 2, name: 'Pickup info' })).toBeInTheDocument();
Expand Down Expand Up @@ -1111,6 +1120,15 @@ describe('MtoShipmentForm component', () => {
).toBeInstanceOf(HTMLTextAreaElement);
});

it('renders the correct helper text when the UB allowance is null', async () => {
renderUBShipmentForm({ orders: { entitlement: { ub_allowance: null } } });
expect(
screen.queryByText(
'Remember: You can move up to your UB allowance for this UB shipment. The weight of your UB is part of your authorized weight allowance. You’ll be billed for any excess weight you move.',
),
).toBeInTheDocument();
});

it('renders the correct helper text for Delivery Address when orders type is RETIREMENT', async () => {
renderUBShipmentForm({ orders: { orders_type: ORDERS_TYPE.RETIREMENT } });
await waitFor(() =>
Expand Down
22 changes: 18 additions & 4 deletions src/pages/MyMove/Home/MoveHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
selectUploadsForCurrentAmendedOrders,
selectUploadsForCurrentOrders,
} from 'store/entities/selectors';
import { formatCustomerDate, formatWeight } from 'utils/formatters';
import { formatCustomerDate, formatUBAllowanceWeight, formatWeight } from 'utils/formatters';
import {
isPPMAboutInfoComplete,
isPPMShipmentComplete,
Expand All @@ -68,6 +68,7 @@ import {
import withRouter from 'utils/routing';
import { ADVANCE_STATUSES } from 'constants/ppms';
import { isBooleanFlagEnabled } from 'utils/featureFlags';
import ToolTip from 'shared/ToolTip/ToolTip';

const Description = ({ className, children, dataTestId }) => (
<p className={`${styles.description} ${className}`} data-testid={dataTestId}>
Expand Down Expand Up @@ -425,17 +426,30 @@ const MoveHome = ({ serviceMemberMoves, isProfileComplete, serviceMember, signed
<>
<p>
You’re moving to <strong>{orders.new_duty_location.name}</strong> from{' '}
<strong>{orders.origin_duty_location?.name}.</strong>
<strong>{orders.origin_duty_location?.name}</strong>
<br />
{` ${reportByLabel()} `}
<strong>{moment(orders.report_by_date).format('DD MMM YYYY')}.</strong>
<strong>{moment(orders.report_by_date).format('DD MMM YYYY')}</strong>
</p>

<dl className={styles.subheaderContainer}>
<div className={styles.subheaderSubsection}>
<dt>Weight allowance</dt>
<dd>{formatWeight(orders.authorizedWeight)}.</dd>
<dd>{formatWeight(orders.authorizedWeight)}</dd>
</div>
{orders?.entitlement?.ub_allowance > 0 && (
<div className={styles.subheaderSubsection}>
<dt>UB allowance</dt>
<dd>
{formatUBAllowanceWeight(orders?.entitlement?.ub_allowance)}{' '}
<ToolTip
color="#8cafea"
text="The weight of your UB shipment is also part of your overall authorized weight allowance."
data-testid="ubAllowanceToolTip"
/>
</dd>
</div>
)}
{move.moveCode && (
<div className={styles.subheaderSubsection}>
<dt>Move code</dt>
Expand Down
153 changes: 151 additions & 2 deletions src/pages/MyMove/Home/MoveHome.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import React from 'react';
import { v4 } from 'uuid';
import { mount } from 'enzyme';
import { waitFor } from '@testing-library/react';
import { act, waitFor } from '@testing-library/react';

import MoveHome from './MoveHome';

import { MockProviders } from 'testUtils';
import { customerRoutes } from 'constants/routes';
import { cancelMove, downloadPPMAOAPacket } from 'services/internalApi';
import { ORDERS_TYPE } from 'constants/orders';
import { isBooleanFlagEnabled } from 'utils/featureFlags';

jest.mock('containers/FlashMessage/FlashMessage', () => {
const MockFlash = () => <div>Flash message</div>;
Expand Down Expand Up @@ -38,7 +39,7 @@ jest.mock('services/internalApi', () => ({

jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve()),
}));

const props = {
Expand Down Expand Up @@ -86,6 +87,130 @@ const defaultPropsNoOrders = {
uploadedAmendedOrderDocuments: [],
};

const defaultPropsOrdersWithUBAllowance = {
...props,
serviceMemberMoves: {
currentMove: [
{
createdAt: '2024-02-16T15:55:20.639Z',
eTag: 'MjAyNC0wMi0xNlQxNTo1NToyMC42Mzk5MDRa',
id: '6dad799c-4567-4a7d-9419-1a686797768f',
moveCode: '4H8VCD',
orders: {
authorizedWeight: 11000,
created_at: '2024-02-16T15:55:20.634Z',
entitlement: {
proGear: 2000,
proGearSpouse: 500,
ub_allowance: 2000,
},
grade: 'E_7',
has_dependents: false,
id: '667b1ca7-f904-43c4-8f2d-a2ea2375d7d3',
issue_date: '2024-02-22',
new_duty_location: {
address: {
city: 'Fort Knox',
country: 'United States',
id: '31ed530d-4b59-42d7-9ea9-88ccc2978723',
postalCode: '40121',
state: 'KY',
streetAddress1: 'n/a',
},
address_id: '31ed530d-4b59-42d7-9ea9-88ccc2978723',
affiliation: 'ARMY',
created_at: '2024-02-15T14:42:58.875Z',
id: '866ac8f6-94f5-4fa0-b7d1-be7fcf9d51e9',
name: 'Fort Knox, KY 40121',
transportation_office: {
address: {
city: 'Fort Knox',
country: 'United States',
id: 'ca758d13-b3b7-48a5-93bd-64912f0e2434',
postalCode: '40121',
state: 'KY',
streetAddress1: 'LRC 25 W. Chaffee Ave',
streetAddress2: 'Bldg 1384, 2nd Floor',
},
created_at: '2018-05-28T14:27:36.193Z',
gbloc: 'BGAC',
id: '0357f830-2f32-41f3-9ca2-268dd70df5cb',
name: 'PPPO Fort Knox - USA',
phone_lines: [],
updated_at: '2018-05-28T14:27:36.193Z',
},
transportation_office_id: '0357f830-2f32-41f3-9ca2-268dd70df5cb',
updated_at: '2024-02-15T14:42:58.875Z',
},
orders_type: ORDERS_TYPE.PERMANENT_CHANGE_OF_STATION,
originDutyLocationGbloc: 'HAFC',
origin_duty_location: {
address: {
city: 'Tinker AFB',
country: 'United States',
id: '7e3ea97c-da9f-4fa1-8a11-87063c857635',
postalCode: '73145',
state: 'OK',
streetAddress1: 'n/a',
},
address_id: '7e3ea97c-da9f-4fa1-8a11-87063c857635',
affiliation: 'AIR_FORCE',
created_at: '2024-02-15T14:42:58.875Z',
id: '2d6eab7d-1a21-4f29-933e-ee8fa7dbc314',
name: 'Tinker AFB, OK 73145',
transportation_office: {
address: {
city: 'Tinker AFB',
country: 'United States',
id: '410b18bc-b270-4b52-9211-532fffc6f59e',
postalCode: '73145',
state: 'OK',
streetAddress1: '7330 Century Blvd',
streetAddress2: 'Bldg 469',
},
created_at: '2018-05-28T14:27:40.605Z',
gbloc: 'HAFC',
id: '7876373d-57e4-4cde-b11f-c26a8feee9e8',
name: 'PPPO Tinker AFB - USAF',
phone_lines: [],
updated_at: '2018-05-28T14:27:40.605Z',
},
transportation_office_id: '7876373d-57e4-4cde-b11f-c26a8feee9e8',
updated_at: '2024-02-15T14:42:58.875Z',
},
report_by_date: '2024-02-29',
service_member_id: '856fec24-a70b-4860-9ba8-98d25676317e',
spouse_has_pro_gear: false,
status: 'DRAFT',
updated_at: '2024-02-16T15:55:20.634Z',
uploaded_orders: {
id: '573a2d22-8edf-467c-90dc-3885de10e2d2',
service_member_id: '856fec24-a70b-4860-9ba8-98d25676317e',
uploads: [
{
bytes: 84847,
contentType: 'image/png',
createdAt: '2024-02-20T17:12:56.328Z',
filename: 'myUpload.png',
id: '99fab296-ad63-4e34-8724-a8b73e357480',
status: 'PROCESSING',
updatedAt: '2024-02-20T17:12:56.328Z',
url: '/storage/user/9e16e5d7-4548-4f70-8a2a-b87d34ab3067/uploads/99fab296-ad63-4e34-8724-a8b73e357480?contentType=image%2Fpng',
},
],
},
},
status: 'DRAFT',
submittedAt: '0001-01-01T00:00:00.000Z',
updatedAt: '0001-01-01T00:00:00.000Z',
},
],
previousMoves: [],
},
uploadedOrderDocuments: [],
uploadedAmendedOrderDocuments: [],
};

const defaultPropsOrdersWithUploads = {
...props,
serviceMemberMoves: {
Expand Down Expand Up @@ -1062,6 +1187,30 @@ afterEach(() => {
});

describe('Home component', () => {
describe('with default props, renders the right allowances', () => {
it('renders Home with the right amount of components', async () => {
isBooleanFlagEnabled.mockResolvedValue(true);
let wrapper;
// wrapping rendering in act to ensure all state updates are complete
await act(async () => {
wrapper = mountMoveHomeWithProviders(defaultPropsOrdersWithUBAllowance);
});
await waitFor(() => {
expect(wrapper.text()).toContain('Weight allowance');
expect(wrapper.text()).toContain('11,000 lbs');
expect(wrapper.text()).toContain('UB allowance');
expect(wrapper.text()).toContain('2,000 lbs');
});

const ubToolTip = wrapper.find('ToolTip');
expect(ubToolTip.exists()).toBe(true);

ubToolTip.simulate('click');
const toolTipText = 'The weight of your UB shipment is also part of your overall authorized weight allowance.';
expect(ubToolTip.text()).toBe(toolTipText);
});
});

describe('with default props, orders but no uploads', () => {
const wrapper = mountMoveHomeWithProviders(defaultPropsNoOrders);

Expand Down
Loading

0 comments on commit bb9cced

Please sign in to comment.