test testimonial card spacing

This commit is contained in:
Yisroel Baum 2026-06-06 22:42:55 +03:00
parent 87012bc236
commit fa70a4a1b7
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -227,6 +227,64 @@ describe('homepage testimonials carousel', () => {
})
})
it('keeps desktop cards equal sized and separated', () => {
const expectedCardGap = 24
const expectedControlsGap = 12
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="testimonial-prev"]')
.parent()
.as('testimonialControls')
})
cy.get('@activeCard').then((activeCardElements) => {
const activeBounds = activeCardElements[0].getBoundingClientRect()
cy.get('@previousPreview').then((previousPreviewElements) => {
const previousBounds =
previousPreviewElements[0].getBoundingClientRect()
const previousGap = activeBounds.left - previousBounds.right
cy.wrap(previousBounds.height).should(
'be.closeTo',
activeBounds.height,
1,
)
cy.wrap(previousGap).should('be.closeTo', expectedCardGap, 1)
})
cy.get('@nextPreview').then((nextPreviewElements) => {
const nextBounds = nextPreviewElements[0].getBoundingClientRect()
const nextGap = nextBounds.left - activeBounds.right
cy.wrap(nextBounds.height).should(
'be.closeTo',
activeBounds.height,
1,
)
cy.wrap(nextGap).should('be.closeTo', expectedCardGap, 1)
})
cy.get('@testimonialControls').then((testimonialControlsElements) => {
const controlsBounds =
testimonialControlsElements[0].getBoundingClientRect()
const controlsGap = controlsBounds.top - activeBounds.bottom
cy.wrap(controlsGap).should(
'be.closeTo',
expectedControlsGap,
1,
)
})
})
})
it('hides side previews on narrow screens', () => {
cy.viewport(390, 800)
cy.get('[data-cy="testimonials"]').within(() => {