Skip to content

Commit

Permalink
Chore: e2e tests on gmcq component (Issue/177) (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmyadams authored Apr 11, 2024
1 parent eeadd8f commit 7964cd7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/e2e/gmcq.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
describe('Graphic Multiple Choice Question', function () {
beforeEach(function () {
cy.getData();
cy.visit('/');
});

it('should display the gmcq component', function () {
const gmcqComponents = this.data.components.filter(component => component._component === 'gmcq');
gmcqComponents.forEach(gmcqComponent => {
cy.visit(`/#/preview/${gmcqComponent._id}`);
const stripHtml = cy.helpers.stripHtml;
cy.testContainsOrNotExists('.gmcq__body', stripHtml(gmcqComponent.body));
cy.testContainsOrNotExists('.gmcq__title', stripHtml(gmcqComponent.displayTitle));
cy.testContainsOrNotExists('.gmcq__instruction', stripHtml(gmcqComponent.instruction));

cy.get('.gmcq-item').should('have.length', gmcqComponent._items.length);
gmcqComponent._items.forEach(item => {
cy.testContainsOrNotExists('.gmcq-item__text', stripHtml(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);
});
});
});

0 comments on commit 7964cd7

Please sign in to comment.