Skip to content

Commit feb7453

Browse files
authored
Chore: e2e tests on mcq component (Issue/218) (#219)
1 parent f585154 commit feb7453

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/e2e/mcq.cy.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
describe('Multiple Choice Question', function () {
2+
beforeEach(function () {
3+
cy.getData();
4+
cy.visit('/');
5+
});
6+
7+
it('should display the mcq component', function () {
8+
const mcqComponents = this.data.components.filter(component => component._component === 'mcq');
9+
mcqComponents.forEach(mcqComponent => {
10+
cy.visit(`/#/preview/${mcqComponent._id}`);
11+
const stripHtml = cy.helpers.stripHtml;
12+
cy.testContainsOrNotExists('.mcq__body', stripHtml(mcqComponent.body));
13+
cy.testContainsOrNotExists('.mcq__title', stripHtml(mcqComponent.displayTitle));
14+
cy.testContainsOrNotExists('.mcq__instruction', stripHtml(mcqComponent.instruction));
15+
16+
cy.get('.mcq-item').should('have.length', mcqComponent._items.length);
17+
mcqComponent._items.forEach(item => {
18+
cy.testContainsOrNotExists('.mcq-item__text', stripHtml(item.text));
19+
});
20+
21+
// Make sure the current component is tested before moving to the next one
22+
// Custom cypress tests are async so we need to wait for them to pass first
23+
cy.wait(1000);
24+
});
25+
});
26+
});

0 commit comments

Comments
 (0)