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(e2e): remove static waits and add new commands #1001

Merged
merged 22 commits into from
Aug 15, 2022

Conversation

seaerchin
Copy link
Contributor

@seaerchin seaerchin commented Aug 5, 2022

This PR builds upon #998 and the newly introduced commands there

Problem

e2e tests are flakey and take extremely long to run, leading to them being a chore to maintain and run (on a release to prod).

the flakiness is due to 2 parts:

  1. async rendering by the UI library (react), causing the initially queried dom element to no longer exist. (this might be more annoying than expected, see this for an overview on the cypress side)
  2. network requests might take extremely long and timeout, leading to the test failing (and possibly causing downstream tests to also fail)

point 1/2 above is also part of why the e2e tests take extremely long - because our e2e tests incur a real network call, the strategy taken is to wait for an arbitrary period of time (which, as noted here, is an anti-pattern). this means that even if the request completes early, we still have to wait. in addition, e2e tests at present also wait for the dom to stabilize through waiting. this also incurs additional time.

Solution

This PR is focused towards tackling point 2 above. this is done through

  1. adding new commands to set up broad interceptors (not ideal, but still better than wait) for our endpoints
  2. waiting on the actual network request so that once the request terminates, e2e tests can continue execution rather than continue waiting
  3. adding new commands for oft repeated tasks + adding constants to reduce boilerplate and ease maintenance

@seaerchin seaerchin temporarily deployed to staging August 5, 2022 04:52 Inactive
@seaerchin seaerchin changed the base branch from fix/context-menu to develop August 5, 2022 04:54
@seaerchin seaerchin changed the base branch from develop to fix/context-menu August 5, 2022 04:54
@seaerchin seaerchin temporarily deployed to staging August 5, 2022 05:00 Inactive
@seaerchin seaerchin temporarily deployed to staging August 5, 2022 05:11 Inactive
@seaerchin seaerchin changed the title Test/cypress/remove waits test(e2e): remove static waits and add new commands Aug 5, 2022
@seaerchin seaerchin force-pushed the test/cypress/remove-waits branch from c8f70bf to 0071673 Compare August 5, 2022 19:22
@seaerchin seaerchin temporarily deployed to staging August 5, 2022 19:22 Inactive
@seaerchin seaerchin temporarily deployed to staging August 5, 2022 19:35 Inactive
@cypress
Copy link

cypress bot commented Aug 5, 2022



Test summary

109 1 0 0


Run details

Project isomercms-frontend
Status Failed
Commit 0071673
Started Aug 8, 2022 4:00 AM
Ended Aug 8, 2022 4:21 AM
Duration 21:16 💡
OS Mac 21.4.0
Browser Electron 100

View run in Cypress Dashboard ➡️


Failures

cypress/e2e/workspace.spec.ts Failed
1 Workspace Pages flow > Create folder, rename folder, and delete folder from Workspace > Should be able to rename a folder

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

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 8, 2022 04:27 Inactive
@seaerchin seaerchin changed the base branch from fix/context-menu to Cypress August 8, 2022 04:28
@seaerchin seaerchin changed the base branch from Cypress to fix/context-menu August 8, 2022 04:28
@seaerchin seaerchin marked this pull request as ready for review August 8, 2022 04:28
@seaerchin
Copy link
Contributor Author

Test summary

109 • 1 • 0 • 0

Run details

Project isomercms-frontend
Status Failed
Commit 0071673
Started Aug 8, 2022 4:00 AM
Ended Aug 8, 2022 4:21 AM
Duration 21:16 💡
OS Mac 21.4.0
Browser Electron 100
View run in Cypress Dashboard ➡️

Failures

cypress/e2e/workspace.spec.ts Failed
1 Workspace Pages flow > Create folder, rename folder, and delete folder from Workspace > Should be able to rename a folder
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

SO CLOSE TO A PERFECT RUN GDI

@seaerchin seaerchin temporarily deployed to staging August 8, 2022 04:38 Inactive
Copy link
Contributor

@alexanderleegs alexanderleegs left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for fixing tests!

@seaerchin seaerchin merged commit 7f6fab3 into fix/context-menu Aug 15, 2022
@seaerchin seaerchin deleted the test/cypress/remove-waits branch August 15, 2022 04:18
seaerchin added a commit that referenced this pull request Aug 15, 2022
* 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 added a commit that referenced this pull request Aug 15, 2022
* chore(package): update cypress

* chore(cypress): removed unused plugins index file

see here https://docs.cypress.io/guides/references/migration-guide#Plugins-File-Removed for more
details

* chore(cypress): ran automatic migration tool

* chore(cypress.config): update cypress config

* chore(cypress): add support for component testing

* chore(editpage): migrate to ts

* refactor(cypress commands): shift to ts

* chore(waitfordom): remove waitfordom and related files

this is because the wait for dom file runs into errors with pre-processing using webpack (see our
cypress config, which loads and uses webpack). this means that the file is currently incompatible
with ts (however, it does work if js). as this file is only used in medias, the file is removed and
the call sites will be updated accordingly

* refactor(files.spec): migrate to ts

* refactor(folders): migrate to ts

* refactor(homepage.spec): migrate to ts

* refactor(images.spec): migrate to ts

* refactor(move.spec): migrate to ts

* chore(support/index.d.ts): remove outdated function declartation

* refactor(resourceacategory): migrate to ts

* refactor(resources.spec): migrate to ts

* refactor(settings.spec): migrate custom commands to own file and migrate to ts

* feat(cypress.config): shift to transpiling ts

* refactor(cypress): migrate remaining specs from js to ts and add allowJS option

* docs(cypress/support): shift JSDocs for commands to index.d.ts so TS reflect them

* refactor(legacy): shift utils to utils/ and renamed it legacy to avoid more code

* build(cypress/tsconfig): update cypress tsconfig to point to the base src/ folder

* chore(cypress/e2e): shorten imports

* chore(toasts): change to ts from jsx

* chore(utils): split some util functions into scoped file

* chore(utils/index): add index

* fix(api): change import to avoid dep cycle

* fix(leftnavgeneration): change export to deslugifyDirectory

* fix(validators): fixed deps cycle

* fix(jest.config): specify setup files to enable mockign for testdecoder

* fix(context-menu): update context menu styling to fix UI breakage (#998)

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