-
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 #13723 from transcom/B-20490-INT
B 20490 int
- Loading branch information
Showing
40 changed files
with
575 additions
and
40 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
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
14 changes: 14 additions & 0 deletions
14
src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipmentApproveMove.jsx
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import a from 'constants/MoveHistory/Database/Actions'; | ||
import t from 'constants/MoveHistory/Database/Tables'; | ||
import o from 'constants/MoveHistory/UIDisplay/Operations'; | ||
import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; | ||
|
||
export default { | ||
action: a.UPDATE, | ||
eventName: o.approveShipment, | ||
tableName: t.moves, | ||
getEventNameDisplay: () => 'Approved shipment', | ||
getDetails: (historyRecord) => <LabeledDetails historyRecord={historyRecord} />, | ||
}; |
25 changes: 25 additions & 0 deletions
25
src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipmentApproveMove.test.jsx
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import getTemplate from 'constants/MoveHistory/TemplateManager'; | ||
import e from 'constants/MoveHistory/EventTemplates/ApproveShipment/approveShipmentApproveMove'; | ||
|
||
describe('when given an Approved shipment, Approved move history record', () => { | ||
const historyRecord = { | ||
action: 'UPDATE', | ||
changedValues: { status: 'APPROVED' }, | ||
eventName: 'approveShipment', | ||
oldValues: { status: 'APPROVALS REQUESTED' }, | ||
tableName: 'moves', | ||
}; | ||
it('correctly matches to the Approved shipment, Approved move template', () => { | ||
const template = getTemplate(historyRecord); | ||
expect(template).toMatchObject(e); | ||
}); | ||
|
||
it('displays the proper value in the details field', () => { | ||
const template = getTemplate(historyRecord); | ||
render(template.getDetails(historyRecord)); | ||
expect(screen.getByText('Status')).toBeInTheDocument(); | ||
expect(screen.getByText(': APPROVED')).toBeInTheDocument(); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipmentUpdateAllowances.jsx
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import a from 'constants/MoveHistory/Database/Actions'; | ||
import t from 'constants/MoveHistory/Database/Tables'; | ||
import o from 'constants/MoveHistory/UIDisplay/Operations'; | ||
import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; | ||
|
||
export default { | ||
action: a.UPDATE, | ||
eventName: o.approveShipment, | ||
tableName: t.entitlements, | ||
getEventNameDisplay: () => 'Updated allowances', | ||
getDetails: (historyRecord) => <LabeledDetails historyRecord={historyRecord} />, | ||
}; |
24 changes: 24 additions & 0 deletions
24
...tants/MoveHistory/EventTemplates/ApproveShipment/approveShipmentUpdateAllowances.test.jsx
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import getTemplate from 'constants/MoveHistory/TemplateManager'; | ||
import e from 'constants/MoveHistory/EventTemplates/ApproveShipment/approveShipmentUpdateAllowances'; | ||
|
||
describe('when given an Approved shipment, Updated allowances history record', () => { | ||
const historyRecord = { | ||
action: 'UPDATE', | ||
changedValues: { authorized_weight: 13230 }, | ||
eventName: 'approveShipment', | ||
tableName: 'entitlements', | ||
}; | ||
it('correctly matches to the Approved shipment, Updated allowances template', () => { | ||
const template = getTemplate(historyRecord); | ||
expect(template).toMatchObject(e); | ||
}); | ||
|
||
it('displays the proper value in the details field', () => { | ||
const template = getTemplate(historyRecord); | ||
render(template.getDetails(historyRecord)); | ||
expect(screen.getByText('Authorized weight')).toBeInTheDocument(); | ||
expect(screen.getByText(': 13,230 lbs')).toBeInTheDocument(); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipmentUpdateMove.jsx
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import a from 'constants/MoveHistory/Database/Actions'; | ||
import t from 'constants/MoveHistory/Database/Tables'; | ||
import o from 'constants/MoveHistory/UIDisplay/Operations'; | ||
import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; | ||
|
||
export default { | ||
action: a.UPDATE, | ||
eventName: o.getMove, | ||
tableName: t.moves, | ||
getEventNameDisplay: () => 'Updated move', | ||
getDetails: (historyRecord) => <LabeledDetails historyRecord={historyRecord} />, | ||
}; |
25 changes: 25 additions & 0 deletions
25
src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipmentUpdateMove.test.jsx
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import getTemplate from 'constants/MoveHistory/TemplateManager'; | ||
import e from 'constants/MoveHistory/EventTemplates/ApproveShipment/approveShipmentUpdateMove'; | ||
|
||
describe('when given an Approved shipment, Updated move history record', () => { | ||
const historyRecord = { | ||
action: 'UPDATE', | ||
changedValues: { status: 'APPROVALS REQUESTED' }, | ||
eventName: 'getMove', | ||
oldValues: { status: 'APPROVED' }, | ||
tableName: 'moves', | ||
}; | ||
it('correctly matches to the Approved shipment, Updated move template', () => { | ||
const template = getTemplate(historyRecord); | ||
expect(template).toMatchObject(e); | ||
}); | ||
|
||
it('displays the proper value in the details field', () => { | ||
const template = getTemplate(historyRecord); | ||
render(template.getDetails(historyRecord)); | ||
expect(screen.getByText('Status')).toBeInTheDocument(); | ||
expect(screen.getByText(': APPROVALS REQUESTED')).toBeInTheDocument(); | ||
}); | ||
}); |
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
26 changes: 26 additions & 0 deletions
26
...ts/MoveHistory/EventTemplates/CreatePaymentRequest/createPaymentRequestUpdateShipment.jsx
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
|
||
import o from 'constants/MoveHistory/UIDisplay/Operations'; | ||
import a from 'constants/MoveHistory/Database/Actions'; | ||
import t from 'constants/MoveHistory/Database/Tables'; | ||
import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; | ||
import { getMtoShipmentLabel } from 'utils/formatMtoShipment'; | ||
|
||
const formatChangedValues = (historyRecord) => { | ||
const newChangedValues = { | ||
...historyRecord.changedValues, | ||
...getMtoShipmentLabel(historyRecord), | ||
}; | ||
|
||
return { ...historyRecord, changedValues: newChangedValues }; | ||
}; | ||
|
||
export default { | ||
action: a.UPDATE, | ||
eventName: o.createPaymentRequest, | ||
tableName: t.mto_shipments, | ||
getEventNameDisplay: () => 'Updated shipment', | ||
getDetails: (historyRecord) => { | ||
return <LabeledDetails historyRecord={formatChangedValues(historyRecord)} />; | ||
}, | ||
}; |
32 changes: 32 additions & 0 deletions
32
...veHistory/EventTemplates/CreatePaymentRequest/createPaymentRequestUpdateShipment.test.jsx
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { screen, render } from '@testing-library/react'; | ||
|
||
import e from 'constants/MoveHistory/EventTemplates/CreatePaymentRequest/createPaymentRequestUpdateShipment'; | ||
import getTemplate from 'constants/MoveHistory/TemplateManager'; | ||
|
||
describe('when given a payment request is created through shipment update', () => { | ||
const historyRecord = { | ||
action: 'UPDATE', | ||
eventName: 'createPaymentRequest', | ||
tableName: 'mto_shipments', | ||
context: [ | ||
{ | ||
shipment_type: 'HHG', | ||
shipment_id_abbr: 'acf7b', | ||
shipment_locator: 'ABC123-01', | ||
}, | ||
], | ||
changedValues: { distance: 30 }, | ||
}; | ||
|
||
it('correctly matches the create payment request event', () => { | ||
const template = getTemplate(historyRecord); | ||
expect(template).toMatchObject(e); | ||
}); | ||
|
||
it('displays the proper payment request record', () => { | ||
const template = getTemplate(historyRecord); | ||
render(template.getDetails(historyRecord)); | ||
expect(screen.getByText('Shipping distance')).toBeInTheDocument(); | ||
expect(screen.getByText(': 30 miles')).toBeInTheDocument(); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
src/constants/MoveHistory/EventTemplates/CreateSITExtension/createSITExtension.jsx
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import o from 'constants/MoveHistory/UIDisplay/Operations'; | ||
import a from 'constants/MoveHistory/Database/Actions'; | ||
import t from 'constants/MoveHistory/Database/Tables'; | ||
import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; | ||
|
||
export default { | ||
action: a.UPDATE, | ||
eventName: o.createSITExtension, | ||
tableName: t.moves, | ||
getEventNameDisplay: () => 'Updated move', | ||
getDetails: (historyRecord) => <LabeledDetails historyRecord={historyRecord} />, | ||
}; |
25 changes: 25 additions & 0 deletions
25
src/constants/MoveHistory/EventTemplates/CreateSITExtension/createSITExtension.test.jsx
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import getTemplate from 'constants/MoveHistory/TemplateManager'; | ||
import e from 'constants/MoveHistory/EventTemplates/CreateSITExtension/createSITExtension'; | ||
|
||
describe('when given a Create SIT extension item history record', () => { | ||
const historyRecord = { | ||
action: 'UPDATE', | ||
changedValues: { status: 'APPROVALS REQUESTED' }, | ||
oldValues: { status: 'APPROVED' }, | ||
eventName: 'createSITExtension', | ||
tableName: 'moves', | ||
}; | ||
it('correctly matches to the Approved shipment, Updated move template', () => { | ||
const template = getTemplate(historyRecord); | ||
expect(template).toMatchObject(e); | ||
}); | ||
|
||
it('correctly matches the Create SIT extension event', () => { | ||
const template = getTemplate(historyRecord); | ||
render(template.getDetails(historyRecord)); | ||
expect(screen.getByText('Status')).toBeInTheDocument(); | ||
expect(screen.getByText(': APPROVALS REQUESTED')).toBeInTheDocument(); | ||
}); | ||
}); |
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.