Skip to content

Commit

Permalink
Merge branch 'main' into B-20526-main
Browse files Browse the repository at this point in the history
  • Loading branch information
pambecker authored Oct 29, 2024
2 parents 2d58a46 + 85f3922 commit 0531951
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 39 deletions.
2 changes: 1 addition & 1 deletion playwright/tests/my/mymove/orders.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ test.describe('Download Amended Orders', () => {
await customerPage.waitForPage.home();

// Go to the Upload Amended Documents page
await page.getByRole('button', { name: 'Upload documents' }).click();
await page.getByRole('button', { name: 'Upload/Manage Orders Documentation' }).click();

// Upload amended orders
const filepondContainer = page.locator('.filepond--wrapper');
Expand Down
2 changes: 2 additions & 0 deletions src/components/Office/AddOrdersForm/AddOrdersForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ORDERS_PAY_GRADE_OPTIONS } from 'constants/orders';
import { dropdownInputOptions } from 'utils/formatters';
import WizardNavigation from 'components/Customer/WizardNavigation/WizardNavigation';
import Callout from 'components/Callout';
import ConnectedFlashMessage from 'containers/FlashMessage/FlashMessage';

const AddOrdersForm = ({ onSubmit, ordersTypeOptions, initialValues, onBack, isSafetyMoveSelected }) => {
const payGradeOptions = dropdownInputOptions(ORDERS_PAY_GRADE_OPTIONS);
Expand All @@ -37,6 +38,7 @@ const AddOrdersForm = ({ onSubmit, ordersTypeOptions, initialValues, onBack, isS
const isRetirementOrSeparation = ['RETIREMENT', 'SEPARATION'].includes(values.ordersType);
return (
<Form className={`${formStyles.form}`}>
<ConnectedFlashMessage />
<h1>Tell us about the orders</h1>

<SectionWrapper className={formStyles.formSection}>
Expand Down
15 changes: 13 additions & 2 deletions src/components/Office/AddOrdersForm/AddOrdersForm.test.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from 'react';
import { render, waitFor, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Provider } from 'react-redux';

import AddOrdersForm from './AddOrdersForm';

import { dropdownInputOptions } from 'utils/formatters';
import { ORDERS_PAY_GRADE_OPTIONS } from 'constants/orders';
import { configureStore } from 'shared/store';

describe('CreateMoveCustomerInfo Component', () => {
const mockStore = configureStore({});
const initialValues = {
ordersType: '',
issueDate: '',
Expand All @@ -25,7 +28,11 @@ describe('CreateMoveCustomerInfo Component', () => {
};

it('renders the form inputs', async () => {
render(<AddOrdersForm {...testProps} />);
render(
<Provider store={mockStore.store}>
<AddOrdersForm {...testProps} />
</Provider>,
);

await waitFor(() => {
expect(screen.getByText('Tell us about the orders')).toBeInTheDocument();
Expand All @@ -42,7 +49,11 @@ describe('CreateMoveCustomerInfo Component', () => {
});

it('shows an error message if trying to submit an invalid form', async () => {
const { getByRole, findAllByRole, getByLabelText } = render(<AddOrdersForm {...testProps} />);
const { getByRole, findAllByRole, getByLabelText } = render(
<Provider store={mockStore.store}>
<AddOrdersForm {...testProps} />
</Provider>,
);
await userEvent.click(getByLabelText('Orders type'));
await userEvent.click(getByLabelText('Orders date'));
await userEvent.click(getByLabelText('Report by date'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { act } from 'react-dom/test-utils';
import { render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { generatePath } from 'react-router-dom';
import { Provider } from 'react-redux';

import {
shipments,
Expand All @@ -24,6 +25,7 @@ import { SHIPMENT_OPTIONS_URL } from 'shared/constants';
import { tooRoutes } from 'constants/routes';
import { MockProviders } from 'testUtils';
import { permissionTypes } from 'constants/permissions';
import { configureStore } from 'shared/store';

const mockNavigate = jest.fn();
jest.mock('react-router-dom', () => ({
Expand All @@ -49,17 +51,20 @@ const moveTaskOrderServicesCounselingCompleted = {
};

const approveMTO = jest.fn().mockResolvedValue({ response: { status: 200 } });
const mockStore = configureStore({});

const submittedRequestedShipmentsComponent = (
<SubmittedRequestedShipments
allowancesInfo={allowancesInfo}
moveCode="TE5TC0DE"
mtoShipments={shipments}
closeoutOffice={closeoutOffice}
customerInfo={customerInfo}
ordersInfo={ordersInfo}
approveMTO={approveMTO}
/>
<Provider store={mockStore.store}>
<SubmittedRequestedShipments
allowancesInfo={allowancesInfo}
moveCode="TE5TC0DE"
mtoShipments={shipments}
closeoutOffice={closeoutOffice}
customerInfo={customerInfo}
ordersInfo={ordersInfo}
approveMTO={approveMTO}
/>
</Provider>
);

const submittedRequestedShipmentsComponentWithPermission = (
Expand Down Expand Up @@ -106,16 +111,18 @@ const submittedRequestedShipmentsComponentAvailableToPrimeAt = (
);

const submittedRequestedShipmentsComponentServicesCounselingCompleted = (
<SubmittedRequestedShipments
ordersInfo={ordersInfo}
allowancesInfo={allowancesInfo}
customerInfo={customerInfo}
mtoShipments={shipments}
closeoutOffice={closeoutOffice}
approveMTO={approveMTO}
moveTaskOrder={moveTaskOrderServicesCounselingCompleted}
moveCode="TE5TC0DE"
/>
<Provider store={mockStore.store}>
<SubmittedRequestedShipments
ordersInfo={ordersInfo}
allowancesInfo={allowancesInfo}
customerInfo={customerInfo}
mtoShipments={shipments}
closeoutOffice={closeoutOffice}
approveMTO={approveMTO}
moveTaskOrder={moveTaskOrderServicesCounselingCompleted}
moveCode="TE5TC0DE"
/>
</Provider>
);

const submittedRequestedShipmentsComponentMissingRequiredInfo = (
Expand Down Expand Up @@ -429,11 +436,14 @@ describe('RequestedShipments', () => {

const Component = statusComponents[status];

render(<Component {...statusTestProps[status]} />);
render(
<Provider store={mockStore.store}>
<Component {...statusTestProps[status]} />
</Provider>,
);

const customerRemarks = screen.getAllByTestId('customerRemarks');
const counselorRemarks = screen.getAllByTestId('counselorRemarks');

expect(customerRemarks.at(0).textContent).toBe('please treat gently');
expect(customerRemarks.at(1).textContent).toBe('please treat gently');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as PropTypes from 'prop-types';
import { Button, Checkbox, Fieldset } from '@trussworks/react-uswds';
import { generatePath, useParams, useNavigate } from 'react-router-dom';
import { debounce } from 'lodash';
import { connect } from 'react-redux';

import styles from './RequestedShipments.module.scss';

Expand All @@ -23,6 +24,7 @@ import { ShipmentShape } from 'types/shipment';
import { fieldValidationShape } from 'utils/displayFlags';
import ButtonDropdown from 'components/ButtonDropdown/ButtonDropdown';
import { SHIPMENT_OPTIONS_URL } from 'shared/constants';
import { setFlashMessage as setFlashMessageAction } from 'store/flash/actions';

// nts defaults show preferred pickup date and pickup address, flagged items when collapsed
// ntsr defaults shows preferred delivery date, storage facility address, destination address, flagged items when collapsed
Expand Down Expand Up @@ -52,6 +54,7 @@ const SubmittedRequestedShipments = ({
displayDestinationType,
mtoServiceItems,
isMoveLocked,
setFlashMessage,
}) => {
const [isModalVisible, setIsModalVisible] = useState(false);
const [filteredShipments, setFilteredShipments] = useState([]);
Expand Down Expand Up @@ -137,11 +140,13 @@ const SubmittedRequestedShipments = ({
onError: () => {
// TODO: Decide if we want to display an error notice, log error event, or retry
setSubmitting(false);
setFlashMessage(null);
},
},
);
}),
);
setFlashMessage('TASK_ORDER_CREATE_SUCCESS', 'success', 'Task order created successfully.');
handleAfterSuccess('../mto', { showMTOpostedMessage: true });
} catch {
setSubmitting(false);
Expand Down Expand Up @@ -376,4 +381,7 @@ SubmittedRequestedShipments.defaultProps = {
mtoServiceItems: [],
};

export default SubmittedRequestedShipments;
const mapDispatchToProps = {
setFlashMessage: setFlashMessageAction,
};
export default connect(() => ({}), mapDispatchToProps)(SubmittedRequestedShipments);
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { Provider } from 'react-redux';

import {
shipments,
Expand All @@ -12,6 +13,7 @@ import SubmittedRequestedShipments from './SubmittedRequestedShipments';

import { MockProviders, MockRouterProvider } from 'testUtils';
import { permissionTypes } from 'constants/permissions';
import { store } from 'shared/store';

export default {
title: 'Office Components/SubmittedRequestedShipments',
Expand All @@ -21,17 +23,21 @@ export default {
// Don't wrap with permissions for the read only tests
if (context.name.includes('Read Only')) {
return (
<MockRouterProvider>
<Story />
</MockRouterProvider>
<Provider store={store}>
<MockRouterProvider>
<Story />
</MockRouterProvider>
</Provider>
);
}

// By default, show component with permissions
return (
<MockProviders permissions={[permissionTypes.updateShipment]}>
<Story />
</MockProviders>
<Provider store={store}>
<MockProviders permissions={[permissionTypes.updateShipment]}>
<Story />
</MockProviders>
</Provider>
);
},
],
Expand Down
6 changes: 4 additions & 2 deletions src/pages/MyMove/Home/MoveHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,9 @@ const MoveHome = ({ serviceMemberMoves, isProfileComplete, serviceMember, signed
headerText="Profile complete"
step="1"
onEditBtnClick={() => handleNewPathClick(profileEditPath)}
actionBtnLabel={isAdditionalDocumentsButtonAvailable() ? 'Upload Additional Documents' : null}
actionBtnLabel={
isAdditionalDocumentsButtonAvailable() ? 'Upload/Manage Non-Orders Documentation' : null
}
onActionBtnClick={() => additionalDocumentsClick()}
>
<Description>Make sure to keep your personal information up to date during your move.</Description>
Expand All @@ -530,7 +532,7 @@ const MoveHome = ({ serviceMemberMoves, isProfileComplete, serviceMember, signed
<Step
complete={hasOrdersAndUpload() && hasSubmittedMove()}
completedHeaderText="Orders"
editBtnLabel="Upload documents"
editBtnLabel="Upload/Manage Orders Documentation"
onEditBtnClick={() => handleNewPathClick(ordersAmendPath)}
headerText="Orders"
step="2"
Expand Down
8 changes: 4 additions & 4 deletions src/pages/MyMove/Home/MoveHome.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ describe('Home component', () => {
const profileStep = wrapper.find('Step[step="1"]');
expect(profileStep.prop('editBtnLabel')).toEqual('Edit');
const orderStep = wrapper.find('Step[step="2"]');
expect(orderStep.prop('editBtnLabel')).toEqual('Upload documents');
expect(orderStep.prop('editBtnLabel')).toEqual('Upload/Manage Orders Documentation');
});

it('has appropriate step headers for orders with shipments', () => {
Expand Down Expand Up @@ -1233,7 +1233,7 @@ describe('Home component', () => {
const profileStep = wrapper.find('Step[step="1"]');
expect(profileStep.prop('editBtnLabel')).toEqual('Edit');
const orderStep = wrapper.find('Step[step="2"]');
expect(orderStep.prop('editBtnLabel')).toEqual('Upload documents');
expect(orderStep.prop('editBtnLabel')).toEqual('Upload/Manage Orders Documentation');
});

it('has appropriate step headers for orders with shipments', () => {
Expand Down Expand Up @@ -1277,7 +1277,7 @@ describe('Home component', () => {
const profileStep = wrapper.find('Step[step="1"]');
expect(profileStep.prop('editBtnLabel')).toEqual('Edit');
const orderStep = wrapper.find('Step[step="2"]');
expect(orderStep.prop('editBtnLabel')).toEqual('Upload documents');
expect(orderStep.prop('editBtnLabel')).toEqual('Upload/Manage Orders Documentation');
const advanceStep = wrapper.find('Step[step="5"]');
expect(advanceStep.prop('completedHeaderText')).toEqual('Advance request reviewed');
});
Expand Down Expand Up @@ -1560,7 +1560,7 @@ describe('Home component', () => {
const profileStep = wrapper.find('Step[step="1"]');
expect(profileStep.prop('editBtnLabel')).toEqual('Edit');
const orderStep = wrapper.find('Step[step="2"]');
expect(orderStep.prop('editBtnLabel')).toEqual('Upload documents');
expect(orderStep.prop('editBtnLabel')).toEqual('Upload/Manage Orders Documentation');
const advanceStep = wrapper.find('Step[step="5"]');
expect(advanceStep.prop('completedHeaderText')).toEqual('Advance request reviewed');
});
Expand Down
5 changes: 4 additions & 1 deletion src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import { isBooleanFlagEnabled } from 'utils/featureFlags';
import departmentIndicators from 'constants/departmentIndicators';
import { generateUniqueDodid, generateUniqueEmplid } from 'utils/customer';
import Hint from 'components/Hint';
import { setCanAddOrders as setCanAddOrdersAction } from 'store/general/actions';

export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => {
export const CreateCustomerForm = ({ userPrivileges, setFlashMessage, setCanAddOrders }) => {
const [serverError, setServerError] = useState(null);
const [showEmplid, setShowEmplid] = useState(false);
const [isSafetyMove, setIsSafetyMove] = useState(false);
Expand Down Expand Up @@ -133,6 +134,7 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => {
return createCustomerWithOktaOption({ body })
.then((res) => {
const customerId = Object.keys(res.createdCustomer)[0];
setCanAddOrders(true);
setFlashMessage('CUSTOMER_CREATE_SUCCESS', 'success', `Customer created successfully.`);
navigate(
generatePath(servicesCounselingRoutes.BASE_CUSTOMERS_ORDERS_ADD_PATH, {
Expand Down Expand Up @@ -555,6 +557,7 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => {

const mapDispatchToProps = {
setFlashMessage: setFlashMessageAction,
setCanAddOrders: setCanAddOrdersAction,
};

export default connect(() => ({}), mapDispatchToProps)(CreateCustomerForm);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jest.mock('services/ghcApi', () => ({
}));

jest.mock('store/flash/actions', () => ({
...jest.requireActual('store/flash/actions'),
setFlashMessage: jest.fn(),
}));

Expand All @@ -32,6 +31,10 @@ jest.mock('utils/featureFlags', () => ({
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
}));

jest.mock('store/general/actions', () => ({
setCanAddOrders: jest.fn(),
}));

beforeEach(jest.resetAllMocks);

const fakePayload = {
Expand Down Expand Up @@ -169,6 +172,7 @@ const mockUserPrivileges = [

const testProps = {
setFlashMessage: jest.fn(),
setCanAddOrders: jest.fn(),
userPrivileges: mockUserPrivileges,
};

Expand Down Expand Up @@ -337,6 +341,7 @@ describe('CreateCustomerForm', () => {

await waitFor(() => {
expect(createCustomerWithOktaOption).toHaveBeenCalled();
expect(testProps.setCanAddOrders).toHaveBeenCalledWith(true);
expect(mockNavigate).toHaveBeenCalledWith(ordersPath, {
state: {
isSafetyMoveSelected: false,
Expand Down

0 comments on commit 0531951

Please sign in to comment.