From 824acaeb71c68fda3945ce723ed3f5833517a1af Mon Sep 17 00:00:00 2001 From: Will O'Beirne Date: Sat, 5 Mar 2022 00:20:42 -0600 Subject: [PATCH] Add cypress test for modalOverlayOpeningElement Also added getOpeningProperties function to modal class to easily verify in testing --- src/js/components/shepherd-modal.svelte | 1 + test/cypress/integration/modal.spec.js | 27 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/js/components/shepherd-modal.svelte b/src/js/components/shepherd-modal.svelte index ee95e58e31..77b51eda37 100644 --- a/src/js/components/shepherd-modal.svelte +++ b/src/js/components/shepherd-modal.svelte @@ -13,6 +13,7 @@ closeModalOpening(); export const getElement = () => element; + export const getOpeningProperties = () => openingProperties; export function closeModalOpening() { openingProperties = { diff --git a/test/cypress/integration/modal.spec.js b/test/cypress/integration/modal.spec.js index 0fe454c727..3f3117e81b 100644 --- a/test/cypress/integration/modal.spec.js +++ b/test/cypress/integration/modal.spec.js @@ -118,4 +118,31 @@ describe('Modal mode', () => { cy.get('.shepherd-modal-is-visible').should('have.length', 1); }); }); + + describe('Modal with separate selector', function() { + const steps = () => { + return [ + { + attachTo: { + element: '.hero-welcome', + on: 'bottom' + }, + modalOverlayOpeningElement: '.hero-welcome h1', + } + ]; + }; + + beforeEach(() => { + tour = setupTour(Shepherd, {}, steps, { + useModalOverlay: true + }); + }); + + it('has the modal target the separate selector element', function() { + tour.start(); + cy.get('.shepherd-modal-is-visible').should('have.length', 1); + const openingPropertyHeight = tour.modal.getOpeningProperties().height; + cy.get('.hero-welcome h1').invoke('outerHeight').should('eq', openingPropertyHeight); + }); + }); });