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

fix: Fix Issue 27103. Retain original array after defaultsDeep #27240

Closed
wants to merge 11 commits into from
Closed

fix: Fix Issue 27103. Retain original array after defaultsDeep #27240

wants to merge 11 commits into from

Conversation

NiharPhansalkar
Copy link
Contributor

Additional details

What is affected by this change?
Previously the defaultsDeep function was merging/combining arrays. This PR will fix that issue and restore any arrays modified by the setupNodeEvents function.

Steps to test

To test, copy the cypress.config.js from the reproduction section of the issue and configure for e2e testing. Then run cypress using yarn cypress open --dev --config-file cypress.config.js. After setting any key within the config object to any array value (within the setupNodeEvents function), it should reflect as is in the final config.

How has the user experience changed?

User will get the exact config they supply in the setupNodeEvents function.

PR Tasks

@CLAassistant
Copy link

CLAassistant commented Jul 8, 2023

CLA assistant check
All committers have signed the CLA.

@cypress-app-bot
Copy link
Collaborator

@NiharPhansalkar NiharPhansalkar changed the title fix Issue 27103 fix: Fix Issue 27103. Retain original array after defaultsDeep Jul 8, 2023
@NiharPhansalkar NiharPhansalkar marked this pull request as draft July 8, 2023 07:05
@cypress
Copy link

cypress bot commented Jul 8, 2023

1 failed and 29 flaky tests on run #48661 ↗︎

1 27936 1349 0 Flakiness 29

Details:

Merge branch 'cypress-io:develop' into issue-27103-defaultsDeep-array-combinatio...
Project: cypress Commit: b7e30a42d0
Status: Failed Duration: 20:08 💡
Started: Jul 8, 2023 10:48 AM Ended: Jul 8, 2023 11:09 AM
Failed  cypress/e2e/e2e/origin/user_agent_override.cy.ts • 1 failed test • 5x-driver-electron

View Output Video

Test Artifacts
user agent override > persists modified user agent after cy.go Output Video
Flakiness  runs.cy.ts • 1 flaky test • app-e2e

View Output Video

Test Artifacts
... > displays a list of recorded runs if a run has been recorded Output Screenshots Video
Flakiness  specs_list_latest_runs.cy.ts • 1 flaky test • app-e2e

View Output Video

Test Artifacts
App/Cloud Integration - Latest runs and Average duration > when no runs are recorded > shows placeholders for all visible specs Output Screenshots Video
Flakiness  cypress-origin-communicator.cy.ts • 1 flaky test • app-e2e

View Output Video

Test Artifacts
Cypress In Cypress Origin Communicator > cy.origin passivity with app interactions > passes upon test reload mid test execution Output Screenshots Video
Flakiness  commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-firefox

View Output Video

Test Artifacts
network stubbing > intercepting request > can delay and throttle a StaticResponse Output
Flakiness  commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-electron

View Output Video

Test Artifacts
network stubbing > intercepting request > can delay and throttle a StaticResponse Output Video

The first 5 flaky specs are shown, see all 17 specs in Cypress Cloud.

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@NiharPhansalkar NiharPhansalkar marked this pull request as ready for review July 8, 2023 10:37
Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

Great job. I've recommended one refactor, and added a test to ensure this won't regress again. 47c12f1

Comment on lines 113 to 118
for (const key in diffsClone) {
if (Array.isArray(diffsClone[key])) {
merged[key] = _.cloneDeep(diffsClone[key])
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (const key in diffsClone) {
if (Array.isArray(diffsClone[key])) {
merged[key] = _.cloneDeep(diffsClone[key])
}
}
for (const [key, value] of Object.entries(diffsClone)) {
if (Array.isArray(value)) {
merged[key] = _.cloneDeep(value)
}
}

I think this can be a bit more concise. I did not try this, but it should work.

I've also added a test. 47c12f1e4e712f62b0cec582b7dfda98f3177583

You could use this to see if my refactor works. cd packages/app then yarn dev. Select the spec (or use it.only to only run the one test I added).

Copy link
Contributor Author

@NiharPhansalkar NiharPhansalkar Jul 11, 2023

Choose a reason for hiding this comment

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

Hello @lmiller1990. I made the suggested changes and locally tried the original reproduction repo, and it works perfectly fine for it. However, I was not able to run the tests locally. After selecting the spec, I was met with a lot of errors. I modified the it() block under which you had added the test to it.only(), however it gave me the following error.

cy.task('__internal_withCtx') timed out after waiting 60000ms.



Because this error occurred during a before each hook we are skipping the remaining tests in the current suite: specChange subscription

Please guide me on how I can actually try and run the tests on my local device?

@lmiller1990
Copy link
Contributor

Let me run CI and see how it goes.

@lmiller1990
Copy link
Contributor

This seems to massively break things. https://app.circleci.com/pipelines/github/cypress-io/cypress?branch=pull%2F27240

What operating system are you on @NiharPhansalkar? Does yarn complete when you first clone the repo? Note you must use Chrome for the packages/app tests.

Are you able to run other tests - try yarn cypress:open in packages/app and choose Component Testing -- do those run?

@NiharPhansalkar
Copy link
Contributor Author

NiharPhansalkar commented Jul 12, 2023

@lmiller1990 Hello, I am running this in a VM running Fedora 38. Yes yarn does complete (however, one catch is I had to disable the NX daemon in order for it to work properly) and yes I ran it on Google Chrome. However, when I select component testing, it says the following

Cannot convert undefined or null to object

TypeError: Cannot convert undefined or null to object
    at Function.entries ()
    at updateWithPluginValues (/home/vm_work/cypress/packages/config/src/project/index.ts:113:37)
    at ProjectConfigManager.handleSetupTestingTypeReply (/home/vm_work/cypress/packages/data-context/src/data/ProjectConfigManager.ts:333:73)
    at ProjectConfigManager.setupNodeEvents (/home/vm_work/cypress/packages/data-context/src/data/ProjectConfigManager.ts:267:7)

@NiharPhansalkar
Copy link
Contributor Author

NiharPhansalkar commented Jul 12, 2023

At least here on GitHub where it shows the checks, it was previously passing most tests, failing about 7. Now all of a sudden it is failing 25 tests. I hope this is only related to the change I made? And has nothing to do with me updating the branch?

@lmiller1990
Copy link
Contributor

@NiharPhansalkar I think we need a default value: 1deb871

It was trying to do Object.entries(undefined). Let's see how this goes.

@NiharPhansalkar
Copy link
Contributor Author

@lmiller1990 Hello Lachlan, the cy.startAppServer() keeps on giving me a timeout error when I try to run the e2e tests. I even tried commenting out some code, but of course, other things start breaking.

@lmiller1990
Copy link
Contributor

I'll try and get this one merged up.

@NiharPhansalkar
Copy link
Contributor Author

Yes, but say for future contributions for cypress, I may have to test other parts? Where can I actually understand the reason for such issues occurring and try to fix them?

@lmiller1990
Copy link
Contributor

Right, I understand your question.

VM running Fedora 38.

I haven't run on Fedora or under a VM before, but the first thing I usually do to debug is run the build with DEBUG=cypress:* yarn dev and see what comes up in the logs. I have run the development scripts on Ubuntu, MacOS and windows before. If you'd like to give that a try and see if there's anything useful in the debug logs.

@NiharPhansalkar
Copy link
Contributor Author

Sure! Thank you.

@NiharPhansalkar
Copy link
Contributor Author

@lmiller1990 Hello Lachlan. I did run it with DEBUG=* yarn dev and there were quite a few errors. Can you tell me if you too have received such errors?

  1. cypress:ts registering ts-node on directory undefined
  2. nexusTypegen: cypress:ts registering ts-node on directory undefined'
  3. cypress:server environment error Cannot read properties of undefined (reading 'commandLine')
  4. cypress:packherd:error Error: Cannot find module 'pnpapi' (Lot of packherd errors)
  5. NexusSlowGuard: Taking more than 100ms to execute ["currentProject","projectId"] for query HeaderBar_HeaderBarQuery (total time 161ms)

@lmiller1990
Copy link
Contributor

Here is the entirely of what I see. I am not sure I can help with running of Fedora specifically; I don't have the time / bandwidth to try Fedora development right now. If you are able to try another distro (eg Ubuntu) where it's known to run, I can possibly help.

In the meantime, I'll get this PR ready to go.

logs.txt

@lmiller1990
Copy link
Contributor

Close in favor of #27312

AtofStryker added a commit that referenced this pull request Mar 25, 2024
* modifying object after array combination to hold older values

* regression test

* made suggested changes

* config defaults

* log

* logs

* log

* log again

* update log

* changelog

* updates changelog

* fix typo and move changelog entry and fix link

---------

Co-authored-by: Nihar Phansalkar <phansalkarnihar@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com>
Co-authored-by: Cacie Prins <cacie@cypress.io>
Co-authored-by: AtofStryker <bglesias@gmail.com>
cacieprins added a commit that referenced this pull request Mar 26, 2024
* modifying object after array combination to hold older values

* regression test

* made suggested changes

* config defaults

* log

* logs

* log

* log again

* update log

* changelog

* updates changelog

* fix typo and move changelog entry and fix link

---------

Co-authored-by: Nihar Phansalkar <phansalkarnihar@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com>
Co-authored-by: Cacie Prins <cacie@cypress.io>
Co-authored-by: AtofStryker <bglesias@gmail.com>
cacieprins added a commit that referenced this pull request Mar 26, 2024
* modifying object after array combination to hold older values

* regression test

* made suggested changes

* config defaults

* log

* logs

* log

* log again

* update log

* changelog

* updates changelog

* fix typo and move changelog entry and fix link

---------

Co-authored-by: Nihar Phansalkar <phansalkarnihar@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com>
Co-authored-by: Cacie Prins <cacie@cypress.io>
Co-authored-by: AtofStryker <bglesias@gmail.com>
cacieprins added a commit that referenced this pull request Mar 26, 2024
* modifying object after array combination to hold older values

* regression test

* made suggested changes

* config defaults

* log

* logs

* log

* log again

* update log

* changelog

* updates changelog

* fix typo and move changelog entry and fix link

---------

Co-authored-by: Nihar Phansalkar <phansalkarnihar@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com>
Co-authored-by: Cacie Prins <cacie@cypress.io>
Co-authored-by: AtofStryker <bglesias@gmail.com>
cacieprins added a commit that referenced this pull request Mar 26, 2024
* modifying object after array combination to hold older values

* regression test

* made suggested changes

* config defaults

* log

* logs

* log

* log again

* update log

* changelog

* updates changelog

* fix typo and move changelog entry and fix link

---------

Co-authored-by: Nihar Phansalkar <phansalkarnihar@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com>
Co-authored-by: Cacie Prins <cacie@cypress.io>
Co-authored-by: AtofStryker <bglesias@gmail.com>
cacieprins added a commit that referenced this pull request Mar 26, 2024
* modifying object after array combination to hold older values

* regression test

* made suggested changes

* config defaults

* log

* logs

* log

* log again

* update log

* changelog

* updates changelog

* fix typo and move changelog entry and fix link

---------

Co-authored-by: Nihar Phansalkar <phansalkarnihar@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com>
Co-authored-by: Cacie Prins <cacie@cypress.io>
Co-authored-by: AtofStryker <bglesias@gmail.com>
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 2, 2024
@cypress-io cypress-io deleted a comment from cypress-bot bot Apr 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty returned specPattern doesn't yield error if specPattern was originally an array
4 participants