Skip to content

Commit

Permalink
Fix: Update tests to meet new standards (fixes #101) (#102)
Browse files Browse the repository at this point in the history
* Added graphic tests

* Improved graphic tests for new system [wip]

* Updated to use preview pages

* Comments

* Changed back to wait

* removed visit /

* Updated test

* moved out html
  • Loading branch information
lemmyadams authored Jun 18, 2024
1 parent 5c95298 commit be1af4c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/e2e/graphic.cy.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
describe('Graphic', function () {
beforeEach(function () {
cy.getData()
cy.getData();
});

it('should display the graphic component', function () {
const graphicComponents = this.data.components.filter((component) => component._component === 'graphic')
graphicComponents.forEach((graphicComponent) => {
const graphicComponents = this.data.components.filter(component => component._component === 'graphic');
const stripHtml = cy.helpers.stripHtml;
graphicComponents.forEach(graphicComponent => {
cy.visit(`/#/preview/${graphicComponent._id}`);
const bodyWithoutHtml = graphicComponent.body.replace(/<[^>]*>/g, '');

cy.testContainsOrNotExists('.graphic__title', graphicComponent.displayTitle)
cy.testContainsOrNotExists('.graphic__body', bodyWithoutHtml)

cy.testContainsOrNotExists('.graphic__body', stripHtml(graphicComponent.body));
cy.testContainsOrNotExists('.graphic__title', stripHtml(graphicComponent.displayTitle));
if(graphicComponent._graphic.large) {
cy.get('.graphic__image').should('have.attr', 'src', graphicComponent._graphic.large)
cy.get('.graphic__image').should('have.attr', 'src', graphicComponent._graphic.large);
} else if(graphicComponent._graphic.src) {
cy.get('.graphic__image').should('have.attr', 'src', graphicComponent._graphic.src)
}
cy.get('.graphic__image').should('have.attr', 'src', graphicComponent._graphic.src);
};

// 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)
cy.wait(1000);
});
});
});

0 comments on commit be1af4c

Please sign in to comment.