Skip to content

Commit

Permalink
Ensure new question template number gets highest number of all questi…
Browse files Browse the repository at this point in the history
…on templates
  • Loading branch information
petterwildhagen committed Oct 20, 2021
1 parent 3516544 commit f124a07
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions frontend/cypress/integration/admin_page_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,37 @@ describe('Admin page', () => {
})
})

it('Add new question template, fill in title, support notes, select organization, verify question template is added', () => {
adminPage.createNewQuestion().click()
const title = 'title ' + generateRandomString(10)
adminPage.newQuestionTitle().type(title)
const supportNotes = 'supportNotes' + generateRandomString(20)
adminPage.setSupportNotes(supportNotes)
const organization = faker.random.arrayElement(Object.keys(Organization))
const dropdownSelect = new DropdownSelect()
dropdownSelect.select(cy.getByDataTestid(selectOrganizationDropdown).contains('Organization'), organization)
adminPage.saveQuestionButton().click()
cy.testCacheAndDB(() => {
goToAdminTab()
adminPage
.allQuestionNo()
.last()
.then(qn => {
const createdQuestionNo = parseInt(Cypress.$(qn).text().replace('.', ''))
adminPage.questionTitleByNo(createdQuestionNo).should('have.text', title)
adminPage.supportNotes(createdQuestionNo).should('contain.text', supportNotes)
adminPage.organization(createdQuestionNo).should('have.text', organization)
})
}, fusionProject1.id)
it(`Add new question template, fill in title, support notes, select organization,
verify question template is added at the bottom of the barrier
and question template has expected title, support notes and organization
and is assigned highest number across all question templates`, () => {
activeQuestionTemplates().then(questionTemplatesPreCopy => {
const numberOfQuestionTemplatesInitial = Cypress.$(questionTemplatesPreCopy).length
adminPage.createNewQuestion().click()
const title = 'title ' + generateRandomString(10)
adminPage.newQuestionTitle().type(title)
const supportNotes = 'supportNotes' + generateRandomString(20)
adminPage.setSupportNotes(supportNotes)
const organization = faker.random.arrayElement(Object.keys(Organization))
const dropdownSelect = new DropdownSelect()
dropdownSelect.select(cy.getByDataTestid(selectOrganizationDropdown).contains('Organization'), organization)
adminPage.saveQuestionButton().click()
cy.testCacheAndDB(() => {
goToAdminTab()
adminPage
.allQuestionNo()
.last()
.then(qn => {
const createdQuestionNo = parseInt(Cypress.$(qn).text().replace('.', ''))
expect(createdQuestionNo, ' new question is assigned globally highest number').to.equal(
numberOfQuestionTemplatesInitial + 1
)
adminPage.questionTitleByNo(createdQuestionNo).should('have.text', title)
adminPage.supportNotes(createdQuestionNo).should('contain.text', supportNotes)
adminPage.organization(createdQuestionNo).should('have.text', organization)
})
})
})
})

it('Cancel create new question template, verify question template is not added', () => {
Expand Down

0 comments on commit f124a07

Please sign in to comment.