Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B 20473 office user cancel move #13863

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4ec32e8
cancel move for SC and TOO
pambecker Oct 1, 2024
249bdb7
updates to button and modal
pambecker Oct 4, 2024
31fcb59
connect cancel to backend call
pambecker Oct 4, 2024
903e2ae
cleanup
pambecker Oct 7, 2024
65d6e3c
fix issue with PPM only not canceling
pambecker Oct 8, 2024
29804ed
Fix MTO Canceled label for PPM
pambecker Oct 8, 2024
bf5634f
button placement
pambecker Oct 9, 2024
9fc955c
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 9, 2024
5710bc5
update tests
pambecker Oct 10, 2024
abca4eb
updates to refresh page
pambecker Oct 10, 2024
dc08742
update shipment labels on cards
pambecker Oct 11, 2024
d305f72
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 11, 2024
6dd1149
update
pambecker Oct 11, 2024
71165cd
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 15, 2024
81e6332
Merge remote-tracking branch 'origin/B-21077-Move-Shipment-Button-MAI…
pambecker Oct 17, 2024
b65c621
button alignment, css changes
pambecker Oct 17, 2024
82ba4ea
Merge branch 'B-21077-Move-Shipment-Button-MAIN' into B-20473-Office-…
pambecker Oct 18, 2024
8798f41
Merge branch 'B-21077-Move-Shipment-Button-MAIN' into B-20473-Office-…
pambecker Oct 18, 2024
7e5ab75
spelling updates, happo changes
pambecker Oct 18, 2024
e466457
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 21, 2024
dca783f
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 21, 2024
850a530
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 22, 2024
d4382f7
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 22, 2024
63e0a67
changes per peer review, not needed code
pambecker Oct 22, 2024
cda7294
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 23, 2024
a752a61
adding tests
pambecker Oct 23, 2024
54dba27
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 23, 2024
0b0a376
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 23, 2024
c3f1059
more tests
pambecker Oct 23, 2024
f39352c
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 23, 2024
836038e
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 28, 2024
b4b20cd
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 28, 2024
c79240d
test coverage
pambecker Oct 28, 2024
ceca886
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 28, 2024
6b801e6
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 29, 2024
2ddd9ac
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 29, 2024
fb9bb9f
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 30, 2024
f3e384a
Merge branch 'main' into B-20473-Office-user-cancel-move
pambecker Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions pkg/gen/ghcapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/gen/ghcapi/ghcoperations/move/search_moves.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/gen/ghcmessages/p_p_m_status.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/handlers/authentication/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var TOO = RolePermissions{
"update.closeoutOffice",
"update.MTOPage",
"create.TXOShipment",
"update.cancelMoveFlag",
},
}

Expand Down Expand Up @@ -86,6 +87,7 @@ var ServicesCounselor = RolePermissions{
"update.customer",
"update.closeoutOffice",
"view.closeoutOffice",
"update.cancelMoveFlag",
},
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/services/move/move_canceler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (f *moveCanceler) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID

if shipment.PPMShipment != nil {
if shipment.PPMShipment.Status == models.PPMShipmentStatusCloseoutComplete {
return apperror.NewConflictError(move.ID, " cannot cancel move with approved shipment.")
return apperror.NewConflictError(move.ID, " cannot cancel move with a closeout complete shipment.")
}
var ppmshipment models.PPMShipment
qerr := appCtx.DB().Where("id = ?", shipment.PPMShipment.ID).First(&ppmshipment)
Expand All @@ -55,9 +55,7 @@ func (f *moveCanceler) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID
} else if err != nil {
return apperror.NewQueryError("PPM Shipment", err, "Failed to update status for ppm shipment")
}
}

if shipment.Status != models.MTOShipmentStatusApproved {
} else if shipment.Status != models.MTOShipmentStatusApproved {
verrs, err := txnAppCtx.DB().ValidateAndUpdate(&shipmentDelta)
if verrs != nil && verrs.HasAny() {
return apperror.NewInvalidInputError(shipment.ID, err, verrs, "Validation errors found while setting shipment status")
Expand Down
19 changes: 19 additions & 0 deletions pkg/services/move/move_canceler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,23 @@ func (suite *MoveServiceSuite) TestMoveCanceler() {
_, err := moveCanceler.CancelMove(suite.AppContextForTest(), move.ID)
suite.Error(err)
})

suite.Run("fails to cancel move with close complete ppm shipment", func() {
move := factory.BuildMove(suite.DB(), nil, nil)

factory.BuildPPMShipment(suite.DB(), []factory.Customization{
{
Model: move,
LinkOnly: true,
},
{
Model: models.PPMShipment{
Status: models.PPMShipmentStatusCloseoutComplete,
},
},
}, nil)

_, err := moveCanceler.CancelMove(suite.AppContextForTest(), move.ID)
suite.Error(err)
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from '@trussworks/react-uswds';

import Modal, { ModalTitle, ModalClose, ModalActions, connectModal } from 'components/Modal/Modal';

export const CancelMoveConfirmationModal = ({ onClose, onSubmit, moveID, title, content, submitText, closeText }) => (
<Modal>
<ModalClose handleClick={() => onClose()} />
<ModalTitle>
<h3>{title}</h3>
</ModalTitle>
<p>{content}</p>
<ModalActions autofocus="true">
<Button data-focus="true" className="usa-button--destructive" type="submit" onClick={() => onSubmit(moveID)}>
{submitText}
</Button>
<Button className="usa-button--secondary" type="button" onClick={() => onClose()} data-testid="modalBackButton">
{closeText}
</Button>
</ModalActions>
</Modal>
);

CancelMoveConfirmationModal.propTypes = {
onClose: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,

title: PropTypes.string,
content: PropTypes.string,
submitText: PropTypes.string,
closeText: PropTypes.string,
};

CancelMoveConfirmationModal.defaultProps = {
title: 'Are you sure?',
content:
'You’ll lose all the information in this move. If you want it back later, you’ll have to request a new move.',
submitText: 'Cancel move',
closeText: 'Keep move',
};

CancelMoveConfirmationModal.displayName = 'CancelMoveConfirmationModal';

export default connectModal(CancelMoveConfirmationModal);
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';

import CancelMoveConfirmationModal from './CancelMoveConfirmationModal';

export default {
title: 'Components/CancelMoveConfirmationModal',
component: CancelMoveConfirmationModal,
args: {
moveID: '111',
},
argTypes: {
onClose: { action: 'close button clicked' },
onSubmit: { action: 'submit button clicked' },
},
};

const Template = (args) => <CancelMoveConfirmationModal {...args} />;

export const Basic = Template.bind({});

export const WithOverrides = Template.bind({});
WithOverrides.args = {
title: 'This is a sample title',
content: 'Some sample description',
submitText: 'YES!',
closeText: 'NO',
};

const ConnectedTemplate = (args) => <CancelMoveConfirmationModal {...args} />;
export const ConnectedModal = ConnectedTemplate.bind({});
ConnectedModal.args = {
isOpen: true,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import { CancelMoveConfirmationModal } from 'components/ConfirmationModals/CancelMoveConfirmationModal';

let onClose;
let onSubmit;
beforeEach(() => {
onClose = jest.fn();
onSubmit = jest.fn();
});

describe('CancelMoveConfirmationModal', () => {
const moveID = '123456';

it('renders the component', async () => {
render(<CancelMoveConfirmationModal onSubmit={onSubmit} onClose={onClose} moveID={moveID} />);

expect(await screen.findByRole('heading', { level: 3, name: 'Are you sure?' })).toBeInTheDocument();
});

it('closes the modal when close icon is clicked', async () => {
render(<CancelMoveConfirmationModal onSubmit={onSubmit} onClose={onClose} shipmentID={moveID} />);

const closeButton = await screen.findByTestId('modalCloseButton');

await userEvent.click(closeButton);

expect(onClose).toHaveBeenCalledTimes(1);
});

it('closes the modal when the keep button is clicked', async () => {
render(<CancelMoveConfirmationModal onSubmit={onSubmit} onClose={onClose} moveID={moveID} />);

const keepButton = await screen.findByRole('button', { name: 'Keep move' });

await userEvent.click(keepButton);

expect(onClose).toHaveBeenCalledTimes(1);
});

it('calls the submit function when cancel button is clicked', async () => {
render(<CancelMoveConfirmationModal onSubmit={onSubmit} onClose={onClose} moveID={moveID} />);

const cancelButton = await screen.findByRole('button', { name: 'Cancel move' });

await userEvent.click(cancelButton);

expect(onSubmit).toHaveBeenCalledWith(moveID);
expect(onSubmit).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const EvaluationReportShipmentDisplay = ({
<label id={`shipment-display-label-${shipmentId}`}>{displayInfo.heading}</label>
</h5>
{displayInfo.isDiversion && <Tag>diversion</Tag>}
{displayInfo.shipmentStatus === shipmentStatuses.CANCELED && <Tag className="usa-tag--red">cancelled</Tag>}
{displayInfo.shipmentStatus === shipmentStatuses.CANCELED && <Tag className="usa-tag--red">canceled</Tag>}
{displayInfo.shipmentStatus === shipmentStatuses.DIVERSION_REQUESTED && <Tag>diversion requested</Tag>}
{displayInfo.shipmentStatus === shipmentStatuses.CANCELLATION_REQUESTED && (
<Tag>cancellation requested</Tag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
hhgInfo,
ntsInfo,
ntsReleaseInfo,
canceledInfo,
ordersLOA,
ppmInfo,
} from 'components/Office/ShipmentDisplay/ShipmentDisplayTestData';
Expand All @@ -25,6 +26,12 @@ describe('Evaluation report - HHG Shipment', () => {
expect(screen.getByTestId('shipment-display')).toHaveTextContent('HHG');
expect(screen.getByTestId('ShipmentContainer')).toHaveTextContent('EVLRPT-01');
});
it('renders with canceled tag', () => {
render(
<EvaluationReportShipmentDisplay shipmentId="1" displayInfo={canceledInfo} onChange={jest.fn()} isSubmitted />,
);
expect(screen.getByText('canceled')).toBeInTheDocument();
});
});

describe('Evaluation report - NTS Shipment', () => {
Expand All @@ -41,6 +48,12 @@ describe('Evaluation report - NTS Shipment', () => {
expect(screen.getByTestId('shipment-display')).toHaveTextContent('NTS');
expect(screen.getByTestId('ShipmentContainer')).toHaveTextContent('EVLRPT-02');
});
it('renders with canceled tag', () => {
render(
<EvaluationReportShipmentDisplay shipmentId="1" displayInfo={canceledInfo} onChange={jest.fn()} isSubmitted />,
);
expect(screen.getByText('canceled')).toBeInTheDocument();
});
});

describe('Evaluation report - NTSR Shipment', () => {
Expand All @@ -56,6 +69,12 @@ describe('Evaluation report - NTSR Shipment', () => {
);
expect(screen.getByTestId('shipment-display')).toHaveTextContent('NTS-release');
});
it('renders with canceled tag', () => {
render(
<EvaluationReportShipmentDisplay shipmentId="1" displayInfo={canceledInfo} onChange={jest.fn()} isSubmitted />,
);
expect(screen.getByText('canceled')).toBeInTheDocument();
});
});

describe('Evaluation report - PPM Shipment', () => {
Expand All @@ -72,4 +91,10 @@ describe('Evaluation report - PPM Shipment', () => {
expect(screen.getByTestId('shipment-display')).toHaveTextContent('PPM');
expect(screen.getByTestId('ShipmentContainer')).toHaveTextContent('EVLRPT-03');
});
it('renders with canceled tag', () => {
render(
<EvaluationReportShipmentDisplay shipmentId="1" displayInfo={canceledInfo} onChange={jest.fn()} isSubmitted />,
);
expect(screen.getByText('canceled')).toBeInTheDocument();
});
});
6 changes: 4 additions & 2 deletions src/components/Office/ShipmentDisplay/ShipmentDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ const ShipmentDisplay = ({
</h3>
<div>
{displayInfo.isDiversion && <Tag>diversion</Tag>}
{displayInfo.shipmentStatus === shipmentStatuses.CANCELED && (
<Tag className="usa-tag--red">cancelled</Tag>
{(displayInfo.shipmentStatus === shipmentStatuses.CANCELED ||
displayInfo.status === shipmentStatuses.CANCELED ||
displayInfo.ppmShipment?.status === ppmShipmentStatuses.CANCELED) && (
<Tag className="usa-tag--red">canceled</Tag>
)}
{displayInfo.shipmentStatus === shipmentStatuses.DIVERSION_REQUESTED && <Tag>diversion requested</Tag>}
{displayInfo.shipmentStatus === shipmentStatuses.CANCELLATION_REQUESTED && (
Expand Down
Loading
Loading