Skip to content

Commit

Permalink
test: Fix organisation survey spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Veikkosuhonen committed Mar 11, 2024
1 parent 0eae9f9 commit 98817dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/interimFeedback.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describe('Students', () => {
cy.loginAs(student)
})

it.only('can view ongoing interim feedbacks and give interim feedback', () => {
it('can view ongoing interim feedbacks and give interim feedback', () => {
cy.visit(`/feedbacks`)

cy.get('[data-cy="my-feedbacks-waiting-tab"]').should('exist').click()
Expand Down
7 changes: 1 addition & 6 deletions cypress/integration/organisationSurvey.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ describe('Students', () => {
cy.loginAs(studentHenri)
})

it.only('can view ongoing organisation surveys and give organisation survey feedback', () => {
it('can view ongoing organisation surveys and give organisation survey feedback', () => {
cy.visit(`/feedbacks`)

cy.get('@organisationSurvey').then(organisationSurvey => {
Expand All @@ -689,12 +689,7 @@ describe('Students', () => {
cy.contains('Feedback has been given. Thank you for your feedback!')

// New tabs are rendered when feedback was given
cy.get('[data-cy="feedback-target-edit-feedback-tab"]').should('exist')
cy.get('[data-cy="feedback-target-results-tab"]').should('exist').click()
cy.get('[data-cy="feedback-target-results-thank-you"]').should('exist')
cy.get('[data-cy="feedback-target-results-feedback-chart"]').should('exist')
cy.get('[data-cy="feedback-target-results-multiple-choice-questions-0"]').should('exist')
cy.get('[data-cy="feedback-target-results-open-questions-0"]').should('exist')

cy.url().should('include', '/results')

Expand Down
10 changes: 9 additions & 1 deletion src/server/routes/organisations/util.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
const { Organisation } = require('../../models')
const { ApplicationError } = require('../../util/customErrors')

const getAccessAndOrganisation = async (user, code, requiredAccess) => {
const organisationAccess = await user.getOrganisationAccess()

const { access, organisation } = organisationAccess.find(({ organisation }) => organisation.code === code) ?? {}
const { access, organisation: organisationByAccess } =
organisationAccess.find(({ organisation }) => organisation.code === code) ?? {}
// eslint-disable-next-line no-nested-ternary
const organisation = organisationByAccess
? organisationAccess
: user.isAdmin
? await Organisation.findOne({ where: { code } })
: null

const hasReadAccess = user.isAdmin || Boolean(access?.read)
const hasWriteAccess = user.isAdmin || Boolean(access?.write)
Expand Down

0 comments on commit 98817dc

Please sign in to comment.