-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(component-testing): make content adjust to size of window (#14876)
- Loading branch information
Barthélémy Ledoux
authored
Feb 5, 2021
1 parent
62df1e7
commit 4cf3896
Showing
8 changed files
with
99 additions
and
61 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react' | ||
import { mount } from '@cypress/react' | ||
|
||
const viewportWidth = 200 | ||
const viewportHeight = 100 | ||
|
||
describe('cypress.json viewport', | ||
{ viewportWidth, viewportHeight }, | ||
() => { | ||
it('should have the correct dimensions', () => { | ||
// cy.should cannot be the first cy command we run | ||
cy.window().should((w) => { | ||
expect(w.innerWidth).to.eq(viewportWidth) | ||
expect(w.innerHeight).to.eq(viewportHeight) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('cy.viewport', () => { | ||
it('should resize the viewport', () => { | ||
cy.viewport(viewportWidth, viewportHeight).should(() => { | ||
expect(window.innerWidth).to.eq(viewportWidth) | ||
expect(window.innerHeight).to.eq(viewportHeight) | ||
}) | ||
}) | ||
|
||
it('should make it scale down when overflowing', () => { | ||
mount(<p> | ||
Lorem, ipsum dolor sit amet consectetur adipisicing elit. | ||
Incidunt necessitatibus quia quo obcaecati tempora numquam nobis | ||
minima libero vel? Nam sequi iusto quod fugit vel rerum eligendi beatae voluptatibus numquam. | ||
</p>) | ||
|
||
expect(getComputedStyle(window.parent.document.querySelector('iframe').parentElement).transform).to.contain('matrix(1') | ||
cy.viewport(2000, 200).should(() => { | ||
expect(getComputedStyle(window.parent.document.querySelector('iframe').parentElement).transform).not.to.contain('matrix(1') | ||
}) | ||
}) | ||
}) |
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
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
4cf3896
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
4cf3896
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 ia32
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
4cf3896
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
4cf3896
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: