Skip to content

Commit

Permalink
Merge pull request #836 from maiaht/disable-edit-complete-action
Browse files Browse the repository at this point in the history
Disable edit for completed actions
  • Loading branch information
maiaht authored Oct 29, 2021
2 parents a1b133b + f2d5dde commit cb2875d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
19 changes: 19 additions & 0 deletions frontend/cypress/integration/actions_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 19 additions & 0 deletions frontend/cypress/page_objects/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Action/EditForm/ActionEditSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const ActionEditSidebar = ({
isClosingRemarkSaved={isClosingRemarkSaved}
apiErrorClosingRemark={apiErrorClosingRemark}
apiErrorAction={apiErrorAction}
disableEditAction={disableActionEdit(isEditingFromDashboard, participant, action.isVoided)}
disableEditAction={disableActionEdit(isEditingFromDashboard, participant, action)}
/>
{apiErrorAction && (
<div style={{ marginTop: 20 }}>
Expand All @@ -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)}
/>
<NotesAndClosingRemarksList notesAndClosingRemarks={notesAndClosingRemarks} participantsDetails={personDetailsList} />
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/disableComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit cb2875d

Please sign in to comment.