-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64ba630
commit 5664503
Showing
4 changed files
with
57 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,67 @@ | ||
import { translateXRegex } from '../../support/utils'; | ||
import { getSlideshowWidth, translateXRegex } from '../../support/utils'; | ||
|
||
describe('introduction slide functionality', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:6006'); | ||
cy.frameLoaded("#storybook-preview-iframe"); | ||
cy.get('[title="Go full screen [F]"]').click(); | ||
cy.wait(2000); | ||
cy.iframe('#storybook-preview-iframe') | ||
.find('.react-slideshow-container') | ||
.as("slide") | ||
}) | ||
|
||
it('loads the introduction slide and the slide with slide 1', () => { | ||
it('loads the introduction slide and the slide with slide 1', async () => { | ||
cy.get('@slide').should('exist'); | ||
cy.get('@slide').find('.images-wrap').should('have.class', 'horizontal'); | ||
const width = await getSlideshowWidth(); | ||
cy.get('@slide').invoke('width').should('gt', 0); | ||
cy.get('@slide').find('.images-wrap > div').should('have.length', 5); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'width').and('match', /4590px/) | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-918')) | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'width').and('match', new RegExp(`${width * 5}px`)) | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(`-${width}`)) | ||
cy.get('@slide').find('.images-wrap > div:nth-of-type(2)').should('have.class', 'active') | ||
cy.get('@slide').find('.images-wrap > div:nth-of-type(2)').should('have.css', 'width').and('match', /918px/) | ||
cy.get('@slide').find('.images-wrap > div:nth-of-type(2)').should('have.css', 'width').and('match', new RegExp(`${width}px`)) | ||
}); | ||
|
||
it('loads the next slides when the next button is clicked', () => { | ||
it('loads the next slides when the next button is clicked', async () => { | ||
cy.get('@slide').should('exist'); | ||
const width = await getSlideshowWidth(); | ||
cy.get('@slide').invoke('width').should('gt', 0); | ||
cy.get('@slide').find('.nav:last-of-type').click(); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-1836')); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(-2 * width)); | ||
cy.get('@slide').find('.nav:last-of-type').click(); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-2754')); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(-3 * width)); | ||
cy.get('@slide').find('.nav:last-of-type').click(); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-918')); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(-1 * width)); | ||
}); | ||
|
||
it('loads the previous slides when the previous button is clicked', () => { | ||
it('loads the previous slides when the previous button is clicked', async () => { | ||
cy.get('@slide').should('exist'); | ||
const width = await getSlideshowWidth(); | ||
cy.get('@slide').invoke('width').should('gt', 0); | ||
cy.get('@slide').find('.nav:first-of-type').click(); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-2754')); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(-3 * width)); | ||
cy.get('@slide').find('.nav:first-of-type').click(); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-1836')); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(-2 * width)); | ||
cy.get('@slide').find('.nav:first-of-type').click(); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-918')); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(-1 * width)); | ||
}); | ||
|
||
it('allows dragging the slide to go next and back', () => { | ||
it('allows dragging the slide to go next and back', async () => { | ||
cy.get('@slide').should('exist'); | ||
const width = await getSlideshowWidth(); | ||
cy.get('@slide').invoke('width').should('gt', 0); | ||
// before the move | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-918')); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(-1 * width)); | ||
cy.get('@slide') | ||
.trigger('mousedown', { which: 1, clientX: 450 }) | ||
.trigger('mousemove', { clientX: 200 }) | ||
.trigger('mouseup', { force: true }); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-1836')); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(-2 * width)); | ||
|
||
cy.get('@slide') | ||
.trigger('mousedown', { which: 1, clientX: 200 }) | ||
.trigger('mousemove', { clientX: 450 }) | ||
.trigger('mousemove', { clientX08: 450 }) | ||
.trigger('mouseup', { force: true }); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex('-918')); | ||
cy.get('@slide').find('.images-wrap').should('have.css', 'transform').and('match', translateXRegex(-1 * width)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters