Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump jquery to 3.1.1 #1229

Merged
merged 23 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6fa1edc
bump jquery to 3.0
jennifer-shehane Jan 25, 2018
d817137
Merge branch 'develop' into issue-1215-jquery-3
jennifer-shehane Jan 16, 2019
7407149
Merge branch 'develop' into issue-1215-jquery-3
jennifer-shehane Feb 25, 2019
eb3cb61
Merge branch 'develop' into issue-1215-jquery-3
bahmutov Sep 4, 2019
cc3cf34
add selector property to the element returned by jQuery query
bahmutov Sep 6, 2019
389f7fa
do not try setting highlight attribute on non-elements
bahmutov Sep 6, 2019
57f20da
use jquery v3 on load callback
bahmutov Sep 6, 2019
2f0af22
another instance of jquery load
bahmutov Sep 6, 2019
388f1cb
better element check before setting an attribute
bahmutov Sep 6, 2019
b132875
Merge branch 'develop' into issue-1215-jquery-3
chrisbreiding Sep 12, 2019
9a8260a
use dom APIs instead of jQuery when unscaling AUT for screenshot
chrisbreiding Sep 13, 2019
9266739
Merge branch 'develop' into issue-1215-jquery-3
chrisbreiding Sep 19, 2019
8b2641a
bump jquery to 3.4.1
chrisbreiding Sep 19, 2019
d900c32
Merge branch 'develop' into issue-1215-jquery-3
chrisbreiding Sep 24, 2019
72c543e
replace instances of $.fn.width/height with respective dom APIs
chrisbreiding Sep 24, 2019
91fdbde
try should instead of then
chrisbreiding Sep 24, 2019
abe5620
Revert "try should instead of then"
chrisbreiding Sep 24, 2019
054ede8
try getting rid of borders
chrisbreiding Sep 24, 2019
b2ee1e2
Merge branch 'develop' into issue-1215-jquery-3
chrisbreiding Sep 24, 2019
b715b9a
Merge branch 'develop' into issue-1215-jquery-3
chrisbreiding Sep 25, 2019
69256dc
try jquery 3.3.1
chrisbreiding Sep 25, 2019
beac9e4
try jquery 3.2.1
chrisbreiding Sep 25, 2019
81d15f7
try jquery 3.1.1
chrisbreiding Sep 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ cd packages/driver
npm start
```

If you would like to run a particular integration test, see the GUI and poke around during the test, you can an exclusive test like:

```bash
cd packages/driver
node ../../scripts/cypress run \
--project ./test \
--spec test/cypress/integration/cypress/cy_spec.coffee \
--headed --no-exit
```

## Debugging

In the browser
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"errorhandler": "1.5.1",
"eventemitter2": "4.1.2",
"express": "4.16.4",
"jquery": "2.2.4",
"jquery": "3.0.0",
"jquery.scrollto": "2.1.2",
"js-cookie": "2.2.0",
"jsdom": "14.1.0",
Expand Down
5 changes: 5 additions & 0 deletions packages/driver/src/cy/commands/querying.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ module.exports = (Commands, Cypress, cy, state, config) ->
## and catch any sizzle errors!
try
$el = cy.$$(selector, options.withinSubject)
# jQuery v3 has removed its deprecated properties like ".selector"
# https://jquery.com/upgrade-guide/3.0/#breaking-change-deprecated-context-and-selector-properties-removed
# but our error messages use this property to actually show the missing element
# so let's put it back
$el.selector = selector unless $el.selector
catch e
e.onFail = -> if options.log is false then e else options._log.error(e)
throw e
Expand Down
10 changes: 8 additions & 2 deletions packages/driver/src/cy/snapshots.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ create = ($$, state) ->

createSnapshot = (name, $elToHighlight) ->
## create a unique selector for this el
$elToHighlight.attr(HIGHLIGHT_ATTR, true) if $elToHighlight?.attr
## but only IF the subject is truly an element. For example
## we might be wrapping a primitive like "$([1, 2]).first()"
## which arrives here as number 1
## jQuery v2 allowed to silently try setting 1[HIGHLIGHT_ATTR] doing nothing
## jQuery v3 runs in strict mode and throws an error if you attempt to set a property
canHaveAttributes = _.isElement($elToHighlight && $elToHighlight[0])
$elToHighlight.attr(HIGHLIGHT_ATTR, true) if canHaveAttributes and $elToHighlight?.attr

## TODO: throw error here if cy is undefined!

Expand Down Expand Up @@ -146,7 +152,7 @@ create = ($$, state) ->
## which would reduce memory, and some CPU operations

## now remove it after we clone
$elToHighlight.removeAttr(HIGHLIGHT_ATTR) if $elToHighlight?.removeAttr
$elToHighlight.removeAttr(HIGHLIGHT_ATTR) if canHaveAttributes and $elToHighlight?.removeAttr

## preserve attributes on the <html> tag
htmlAttrs = getHtmlAttrs($$("html")[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ describe('src/cy/commands/actions/type', () => {

cy.get('#generic-iframe')
.then(($iframe) => {
$iframe.load(() => {
$iframe.on('load', () => {
loaded = true
})
}).scrollIntoView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ const normalizeStyles = (styles) => {

const addStyles = (styles, to) => {
return new Promise((resolve) => {
$(styles)
.load(() => {
return resolve()
})
.appendTo(cy.$$(to))
$(styles).on('load', resolve).appendTo(cy.$$(to))
})
}

Expand Down
7 changes: 2 additions & 5 deletions packages/runner/src/app/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,8 @@ class App extends Component {
containerNode.className += ' screenshotting'

if (!config.scale) {
const $window = $(window)
const $iframesSizeNode = $(iframesSizeNode)

iframesSizeNode.style.width = `${Math.min($window.width(), $iframesSizeNode.width())}px`
iframesSizeNode.style.height = `${Math.min($window.height(), $iframesSizeNode.height())}px`
iframesSizeNode.style.width = `${Math.min(window.innerWidth, iframesSizeNode.offsetWidth)}px`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jQuery 3 changes how it does width and height calculations (it now uses getBoundingClientRect), which takes into account the scaling. We want the absolute value without scaling, so we're better off directly using the DOM properties.

iframesSizeNode.style.height = `${Math.min(window.innerHeight, iframesSizeNode.offsetHeight)}px`
iframesSizeNode.style.transform = null
}

Expand Down
14 changes: 8 additions & 6 deletions packages/server/__snapshots__/5_screenshots_spec.coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ exports['e2e screenshots passes 1'] = `
✓ retries each screenshot for up to XX:XX
✓ ensures unique paths for non-named screenshots
2) ensures unique paths when there's a non-named screenshot and a failure
✓ properly resizes the AUT iframe
- doesn't take a screenshot for a pending test
clipping
✓ can clip app screenshots
Expand All @@ -47,7 +48,7 @@ exports['e2e screenshots passes 1'] = `
✓ takes another screenshot


17 passing
18 passing
1 pending
5 failing

Expand Down Expand Up @@ -83,12 +84,12 @@ Because this error occurred during a 'after each' hook we are skipping the remai
(Results)

┌───────────────────────────────────────┐
│ Tests: 22
│ Passing: 17
│ Tests: 23
│ Passing: 18
│ Failing: 4 │
│ Pending: 1 │
│ Skipped: 0 │
│ Screenshots: 25
│ Screenshots: 26
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: screenshots_spec.coffee │
Expand All @@ -113,6 +114,7 @@ Because this error occurred during a 'after each' hook we are skipping the remai
- /foo/bar/.projects/e2e/cypress/screenshots/screenshots_spec.coffee/taking screenshots -- ensures unique paths for non-named screenshots (2).png (1280x720)
- /foo/bar/.projects/e2e/cypress/screenshots/screenshots_spec.coffee/taking screenshots -- ensures unique paths when there's a non-named screenshot and a failure.png (1000x660)
- /foo/bar/.projects/e2e/cypress/screenshots/screenshots_spec.coffee/taking screenshots -- ensures unique paths when there's a non-named screenshot and a failure (failed).png (1280x720)
- /foo/bar/.projects/e2e/cypress/screenshots/screenshots_spec.coffee/aut-resize.png (1000x2000)
- /foo/bar/.projects/e2e/cypress/screenshots/screenshots_spec.coffee/app-clip.png (100x50)
- /foo/bar/.projects/e2e/cypress/screenshots/screenshots_spec.coffee/runner-clip.png (120x60)
- /foo/bar/.projects/e2e/cypress/screenshots/screenshots_spec.coffee/fullPage-clip.png (140x70)
Expand All @@ -137,9 +139,9 @@ Because this error occurred during a 'after each' hook we are skipping the remai

Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ screenshots_spec.coffee XX:XX 22 17 4 1 - │
│ ✖ screenshots_spec.coffee XX:XX 23 18 4 1 - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
1 of 1 failed (100%) XX:XX 22 17 4 1 -
1 of 1 failed (100%) XX:XX 23 18 4 1 -


`
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ describe "taking screenshots", ->
.screenshot("color-check", { capture: "runner" })
.task("ensure:pixel:color", {
devicePixelRatio
coords: [1, 0]
color: [255, 255, 255] ## white
colors: [{
coords: [1, 0]
color: [255, 255, 255] ## white
}]
name: "screenshots_spec.coffee/color-check"
})
.task("ensure:pixel:color", {
devicePixelRatio
coords: [0, 1]
color: [255, 255, 255] ## white
colors: [{
coords: [0, 1]
color: [255, 255, 255] ## white
}]
name: "screenshots_spec.coffee/color-check"
})

Expand Down Expand Up @@ -161,6 +165,35 @@ describe "taking screenshots", ->
cy.screenshot({ capture: "viewport" }).then ->
throw new Error("failing on purpose")

it "properly resizes the AUT iframe", ->
## ensures that the aut iframe is not undersized by making sure the screenshot
## is completely white and doesn't have the black background showing
cy
.visit("http://localhost:3322/color/white")
.screenshot("aut-resize")
.task("ensure:pixel:color", {
devicePixelRatio
colors: [
{
coords: [5, 5]
color: [255, 255, 255] ## white
}
{
coords: [1275, 5]
color: [255, 255, 255] ## white
}
{
coords: [5, 715]
color: [255, 255, 255] ## white
}
{
coords: [1275, 715]
color: [255, 255, 255] ## white
}
]
name: "screenshots_spec.coffee/aut-resize"
})

describe "clipping", ->
it "can clip app screenshots", ->
cy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@ module.exports = (on) => {
throw new Error(message)
},

'ensure:pixel:color' ({ name, coords, color, devicePixelRatio }) {
'ensure:pixel:color' ({ name, colors, devicePixelRatio }) {
const imagePath = path.join(__dirname, '..', 'screenshots', `${name}.png`)

return Jimp.read(imagePath)
.then((image) => {
let [x, y] = coords
_.each(colors, ({ coords, color }) => {
let [x, y] = coords

x = x * devicePixelRatio
y = y * devicePixelRatio
x = x * devicePixelRatio
y = y * devicePixelRatio

const pixels = Jimp.intToRGBA(image.getPixelColor(x, y))
const pixels = Jimp.intToRGBA(image.getPixelColor(x, y))

const { r, g, b } = pixels
const { r, g, b } = pixels

if (!_.isEqual(color, [r, g, b])) {
throw new Error(`The pixel color at coords: [${x}, ${y}] does not match the expected pixel color. The color was [${r}, ${g}, ${b}] and was expected to be [${color.join(', ')}].`)
}
if (!_.isEqual(color, [r, g, b])) {
throw new Error(`The pixel color at coords: [${x}, ${y}] does not match the expected pixel color. The color was [${r}, ${g}, ${b}] and was expected to be [${color.join(', ')}].`)
}
})

return null
})
Expand Down