Skip to content

fix: correctly migrate projects with custom integration folder #19929

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

Merged
merged 23 commits into from
Jan 28, 2022

Conversation

lmiller1990
Copy link
Contributor

@lmiller1990 lmiller1990 commented Jan 27, 2022

resolves: https://cypress-io.atlassian.net/browse/UNIFY-989

One of the migration use cases was not handled correctly. We had an example project but didn't have the right assertions to verify it. Now we do.

The correct UI looks like this (screenshot from the test I added). Note it shows src/basic.spec.js correctly (src is the custom integration folder for this project).

image

We were not handling the case where the config is:

{
  "integrationFolder": "src"
}

We had a regexp hard-coded to use cypress/..., we should use their custom integration folder.

Also, we were including component specs in the E2E auto migration step - that's incorrect, so I fixed it. All of the fixes have tests - finally, the migration UI is getting in shape.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 27, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Jan 27, 2022



Test summary

17933 0 216 0Flakiness 0


Run details

Project cypress
Status Passed
Commit 24596ea
Started Jan 28, 2022 2:47 PM
Ended Jan 28, 2022 2:59 PM
Duration 12:17 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


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

@elevatebart elevatebart left a comment

Choose a reason for hiding this comment

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

I have a few question before I feel comfortable approving this one.

Comment on lines 49 to 50
// TODO: the current logic is wrong and does not consider
// the case of a custom integration folder!
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this test and I see it using a custom integrationFolder (src).
I see that files are renamed but left in the same folder.
This feels right.

Can you be more explicit? What logic is wrong? What do we need to consider?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, the comment was from before (when it was wrong). This PR fixes the wrong. I will remove the comment.

afterRegexp: getNewHighlightRegexp('e2e'),
},
usingCustomIntegrationFolder: {
beforeRegexp: (folder: string) => `${folder}\/.*?(?<ext>[._-]?[s|S]pec.|[.])(?=[j|t]s[x]?)`,
Copy link
Contributor

Choose a reason for hiding this comment

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

can folder contain any special characters? . or / could probably make it fail right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no idea, this regexp has been here for a while. We almost certainly need more unit tests around it. This should be a separate PR, there's likely a ton of complexity to be uncovered when working on this regexp, I will follow it up.

I am thinking the regexp approach may not be ideal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is big, let's do it elsewhere. https://cypress-io.atlassian.net/browse/UNIFY-997

findByTestingType(projectRoot, e2eDirPath, 'e2e'),
])
): Promise<GetRelativeSpecs> {
const e2e = await findByTestingType(projectRoot, e2eDirPath, 'e2e')
Copy link
Contributor

Choose a reason for hiding this comment

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

So we do not rename component specs anymore?

My understanding was that we wanted the rename to avoid collision with jest when moving component tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We never did auto rename on component specs - only E2E. Component is always manual.

Basically,

  • autoRename === e2e
  • manualRename === CT

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Edit, apparently this is NOT the case, rename is automated, moving is not. 😮‍💨


debug('looked in %s and %s and found %o', compFolder, intFolder, specs)
debug('looked in %s and %s and found %o', intFolder, specs)
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
debug('looked in %s and %s and found %o', intFolder, specs)
debug('looked in %s and found %o', intFolder, specs)

const intFolder = await this.integrationFolder()

const specs = await getSpecs(this.ctx.currentProject, compFolder || null, intFolder || null)
const specs = await getSpecs(this.ctx.currentProject, intFolder || null)
Copy link
Member

@emilyrohrbough emilyrohrbough Jan 28, 2022

Choose a reason for hiding this comment

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

Should we worry about users who have custom testSpec regex pattern in their <10.0 configuration? Currently the pattern(s) will be used to find the specs, whether or not they are in the integration folder: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/util/specs.ts#L173

EDIT: Also, why did we remove migrating the tests found in the component folder?
Nevermind. The naming here didn't seem specific to E2e.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixing this one up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also re: migrating component tests, you were right, I'd misunderstood a requirement - the first step of the migration will rename them if you are using the defaults, eg cypress/component/foo.spec.js will become cypress/component/foo.cy.js. In the next step, we ask you to manually move the component specs to be colocated with their component.

This part of the migration (specifically, for component tests) is really not ideal. Although you can opt to leave them in cypress/component, most people like to colocate their component tests. Anyway, that's a product/design decision beyond the scope of this PR - the vast majority of users are E2E, and the workflow works really well for those users.

@lmiller1990 lmiller1990 merged commit 97e9378 into 10.0-release Jan 28, 2022
@lmiller1990 lmiller1990 deleted the lmiller1990/UNIFY-989 branch January 28, 2022 15:08
tgriesser added a commit that referenced this pull request Jan 31, 2022
* 10.0-release: (25 commits)
  fix(unify): improve dev server config ergonomics (#19957)
  feat: add spec pattern modal (#19801)
  fix: Windows e2e project scaffolding issues (#19938)
  feat: update @cypress/schematic to use proper e2e config for 10.0.0 (#19827)
  fix: correctly migrate projects with custom integration folder (#19929)
  fix: component spec creation with spec pattern (#19862)
  fix: missed committing yarn.lock after merge conflict
  fix: correct reference branch / commitSha in performance-reporter (#19941)
  feat: update navbar UI per Figma (#19926)
  fix: seed examples files when no e2e directory is created (#19768)
  chore: remove windy lightBlue warning
  test: component test updates (#19925)
  feat: Focus browser from select browser screen and on dashboard login (#19842)
  test: Honeycomb system-test reporter (#19855)
  fix(deps): update dependency engine.io to v5.2.1 [security]
  feat: Retain fileName when working with aliased fixtures and files (#19820)
  Update release-process.md
  Update release-process.md
  Update release-process.md
  Update release-process.md
  ...
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.

3 participants