Skip to content

Commit

Permalink
chore(cypress): extend test suite to cover selection qestion usage in…
Browse files Browse the repository at this point in the history
… practice quizzes and microlearnings (#4445)
  • Loading branch information
sjschlapbach authored Jan 9, 2025
1 parent 619ad2d commit 697f216
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 19 deletions.
23 changes: 20 additions & 3 deletions cypress/cypress/e2e/D-questions-workflow.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,6 @@ describe('Create different types of elements (with and without sample solution)
cy.get(`[data-cy="element-item-${SETitle}"]`).contains(
messages.shared.READY.statusLabel
)

cy.get(`[data-cy="edit-question-${SETitle}"]`).click()
// TODO: check that preview of selection question is visible and correct
})

it('Verify that the correct content has been saved', () => {
Expand All @@ -1151,6 +1148,26 @@ describe('Create different types of elements (with and without sample solution)
cy.get('[data-cy="close-question-modal"]').click()
})

it('Verify that creation was successful and that preview is visible and correct', () => {
cy.get(`[data-cy="edit-question-${SETitle}"]`).click()
cy.get(`[data-cy="element-item-${SETitle}"]`).contains(SETitle)
cy.get(`[data-cy="element-item-${SETitle}"]`).contains(SEContent)

// check that inputs are available
for (let i = 1; i < SEInputs; i++) {
cy.get(`[data-cy="selection-1-field-${i + 1}"]`).should('exist')
}

// check that all options are available
cy.get('[data-cy="selection-1-field-1"]').click()
SESolutions.forEach((value) => {
cy.get(`[data-cy="select-answer-${value}"]`).contains(value)
})
SESolutionsNotChosen.forEach((value) => {
cy.get(`[data-cy="select-answer-${value}"]`).contains(value)
})
})

it('Check that all options of the answer collection can be edited', () => {
cy.loginLecturer()
cy.get('[data-cy="resources"]').click()
Expand Down
54 changes: 49 additions & 5 deletions cypress/cypress/e2e/G-microlearning-workflow.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ const FCQuestion = 'FC Question Micro'
const FCAnswer = 'FC Answer Micro'
const CTQuestionTitle = 'CT ' + uuid()
const CTQuestion = 'CT Question Micro'
const SEQuestion = 'SE Question ML'
const SEQuestionTitle = 'SE ' + uuid()
const SEQuestionInputs = 3
const SECollection = 'SE Collection ML'
const SECollectionDescription = 'SE Collection ML Description'
const SECollectionOptions = [
'SE ML Option 1',
'SE ML Option 2',
'SE ML Option 3',
'SE ML Option 4',
'SE ML Option 5',
]
const SECollectionSolutions = [0, 1, 3]

const runningMLNameOLD = 'Running microlearning OLD'
const runningMLDisplayNameOLD = runningMLNameOLD + ' (Display)'
Expand Down Expand Up @@ -131,6 +144,28 @@ describe('Different microlearning workflows', () => {
title: CTQuestionTitle,
content: CTQuestion,
})

// create answer collection
cy.get('[data-cy="resources"]').click()
cy.createAnswerCollection({
name: SECollection,
description: SECollectionDescription,
entries: SECollectionOptions,
access: messages.manage.resources.accessPRIVATE,
accessCy: 'private',
})

// create selection question
cy.get('[data-cy="library"]').click()
cy.createQuestionSE({
title: SEQuestionTitle,
content: SEQuestion,
numberOfInputs: SEQuestionInputs,
collectionName: SECollection,
correctAnswers: SECollectionOptions.filter((_, i) =>
SECollectionSolutions.includes(i)
),
})
})

// ! Part 1: Microlearning Creation
Expand Down Expand Up @@ -207,7 +242,6 @@ describe('Different microlearning workflows', () => {
cy.get('[data-cy="next-or-submit"]').should('not.be.disabled')

// add displayname and description to stacks

cy.get('[data-cy="open-stack-0-description"]').realClick()
cy.get('[data-cy="stack-0-displayname"]').click().type(stackTitle1OLD)
cy.get('[data-cy="stack-0-displayname"]').should(
Expand Down Expand Up @@ -526,6 +560,7 @@ describe('Different microlearning workflows', () => {
KPRIMQuestionTitle,
NRQuestionTitle,
FTQuestionTitle,
SEQuestionTitle,
FCQuestionTitle,
CTQuestionTitle,
],
Expand Down Expand Up @@ -887,10 +922,19 @@ describe('Different microlearning workflows', () => {
cy.get('[data-cy="toggle-kp-3-answer-4-correct"]').click()
cy.get('[data-cy="input-numerical-4"]').clear().type('0.55')
cy.get('[data-cy="free-text-input-5"]').type('Testinput')
cy.get('[data-cy="flashcard-front-6"]').click()
cy.get('[data-cy="flashcard-response-6-No"]').click()
cy.get('[data-cy="flashcard-response-6-Yes"]').click()
cy.get('[data-cy="read-content-element-7"]').click()
cy.get('[data-cy="selection-6-field-1"]').click()
cy.get(`[data-cy="select-answer-${SECollectionOptions[0]}"]`).click()
cy.get('[data-cy="selection-6-field-1"]').contains(SECollectionOptions[0])
cy.get('[data-cy="selection-6-field-2"]').click()
cy.get(`[data-cy="select-answer-${SECollectionOptions[1]}"]`).click()
cy.get('[data-cy="selection-6-field-2"]').contains(SECollectionOptions[1])
cy.get('[data-cy="selection-6-field-3"]').click()
cy.get(`[data-cy="select-answer-${SECollectionOptions[2]}"]`).click()
cy.get('[data-cy="selection-6-field-3"]').contains(SECollectionOptions[2])
cy.get('[data-cy="flashcard-front-7"]').click()
cy.get('[data-cy="flashcard-response-7-No"]').click()
cy.get('[data-cy="flashcard-response-7-Yes"]').click()
cy.get('[data-cy="read-content-element-8"]').click()
cy.get('[data-cy="student-stack-submit"]').should('not.be.disabled')

// test inputs to MC question (2)
Expand Down
82 changes: 75 additions & 7 deletions cypress/cypress/e2e/H-practice-quiz-workflow.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ const FCQuestion = 'FC Question PQ'
const FCAnswer = 'FC Answer PQ'
const CTQuestionTitle = 'CT ' + uuid()
const CTQuestion = 'CT Question PQ'
const SEQuestion = 'SE Question PQ'
const SEQuestionTitle = 'SE ' + uuid()
const SEQuestionInputs = 3
const SECollection = 'SE Collection PQ'
const SECollectionDescription = 'SE Collection PQ Description'
const SECollectionOptions = [
'SE PQ Option 1',
'SE PQ Option 2',
'SE PQ Option 3',
'SE PQ Option 4',
'SE PQ Option 5',
]
const SECollectionSolutions = [0, 1, 2, 4]

const runningNameOLD = 'Running Practice Quiz OLD'
const runningDisplayNameOLD = 'Running Practice Quiz OLD (Display)'
Expand Down Expand Up @@ -117,6 +130,28 @@ describe('Different practice quiz workflows', () => {
title: CTQuestionTitle,
content: CTQuestion,
})

// create answer collection
cy.get('[data-cy="resources"]').click()
cy.createAnswerCollection({
name: SECollection,
description: SECollectionDescription,
entries: SECollectionOptions,
access: messages.manage.resources.accessPRIVATE,
accessCy: 'private',
})

// create selection question
cy.get('[data-cy="library"]').click()
cy.createQuestionSE({
title: SEQuestionTitle,
content: SEQuestion,
numberOfInputs: SEQuestionInputs,
collectionName: SECollection,
correctAnswers: SECollectionOptions.filter((_, i) =>
SECollectionSolutions.includes(i)
),
})
})

// ! Part 1: Practice Quiz Creation
Expand Down Expand Up @@ -190,6 +225,7 @@ describe('Different practice quiz workflows', () => {
{ elements: [KPRIMQuestionTitle] },
{ elements: [NRQuestionTitle] },
{ elements: [FTQuestionTitle] },
{ elements: [SEQuestionTitle] },
{ elements: [FCQuestionTitle] },
{ elements: [CTQuestionTitle] },
],
Expand Down Expand Up @@ -296,9 +332,12 @@ describe('Different practice quiz workflows', () => {
FTQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-5"]').contains(
FCQuestionTitle.substring(0, 20)
SEQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-6"]').contains(
FCQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-7"]').contains(
CTQuestionTitle.substring(0, 20)
)

Expand All @@ -309,10 +348,10 @@ describe('Different practice quiz workflows', () => {
.trigger('dragstart', {
dataTransfer,
})
cy.get('[data-cy="drop-elements-stack-7"]').trigger('drop', {
cy.get('[data-cy="drop-elements-stack-8"]').trigger('drop', {
dataTransfer,
})
cy.get('[data-cy="element-0-stack-7"]').contains(
cy.get('[data-cy="element-0-stack-8"]').contains(
SCQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="next-or-submit"]').click()
Expand Down Expand Up @@ -380,12 +419,15 @@ describe('Different practice quiz workflows', () => {
FTQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-5"]').contains(
FCQuestionTitle.substring(0, 20)
SEQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-6"]').contains(
CTQuestionTitle.substring(0, 20)
FCQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-7"]').contains(
CTQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-8"]').contains(
SCQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="next-or-submit"]').click()
Expand Down Expand Up @@ -459,12 +501,15 @@ describe('Different practice quiz workflows', () => {
FTQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-5"]').contains(
FCQuestionTitle.substring(0, 20)
SEQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-6"]').contains(
CTQuestionTitle.substring(0, 20)
FCQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-7"]').contains(
CTQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="element-0-stack-8"]').contains(
SCQuestionTitle.substring(0, 20)
)
cy.get('[data-cy="next-or-submit"]').click()
Expand All @@ -490,6 +535,7 @@ describe('Different practice quiz workflows', () => {
cy.get('[data-cy="start-practice-quiz"]').click()

// SC question
cy.findByText(SCQuestion).should('exist')
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="sc-1-answer-option-2"]').click()
cy.get('[data-cy="student-stack-submit"]').should('not.be.disabled')
Expand All @@ -499,6 +545,7 @@ describe('Different practice quiz workflows', () => {
cy.get('[data-cy="student-stack-continue"]').click()

// MC question
cy.findByText(MCQuestion).should('exist')
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="mc-1-answer-option-2"]').click()
cy.get('[data-cy="student-stack-submit"]').should('not.be.disabled')
Expand All @@ -510,6 +557,7 @@ describe('Different practice quiz workflows', () => {
cy.get('[data-cy="student-stack-continue"]').click()

// KPRIM question
cy.findByText(KPRIMQuestion).should('exist')
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="toggle-kp-1-answer-1-correct"]').click()
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
Expand All @@ -523,6 +571,7 @@ describe('Different practice quiz workflows', () => {
cy.get('[data-cy="student-stack-continue"]').click()

// NR question
cy.findByText(NRQuestion).should('exist')
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="input-numerical-1"]').clear().type('-20')
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
Expand All @@ -536,6 +585,7 @@ describe('Different practice quiz workflows', () => {
cy.get('[data-cy="student-stack-continue"]').click()

// FT question
cy.findByText(FTQuestion).should('exist')
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="free-text-input-1"]').type('Testinput')
cy.get('[data-cy="student-stack-submit"]').should('not.be.disabled')
Expand All @@ -545,6 +595,20 @@ describe('Different practice quiz workflows', () => {
cy.get('[data-cy="student-stack-submit"]').click()
cy.get('[data-cy="student-stack-continue"]').click()

// SE QUESTION
cy.findByText(SEQuestion).should('exist')
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="selection-1-field-1"]').click()
cy.get(`[data-cy="select-answer-${SECollectionOptions[0]}"]`).click()
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="selection-1-field-2"]').click()
cy.get(`[data-cy="select-answer-${SECollectionOptions[1]}"]`).click()
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="selection-1-field-3"]').click()
cy.get(`[data-cy="select-answer-${SECollectionOptions[3]}"]`).click()
cy.get('[data-cy="student-stack-submit"]').click()
cy.get('[data-cy="student-stack-continue"]').click()

// skip back and forth
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="practice-quiz-progress-3"]').click()
Expand All @@ -559,14 +623,17 @@ describe('Different practice quiz workflows', () => {
cy.get('[data-cy="student-stack-continue"]').click()
cy.get('[data-cy="student-stack-continue"]').click()
cy.get('[data-cy="student-stack-continue"]').click()
cy.get('[data-cy="student-stack-continue"]').click()

// Flashcard
cy.findByText(FCQuestion).should('exist')
cy.get('[data-cy="flashcard-front-1"]').click()
cy.get('[data-cy="flashcard-response-1-No"]').click()
cy.get('[data-cy="flashcard-response-1-Yes"]').click()
cy.get('[data-cy="student-stack-submit"]').click()

// Content
cy.findByText(CTQuestion).should('exist')
cy.get('[data-cy="read-content-element-1"]').should('exist')
cy.get('[data-cy="practice-quiz-mark-all-as-read"]')
.contains(messages.pwa.practiceQuiz.markAllAsRead)
Expand All @@ -576,6 +643,7 @@ describe('Different practice quiz workflows', () => {
.click()

// SC question
cy.findByText(SCQuestion).should('exist')
cy.get('[data-cy="student-stack-submit"]').should('be.disabled')
cy.get('[data-cy="sc-1-answer-option-2"]').click()
cy.get('[data-cy="student-stack-submit"]').should('not.be.disabled')
Expand Down
Loading

0 comments on commit 697f216

Please sign in to comment.