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

B 21544 prime successful update message int #14588

Merged
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a002ddd
trying mount retun. working on catching undefined then or return promise
KonstanceH Jan 10, 2025
dfb662a
add in setflashmessage connect
KonstanceH Jan 14, 2025
78f694d
change address form back to original
KonstanceH Jan 14, 2025
0a655c8
Merge branch 'main' into B-21544-Prime-Successful-Update-Message-MAIN
KonstanceH Jan 14, 2025
279f38f
Merge branch 'main' into B-21544-Prime-Successful-Update-Message-MAIN
KonstanceH Jan 15, 2025
9881ebc
merging in from main trying to fix conflicts
KonstanceH Jan 15, 2025
b7571ef
Merge branch 'integrationTesting' into B-21544-Prime-Successful-Updat…
KonstanceH Jan 15, 2025
f8baaa5
reverting changes
KonstanceH Jan 15, 2025
39bf1c8
rolling this rate stuff back.. please stop breaking erverything
KonstanceH Jan 15, 2025
f2502ad
Merge branch 'integrationTesting' into B-21544-Prime-Successful-Updat…
taeJungCaci Jan 15, 2025
1c02ef9
trying to get test working lol
KonstanceH Jan 21, 2025
bdb0392
Merge branch 'main' into B-21544-Prime-Successful-Update-Message-MAIN
KonstanceH Jan 21, 2025
1ea8502
pausing for lunch
KonstanceH Jan 22, 2025
0270705
added tests from comments and modified path assert
KonstanceH Jan 22, 2025
9b5ed98
Merge branch 'main' into B-21544-Prime-Successful-Update-Message-MAIN
KonstanceH Jan 22, 2025
c340cf3
merge in latest and fix conflicts
KonstanceH Jan 22, 2025
853bacd
Merge branch 'B-21544-Prime-Successful-Update-Message-MAIN' into B-21…
KonstanceH Jan 22, 2025
e2a6b65
use params and remove beforeAll
KonstanceH Jan 22, 2025
188f7f2
oops generated files
KonstanceH Jan 22, 2025
c58e87a
Merge branch 'integrationTesting' into B-21544-Prime-Successful-Updat…
KonstanceH Jan 23, 2025
2944d59
adding orders fix
KonstanceH Jan 23, 2025
1a80a38
Merge branch 'integrationTesting' into B-21544-Prime-Successful-Updat…
KonstanceH Jan 23, 2025
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
20 changes: 20 additions & 0 deletions src/components/Office/AddOrdersForm/AddOrdersForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,3 +485,23 @@ describe('AddOrdersForm - With Counseling Office', () => {
expect(nextBtn).toBeDisabled();
});
});
describe('AddOrdersForm - Edge Cases and Additional Scenarios', () => {
it('disables orders type when safety move is selected', async () => {
render(
<Provider store={mockStore.store}>
<AddOrdersForm {...testProps} isSafetyMoveSelected />
</Provider>,
);

expect(screen.getByLabelText('Orders type')).toBeDisabled();
});

it('disables orders type when bluebark move is selected', async () => {
render(
<Provider store={mockStore.store}>
<AddOrdersForm {...testProps} isBluebarkMoveSelected />
</Provider>,
);
expect(screen.getByLabelText('Orders type')).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -736,4 +736,4 @@ describe('CreateCustomerForm', () => {
});
});
}, 50000);
}, 60000);
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useNavigate, useParams, generatePath } from 'react-router-dom';
import { useMutation } from '@tanstack/react-query';
import { Alert, Grid, GridContainer } from '@trussworks/react-uswds';
import * as Yup from 'yup';
import { connect } from 'react-redux';
import { func } from 'prop-types';

import PrimeUIShipmentUpdateDestinationAddressForm from './PrimeUIShipmentUpdateDestinationAddressForm';

Expand All @@ -17,7 +19,7 @@ import { updateShipmentDestinationAddress } from 'services/primeApi';
import primeStyles from 'pages/PrimeUI/Prime.module.scss';
import { isEmpty } from 'shared/utils';
import { fromPrimeAPIAddressFormat } from 'utils/formatters';
import { setFlashMessage } from 'store/flash/actions';
import { setFlashMessage as setFlashMessageAction } from 'store/flash/actions';

const updateDestinationAddressSchema = Yup.object().shape({
mtoShipmentID: Yup.string(),
Expand All @@ -28,7 +30,7 @@ const updateDestinationAddressSchema = Yup.object().shape({
eTag: Yup.string(),
});

const PrimeUIShipmentUpdateDestinationAddress = () => {
const PrimeUIShipmentUpdateDestinationAddress = ({ setFlashMessage }) => {
const [errorMessage, setErrorMessage] = useState();
const { moveCodeOrID, shipmentId } = useParams();
const { moveTaskOrder, isLoading, isError } = usePrimeSimulatorGetMove(moveCodeOrID);
Expand All @@ -40,7 +42,6 @@ const PrimeUIShipmentUpdateDestinationAddress = () => {
navigate(generatePath(primeSimulatorRoutes.VIEW_MOVE_PATH, { moveCodeOrID }));
};

/* istanbul ignore next */
const { mutate: updateShipmentDestinationAddressAPI } = useMutation(updateShipmentDestinationAddress, {
onSuccess: (updatedMTOShipment) => {
mtoShipments[mtoShipments.findIndex((mtoShipment) => mtoShipment.id === updatedMTOShipment.id)] =
Expand Down Expand Up @@ -146,4 +147,16 @@ const PrimeUIShipmentUpdateDestinationAddress = () => {
);
};

export default PrimeUIShipmentUpdateDestinationAddress;
PrimeUIShipmentUpdateDestinationAddress.propTypes = {
setFlashMessage: func,
};

PrimeUIShipmentUpdateDestinationAddress.defaultProps = {
setFlashMessage: () => {},
};

const mapDispatchToProps = {
setFlashMessage: setFlashMessageAction,
};

export default connect(() => ({}), mapDispatchToProps)(PrimeUIShipmentUpdateDestinationAddress);
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { act, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { generatePath } from 'react-router-dom';

import { usePrimeSimulatorGetMove } from '../../../hooks/queries';
import { updateShipmentDestinationAddress } from '../../../services/primeApi';
Expand All @@ -26,6 +27,13 @@ jest.mock('services/primeApi', () => ({
updateShipmentDestinationAddress: jest.fn(),
}));

const mockSetFlashMessage = jest.fn();

jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
connect: jest.fn(() => (component) => (props) => component({ ...props, setFlashMessage: mockSetFlashMessage })),
}));

const routingParams = { moveCodeOrID: 'LN4T89', shipmentId: '4' };

const moveTaskOrder = {
Expand Down Expand Up @@ -97,6 +105,11 @@ const testShipmentReturnValue = {
isError: false,
};

const moveReviewPath = generatePath(primeSimulatorRoutes.VIEW_MOVE_PATH, {
moveCodeOrID: 'LN4T89',
setFlashMessage: jest.fn(),
});

const renderComponent = () => {
render(
<ReactQueryWrapper>
Expand All @@ -107,7 +120,7 @@ const renderComponent = () => {
);
};

describe('PrimeUIShipmentUpdateAddress page', () => {
describe('PrimeUIShipmentUpdateDestinationAddress page', () => {
describe('check loading and error component states', () => {
const loadingReturnValue = {
moveTaskOrder: undefined,
Expand Down Expand Up @@ -215,7 +228,14 @@ describe('PrimeUIShipmentUpdateAddress page', () => {
});

await waitFor(() => {
expect(mockNavigate).toHaveBeenCalledWith('/simulator/moves/LN4T89/details');
expect(mockSetFlashMessage).toHaveBeenCalledWith(
`MSG_UPDATE_SUCCESS${routingParams.shipmentId}`,
'success',
'Successfully updated shipment',
'',
true,
);
expect(mockNavigate).toHaveBeenCalledWith(moveReviewPath);
});
});
});
Expand Down
Loading