-
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 branch 'main' into B-20532-MAIN
- Loading branch information
Showing
18 changed files
with
328 additions
and
17 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
31 changes: 31 additions & 0 deletions
31
src/constants/MoveHistory/EventTemplates/CreateOrder/createOrder.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,31 @@ | ||
import React from 'react'; | ||
|
||
import t from 'constants/MoveHistory/Database/Tables'; | ||
import a from 'constants/MoveHistory/Database/Actions'; | ||
import o from 'constants/MoveHistory/UIDisplay/Operations'; | ||
import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; | ||
|
||
const formatChangedValues = (historyRecord) => { | ||
let newChangedValues = { | ||
...historyRecord.changedValues, | ||
}; | ||
|
||
if (historyRecord.context) { | ||
newChangedValues = { | ||
...newChangedValues, | ||
...historyRecord.context[0], | ||
}; | ||
} | ||
|
||
return { ...historyRecord, changedValues: newChangedValues }; | ||
}; | ||
|
||
export default { | ||
action: a.INSERT, | ||
eventName: o.createOrder, | ||
tableName: t.orders, | ||
getEventNameDisplay: () => 'Created orders', | ||
getDetails: (historyRecord) => { | ||
return <LabeledDetails historyRecord={formatChangedValues(historyRecord)} />; | ||
}, | ||
}; |
50 changes: 50 additions & 0 deletions
50
src/constants/MoveHistory/EventTemplates/CreateOrder/createOrder.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,50 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import getTemplate from 'constants/MoveHistory/TemplateManager'; | ||
import e from 'constants/MoveHistory/EventTemplates/CreateOrder/createOrder'; | ||
|
||
describe('When given a create order event for the orders table from the office side', () => { | ||
const item = { | ||
action: 'INSERT', | ||
eventName: 'createOrder', | ||
tableName: 'orders', | ||
eventNameDisplay: 'Created orders', | ||
changedValues: { | ||
status: 'DRAFT', | ||
report_by_date: '2022-10-18', | ||
issue_date: '2022-10-11', | ||
orders_type: 'PERMANENT_CHANGE_OF_STATION', | ||
origin_duty_location_name: 'Los Angeles AFB', | ||
new_duty_location_name: 'Fairchild AFB', | ||
has_dependents: true, | ||
grade: 'E_1', | ||
}, | ||
context: [ | ||
{ | ||
new_duty_location_name: 'Fairchild AFB', | ||
origin_duty_location_name: 'Los Angeles AFB', | ||
}, | ||
], | ||
}; | ||
it('correctly matches to the proper template', () => { | ||
const result = getTemplate(item); | ||
expect(result).toMatchObject(e); | ||
}); | ||
describe('When given a specific set of details for created orders', () => { | ||
it.each([ | ||
['Status', ': DRAFT'], | ||
['Report by date', ': 18 Oct 2022'], | ||
['Orders date', ': 11 Oct 2022'], | ||
['Orders type', ': Permanent Change Of Station (PCS)'], | ||
['Origin duty location name', ': Los Angeles AFB'], | ||
['New duty location name', ': Fairchild AFB'], | ||
['Dependents included', ': Yes'], | ||
['Pay grade', ': E-1'], | ||
])('displays the proper details value for %s', async (label, value) => { | ||
const result = getTemplate(item); | ||
render(result.getDetails(item)); | ||
expect(screen.getByText(label)).toBeInTheDocument(); | ||
expect(screen.getByText(value)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
16 changes: 9 additions & 7 deletions
16
...es/UpdateOrders/updateOrderUpdateMove.jsx → ...teOrder/createOrderCreateEntitlements.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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
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 a from 'constants/MoveHistory/Database/Actions'; | ||
import o from 'constants/MoveHistory/UIDisplay/Operations'; | ||
import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; | ||
|
||
export default { | ||
action: a.UPDATE, | ||
eventName: o.updateOrder, | ||
tableName: t.moves, | ||
getEventNameDisplay: () => 'Updated move', | ||
getDetails: (historyRecord) => <LabeledDetails historyRecord={historyRecord} />, | ||
action: a.INSERT, | ||
eventName: o.createOrder, | ||
tableName: t.entitlements, | ||
getEventNameDisplay: () => 'Created allowances', | ||
getDetails: (historyRecord) => { | ||
return <LabeledDetails historyRecord={historyRecord} />; | ||
}, | ||
}; |
34 changes: 34 additions & 0 deletions
34
src/constants/MoveHistory/EventTemplates/CreateOrder/createOrderCreateEntitlements.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,34 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import getTemplate from 'constants/MoveHistory/TemplateManager'; | ||
import e from 'constants/MoveHistory/EventTemplates/CreateOrder/createOrderCreateEntitlements'; | ||
|
||
describe('When given a created order event for the entitlements table from the office side', () => { | ||
const item = { | ||
action: 'INSERT', | ||
eventName: 'createOrder', | ||
tableName: 'entitlements', | ||
eventNameDisplay: 'Created allowances', | ||
changedValues: { | ||
authorized_weight: 8000, | ||
dependents_authorized: true, | ||
storage_in_transit: 90, | ||
}, | ||
}; | ||
it('correctly matches the created orders template', () => { | ||
const result = getTemplate(item); | ||
expect(result).toMatchObject(e); | ||
}); | ||
describe('When given a specific set of details', () => { | ||
it.each([ | ||
['Authorized weight', ': 8,000 lbs'], | ||
['Storage in transit (SIT)', ': 90 days'], | ||
['Dependents', ': Yes'], | ||
])('displays the proper details value for %s', async (label, value) => { | ||
const result = getTemplate(item); | ||
render(result.getDetails(item)); | ||
expect(screen.getByText(label)).toBeInTheDocument(); | ||
expect(screen.getByText(value)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
src/constants/MoveHistory/EventTemplates/CreateOrder/createOrderCreateMoves.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,31 @@ | ||
import React from 'react'; | ||
|
||
import t from 'constants/MoveHistory/Database/Tables'; | ||
import a from 'constants/MoveHistory/Database/Actions'; | ||
import o from 'constants/MoveHistory/UIDisplay/Operations'; | ||
import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; | ||
|
||
const formatChangedValues = (historyRecord) => { | ||
let newChangedValues = { | ||
...historyRecord.changedValues, | ||
}; | ||
|
||
if (historyRecord.context) { | ||
newChangedValues = { | ||
...newChangedValues, | ||
...historyRecord.context[0], | ||
}; | ||
} | ||
|
||
return { ...historyRecord, changedValues: newChangedValues }; | ||
}; | ||
|
||
export default { | ||
action: a.INSERT, | ||
eventName: o.createOrder, | ||
tableName: t.moves, | ||
getEventNameDisplay: () => 'Created move', | ||
getDetails: (historyRecord) => { | ||
return <LabeledDetails historyRecord={formatChangedValues(historyRecord)} />; | ||
}, | ||
}; |
36 changes: 36 additions & 0 deletions
36
src/constants/MoveHistory/EventTemplates/CreateOrder/createOrderCreateMoves.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,36 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import getTemplate from 'constants/MoveHistory/TemplateManager'; | ||
import e from 'constants/MoveHistory/EventTemplates/CreateOrder/createOrderCreateMoves'; | ||
|
||
describe('When given a create order event for the moves table from the office side', () => { | ||
const item = { | ||
action: 'INSERT', | ||
eventName: 'createOrder', | ||
tableName: 'moves', | ||
eventNameDisplay: 'Created move', | ||
changedValues: { | ||
status: 'DRAFT', | ||
}, | ||
context: [ | ||
{ | ||
counseling_office_name: 'Scott AFB', | ||
}, | ||
], | ||
}; | ||
it('correctly matches to the proper template', () => { | ||
const result = getTemplate(item); | ||
expect(result).toMatchObject(e); | ||
}); | ||
describe('When given a specific set of details for created move', () => { | ||
it.each([ | ||
['Status', ': DRAFT'], | ||
['Counseling office', ': Scott AFB'], | ||
])('displays the proper details value for %s', async (label, value) => { | ||
const result = getTemplate(item); | ||
render(result.getDetails(item)); | ||
expect(screen.getByText(label)).toBeInTheDocument(); | ||
expect(screen.getByText(value)).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
34 changes: 34 additions & 0 deletions
34
src/constants/MoveHistory/EventTemplates/UpdateOrder/updateOrderUpdateMove.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,34 @@ | ||
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'; | ||
|
||
const formatChangedValues = (historyRecord) => { | ||
let newChangedValues = { | ||
...historyRecord.changedValues, | ||
}; | ||
|
||
if (newChangedValues.counseling_transportation_office_id === null) { | ||
newChangedValues.counseling_office_name = ' - '; | ||
} | ||
if (historyRecord.context) { | ||
newChangedValues = { | ||
...newChangedValues, | ||
...historyRecord.context[0], | ||
}; | ||
} | ||
|
||
return { ...historyRecord, changedValues: newChangedValues }; | ||
}; | ||
|
||
export default { | ||
action: a.UPDATE, | ||
eventName: o.updateOrder, | ||
tableName: t.moves, | ||
getEventNameDisplay: () => 'Updated move', | ||
getDetails: (historyRecord) => { | ||
return <LabeledDetails historyRecord={formatChangedValues(historyRecord)} />; | ||
}, | ||
}; |
4 changes: 2 additions & 2 deletions
4
...dateOrders/updateOrderUpdateMove.test.jsx → ...pdateOrder/updateOrderUpdateMove.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
Oops, something went wrong.