Skip to content

Commit

Permalink
dependency: replace circularJSON with flatted (#28683)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyrohrbough authored Jan 11, 2024
1 parent 33f132d commit 09ce5c1
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ _Released 1/16/2024 (PENDING)_

- Remove dependency on `@types/node` package. Addresses [#28473](https://github.com/cypress-io/cypress/issues/28473).
- Updated `@cypress/unique-selector` to include a performance optimization. It's possible this could improve performance of the selector playground. Addressed in [#28571](https://github.com/cypress-io/cypress/pull/28571).
- Replace [`CircularJSON`](https://www.npmjs.com/package/circular-json) with its successor [`flatted`](https://www.npmjs.com/package/flatted) version `3.2.9`. This resolves decoding issues observed in complex objects sent from the browser. Addressed in [#28683](https://github.com/cypress-io/cypress/pull/28683).

**Misc:**

Expand Down
11 changes: 6 additions & 5 deletions packages/driver/cypress/e2e/commands/querying/querying.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1594,14 +1594,15 @@ space
})

describe('special characters', () => {
const specialCharacters = '\' " [ ] { } . @ # $ % ^ & * ( ) , ; :'.split(' ')
const specialCharacters = '\' " [ ] { } . @ # $ % ^ & * ( ) , ; : ~'.split(' ')

it(`finds content by string with characters`, () => {
it(`finds selector with characters`, () => {
Cypress.config({ numTestsKeptInMemory: 0 })
_.each(specialCharacters, (char) => {
const span = $(`<span>special char ${char} content</span>`).appendTo(cy.$$('body'))
const button = $(`<button id="form-field${char}:r1:">special char ${char} content</button>`).appendTo(cy.$$('body'))

cy.contains('span', char).then(($span) => {
expect($span.get(0)).to.eq(span.get(0))
cy.contains('button', char).then(($button) => {
expect($button.get(0)).to.eq(button.get(0))
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/socket/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, ."
},
"dependencies": {
"circular-json": "0.5.9",
"engine.io": "6.4.2",
"engine.io-parser": "4.0.2",
"flatted": "3.2.9",
"socket.io": "4.0.1",
"socket.io-client": "4.0.1",
"uuid": "8.3.2"
Expand Down
6 changes: 3 additions & 3 deletions packages/socket/patches/socket.io-parser+4.0.5.patch
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ index b0c8727..3b2dcc3 100644
const binary_1 = require("./binary");
const is_binary_1 = require("./is-binary");
const debug = require("debug")("socket.io-parser");
+const CircularJSON = require('circular-json')
+const flatted = require("flatted");
/**
* Protocol version.
*
Expand All @@ -114,7 +114,7 @@ index b0c8727..3b2dcc3 100644
// json data
if (null != obj.data) {
- str += JSON.stringify(obj.data);
+ str += CircularJSON.stringify(obj.data);
+ str += flatted.stringify(obj.data);
}
debug("encoded %j as %s", obj, str);
return str;
Expand All @@ -123,7 +123,7 @@ index b0c8727..3b2dcc3 100644
function tryParse(str) {
try {
- return JSON.parse(str);
+ return CircularJSON.parse(str);
+ return flatted.parse(str);
}
catch (e) {
return false;
Expand Down
19 changes: 19 additions & 0 deletions packages/socket/test/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ describe('utils', () => {
expect(decoded).to.deep.equal(message)
})

it('encodes and decodes a message with complex data', async () => {
const message = [{
type: 'test',
data: {
foo: 'bar',
baz: [{ selector: '#id\\~\\:r\\:', elementsToHighlight: [{ selector: '#id\\~\\:r\\:' }] }],
},
}]
const encoded = await encode(message, '/namespace')

// Ensure we can stringify and parse the result
const stringifiedEncoded = JSON.stringify(encoded)
const parsedEncoded = JSON.parse(stringifiedEncoded)

const decoded = await decode(parsedEncoded)

expect(decoded).to.deep.equal(message)
})

it('encodes and decodes a message with binary data', async () => {
const message = [{ file: await fs.readFile(path.join(__dirname, 'fixtures', 'cypress.png')) }]
const encoded = await encode(message, '/namespace')
Expand Down
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10810,11 +10810,6 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3:
inherits "^2.0.1"
safe-buffer "^5.0.1"

circular-json@0.5.9:
version "0.5.9"
resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.5.9.tgz#932763ae88f4f7dead7a0d09c8a51a4743a53b1d"
integrity sha512-4ivwqHpIFJZBuhN3g/pEcdbnGUywkBblloGbkglyloVjjR3uT6tieI89MVOfbP2tHX5sgb01FuLgAOzebNlJNQ==

class-utils@^0.3.5:
version "0.3.6"
resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
Expand Down Expand Up @@ -15167,10 +15162,10 @@ flat@^5.0.2:
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==

flatted@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469"
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==
flatted@3.2.9, flatted@^3.1.0:
version "3.2.9"
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.9.tgz#7eb4c67ca1ba34232ca9d2d93e9886e611ad7daf"
integrity sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==

floating-vue@2.0.0-beta.17:
version "2.0.0-beta.17"
Expand Down

5 comments on commit 09ce5c1

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 09ce5c1 Jan 11, 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.6.3/linux-x64/develop-09ce5c1f0c4920d820f10b96666cb3a7f259000a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 09ce5c1 Jan 11, 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.6.3/linux-arm64/develop-09ce5c1f0c4920d820f10b96666cb3a7f259000a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 09ce5c1 Jan 11, 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.6.3/darwin-x64/develop-09ce5c1f0c4920d820f10b96666cb3a7f259000a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 09ce5c1 Jan 11, 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.6.3/darwin-arm64/develop-09ce5c1f0c4920d820f10b96666cb3a7f259000a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 09ce5c1 Jan 11, 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.6.3/win32-x64/develop-09ce5c1f0c4920d820f10b96666cb3a7f259000a/cypress.tgz

Please sign in to comment.