Skip to content

Commit

Permalink
Merge branch 'integrationTesting' into 20621-Add-Mobile-Shipment-Cust…
Browse files Browse the repository at this point in the history
…omer-Flows-INT
  • Loading branch information
KonstanceH authored Sep 30, 2024
2 parents d6c457d + 4457f19 commit 1bc01bc
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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 (historyRecord.context) {
newChangedValues = {
...newChangedValues,
...historyRecord.context[0],
};
}

return { ...historyRecord, changedValues: newChangedValues };
};

export default {
action: a.UPDATE,
eventName: o.patchMove,
tableName: t.moves,
getEventNameDisplay: () => 'Updated move',
getDetails: (historyRecord) => <LabeledDetails historyRecord={formatChangedValues(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/UpdateMTOShipment/patchMTOShipment';

describe('when given a patch move record', () => {
const historyRecord = {
action: 'UPDATE',
eventName: 'patchMove',
tableName: 'moves',
changedValues: { closeout_office_name: 'PPPO Scott AFB - USAF' },
};

it('correctly matches the patch move event', () => {
const template = getTemplate(historyRecord);
expect(template).toMatchObject(e);
});

it('displays the proper update order record', () => {
const template = getTemplate(historyRecord);
render(template.getDetails(historyRecord));
expect(screen.getByText('Closeout office')).toBeInTheDocument();
expect(screen.getByText(': PPPO Scott AFB - USAF')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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';

export default {
action: a.UPDATE,
eventName: o.uploadAdditionalDocuments,
tableName: t.moves,
getEventNameDisplay: () => 'Updated move',
getDetails: () => <>Uploaded additional document</>,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, screen } from '@testing-library/react';

import getTemplate from 'constants/MoveHistory/TemplateManager';

describe('when customer uploads additional documents', () => {
const historyRecord = {
action: 'UPDATE',
eventName: 'uploadAdditionalDocuments',
tableName: 'moves',
};
it('correctly matches the Upload additional documents event', () => {
const template = getTemplate(historyRecord);

render(template.getDetails(historyRecord));
expect(screen.getByText('Uploaded additional document')).toBeInTheDocument();
});
});
2 changes: 2 additions & 0 deletions src/constants/MoveHistory/EventTemplates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ export { default as updateAllowanceUpdateOrder } from './UpdateAllowances/update
export { default as updateAllowanceUpdateMTOShipment } from './UpdateAllowances/updateAllowanceUpdateMTOShipment';
export { default as approveShipmentUpdateAllowances } from './ApproveShipment/approveShipmentUpdateAllowances';
export { default as updateOrderUpdateAllowances } from './UpdateOrders/updateOrderUpdateAllowances';
export { default as patchMTOShipment } from './UpdateMTOShipment/patchMTOShipment';
export { default as uploadAdditionalDocuments } from './UploadAdditionalDocuments/uploadAdditionalDocuments';
2 changes: 2 additions & 0 deletions src/constants/MoveHistory/UIDisplay/Operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ export default {
finishDocumentReview: 'finishDocumentReview', // ghc.yaml
getMove: 'getMove', // ghc.yaml
createSITExtension: 'createSITExtension', // prime.yaml
patchMove: 'patchMove', // internal.yaml
uploadAdditionalDocuments: 'uploadAdditionalDocuments', // internal.yaml
};

0 comments on commit 1bc01bc

Please sign in to comment.