-
Notifications
You must be signed in to change notification settings - Fork 35
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 main #14632
base: main
Are you sure you want to change the base?
Conversation
Bundle StatsHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded
Removed
Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
Bundle StatsHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded
Removed
Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
it('routes to the review page when the user clicks save', async () => { | ||
usePrimeSimulatorGetMove.mockReturnValue(moveReturnValue); | ||
updateShipmentDestinationAddress.mockReturnValue({ | ||
id: 'c56a4180-65aa-42ec-a945-5fd21dec0538', | ||
streetAddress1: '444 Main Ave', | ||
streetAddress2: 'Apartment 9000', | ||
streetAddress3: '', | ||
city: 'Anytown', | ||
state: 'AL', | ||
postalCode: '90210', | ||
country: 'USA', | ||
eTag: '1234567890', | ||
setFlashMessage: jest.fn(), | ||
}); | ||
renderComponent(); | ||
|
||
const addressChange = screen.getByLabelText('Address 1'); | ||
const contractorRemarks = screen.getByLabelText('Contractor Remarks'); | ||
await act(() => userEvent.type(addressChange, 'Address Tester')); | ||
await act(() => userEvent.type(contractorRemarks, 'testing contractor remarks')); | ||
|
||
const saveButton = await screen.findByRole('button', { name: 'Save' }); | ||
await act(() => userEvent.click(saveButton)); | ||
|
||
await waitFor(() => { | ||
expect(mockNavigate).toHaveBeenCalledWith(movePath); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think test above your added test is already checking this - line where it starts with describe('successful submission of form', () => {
.
Your should just be able to add this test:
expect(mockSetFlashMessage).toHaveBeenCalledTimes(1);
with
await waitFor(() => {
expect(mockNavigate).toHaveBeenCalledWith('/simulator/moves/LN4T89/details');
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use .toHaveBeenCalledWith()
if you want to check details
// const mockedComponent = ( | ||
// <MockProviders path={primeSimulatorRoutes.SHIPMENT_UPDATE_DESTINATION_ADDRESS_PATH} params={routingParams}> | ||
// <PrimeUIShipmentUpdateDestinationAddress setFlashMessage={jest.fn()} /> | ||
// </MockProviders> | ||
// ); | ||
|
||
const movePath = generatePath(primeSimulatorRoutes.VIEW_MOVE_PATH, { | ||
moveCodeOrID: 'LN4T89', | ||
setFlashMessage: jest.fn(), | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need these I don't think
|
||
import { usePrimeSimulatorGetMove } from '../../../hooks/queries'; | ||
import { updateShipmentDestinationAddress } from '../../../services/primeApi'; | ||
|
||
import PrimeUIShipmentUpdateDestinationAddress from './PrimeUIShipmentUpdateDestinationAddress'; | ||
|
||
// import { setFlashMessage } from 'store/flash/actions'; | ||
import { ReactQueryWrapper, MockProviders } from 'testUtils'; | ||
import { primeSimulatorRoutes } from 'constants/routes'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this mock for the flashmessage:
const mockSetFlashMessage = jest.fn();
jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
connect: jest.fn(() => (component) => (props) => component({ ...props, setFlashMessage: mockSetFlashMessage })),
}));
Agility ticket
Summary
Is there anything you would like reviewers to give additional scrutiny?
this article explains more about the approach used.
Verification Steps for the Author
These are to be checked by the author.
Verification Steps for Reviewers
These are to be checked by a reviewer.
Setup to Run the Code
How to test
Frontend
officeApp
class or custommin-width
styling is used to hide any states the would not be visible to the user.Backend
Database
Any new migrations/schema changes:
Screenshots