Skip to content

Commit 3b1f4d5

Browse files
wbobeirnemonshan
authored andcommitted
Add cypress test for modalOverlayOpeningElement
Also added getOpeningProperties function to modal class to easily verify in testing
1 parent 1840400 commit 3b1f4d5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/js/components/shepherd-modal.svelte

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
closeModalOpening();
1414
1515
export const getElement = () => element;
16+
export const getOpeningProperties = () => openingProperties;
1617
1718
export function closeModalOpening() {
1819
openingProperties = {

test/cypress/integration/modal.cy.js

+27
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,31 @@ describe('Modal mode', () => {
118118
cy.get('.shepherd-modal-is-visible').should('have.length', 1);
119119
});
120120
});
121+
122+
describe('Modal with separate selector', function() {
123+
const steps = () => {
124+
return [
125+
{
126+
attachTo: {
127+
element: '.hero-welcome',
128+
on: 'bottom'
129+
},
130+
modalOverlayOpeningElement: '.hero-welcome h1',
131+
}
132+
];
133+
};
134+
135+
beforeEach(() => {
136+
tour = setupTour(Shepherd, {}, steps, {
137+
useModalOverlay: true
138+
});
139+
});
140+
141+
it('has the modal target the separate selector element', function() {
142+
tour.start();
143+
cy.get('.shepherd-modal-is-visible').should('have.length', 1);
144+
const openingPropertyHeight = tour.modal.getOpeningProperties().height;
145+
cy.get('.hero-welcome h1').invoke('outerHeight').should('eq', openingPropertyHeight);
146+
});
147+
});
121148
});

0 commit comments

Comments
 (0)