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

Get Cypress up and running again (with docker and interactive testing) #652

Merged
merged 39 commits into from
Jul 2, 2024

Conversation

Splines
Copy link
Member

@Splines Splines commented Jun 18, 2024

This PR does not rework the cypress tests. Instead, it sets all the necessary infrastructure to run cypress tests locally and in our GitHub Actions pipeline without a big fuss.

Start cypress interactive GUI

This may be subject to frequent changes as this PR is only a draft right now.

  • Install VcXsrv Windows X Server. Run XLaunch. In the "Extra settings", make sure to choose "Disable access control".
    This is not needed anymore, new versions of WSL come with an X11 server, yeah 🙌 See the WSLg repo.
    The only thing you have to do is run wsl --update (in Powershell).
  • To start Cypress with the interactive test runner, execute the following command inside the docker/test/ folder:
docker compose -f docker-compose.yml -f cypress.yml -f cypress-interactive.yml up --exit-code-from cypress

Wait a few seconds and the GUI should automatically pop up. Choose E2E testing and try to run the submission dummy test I've added. You should see the edit profile page at the end.

Note that cypress shares the test database with the Rails unit tests. This shouldn't be a problem as they both clean the whole database before they execute anything. But this means, we shouldn't run cypress and unit tests at the same time. I don't feel like this is a big issue locally, if you feel it is, it's easy to spin up another docker environment.

cypress-on-rails & more links

We don't use cypress-on-rails anymore.

TODOs

  • Add Cypress back to CI/CD
  • Use GitHub Actions formatter -> I've opened a feature request here -> ▶ probably not available right now, so will do in future PR
  • Long-term: write more robust cypress tests following best practices. The starting guide is also a good resource. -> ▶ will do in future PRs
  • Fix ESLint errors in cypress files (these are not visible here in the pipeline as we didn't change these files)
  • Implement clean login mechanism in combination with app scenarios, unify interfaces
  • Provide just commands for easy startup of cypress GUI -> ▶ in future PR
  • Maybe find a better way than X11 server, see here and my StackOverflow question.
  • Add Cypress section to wiki

@Splines Splines added CI/CD Continuous Integration / Continuous Delivery (aka pipeline stuff) tests Unit tests, integration tests etc. labels Jun 18, 2024
@Splines Splines self-assigned this Jun 18, 2024
Also updated the cypress user emails and passwords.
Along side this, the schema was automatically updated and got rid of
old translation tables originally created by the globalize gem.
They were still in here as remnant of #609.
See https://github.com/rails/rails/blob/d43ee2088118425e493766aeb20575e9ce7159d1/actionmailbox/test/dummy/db/schema.rb#L5-L9

We also abort the script if it is called from the production
environment. It's only intended for usage in the dev/test environment.
For production, we have the respective master and worker entrypoints.
initialize.sh Show resolved Hide resolved
initialize.sh Show resolved Hide resolved
Copy link
Collaborator

@fosterfarrell9 fosterfarrell9 left a comment

Choose a reason for hiding this comment

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

LGTM. Great work!

@Splines Splines merged commit 6bde35d into dev Jul 2, 2024
9 of 11 checks passed
@Splines Splines deleted the tests/cypress branch July 2, 2024 21:50
@Splines Splines mentioned this pull request Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/CD Continuous Integration / Continuous Delivery (aka pipeline stuff) tests Unit tests, integration tests etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants