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

test(cypress): upgrade cypress to v10 and migrate to ts #991

Merged
merged 31 commits into from
Aug 15, 2022

Conversation

seaerchin
Copy link
Contributor

@seaerchin seaerchin commented Jul 21, 2022

note: most line changes are from package-lock

Problem

our cypress version is ~4 major versions behind. the v6 ui is not that intuitive and it lacks features as compared to the v10 one (eg: dashboard sync/component testing).

furthermore, our tests are written in js originally, which lacks many intellisense features compared to ts. this is most evident during usage of custom commands, where the types cannot be automatically inferred and the command has no intellisense.

this PR migrates cypress to v10, together with a migration to ts.

Solution

  1. upgrade cypress to v10 and followed migration guide
  2. removed old settings for cypress
    • most notably, this had the setUpNodeEvents to point cypress at the underlying react-scripts webpack config but has since been removed as we need a ts step, which is already done by the webpack pre-processor. the alias and such has been replaced using ts-paths, in the plugins folder (see here)
  3. migrate cypress custom commands to ts.
    • for parent commands, this is now a 2-step process, requiring a function signature in index.d.ts (so that the global cypress object will have the correct types for the custom command - note that this should return Chainable<void>) and the command definition itself
    • for child commands, it's similar to the above except that we have to declare the type correctly as Chainable<ChildType> (for commands returning element, this is Chainable<JQuery<HTMLElement>> and the function definition has to take a prevSubject argument).
  4. add custom tsconfig for cypress - this is to allow for top level suggestions of hte cy object without it being present in app code

@seaerchin seaerchin temporarily deployed to staging July 21, 2022 13:42 Inactive
@seaerchin seaerchin marked this pull request as draft July 21, 2022 13:42
@seaerchin seaerchin temporarily deployed to staging July 21, 2022 13:47 Inactive
@seaerchin seaerchin temporarily deployed to staging July 21, 2022 14:01 Inactive
@seaerchin seaerchin changed the title [wip] test(cypress): upgrade cypress to v10 and migrate to ts test(cypress): upgrade cypress to v10 and migrate to ts Jul 22, 2022
@seaerchin seaerchin marked this pull request as ready for review July 22, 2022 03:42
@seaerchin seaerchin temporarily deployed to staging August 1, 2022 05:11 Inactive
@seaerchin seaerchin temporarily deployed to staging August 1, 2022 05:16 Inactive
@seaerchin seaerchin temporarily deployed to staging August 1, 2022 05:26 Inactive
@seaerchin seaerchin force-pushed the test/update-cypress branch from 5634f51 to 49b712a Compare August 1, 2022 05:30
@seaerchin seaerchin temporarily deployed to staging August 1, 2022 05:31 Inactive
@seaerchin seaerchin force-pushed the test/update-cypress branch from 49b712a to 672db3e Compare August 1, 2022 06:15
@seaerchin seaerchin temporarily deployed to staging August 1, 2022 06:15 Inactive
@seaerchin seaerchin temporarily deployed to staging August 1, 2022 09:52 Inactive
@seaerchin seaerchin temporarily deployed to staging August 1, 2022 10:05 Inactive
@@ -1,22 +0,0 @@
import waitForDom from "./waitForDom"
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, does cypress 10 no longer need waitForDom to reduce test flakiness?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oof i missed this. the waitForDom actually didnt seem to have any effect - this might be because i added some assertions.

just double checking here - the waitForDom prevents the xxx is detached from the dom error? if so, i think it might be useful for me to undo the deletion and instead, migrate it to ts

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this seemed to help with the issue originally - not sure if moving to cypress 10 helps already though. If the tests are less flaky now, maybe it doesn't need to be readded?

* chore(package lock): update deps

* fix(cards): update cards to avoid broken styling

* chore(package-lock): down to npm v6

* fix(foldercard.jsx): updated old folder card to prevent weird ui styling

* chore(cypress commands): shift assertion into commands and remove wait

* fix(files/folders spec): fix spec

* test(cypress.config): update cypress config to hold only 10 tests in mem

* fix(move.spec): update commands for new context menu dom structure

* fix(cypress specs): fix remaining specs affected by context menu refactor

* test(e2e): remove static waits and add new commands  (#1001)

* refactor(cypress commands): add more custom commands to cypress

* fix(cypress tests): fixed using static wait times and instead use assertions

* chore(settings.spec): refactor settings spec to use new constants

* test(cypress commands): add new command for setting up default interceptors

* test(editpage.spec): update editpage.spec to use new interceptor commnad

* fix(cypress specs): remove accidental .only

* test(cypress.config): change base url to be set in config rather than dynamically for each test

* test(files.spec): use new commands to smooth api

* chore(cypress constants): add more cypress constants

* refactor(folders.spec): refactor to use new commands and remove old constants

* refactor(cypress specs): use new commands and constants

* test(resourcecategory.spec): add new command and refactor resource category to use new commands

* refactor(resources.spec): shift to new api

* chore(settings.spec): use new constants

* refactor(sites.spec): update to new interceptors

* chore(workspace.spec): update to new commands

* chore(cypress constants): remove wait time constants

* fix(editpage.spec): updddate test to have more specific wait

* fix(cypress specs): update flakey tests

* chore(cypress commands): update commands and docs

* test(cypress specs): fix remaining specs

* ci(ci-e2e): adds github commit message and info

this is to avoid inconsistent dashboard messages for cypress - during push events, the title is
empty so cypress uses the commit hash for hte dashboard; this isn't useful and this commit changes
it to the PR title instead. see
https://docs.cypress.io/guides/continuous-integration/github-actions#Pull-requests-commit-message-is-merge-SHA-into-SHA
for more info
@seaerchin seaerchin temporarily deployed to staging August 15, 2022 04:19 Inactive
@seaerchin seaerchin merged commit bc57e1e into develop Aug 15, 2022
@seaerchin seaerchin deleted the test/update-cypress branch August 15, 2022 04:21
@seaerchin seaerchin temporarily deployed to staging August 15, 2022 04:34 Inactive
This was referenced Aug 25, 2022
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.

2 participants