Skip to content

Commit

Permalink
Merge pull request #13723 from transcom/B-20490-INT
Browse files Browse the repository at this point in the history
B 20490 int
  • Loading branch information
pambecker authored Sep 18, 2024
2 parents ebf2c6b + 0a6e0e0 commit 079eec6
Show file tree
Hide file tree
Showing 40 changed files with 575 additions and 40 deletions.
6 changes: 6 additions & 0 deletions src/constants/MoveHistory/Database/BooleanFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ export default {
has_received_advance: 'has_received_advance',
paid_with_gtcc: 'paid_with_gtcc',
missing_receipt: 'missing_receipt',
organizational_clothing_and_individual_equipment: 'organizational_clothing_and_individual_equipment',
gun_safe: 'gun_safe',
email_is_preferred: 'email_is_preferred',
phone_is_preferred: 'phone_is_preferred',
uses_external_vendor: 'uses_external_vendor',
diversion: 'diversion',
};
4 changes: 4 additions & 0 deletions src/constants/MoveHistory/Database/FieldMappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default {
spouse_pro_gear_weight: 'Spouse pro-gear weight', // ppm_shipments table
required_medical_equipment_weight: 'Required medical equipment',
organizational_clothing_and_individual_equipment: 'OCIE',
gun_safe: 'Gun Safe',
requested_pickup_date: 'Requested pickup date',
grade: 'Pay grade',
shipment_type: 'Shipment type',
Expand Down Expand Up @@ -136,4 +137,7 @@ export default {
distance: 'Shipping distance',
ppm_status: 'PPM status', // custom front end status, not database value: resolved conflict
moving_expense_type: 'Expense type',
dest_sit_auth_end_date: 'Destination SIT authorized date',
approvals_requested_at: 'Approvals requested at',
approved_at: 'Approved at',
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import React from 'react';
import a from 'constants/MoveHistory/Database/Actions';
import o from 'constants/MoveHistory/UIDisplay/Operations';
import t from 'constants/MoveHistory/Database/Tables';
import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails';

export default {
action: a.UPDATE,
eventName: o.acknowledgeExcessWeightRisk,
tableName: t.moves,
getEventNameDisplay: () => 'Updated move',
getDetails: (historyRecord) => (
<>{historyRecord?.changedValues?.excess_weight_acknowledged_at ? 'Dismissed excess weight alert' : '-'} </>
),
getDetails: (historyRecord) => {
if (historyRecord?.changedValues?.excess_weight_acknowledged_at) {
return 'Dismissed excess weight alert';
}
return <LabeledDetails historyRecord={historyRecord} />;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@ describe('when given an Acknowledge excess weight risk history record', () => {
expect(result).toMatchObject(e);
});
it('renders the default details in the details column when excess risk key is not present ', () => {
const template = getTemplate(historyRecord);
render(template.getDetails(historyRecord));
expect(screen.getByText('-')).toBeInTheDocument();
const newHistoryRecord = {
...historyRecord,
changedValues: { status: 'APPROVED' },
};
const template = getTemplate(newHistoryRecord);
render(template.getDetails(newHistoryRecord));
expect(screen.getByText('Status')).toBeInTheDocument();
expect(screen.getByText(': APPROVED')).toBeInTheDocument();
});

it('renders the proper message in the details column when excess_weight_acknowledged_at is present ', () => {
const newHistoryRecord = {
const newHistoryRecordAcknowledged = {
...historyRecord,
changedValues: { excess_weight_acknowledged_at: 'this would usually be a time value' },
};
const template = getTemplate(newHistoryRecord);
render(template.getDetails(newHistoryRecord));
const template = getTemplate(newHistoryRecordAcknowledged);
render(template.getDetails(newHistoryRecordAcknowledged));
expect(screen.getByText('Dismissed excess weight alert')).toBeInTheDocument();
});
});
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} />,
};
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();
});
});
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} />,
};
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();
});
});
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} />,
};
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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ import { getMtoShipmentLabel } from 'utils/formatMtoShipment';

const formatChangedValues = (historyRecord) => {
const { changedValues } = historyRecord;
const { diversion, usesExternalVendor } = historyRecord.changedValues;

const newChangedValues = {
...changedValues,
...getMtoShipmentLabel(historyRecord),
};

if (diversion) {
newChangedValues.diversion = 'Yes';
} else {
newChangedValues.diversion = 'No';
}
if (usesExternalVendor) {
newChangedValues.uses_external_vendor = 'Yes';
} else {
newChangedValues.uses_external_vendor = 'No';
}
if (historyRecord.context[0].shipment_type === 'PPM') {
newChangedValues.status = null; // Status will always be draft when shipment is created, not useful information.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ 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';

export default {
action: a.INSERT,
eventName: o.createOrders,
eventName: '*', // Needs wild card to handle both createOrders and createOrder
tableName: t.entitlements,
getEventNameDisplay: () => 'Created allowances',
getDetails: (historyRecord) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ 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';

export default {
action: a.INSERT,
eventName: o.createOrders,
eventName: '*', // Needs wild card to handle both createOrders and createOrder
tableName: t.moves,
getEventNameDisplay: () => 'Created move',
getDetails: (historyRecord) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ 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) => {
Expand All @@ -22,7 +21,7 @@ const formatChangedValues = (historyRecord) => {

export default {
action: a.INSERT,
eventName: o.createOrders,
eventName: '*', // Needs wild card to handle both createOrders and createOrder
tableName: t.orders,
getEventNameDisplay: () => 'Created orders',
getDetails: (historyRecord) => {
Expand Down
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)} />;
},
};
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();
});
});
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} />,
};
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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export default {
action: a.INSERT,
eventName: '*',
tableName: t.service_members,
getEventNameDisplay: () => 'Created Profile',
getDetails: () => <> - </>,
getEventNameDisplay: () => 'Created profile',
getDetails: () => <> New profile created </>,
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ describe('When a service members creates a profile', () => {
const item = {
action: 'INSERT',
tableName: 'service_members',
eventNameDisplay: 'Created Profile',
eventNameDisplay: 'Created profile',
};
it('correctly matches the create service member event template', () => {
const result = getTemplate(item);
expect(result).toMatchObject(createServiceMember);
expect(result.getEventNameDisplay()).toEqual('Created Profile');
expect(result.getEventNameDisplay()).toEqual('Created profile');
});
it('correctly displays the details component', () => {
const result = getTemplate(item);
render(result.getDetails(item));
expect(screen.getByText('-')).toBeInTheDocument();
expect(screen.getByText('New profile created')).toBeInTheDocument();
});
});
Loading

0 comments on commit 079eec6

Please sign in to comment.