mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-26 17:09:11 -06:00
Adding presets for following viewports: 1) iPhone-XR, 2) iPhone-X, 3)… (#4967)
* Adding presets for following viewports: 1) iPhone-XR, 2) iPhone-X, 3) Samsung-S10, 4) Samsung-Note9 * Adding presets for following viewports: 1) iPhone-XR, 2) iPhone-X, 3) Samsung-S10, 4) Samsung-Note9 * Fix casing * Cleanup * Update window_spec
This commit is contained in:
committed by
Zach Bloomquist
parent
ed3c3ebab9
commit
1b2faa2748
2
cli/types/index.d.ts
vendored
2
cli/types/index.d.ts
vendored
@@ -4364,7 +4364,7 @@ declare namespace Cypress {
|
||||
|
||||
type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le'
|
||||
type PositionType = "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight"
|
||||
type ViewportPreset = 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-6+' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3'
|
||||
type ViewportPreset = 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-xr' | 'iphone-x' | 'iphone-6+' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3' | 'samsung-s10' | 'samsung-note9'
|
||||
interface Offset {
|
||||
top: number,
|
||||
left: number
|
||||
|
||||
@@ -9,11 +9,15 @@ viewports = {
|
||||
"macbook-11" : "1366x768"
|
||||
"ipad-2" : "768x1024"
|
||||
"ipad-mini" : "768x1024"
|
||||
"iphone-xr" : "414x896"
|
||||
"iphone-x" : "375x812"
|
||||
"iphone-6+" : "414x736"
|
||||
"iphone-6" : "375x667"
|
||||
"iphone-5" : "320x568"
|
||||
"iphone-4" : "320x480"
|
||||
"iphone-3" : "320x480"
|
||||
"samsung-s10" : "360x760"
|
||||
"samsung-note9" : "414x846"
|
||||
}
|
||||
|
||||
validOrientations = ["landscape", "portrait"]
|
||||
|
||||
@@ -546,6 +546,20 @@ describe "src/cy/commands/window", ->
|
||||
|
||||
cy.viewport("ipad-mini")
|
||||
|
||||
it "iphone-xr", (done) ->
|
||||
cy.on "viewport:changed", (viewport) ->
|
||||
expect(viewport).to.deep.eq {viewportWidth: 414, viewportHeight: 896}
|
||||
done()
|
||||
|
||||
cy.viewport("iphone-xr")
|
||||
|
||||
it "iphone-x", (done) ->
|
||||
cy.on "viewport:changed", (viewport) ->
|
||||
expect(viewport).to.deep.eq {viewportWidth: 375, viewportHeight: 812}
|
||||
done()
|
||||
|
||||
cy.viewport("iphone-x")
|
||||
|
||||
it "iphone-6+", (done) ->
|
||||
cy.on "viewport:changed", (viewport) ->
|
||||
expect(viewport).to.deep.eq {viewportWidth: 414, viewportHeight: 736}
|
||||
@@ -581,6 +595,20 @@ describe "src/cy/commands/window", ->
|
||||
|
||||
cy.viewport("iphone-5", "portrait")
|
||||
|
||||
it "samsung-s10", (done) ->
|
||||
cy.on "viewport:changed", (viewport) ->
|
||||
expect(viewport).to.deep.eq {viewportWidth: 360, viewportHeight: 760}
|
||||
done()
|
||||
|
||||
cy.viewport("samsung-s10")
|
||||
|
||||
it "samsung-note9", (done) ->
|
||||
cy.on "viewport:changed", (viewport) ->
|
||||
expect(viewport).to.deep.eq {viewportWidth: 414, viewportHeight: 846}
|
||||
done()
|
||||
|
||||
cy.viewport("samsung-note9")
|
||||
|
||||
context "errors", ->
|
||||
beforeEach ->
|
||||
Cypress.config("defaultCommandTimeout", 50)
|
||||
@@ -596,7 +624,7 @@ describe "src/cy/commands/window", ->
|
||||
it "throws with passed invalid preset", (done) ->
|
||||
cy.on "fail", (err) =>
|
||||
expect(@logs.length).to.eq(1)
|
||||
expect(err.message).to.eq "cy.viewport() could not find a preset for: 'foo'. Available presets are: macbook-15, macbook-13, macbook-11, ipad-2, ipad-mini, iphone-6+, iphone-6, iphone-5, iphone-4, iphone-3"
|
||||
expect(err.message).to.match /^cy.viewport\(\) could not find a preset for: 'foo'. Available presets are: /
|
||||
done()
|
||||
|
||||
cy.viewport("foo")
|
||||
|
||||
Reference in New Issue
Block a user