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

dependency: replace circularJSON with flatted #28683

Merged
merged 6 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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).
Copy link
Contributor

Choose a reason for hiding this comment

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

If the entry is under the Dependency Updates: section, should the PR title be dependency:.


**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