-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
5c95298
commit be1af4c
Showing
1 changed file
with
12 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |