test testimonial previews
This commit is contained in:
parent
f8942ba348
commit
3c72cd296e
1 changed files with 65 additions and 0 deletions
|
|
@ -162,6 +162,71 @@ describe('homepage testimonials carousel', () => {
|
|||
})
|
||||
})
|
||||
|
||||
it('shows faded half-card previews beside the active testimonial', () => {
|
||||
cy.viewport(1200, 800)
|
||||
cy.get('[data-cy="testimonials"]').within(() => {
|
||||
cy.get('[data-cy="testimonial-active"]').as('activeCard')
|
||||
cy.get('[data-cy="testimonial-previous-preview"]').as(
|
||||
'previousPreview',
|
||||
)
|
||||
cy.get('[data-cy="testimonial-next-preview"]').as('nextPreview')
|
||||
cy.get('[data-cy="testimonials-stage"]').as('testimonialStage')
|
||||
})
|
||||
|
||||
cy.get('@activeCard').should('be.visible')
|
||||
cy.get('@previousPreview').should('be.visible')
|
||||
cy.get('@nextPreview').should('be.visible')
|
||||
|
||||
cy.get('@activeCard').then((activeCardElements) => {
|
||||
const activeOpacity = Number(
|
||||
getComputedStyle(activeCardElements[0]).opacity,
|
||||
)
|
||||
|
||||
cy.get('@previousPreview').then((previousPreviewElements) => {
|
||||
const previousPreview = previousPreviewElements[0]
|
||||
const previousOpacity = Number(
|
||||
getComputedStyle(previousPreview).opacity,
|
||||
)
|
||||
|
||||
cy.wrap(previousOpacity).should('be.lessThan', activeOpacity)
|
||||
})
|
||||
|
||||
cy.get('@nextPreview').then((nextPreviewElements) => {
|
||||
const nextPreview = nextPreviewElements[0]
|
||||
const nextOpacity = Number(getComputedStyle(nextPreview).opacity)
|
||||
|
||||
cy.wrap(nextOpacity).should('be.lessThan', activeOpacity)
|
||||
})
|
||||
})
|
||||
|
||||
cy.get('@testimonialStage').then((testimonialStageElements) => {
|
||||
const stageBounds = testimonialStageElements[0].getBoundingClientRect()
|
||||
|
||||
cy.get('@previousPreview').then((previousPreviewElements) => {
|
||||
const previousBounds =
|
||||
previousPreviewElements[0].getBoundingClientRect()
|
||||
const previousVisibleWidth = previousBounds.right - stageBounds.left
|
||||
|
||||
cy.wrap(previousVisibleWidth).should(
|
||||
'be.closeTo',
|
||||
previousBounds.width / 2,
|
||||
1,
|
||||
)
|
||||
})
|
||||
|
||||
cy.get('@nextPreview').then((nextPreviewElements) => {
|
||||
const nextBounds = nextPreviewElements[0].getBoundingClientRect()
|
||||
const nextVisibleWidth = stageBounds.right - nextBounds.left
|
||||
|
||||
cy.wrap(nextVisibleWidth).should(
|
||||
'be.closeTo',
|
||||
nextBounds.width / 2,
|
||||
1,
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('advances to the next testimonial when next is clicked', () => {
|
||||
cy.get('[data-cy="testimonials"]').within(() => {
|
||||
cy.get('[data-cy="testimonial-active"]')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue