Skip to content

Commit

Permalink
Catch exception are not allowed on this operation in delete action test
Browse files Browse the repository at this point in the history
  • Loading branch information
petterwildhagen committed Sep 9, 2021
1 parent cc6c4d8 commit a0c97f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
10 changes: 9 additions & 1 deletion frontend/cypress/integration/actions_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('Actions management', () => {
if (participant === undefined) {
throw 'No user with role ' + role + ' found'
}
cy.log('Logging in the ' + participant.role)
cy.visitEvaluation(seed.evaluationId, participant.user)
evaluationPage.progressionStepLink(progression).click()
return participant.user
Expand Down Expand Up @@ -175,6 +174,15 @@ describe('Actions management', () => {
]
roles.forEach(r => {
it(`${r.role} delete button exists = ${r.deleteButtonExists} can delete action = ${r.canDeleteAction}`, () => {
if (r.role === Role.Participant || r.role === Role.OrganizationLead) {
cy.on('uncaught:exception', (err, runnable) => {
if (err.message.includes('are not allowed to perform this operation')) {
console.log("Swallowing unhandled 'are not allowed to perform this operation'")
return false
}
})
}

logInUser(r.role)
const { actionToDelete, actionToStay } = getActionToDeleteActionToStay()
if (!r.deleteButtonExists) {
Expand Down
12 changes: 0 additions & 12 deletions frontend/cypress/support/mock/external/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ Cypress.on('uncaught:exception', (err, runnable, promise) => {
return false
}

if (message.includes('are not allowed to perform this operation')) {
console.log(
`Swallowing unhandled "are not allowed to perform this operation" promise:\n\n%c${err.message}\n`,
'padding-left: 30px;'
)
return false
}

/* But a certain number falls here */
const failingURLRegex = /\[(http.*?)\]/
const failingURLMatch = err.message.match(failingURLRegex)
Expand Down Expand Up @@ -140,8 +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("are not allowed to perform this operation')")) {
return false
}
})

0 comments on commit a0c97f1

Please sign in to comment.