From 3c72cd296e8aea520e6d1361ae82d1d34c3d0871 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 6 Jun 2026 22:30:23 +0300 Subject: [PATCH] test testimonial previews --- frontend/rabbi_gerzi/cypress/e2e/home.cy.ts | 65 +++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/frontend/rabbi_gerzi/cypress/e2e/home.cy.ts b/frontend/rabbi_gerzi/cypress/e2e/home.cy.ts index 2e9e197..f82e17e 100644 --- a/frontend/rabbi_gerzi/cypress/e2e/home.cy.ts +++ b/frontend/rabbi_gerzi/cypress/e2e/home.cy.ts @@ -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"]')