From 4c7598cf672aea71f37326ad538fe961fe846432 Mon Sep 17 00:00:00 2001 From: pradel Date: Mon, 9 Nov 2020 14:15:40 +0100 Subject: [PATCH] test scroll behavior --- cypress/integration/modal.spec.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cypress/integration/modal.spec.ts b/cypress/integration/modal.spec.ts index 63baaf06..5f7ab5b3 100644 --- a/cypress/integration/modal.spec.ts +++ b/cypress/integration/modal.spec.ts @@ -40,4 +40,29 @@ describe('simple modal', () => { cy.get('body').type('{esc}'); cy.get('[data-testid=modal]').should('not.exist'); }); + + it('should block the scroll when modal is opened', () => { + cy.get('button').eq(2).click(); + cy.get('html').should('have.css', 'position', 'fixed'); + }); + + it('should unblock the scroll when modal is closed', () => { + cy.get('button').eq(2).click(); + cy.get('html').should('have.css', 'position', 'fixed'); + cy.get('body').type('{esc}'); + cy.get('html').should('not.have.css', 'position', 'fixed'); + }); + + it('should unblock scroll only after last modal is closed when multiple modals are opened', () => { + cy.get('button').eq(8).click(); + cy.get('[data-testid=modal] button').eq(0).click(); + cy.get('[data-testid=modal]').should('have.length', 2); + cy.get('html').should('have.css', 'position', 'fixed'); + cy.get('body').type('{esc}'); + cy.get('[data-testid=modal]').should('have.length', 1); + cy.get('html').should('have.css', 'position', 'fixed'); + cy.get('body').type('{esc}'); + cy.get('[data-testid=modal]').should('not.exist'); + cy.get('html').should('not.have.css', 'position', 'fixed'); + }); });