Skip to content

Commit

Permalink
Chore: e2e tests on matching component (Issue/181) (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmyadams authored Apr 11, 2024
1 parent 6f59017 commit 34e299b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/e2e/matching.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
describe('Matching', function () {
beforeEach(function () {
cy.getData();
cy.visit('/');
});

it('should display the matching component', function () {
const matchingComponents = this.data.components.filter(component => component._component === 'matching');
matchingComponents.forEach(matchingComponent => {
cy.visit(`/#/preview/${matchingComponent._id}`);
const stripHtml = cy.helpers.stripHtml;
cy.testContainsOrNotExists('.matching__body', stripHtml(matchingComponent.body));
cy.testContainsOrNotExists('.matching__title', stripHtml(matchingComponent.displayTitle));
cy.testContainsOrNotExists('.matching__instruction', stripHtml(matchingComponent.instruction));

cy.get('.matching-item.item').should('have.length', matchingComponent._items.length);
matchingComponent._items.forEach((item, index) => {
cy.get('.matching-item.item ').eq(index).within(() => {
cy.get('button.dropdown__btn').click();
cy.get('li.dropdown-item').should('have.length', item._options.length);
cy.get('button.dropdown__btn').click();
});
});

// 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 34e299b

Please sign in to comment.