mattermost / mattermost-gitpod-config

5 stars 10 forks source link

Use dockerfile to support cypress tests #10

Closed mickmister closed 2 years ago

mickmister commented 2 years ago

Summary

Inspiration from https://github.com/mikenikles/cypress-on-gitpod

This PR makes it so Gitpod can run tests using a headless chrome browser. In order to get tests to run, I modified the webapp's cypress:run command from:

cross-env TZ=Etc/UTC cypress run --browser chrome --config ignoreTestFiles='**/enterprise/**/*.{js,ts}'
cross-env TZ=Etc/UTC cypress run --browser chrome

As I was getting this error with the original command:

The following configuration option is invalid:

 - ignoreTestFiles

Ticket Link

Fixes https://github.com/mattermost/mattermost-gitpod-config/issues/9

mickmister commented 2 years ago

@sinansonmez Please let me know if this fixes your issue with running cypress tests 🙂

sinansonmez commented 2 years ago

@mickmister it worked perfectly, thanks for the effort. With these enhancements, Gitpod is becoming a full-fledged development environment for Mattermost.

One additional information on this: Some of the tests are failing because it is sending the request to http://localhost:8065/api/v4/[SOMETHING] but server is not running on localhost but remotely on Gitpod server. Please find an example error I received below.

  1) Autocomplete with Elasticsearch - Users
       "before all" hook for "MM-T3863 Users in correct in/out of channel sections":
     CypressError: `cy.request()` failed on:

http://localhost:8065/api/v4/trial-license

The response we received from your web server was:

  > 403: Forbidden

This was considered a failure because the status code was not `2xx` or `3xx`.

If you do not want status codes to cause failures pass the option: `failOnStatusCode: false`
mickmister commented 2 years ago

@sinansonmez This should be fixable by editing the baseUrl field here to be the Gitpod MM server URL: https://github.com/mattermost/mattermost-webapp/blob/66dd6ee74af9b03fe51010bdfb813857f57418a5/e2e/cypress/cypress.config.ts#L50. You can get the server's URL by running gp url 8065 in the Gitpod terminal.

Ideally this is set automatically. We may be able to set this by setting an environment variable such as CYPRESS_e2e_baseUrl but I'm not sure if the env vars support nested values.