Skip to content

Commit

Permalink
Chore: e2e tests on slider component (Issue/201) (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmyadams authored Apr 11, 2024
1 parent 1b5e1b1 commit 4e21470
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/e2e/slider.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
describe('Slider', function () {
beforeEach(function () {
cy.getData();
cy.visit('/');
});

it('should display the slider component', function () {
const sliderComponents = this.data.components.filter(component => component._component === 'slider');
sliderComponents.forEach(sliderComponent => {
cy.visit(`/#/preview/${sliderComponent._id}`);
const stripHtml = cy.helpers.stripHtml;
cy.testContainsOrNotExists('.slider__body', stripHtml(sliderComponent.body));
cy.testContainsOrNotExists('.slider__title', stripHtml(sliderComponent.displayTitle));
cy.testContainsOrNotExists('.slider__instruction', stripHtml(sliderComponent.instruction));

cy.get('.slider__number').should('contain', sliderComponent._scaleStart);
cy.get('.slider__number').should('contain', sliderComponent._scaleEnd);

// 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 4e21470

Please sign in to comment.