-
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?
Changes from 8 commits
a002ddd
dfb662a
78f694d
0a655c8
279f38f
1c02ef9
bdb0392
1ea8502
0270705
9b5ed98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
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'; | ||
|
||
import PrimeUIShipmentUpdateDestinationAddress from './PrimeUIShipmentUpdateDestinationAddress'; | ||
|
||
// import { setFlashMessage } from 'store/flash/actions'; | ||
import { ReactQueryWrapper, MockProviders } from 'testUtils'; | ||
import { primeSimulatorRoutes } from 'constants/routes'; | ||
|
||
|
@@ -97,6 +99,17 @@ const testShipmentReturnValue = { | |
isError: false, | ||
}; | ||
|
||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. don't need these I don't think |
||
const renderComponent = () => { | ||
render( | ||
<ReactQueryWrapper> | ||
|
@@ -107,7 +120,11 @@ const renderComponent = () => { | |
); | ||
}; | ||
|
||
describe('PrimeUIShipmentUpdateAddress page', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
describe('PrimeUIShipmentUpdateDestinationAddress page', () => { | ||
describe('check loading and error component states', () => { | ||
const loadingReturnValue = { | ||
moveTaskOrder: undefined, | ||
|
@@ -218,6 +235,35 @@ describe('PrimeUIShipmentUpdateAddress page', () => { | |
expect(mockNavigate).toHaveBeenCalledWith('/simulator/moves/LN4T89/details'); | ||
}); | ||
}); | ||
|
||
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 commentThe 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 Your should just be able to add this test:
with
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also use |
||
}); | ||
|
||
describe('error alert display', () => { | ||
|
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: