Skip to content

Commit

Permalink
Refactored close action tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petterwildhagen committed Sep 2, 2021
1 parent f013cd4 commit 9c88326
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 42 deletions.
51 changes: 12 additions & 39 deletions frontend/cypress/integration/actions_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ describe('Actions management', () => {

describe('Creating, Editing & Viewing Actions', () => {
beforeEach(() => {
seed = createSeedWithActions(users, {})
seed = createSeedWithActions(users, { completed: false })
seed.plant()
})
it('Action can be created', () => {
const creator = faker.random.arrayElement(users)
cy.visitEvaluation(seed.evaluationId, creator)
const createActionFrom = faker.random.arrayElement([Progression.Workshop, Progression.FollowUp])
evaluationPage.progressionStepLink(createActionFrom).click()
logInSomeRandomUser()
let actionTestData = createActionTestData(users)
actionsGrid.addActionButton(actionTestData.questionOrder).click()
createActionDialog.titleInput().type(actionTestData.title)
Expand Down Expand Up @@ -67,7 +64,7 @@ describe('Actions management', () => {
actionsGrid.actionLink(actionTestData.questionOrder, actionTestData.title).should('exist')
},
() => {
evaluationPage.progressionStepLink(createActionFrom).click()
evaluationPage.progressionStepLink(faker.random.arrayElement([Progression.Workshop, Progression.FollowUp])).click()
actionsGrid.actionLink(actionTestData.questionOrder, actionTestData.title).should('exist')
}
)
Expand All @@ -79,10 +76,7 @@ describe('Actions management', () => {
let newNotes: Note[]

it('Action can be edited', () => {
let user = faker.random.arrayElement(users)
cy.visitEvaluation(seed.evaluationId, user)
const actionProgression = faker.random.arrayElement([Progression.Workshop, Progression.FollowUp])
evaluationPage.progressionStepLink(actionProgression).click()
let user = logInSomeRandomUser()
;({ notesOfSomeAction, someAction } = findActionWithNotes(seed))
actionsGrid.actionLink(someAction.questionOrder, someAction.title).click()
editActionDialog.assertActionValues(someAction, notesOfSomeAction)
Expand All @@ -100,7 +94,7 @@ describe('Actions management', () => {
editActionDialog.assertSaved()
editActionDialog.close()
cy.testCacheAndDB(() => {
evaluationPage.progressionStepLink(actionProgression).click()
evaluationPage.progressionStepLink(faker.random.arrayElement([Progression.Workshop, Progression.FollowUp])).click()
actionsGrid.actionLink(someAction.questionOrder, updatedAction.title).click()
editActionDialog.assertActionValues(updatedAction, notesOfSomeAction.concat(newNotes))
})
Expand Down Expand Up @@ -210,28 +204,8 @@ describe('Actions management', () => {
})
})

// context('Complete action', () => {
// let seed: EvaluationSeed
// let editor: Participant
// let someAction: Action
// let notesOfSomeAction: Note[]
// let updatedAction: Action
let newNote: Note

// const actionProgression = faker.random.arrayElement([Progression.Workshop, Progression.FollowUp])

// beforeEach(() => {
// seed = createSeedWithActions(users, { completed: false })
// //existingAction, existingNotes
// editor = faker.random.arrayElement(seed.participants)
// //;({ updatedAction, newNote } = createCompleteActionData(editor, someAction))

// seed.plant().then(() => {
// cy.visitEvaluation(seed.evaluationId, editor.user)
// evaluationPage.progressionStepLink(actionProgression).click()
// })
// })

function checkView() {
editActionDialog.actionCompletedText().should('not.exist')
editActionDialog.completeActionButton().should('exist')
Expand Down Expand Up @@ -259,36 +233,35 @@ describe('Actions management', () => {
cy.testCacheAndDB(() => {
evaluationPage.progressionStepLink(faker.random.arrayElement([Progression.Workshop, Progression.FollowUp])).click()
actionsGrid.actionLink(oneAction.questionOrder, oneAction.title).click()
editActionDialog.assertActionValues(oneAction, notesInTheAction.concat([newNote]))
editActionDialog.assertActionValues(oneAction, notesInTheAction)
})
}

it.only('Action can be completed without writing a reason', () => {
it('Action can be completed without writing a reason', () => {
let user = logInSomeRandomUser(Progression.FollowUp)
;({ notesOfSomeAction, someAction } = findActionWithNotes(seed))
;({ updatedAction, newNote } = createCompleteActionData(user, someAction))
logInSomeRandomUser(Progression.FollowUp)
actionsGrid.actionLink(someAction.questionOrder, someAction.title).click()
checkView()
openConfirmCompleteView()
confirmAndCheckCompleted()
testCacheInReopenedActionView()
testCacheInReopenedActionView(updatedAction, notesOfSomeAction.concat(newNote))
})

it.only('Action can be completed with a reason', () => {
it('Action can be completed with a reason', () => {
let user = logInSomeRandomUser(Progression.FollowUp)
;({ notesOfSomeAction, someAction } = findActionWithNotes(seed))
;({ updatedAction, newNote } = createCompleteActionData(user, someAction))
logInSomeRandomUser(Progression.FollowUp)
actionsGrid.actionLink(someAction.questionOrder, someAction.title).click()
checkView()
openConfirmCompleteView()
editActionDialog.completedReasonInput().replace('Closed because of a good reason')
confirmAndCheckCompleted()
testCacheInReopenedActionView()
testCacheInReopenedActionView(updatedAction, notesOfSomeAction.concat(newNote))
})

it.only('Completing Action can be cancelled', () => {
it('Completing Action can be cancelled', () => {
logInSomeRandomUser(Progression.FollowUp)
;({ notesOfSomeAction, someAction } = findActionWithNotes(seed))
actionsGrid.actionLink(someAction.questionOrder, someAction.title).click()
checkView()
Expand Down
3 changes: 0 additions & 3 deletions frontend/cypress/support/mock/external/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,4 @@ Cypress.on('uncaught:exception', (err, runnable, promise) => {
if (err.message.includes("Cannot read properties of null (reading 'removeEventListener')")) {
return false
}
if (err.message.includes("Cannot read properties of null (reading 'removeEventListener')")) {
return false
}
})

0 comments on commit 9c88326

Please sign in to comment.