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: add e2e tests for superset embedded dashboards feature #3197

Open
wants to merge 16 commits into
base: feat/embedded-superset-dashboards-DHIS2-17891
Choose a base branch
from

Conversation

HendrikThePendric
Copy link
Contributor

@HendrikThePendric HendrikThePendric commented Jan 29, 2025

The main point of this PR is to add an e2e suite for the new embedded dashboards feature. To run this suite (locally) you will need have a v42 (current dev) DHIS2 Core backend in place and you will need to update the cypress environment config (cypress.env.json) so that version 42 of the web API is used. Note that you do not need a fully functioning superset and superset-gateway instance in place: we use cy.intercept() to fake that.

While writing this PR some loosely related points were also addressed:

  • It has been made possible to use the excludeByVersionTags plugin in this repo. Unfortunately we cannot use version tags on our tests yet because the cypress-cucumber-preprocessor and cypress-tags plugins cannot be used alongside each other. For now "version toggling" of e2e tests needs to be done using a hardcoded check, like this one.
  • It has been made possible to run both cucumber based and "vanilla" cypress tests alongside each other. On of the steps to make this possible included moving separating the files into a cypress/e2e and cypress/e2e_cucumber dir. This will be convenient when we work on removing the cucumber tests in DHIS2-18930

Also while writing the tests, two bugs were identified and fixed.

Note that SonarCube has identified as many as 19 "new" issues, which are in fact all pre-existing issues which have now popped up because a lot of files have been moved from cypress/e2e to cypress/e2e_cucumber.

Also note that the typescript dev-dependency was added because it is needed by cypress-tagify. Additionally I also added @babel/plugin-syntax-dynamic-import for reasons I explain in #3197 (comment)

The node-versions in the workflow files have also been upgraded. This was initially done to ensure the remote NodeJS environment matched my local setup where tests were passing, hoping that this would help getting the tests to pass on CI. Later on I realised that the e2e tests were failing on CI because a change was needed in cypress/support/generateTestMatrix.js, but I decided to keep the node version upgrades because it's a good bit of maintenance.

@dhis2-bot
Copy link
Contributor

dhis2-bot commented Jan 29, 2025

🚀 Deployed on https://pr-3197.dashboard.netlify.dhis2.org

@dhis2-bot dhis2-bot temporarily deployed to netlify January 29, 2025 14:13 Inactive
This prevents the js spec from being included in each cucumber feature.
badeball/cypress-cucumber-preprocessor#1262
@dhis2-bot dhis2-bot temporarily deployed to netlify January 29, 2025 15:39 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify January 30, 2025 16:40 Inactive
@HendrikThePendric HendrikThePendric changed the title Chore/add e2e tests test: add e2e tests for superset embedded dashboards feature Jan 30, 2025
@HendrikThePendric HendrikThePendric marked this pull request as ready for review January 30, 2025 17:05
@dhis2-bot dhis2-bot temporarily deployed to netlify January 30, 2025 17:07 Inactive
@HendrikThePendric HendrikThePendric added the e2e record Apply this label to a pull request to trigger recording of E2E tests on Cypress Cloud label Jan 31, 2025
@dhis2-bot dhis2-bot temporarily deployed to netlify January 31, 2025 08:48 Inactive
Copy link

cypress bot commented Jan 31, 2025

dashboards-app    Run #5104

Run Properties:  status check passed Passed #5104  •  git commit 4a3696b60a ℹ️: Merge 0ac529e1f43940ddfbe66a3b3f012eebaadc5ea0 into d606f385247775a23eb45e6b369f...
Project dashboards-app
Branch Review chore/add-e2e-tests
Run status status check passed Passed #5104
Run duration 02m 13s
Commit git commit 4a3696b60a ℹ️: Merge 0ac529e1f43940ddfbe66a3b3f012eebaadc5ea0 into d606f385247775a23eb45e6b369f...
Committer Hendrik de Graaf
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 23
View all changes introduced in this branch ↗︎

@@ -42,7 +42,8 @@
"cy:run": "start-server-and-test 'yarn cy:start' http://localhost:3000 'yarn cypress run --browser chrome headless'"
},
"devDependencies": {
"@badeball/cypress-cucumber-preprocessor": "^20.1.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this dependency added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After I upgraded and added some some dev-dependencies, I cleared my node_modules and ran npx yarn-deduplicate. This resulted in a significant amount of changes in the yarn.lock and the package @dhis2/cli-app-scripts started complaining about this missing dependency, so I just added it. Since this was a change in the dev dependencies only I didn't worry about it too much. Do you think we need to investigate it further.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, I don't think so. But maybe just add a short comment to the PR description.

@@ -65,7 +67,8 @@
"redux-mock-store": "^1.5.4",
"resize-observer-polyfill": "^1.5.1",
"semantic-release": "^20",
"start-server-and-test": "^1.14.0"
"start-server-and-test": "^1.14.0",
"typescript": "^5.7.3"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a comment in the PR description about why you added typescript?

Ensure it  matches my local version where all tests pass
@dhis2-bot dhis2-bot temporarily deployed to netlify January 31, 2025 10:13 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify January 31, 2025 10:53 Inactive
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
19 New issues
19 New Code Smells (required ≤ 0)
1 New Critical Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e record Apply this label to a pull request to trigger recording of E2E tests on Cypress Cloud
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants