-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f585154
commit d06e4e3
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
describe('Multiple Choice Question', function () { | ||
beforeEach(function () { | ||
cy.getData() | ||
cy.visit('/'); | ||
}); | ||
|
||
it('should display the mcq component', function () { | ||
const mcqComponents = this.data.components.filter((component) => component._component === 'mcq') | ||
mcqComponents.forEach((mcqComponent) => { | ||
cy.visit(`/#/preview/${mcqComponent._id}`); | ||
const bodyWithoutHtml = mcqComponent.body.replace(/<[^>]*>/g, ''); | ||
|
||
cy.testQuestionButtons() | ||
cy.testContainsOrNotExists('.mcq__title', mcqComponent.displayTitle) | ||
cy.testContainsOrNotExists('.mcq__body', bodyWithoutHtml) | ||
cy.testContainsOrNotExists('.mcq__instruction', mcqComponent.instruction) | ||
cy.get('.mcq-item').should('have.length', mcqComponent._items.length) | ||
mcqComponent._items.forEach((item) => { | ||
cy.testContainsOrNotExists('.mcq-item__text', item.text) | ||
}) | ||
|
||
// Make sure the current component is tested before moving to the next one | ||
// Custom cypress tests are async so we need to wait for them to pass first | ||
cy.wait(1000) | ||
}); | ||
}); | ||
}); |