-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13878 from transcom/B-21365-INT
B-21365 Customer UB Shipment Card - INT
- Loading branch information
Showing
16 changed files
with
1,221 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
953 changes: 953 additions & 0 deletions
953
src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import userEvent from '@testing-library/user-event'; | |
import HHGShipmentCard from 'components/Customer/Review/ShipmentCard/HHGShipmentCard/HHGShipmentCard'; | ||
import { formatCustomerDate } from 'utils/formatters'; | ||
import { shipmentStatuses } from 'constants/shipments'; | ||
import { SHIPMENT_OPTIONS } from 'shared/constants'; | ||
|
||
const defaultProps = { | ||
moveId: 'testMove123', | ||
|
@@ -205,3 +206,187 @@ describe('HHGShipmentCard component', () => { | |
expect(mockedOnIncompleteClickFunction).toHaveBeenCalledWith('HHG 1', 'ABC123K-01', 'HHG'); | ||
}); | ||
}); | ||
|
||
const ubProps = { | ||
moveId: 'testMove123', | ||
editPath: '', | ||
onEditClick: jest.fn(), | ||
onDeleteClick: jest.fn(), | ||
shipmentNumber: 1, | ||
shipmentId: '#ABC123K', | ||
shipmentLocator: '#ABC123K-01', | ||
shipmentType: SHIPMENT_OPTIONS.UNACCOMPANIED_BAGGAGE, | ||
showEditAndDeleteBtn: false, | ||
requestedPickupDate: new Date('01/01/2020').toISOString(), | ||
pickupLocation: { | ||
streetAddress1: '17 8th St', | ||
city: 'New York', | ||
state: 'NY', | ||
postalCode: '11111', | ||
}, | ||
releasingAgent: { | ||
firstName: 'Jo', | ||
lastName: 'Xi', | ||
phone: '(555) 555-5555', | ||
email: '[email protected]', | ||
}, | ||
requestedDeliveryDate: new Date('03/01/2020').toISOString(), | ||
destinationZIP: '73523', | ||
receivingAgent: { | ||
firstName: 'Dorothy', | ||
lastName: 'Lagomarsino', | ||
phone: '(999) 999-9999', | ||
email: '[email protected]', | ||
}, | ||
remarks: | ||
'This is 500 characters of customer remarks right here. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', | ||
}; | ||
|
||
const incompleteUBProps = { | ||
moveId: 'testMove123', | ||
editPath: '', | ||
onEditClick: jest.fn(), | ||
onDeleteClick: jest.fn(), | ||
onIncompleteClick: mockedOnIncompleteClickFunction, | ||
shipmentNumber: 1, | ||
shipmentId: 'ABC123K', | ||
shipmentLocator: 'ABC123K-01', | ||
shipmentType: SHIPMENT_OPTIONS.UNACCOMPANIED_BAGGAGE, | ||
showEditAndDeleteBtn: false, | ||
requestedPickupDate: new Date('01/01/2020').toISOString(), | ||
status: shipmentStatuses.DRAFT, | ||
}; | ||
|
||
const completeUBProps = { | ||
moveId: 'testMove123', | ||
editPath: '', | ||
onEditClick: jest.fn(), | ||
onDeleteClick: jest.fn(), | ||
shipmentNumber: 1, | ||
shipmentId: 'ABC123K', | ||
shipmentLocator: 'ABC123K-01', | ||
shipmentType: SHIPMENT_OPTIONS.UNACCOMPANIED_BAGGAGE, | ||
showEditAndDeleteBtn: false, | ||
requestedPickupDate: new Date('01/01/2020').toISOString(), | ||
status: shipmentStatuses.SUBMITTED, | ||
}; | ||
|
||
function mountHHGShipmentCardForUBShipment(props) { | ||
return mount(<HHGShipmentCard {...ubProps} {...props} />); | ||
} | ||
|
||
describe('HHGShipmentCard component can be reused for UB shipment card', () => { | ||
it('renders component with all fields', () => { | ||
const wrapper = mountHHGShipmentCardForUBShipment(); | ||
const tableHeaders = [ | ||
'Requested pickup date', | ||
'Pickup location', | ||
'Releasing agent', | ||
'Requested delivery date', | ||
'Destination', | ||
'Receiving agent', | ||
'Remarks', | ||
]; | ||
const { streetAddress1, city, state, postalCode } = ubProps.pickupLocation; | ||
const { | ||
firstName: releasingFirstName, | ||
lastName: releasingLastName, | ||
phone: releasingTelephone, | ||
email: releasingEmail, | ||
} = ubProps.releasingAgent; | ||
const { | ||
firstName: receivingFirstName, | ||
lastName: receivingLastName, | ||
phone: receivingTelephone, | ||
email: receivingEmail, | ||
} = ubProps.receivingAgent; | ||
const tableData = [ | ||
formatCustomerDate(ubProps.requestedPickupDate), | ||
`${streetAddress1} ${city}, ${state} ${postalCode}`, | ||
`${releasingFirstName} ${releasingLastName} ${releasingTelephone} ${releasingEmail}`, | ||
formatCustomerDate(ubProps.requestedDeliveryDate), | ||
ubProps.destinationZIP, | ||
`${receivingFirstName} ${receivingLastName} ${receivingTelephone} ${receivingEmail}`, | ||
]; | ||
|
||
tableHeaders.forEach((label, index) => expect(wrapper.find('dt').at(index).text()).toBe(label)); | ||
tableData.forEach((label, index) => expect(wrapper.find('dd').at(index).text()).toBe(label)); | ||
expect(wrapper.find('.remarksCell').text()).toBe(ubProps.remarks); | ||
}); | ||
|
||
it('should render UB shipment card without releasing/receiving agents and remarks', () => { | ||
const wrapper = mountHHGShipmentCardForUBShipment({ | ||
...ubProps, | ||
releasingAgent: null, | ||
receivingAgent: null, | ||
remarks: '', | ||
}); | ||
const tableHeaders = ['Requested pickup date', 'Pickup location', 'Requested delivery date', 'Destination']; | ||
const { streetAddress1, city, state, postalCode } = ubProps.pickupLocation; | ||
const tableData = [ | ||
formatCustomerDate(ubProps.requestedPickupDate), | ||
`${streetAddress1} ${city}, ${state} ${postalCode}`, | ||
formatCustomerDate(ubProps.requestedDeliveryDate), | ||
ubProps.destinationZIP, | ||
]; | ||
tableHeaders.forEach((label, index) => expect(wrapper.find('dt').at(index).text()).toBe(label)); | ||
tableData.forEach((label, index) => expect(wrapper.find('dd').at(index).text()).toBe(label)); | ||
expect(wrapper.find('.remarksCell').length).toBe(0); | ||
}); | ||
|
||
it('should not render a secondary pickup location on UB shipment card if not provided one', async () => { | ||
render(<HHGShipmentCard {...ubProps} />); | ||
|
||
const secondPickupLocation = await screen.queryByText('Second pickup location'); | ||
expect(secondPickupLocation).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should not render a secondary destination location on UB shipment card if not provided one', async () => { | ||
render(<HHGShipmentCard {...ubProps} />); | ||
|
||
const secondDestination = await screen.queryByText('Second Destination'); | ||
expect(secondDestination).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render a UB shipment card secondary pickup location if provided one', async () => { | ||
render(<HHGShipmentCard {...ubProps} {...secondaryPickupAddress} />); | ||
|
||
const secondPickupLocation = await screen.getByText('Second pickup location'); | ||
expect(secondPickupLocation).toBeInTheDocument(); | ||
const secondPickupLocationInformation = await screen.getByText(/Some Other Street Name/); | ||
expect(secondPickupLocationInformation).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render a UB shipment card secondary destination location if provided one', async () => { | ||
render(<HHGShipmentCard {...ubProps} {...secondaryDeliveryAddress} />); | ||
|
||
const secondDestination = await screen.getByText('Second Destination'); | ||
expect(secondDestination).toBeInTheDocument(); | ||
const secondDesintationInformation = await screen.getByText(/Some Street Name/); | ||
expect(secondDesintationInformation).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render UB shipment card incomplete label and tooltip icon for completed UB shipment with SUBMITTED status', async () => { | ||
render(<HHGShipmentCard {...completeUBProps} />); | ||
|
||
expect(screen.getByRole('heading', { level: 3 })).toHaveTextContent('UB 1'); | ||
expect(screen.getByText(/^#ABC123K-01$/, { selector: 'p' })).toBeInTheDocument(); | ||
|
||
expect(screen.queryByText('Incomplete')).toBeNull(); | ||
}); | ||
|
||
it('renders incomplete label and tooltip icon for incomplete UB shipment with DRAFT status', async () => { | ||
render(<HHGShipmentCard {...incompleteUBProps} />); | ||
|
||
expect(screen.getByRole('heading', { level: 3 })).toHaveTextContent('UB 1'); | ||
expect(screen.getByText(/^#ABC123K-01$/, { selector: 'p' })).toBeInTheDocument(); | ||
|
||
expect(screen.getByText(/^Incomplete$/, { selector: 'span' })).toBeInTheDocument(); | ||
|
||
expect(screen.getByTitle('Help about incomplete shipment')).toBeInTheDocument(); | ||
await userEvent.click(screen.getByTitle('Help about incomplete shipment')); | ||
|
||
// verify onclick is getting json string as parameter | ||
expect(mockedOnIncompleteClickFunction).toHaveBeenCalledWith('UB 1', 'ABC123K-01', 'UNACCOMPANIED_BAGGAGE'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.