From 1422bf241d6db80fdb592bc77f3f1fd3892f975b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maia=20T=C3=B8mmerbakk?= Date: Thu, 28 Oct 2021 15:28:12 +0200 Subject: [PATCH 1/2] Disable edit for completed actions --- frontend/src/components/Action/EditForm/ActionEditSidebar.tsx | 4 ++-- frontend/src/utils/disableComponents.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Action/EditForm/ActionEditSidebar.tsx b/frontend/src/components/Action/EditForm/ActionEditSidebar.tsx index 600b25e9..e24d7cbe 100644 --- a/frontend/src/components/Action/EditForm/ActionEditSidebar.tsx +++ b/frontend/src/components/Action/EditForm/ActionEditSidebar.tsx @@ -137,7 +137,7 @@ const ActionEditSidebar = ({ isClosingRemarkSaved={isClosingRemarkSaved} apiErrorClosingRemark={apiErrorClosingRemark} apiErrorAction={apiErrorAction} - disableEditAction={disableActionEdit(isEditingFromDashboard, participant, action.isVoided)} + disableEditAction={disableActionEdit(isEditingFromDashboard, participant, action)} /> {apiErrorAction && (
@@ -153,7 +153,7 @@ const ActionEditSidebar = ({ text={note} onChange={onChangeNote} onCreateClick={onCreateNote} - disabled={isNoteSaving || disableActionEdit(isEditingFromDashboard, participant, action.isVoided)} + disabled={isNoteSaving || disableActionEdit(isEditingFromDashboard, participant, action)} />
diff --git a/frontend/src/utils/disableComponents.ts b/frontend/src/utils/disableComponents.ts index 6c138da9..34387311 100644 --- a/frontend/src/utils/disableComponents.ts +++ b/frontend/src/utils/disableComponents.ts @@ -8,8 +8,8 @@ import { participantCanProgressEvaluation, } from './RoleBasedAccess' -export const disableActionEdit = (isEditingFromDashboard: boolean, participant: Participant | undefined, isVoided: boolean) => { - if (isVoided) { +export const disableActionEdit = (isEditingFromDashboard: boolean, participant: Participant | undefined, action: Action) => { + if (action.isVoided || action.completed) { return true } if (isEditingFromDashboard) { From f2d5dde762e2d9706807730f2ecef58adb407da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maia=20T=C3=B8mmerbakk?= Date: Fri, 29 Oct 2021 11:16:20 +0200 Subject: [PATCH 2/2] Add Cypress test completed action is not editable --- frontend/cypress/integration/actions_spec.ts | 19 +++++++++++++++++++ frontend/cypress/page_objects/action.ts | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/frontend/cypress/integration/actions_spec.ts b/frontend/cypress/integration/actions_spec.ts index 337f896d..7fde4a53 100644 --- a/frontend/cypress/integration/actions_spec.ts +++ b/frontend/cypress/integration/actions_spec.ts @@ -313,6 +313,25 @@ describe('Actions management', () => { }, fusionProject1.id) }) + it(`Complete action by ${roleThatCanComplete} on ${randomProgression} + then verify that completed action is not editable`, () => { + let user = seed.findParticipantByRole(roleThatCanComplete).user + cy.visitProgression(randomProgression, seed.evaluationId, user, fusionProject1.id) + ;({ actionNotes, action } = findActionWithNotes(seed)) + ;({ updatedAction, newNote } = createCompleteAction(user, action)) + + actionsGrid.actionLink(action.questionOrder, action.title).click() + + editActionDialog.assertCompletedInView(action.completed) + + editActionDialog.completeActionButton().click() + editActionDialog.assertCompleteConfirmViewVisible(true) + editActionDialog.completedReasonInput().replace(newNote.text) + editActionDialog.completeActionConfirmButton().click() + + editActionDialog.assertEditActionDisabled(seed) + }) + it(`Cancel complete action by ${roleThatCanComplete} on ${randomProgression} then verify action was not completed`, () => { cy.visitProgression( diff --git a/frontend/cypress/page_objects/action.ts b/frontend/cypress/page_objects/action.ts index f172f2f2..778417ca 100644 --- a/frontend/cypress/page_objects/action.ts +++ b/frontend/cypress/page_objects/action.ts @@ -3,6 +3,7 @@ import { Action, Note } from '../support/testsetup/mocks' import { FUSION_DATE_LOCALE } from '../support/helpers/helpers' import { Priority } from '../../src/api/models' import { SavingState } from '../../src/utils/Variables' +import { EvaluationSeed } from '../support/testsetup/evaluation_seed' /** * List of actions under every question @@ -200,6 +201,24 @@ export class EditActionDialog extends ActionDialog { this.completeActionConfirmButton().should(completeViewOpen ? 'be.visible' : 'not.exist') this.completeActionCancelButton().should(completeViewOpen ? 'be.visible' : 'not.exist') } + + /** + * Check that an action is not editable + * @param seed + */ + assertEditActionDisabled = (seed: EvaluationSeed) => { + this.titleInput().should('be.disabled') + this.assignedToInput().click() + const participantList = seed.participants.map(p => { return p.user.name }) + participantList.forEach(participantName => { + cy.get('section').contains(participantName).should('be.disabled') + }) + this.dueDateInput().should('be.disabled') + this.priorityInput().children().eq(0).children().eq(0).should('have.class', 'fc--Select__disabled--TZzty') + this.descriptionInput().should('be.disabled') + this.notesInput().should('be.disabled') + this.addNoteButton().should('be.disabled') + } } /**