Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: e2e tests on gmcq component (Issue/177) #178

Merged
merged 5 commits into from
Apr 11, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 bodyWithoutHtml = cy.helpers.stripHtml(gmcqComponent.body)
cy.testContainsOrNotExists('.gmcq__body', bodyWithoutHtml)

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