Skip to content

Commit

Permalink
Fix: e2e tests on graphic component (fixes #95) (#97)
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 /
  • Loading branch information
lemmyadams authored Mar 11, 2024
1 parent 3ed8b8c commit 7f3f900
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/e2e/graphic.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
describe('Graphic', function () {
beforeEach(function () {
cy.getData()
});

it('should display the graphic component', function () {
const graphicComponents = this.data.components.filter((component) => component._component === 'graphic')
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)
if(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)
}

// 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 7f3f900

Please sign in to comment.