Skip to content

Commit

Permalink
Merge branch 'develop' into feat/vite_5_support
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-shehane authored May 20, 2024
2 parents 39469c0 + 9c11188 commit c6941da
Show file tree
Hide file tree
Showing 22 changed files with 465 additions and 140 deletions.
4 changes: 2 additions & 2 deletions browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"chrome:beta": "125.0.6422.41",
"chrome:stable": "124.0.6367.207",
"chrome:beta": "126.0.6478.7",
"chrome:stable": "125.0.6422.60",
"chrome:minimum": "64.0.3282.0"
}
2 changes: 2 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ _Released 5/21/2024 (PENDING)_

**Bugfixes:**

- Fixed an issue where orphaned Electron processes were inadvertently terminating the browser's CRI client. Fixes [#28397](https://github.com/cypress-io/cypress/issues/28397). Fixed in [#29515](https://github.com/cypress-io/cypress/pull/29515).
- Fixed an issue where Cypress was unable to search in the Specs list for files or folders containing numbers. Fixes [#29034](https://github.com/cypress-io/cypress/issues/29034).
- Fixed an issue where Cypress would use the wrong URL to upload Test Replay recordings when it wasn't able to determine the upload URL. It now displays an error when the upload URL cannot be determined, rather than a "Request Entity Too Large" error. Addressed in [#29512](https://github.com/cypress-io/cypress/pull/29512).

**Dependency Updates:**

Expand Down
106 changes: 0 additions & 106 deletions packages/driver/cypress/e2e/cy/snapshot.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,112 +175,6 @@ describe('driver/src/cy/snapshots', () => {
expect(body.get().find('iframe').css('height')).to.equal('70px')
})
})

context('protocol', () => {
beforeEach(() => {
// set to 0 to ensure protocol snapshots are taken
// since the driver support file sets the value to 1
Cypress.config('numTestsKeptInMemory', 0)
})

it('captures a protocol snapshot with highlight elements', {
protocolEnabled: true,
}, function () {
cy.window().then((win) => {
win.__cypressProtocolMetadata = { frameId: 'test-frame-id' }

const { elementsToHighlight, name, timestamp } = cy.createSnapshot('snapshot', cy.$$('a'))

expect(elementsToHighlight?.length).to.equal(3)
expect(elementsToHighlight?.[0].selector).to.equal('a:nth-child(2)')
expect(elementsToHighlight?.[0].frameId).to.equal('test-frame-id')
expect(elementsToHighlight?.[1].selector).to.equal('#hashchange')
expect(elementsToHighlight?.[1].frameId).to.equal('test-frame-id')
expect(elementsToHighlight?.[2].selector).to.equal('#dimensions')
expect(elementsToHighlight?.[2].frameId).to.equal('test-frame-id')
expect(name).to.equal('snapshot')
expect(timestamp).to.be.a('number')
})
})

it('captures a protocol snapshot with an embedded iframe highlight element', {
protocolEnabled: true,
}, function () {
const iframe = $('<iframe src=\'iframe-inner.html\' />')

iframe.on('load', () => {
const ownerDoc = iframe[0].contentDocument
const elWindow = iframe[0].contentWindow
const element = $(ownerDoc.querySelector('button'))

elWindow.__cypressProtocolMetadata = { frameId: 'test-frame-id' }

const { elementsToHighlight, name, timestamp } = cy.createSnapshot('snapshot', element)

expect(elementsToHighlight?.length).to.equal(1)
expect(elementsToHighlight?.[0].selector).to.equal('button:nth-child(1)')
expect(elementsToHighlight?.[0].frameId).to.equal('test-frame-id')
expect(name).to.equal('snapshot')
expect(timestamp).to.be.a('number')
})

iframe.appendTo(cy.$$('body'))
})

it('captures a protocol snapshot with a body highlight element', {
protocolEnabled: true,
}, function () {
cy.window().then((win) => {
win.__cypressProtocolMetadata = { frameId: 'test-frame-id' }

const { elementsToHighlight, name, timestamp } = cy.createSnapshot('snapshot', cy.$$('body'))

expect(elementsToHighlight?.length).to.equal(1)
expect(elementsToHighlight?.[0].selector).to.equal('body:nth-child(2)')
expect(elementsToHighlight?.[0].frameId).to.equal('test-frame-id')
expect(name).to.equal('snapshot')
expect(timestamp).to.be.a('number')
})
})

it('captures a protocol snapshot and excludes a null element', {
protocolEnabled: true,
}, function () {
// create an element but don't append it to the DOM
const element = $('<div id=\'foo\' />')

const { elementsToHighlight, name, timestamp } = cy.createSnapshot('snapshot', element)

expect(elementsToHighlight?.length).to.equal(0)
expect(name).to.equal('snapshot')
expect(timestamp).to.be.a('number')
})

it('captures shadow DOM selectors structure properly', {
protocolEnabled: true,
}, () => {
cy.visit('/fixtures/shadow-dom-type.html')
cy.window().then((win) => {
win.__cypressProtocolMetadata = { frameId: 'test-frame-id' }

cy.get('#shadow-dom-input', {
includeShadowDom: true,
}).then((shadowDomSlot) => {
const { elementsToHighlight, name, timestamp } = cy.createSnapshot('snapshot', shadowDomSlot)

expect(elementsToHighlight?.length).to.equal(1)
const elementToHighlight = elementsToHighlight[0]

expect(elementToHighlight.selector.length).to.equal(2)
expect(elementToHighlight.selector[0]).to.equal('#element')
expect(elementToHighlight.selector[1]).to.equal('#shadow-dom-input')
expect(elementToHighlight.frameId).to.equal('test-frame-id')
expect(name).to.equal('snapshot')
expect(timestamp).to.be.a('number')
})
})
})
})
})

context('custom elements', () => {
Expand Down
192 changes: 192 additions & 0 deletions packages/driver/cypress/e2e/util/what-is-circular.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
import { whatIsCircular } from '../../../src/util/what-is-circular'

describe('what-is-circular', function () {
it('should return undefined if passed a non-object', function () {
expect(whatIsCircular(2)).to.eq(undefined)
})

it('should return path for circular objects', function () {
const x: any = {}

x.cyclic = { a: 1, x }
expect(whatIsCircular(x)).to.deep.eq(['cyclic', 'x'])
})

it('should return path for circular objects', function () {
const x: any = {}

x.cyclic = { a: {}, x }
expect(whatIsCircular(x)).to.deep.eq(['cyclic', 'x'])
})

it('should return path for circular objects', function () {
const x: any = {}

x.cyclic = { a: {}, indirect: { x } }
expect(whatIsCircular(x)).to.deep.eq(['cyclic', 'indirect', 'x'])
})

it('should return path for circular objects', function () {
const a = {
a: false,
b: {
a: false,
c: {
a: false,
d: {
e: {
a: false,
},
},
},
},
}

a.b.c.d.e = a

expect(whatIsCircular(a)).to.deep.eq(['b', 'c', 'd', 'e'])
})

it('should return path for circular objects', function () {
const x: any = {
a: [
{
a: 'b',
b: 'c',
},
{
a: 'b',
b: 'c',
},
],
b: [
'a',
'b',
],
}

x.c = {
x,
}

expect(whatIsCircular(x)).to.deep.eq(['c', 'x'])
})

it('should return path for circular objects in arrays', function () {
const x: any = {
a: [
{
a: 'b',
b: 'c',
},
{
a: 'b',
b: 'c',
},
],
b: [
'a',
'b',
],
}

x.a[2] = x

expect(whatIsCircular(x)).to.deep.eq(['a', '2'])
})

it('should return undefined for non-circular objects', function () {
const x: any = {}

x.cyclic = { a: 1, b: 2 }
expect(whatIsCircular(x)).to.eq(undefined)
})

it('should return undefined for non-circular objects', function () {
const x: any = {
a: [
{
a: 'b',
b: 'c',
},
{
a: 'b',
b: 'c',
},
],
b: [
'a',
'b',
],
}

expect(whatIsCircular(x)).to.eq(undefined)
})

it('should return undefined for non-circular objects', function () {
const x: any = {}
const y = {}

x.cyclic = { a: y, b: y }
expect(whatIsCircular(x)).to.eq(undefined)
})

it('detects circular objects and returns path', function () {
const obj1: any = {}

obj1.x = obj1
expect(whatIsCircular(obj1)).to.deep.eq(['x'])

const obj2: any = {}

obj2.x = { y: obj2 }
expect(whatIsCircular(obj2)).to.deep.eq(['x', 'y'])
})

it('detects circular arrays and returns path', function () {
const obj1: any = []

obj1.push(obj1)
expect(whatIsCircular(obj1)).to.deep.eq(['0'])
})

it('detects non-circular objects and returns undefined', function () {
const obj1: any = {}

obj1.x = { y: 4 }
expect(whatIsCircular(obj1)).to.be.undefined

expect(whatIsCircular({})).to.be.undefined
})

it('detects non-circular arrays and returns undefined', function () {
const obj1: any[] = []

obj1.push([])
expect(whatIsCircular(obj1)).to.be.undefined
})

it('returns undefined for non-objects', function () {
expect(whatIsCircular(undefined)).to.be.undefined
expect(whatIsCircular(null)).to.be.undefined
expect(whatIsCircular('hi')).to.be.undefined
expect(whatIsCircular(false)).to.be.undefined
expect(whatIsCircular(/a/)).to.be.undefined
})

it('returns undefined for non-circular functions', function () {
expect(whatIsCircular(function () {})).to.be.undefined
})

it('returns path for circular functions', function () {
const f: any = function () {}

f.x = {
y: {
f,
},
}

expect(whatIsCircular(f)).to.deep.eq(['x', 'y', 'f'])
})
})
1 change: 0 additions & 1 deletion packages/driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"@cypress/unique-selector": "0.0.5",
"@cypress/webpack-dev-server": "0.0.0-development",
"@cypress/webpack-preprocessor": "0.0.0-development",
"@cypress/what-is-circular": "1.0.1",
"@medv/finder": "3.1.0",
"@packages/config": "0.0.0-development",
"@packages/network": "0.0.0-development",
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash'
import whatIsCircular from '@cypress/what-is-circular'
import UrlParse from 'url-parse'
import Promise from 'bluebird'

Expand All @@ -9,6 +8,7 @@ import { LogUtils, Log } from '../../cypress/log'
import { bothUrlsMatchAndOneHasHash } from '../navigation'
import { $Location, LocationObject } from '../../cypress/location'
import { isRunnerAbleToCommunicateWithAut } from '../../util/commandAUTCommunication'
import { whatIsCircular } from '../../util/what-is-circular'

import type { RunState } from '@packages/types'

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/request.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import _ from 'lodash'
import whatIsCircular from '@cypress/what-is-circular'
import Promise from 'bluebird'

import $utils from '../../cypress/utils'
import $errUtils from '../../cypress/error_utils'
import { $Location } from '../../cypress/location'
import { whatIsCircular } from '../../util/what-is-circular'

const isOptional = (memo, val, key) => {
if (_.isNull(val)) {
Expand Down
26 changes: 26 additions & 0 deletions packages/driver/src/util/what-is-circular.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const lodash = require('lodash')

export function whatIsCircular (obj) {
if (!lodash.isObject(obj)) {
return
}

return _dfs(obj)
}

function _dfs (obj, parents: any[] = [], parentKeys: any[] = []) {
// recurse depth-first until we hit something we've seen before
for (const key in obj) {
const val = obj[key]

if (lodash.isObject(val)) {
if (lodash.includes(parents, val)) {
return parentKeys
}

const path = _dfs(val, parents.concat([val]), parentKeys.concat([key]))

if (path) return path
}
}
}
Loading

5 comments on commit c6941da

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c6941da May 20, 2024

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.10.0/linux-x64/feat/vite_5_support-c6941da9ef56dbc7e86f4b3e0c32aa258a703404/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c6941da May 20, 2024

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.10.0/linux-arm64/feat/vite_5_support-c6941da9ef56dbc7e86f4b3e0c32aa258a703404/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c6941da May 20, 2024

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.10.0/win32-x64/feat/vite_5_support-c6941da9ef56dbc7e86f4b3e0c32aa258a703404/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c6941da May 20, 2024

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.10.0/darwin-arm64/feat/vite_5_support-c6941da9ef56dbc7e86f4b3e0c32aa258a703404/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c6941da May 21, 2024

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.10.0/darwin-x64/feat/vite_5_support-c6941da9ef56dbc7e86f4b3e0c32aa258a703404/cypress.tgz

Please sign in to comment.