From fbb0787647af0630ad43de2c0c4140992ad0ffa9 Mon Sep 17 00:00:00 2001 From: R Ranathunga Date: Tue, 4 Jun 2024 15:33:43 -0700 Subject: [PATCH] chore: changes to pending change request --- .../PendingChangeRequest/PendingChangeRequest.tsx | 1 - .../PendingChangeRequestModal.tsx | 9 +++------ .../Analyst/PendingChangeRequest.test.tsx | 14 +++++++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/components/Analyst/PendingChangeRequest/PendingChangeRequest.tsx b/app/components/Analyst/PendingChangeRequest/PendingChangeRequest.tsx index 8a98b772d3..6caaff469e 100644 --- a/app/components/Analyst/PendingChangeRequest/PendingChangeRequest.tsx +++ b/app/components/Analyst/PendingChangeRequest/PendingChangeRequest.tsx @@ -160,7 +160,6 @@ const PendingChangeRequest = ({ application, isCbc = false }) => { }} value={isPending ? comment : null} onCancel={() => { - if (!isUpdateMode) handleChangePendingRequest(!isPending, comment); setIsUpdateMode(false); pendingChangeRequestModal.close(); }} diff --git a/app/components/Analyst/PendingChangeRequest/PendingChangeRequestModal.tsx b/app/components/Analyst/PendingChangeRequest/PendingChangeRequestModal.tsx index 8cc502599e..8ae0de4e90 100644 --- a/app/components/Analyst/PendingChangeRequest/PendingChangeRequestModal.tsx +++ b/app/components/Analyst/PendingChangeRequest/PendingChangeRequestModal.tsx @@ -38,17 +38,14 @@ const PendingChangeRequestModal: React.FC = ({ actions={[ { id: 'pending-request-change-save-btn', - label: 'Save comment', + label: 'Save', onClick: () => onSave(formData.comment), - disabled: value === formData?.comment, + disabled: value && value === formData?.comment, }, { id: 'pending-request-change-cancel-btn', label: 'Cancel', - onClick: () => { - setFormData({ comment: value }); - onCancel(); - }, + onClick: onCancel, variant: 'secondary', }, ]} diff --git a/app/tests/components/Analyst/PendingChangeRequest.test.tsx b/app/tests/components/Analyst/PendingChangeRequest.test.tsx index 9738d0eff5..dcad9fecc2 100644 --- a/app/tests/components/Analyst/PendingChangeRequest.test.tsx +++ b/app/tests/components/Analyst/PendingChangeRequest.test.tsx @@ -149,7 +149,7 @@ describe('The Pending Change Request component', () => { target: { value: 'Edited comment.' }, }); - const saveButton = screen.getByRole('button', { name: 'Save comment' }); + const saveButton = screen.getByRole('button', { name: 'Save' }); await act(async () => { fireEvent.click(saveButton); @@ -208,7 +208,7 @@ describe('The Pending Change Request component', () => { target: { value: 'Edited comment.' }, }); - const saveButton = screen.getByRole('button', { name: 'Save comment' }); + const saveButton = screen.getByRole('button', { name: 'Save' }); await act(async () => { fireEvent.click(saveButton); @@ -307,7 +307,7 @@ describe('The Pending Change Request component', () => { const saveButton = screen.getByTestId('pending-request-change-save-btn'); - expect(saveButton).toBeDisabled(); + expect(saveButton).toBeEnabled(); const cancelButton = screen.getByTestId( 'pending-request-change-cancel-btn' @@ -338,7 +338,7 @@ describe('The Pending Change Request component', () => { target: { value: 'This is a test comment.' }, }); - const saveButton = screen.getByRole('button', { name: 'Save comment' }); + const saveButton = screen.getByRole('button', { name: 'Save' }); await act(async () => { fireEvent.click(saveButton); @@ -356,7 +356,7 @@ describe('The Pending Change Request component', () => { ); }); - it('create pending change request comments are mandatory', async () => { + it('create pending change request comments are optional', async () => { componentTestingHelper.loadQuery(mockEmptyQueryPayload); componentTestingHelper.renderComponent(); @@ -372,7 +372,7 @@ describe('The Pending Change Request component', () => { screen.getByText('Comments on pending changes (optional)') ).toBeVisible(); - const cancelButton = screen.getByRole('button', { name: 'Cancel' }); + const cancelButton = screen.getByRole('button', { name: 'Save' }); await act(async () => { fireEvent.click(cancelButton); @@ -390,7 +390,7 @@ describe('The Pending Change Request component', () => { ); }); - it('pending change request comment edit close button handle modal close only', async () => { + it('pending change request close button handle modal close only', async () => { componentTestingHelper.loadQuery(); componentTestingHelper.renderComponent();