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: resolves correctly specPattern #21057

Merged

Conversation

estrada9166
Copy link
Member

User facing changelog

The default specPattern was being resolved as it was coming from the user config file which was incorrect; the reason why it was being resolved from the config file was that when trying to search for the default value, it was never found because it was nested in the testing type - and we are merging the testing type into the top-level config, creating a mismatch between the defaults values and the config itself

Before

image

After

image

Additional details

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • Have new configuration options been added to the cypress.schema.json?

@estrada9166 estrada9166 requested a review from a team as a code owner April 13, 2022 03:16
@estrada9166 estrada9166 requested review from jennifer-shehane and removed request for a team April 13, 2022 03:16
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 13, 2022

Thanks for taking the time to open a PR!

@estrada9166 estrada9166 requested review from emilyrohrbough and lmiller1990 and removed request for jennifer-shehane April 13, 2022 03:17
@cypress
Copy link

cypress bot commented Apr 13, 2022



Test summary

17872 0 217 0Flakiness 2


Run details

Project cypress
Status Passed
Commit dd5a2d1
Started Apr 14, 2022 6:20 PM
Ended Apr 14, 2022 6:34 PM
Duration 13:34 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

commands/xhr.cy.js Flakiness
1 ... > no status when request isnt forced 404
cypress/proxy-logging.cy.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

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.

One recommendation and one general question

})

cy.get('[data-cy="config-code"]').within(() => {
cy.get('.bg-gray-50').contains('cypress/e2e/**/*.cy.{js,jsx,ts,tsx}')
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if these should be data selectors, like [data-cy-config="resolved"]. I do not like using CSS much for test selectors, it's super hard to read and tends to be brittle. What do you think?


// As we normalize the config based on the selected testing type, we need
// to do the same with the default values to resolve those correctly
defaultsForRuntime = { ...defaultsForRuntime, ...defaultsForRuntime[options.testingType] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting - kind of surprised we need to do this, I thought this was a UI only bug - so was the bug more deeper in the system, too?

The config stuff is so spread out all over the place, probably why we have some many bugs around it :(

Copy link
Member

Choose a reason for hiding this comment

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

+1 all configuration things should prob be happening in the config package to keep this logic in one place and so we can make it easily testable.


// As we normalize the config based on the selected testing type, we need
// to do the same with the default values to resolve those correctly
defaultsForRuntime = { ...defaultsForRuntime, ...defaultsForRuntime[options.testingType] }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
defaultsForRuntime = { ...defaultsForRuntime, ...defaultsForRuntime[options.testingType] }
defaultsForRuntime = {
...defaultsForRuntime,
...defaultsForRuntime[options.testingType]
}

Copy link
Member

@emilyrohrbough emilyrohrbough Apr 13, 2022

Choose a reason for hiding this comment

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

Below we spread these values with the ignore type. Was the config overriding the default resolved values?

Are we able to add a unit test for this?

EDIT: talked offline, looks like it was stomping on itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

_.defaultsDeep(config, defaultsForRuntime) is updating the config with the default, including the nested types which are totally correct, but the issue comes here config = setResolvedConfigValues(config, defaultsForRuntime, resolved) because, at that moment config has the nested type merged with the top level, but the nested fields as specPattern do not exist on top-level, so defaultsForRuntime does not include it unless we merge the testing type with the top-level ones, and when we try to search for the resolved one, it does not exist on the top-level (the default) so we assume it was coming from users config

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.

Thanks for the quick follow up... ✔️

@flotwig flotwig requested review from flotwig and removed request for emilyrohrbough and tbiethman April 14, 2022 15:36
Comment on lines 143 to 148
// As we normalize the config based on the selected testing type, we need
// to do the same with the default values to resolve those correctly
defaultsForRuntime = {
...defaultsForRuntime,
...defaultsForRuntime[options.testingType],
}
Copy link
Contributor

Choose a reason for hiding this comment

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

imo, this logic would be more suitably moved to packages/config/src/index.ts where getDefaultValues is defined. this is the only usage of that function, so IMO it would make sense to confine this logic to the config package. what do you think @estrada9166 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good! yeah, I'm gonna update it!

@estrada9166 estrada9166 merged commit 7f69f94 into 10.0-release Apr 14, 2022
@estrada9166 estrada9166 deleted the alejandro/fix/resolve-correctly-default-specPattern branch April 14, 2022 18:39
tgriesser added a commit that referenced this pull request Apr 20, 2022
…e-config

* 10.0-release:
  fix: make error on integration folder point to e2e (#20853)
  fix(unify): Update Cypress Dashboard Service Link in Login Modal (#21084)
  chore: fix windows node_modules install step (#21098)
  fix: webpack integration tests for app w webpack-dev-server-fresh (#21093)
  fix: move non spec files on migration (#21054)
  Bumping electron version in root
  chore(deps): Bumping electron dependency to 15.5.1 (#21072)
  fix: resolves correctly specPattern (#21057)
  feat: replace reconfigure button on settings page with link to config doc (#21077)
  feat(launchpad): update CT setup and config scaffolding (#20893)
  fix: cy.type('{enter}') on <input> elements submits the form correctly after Firefox 98. (#21042)
  chore: making the npm deps for vue, react, and vue2 use 0.0.0-dev (#21081)
  fix(cli): show additional mitigation steps for max path length error (#21047)
  fix: Plugin error when sending on disconnected IPC channel (#21011)
  chore: add internal types for cy.session command (#21028)
  chore: Update Chrome (stable) to 100.0.4896.88 (#21043)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants