-
Notifications
You must be signed in to change notification settings - Fork 67
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
Setup Cypress UI testing #234
Conversation
2808e1e
to
73eb429
Compare
@Griffin-Sullivan, I'll be back tomorrow to review this PR. Sorry for the delay on it! |
73eb429
to
3fdebb0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've left a couple of comments here, I'm running the commands now, if I find something else I'll re-review it.
@@ -0,0 +1,2 @@ | |||
# Test against prod build hosted by lightweight http server | |||
BASE_URL=http://localhost:9001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to do a follow up to better handled .env variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created a follow up doc to handle this, but it's more than enough right now.
import { env, BASE_URL } from '~/src/__tests__/cypress/cypress/utils/testConfig'; | ||
|
||
|
||
const resultsDir = `${env.CY_RESULTS_DIR || 'results'}/${env.CY_MOCK ? 'mocked' : 'e2e'}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be sure we carry over som of these env variables to either a .env
file or a package.json command, where CY_RESULTS_DIR
comes from? if we get the default, it might be great to document it somewhere.
videosFolder: `${resultsDir}/videos`, | ||
env: { | ||
MOCK: !!env.CY_MOCK, | ||
coverage: !!env.CY_COVERAGE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as this, we got a cypress:run:mock_coverage
command with that env variable set to true, but here it will be always false, should we add that command or just handle this?
}), | ||
); | ||
|
||
export const BASE_URL = env.BASE_URL || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok great, we'll need to do follow ups with env variables, but head to a great start here.
@Griffin-Sullivan can you also update ../ui/frontend/docs/dev-setup.md together with this PR? |
@Griffin-Sullivan could you please also reintroduce test runs in GHA? #237 |
b0f9495
to
de49516
Compare
@ederign Ok I updated everything if you want to take another look |
/ok-to-test |
1 similar comment
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's only a couple of nits left, but really great work here!!
## Cypress Tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one nit, can you update the CONTRIBUTING.MD
file?
Thre're the Debugging and Testing
section, there you can put something like:
See [frontend testing guidelines](docs/testing.md) for more information.
|
||
Single command to run all Cypress tests or a specific test (build frontend, start HTTP server, run Cypress): | ||
```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave a blank space: MD031/blanks-around-fences
|
||
To best match production, build the frontend and use a lightweight HTTP server to host the files. This method will require manual rebuilds when changes are made to the dashboard frontend code. | ||
```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave a blan space: MD031/blanks-around-fences
|
||
To run all Cypress tests or a specific test headless | ||
```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same: MD031/blanks-around-fences
"test:watch": "jest --watch", | ||
"test:coverage": "jest --coverage", | ||
"cypress:run": "cypress run -b chrome --project src/__tests__/cypress", | ||
"cypress:run:mock": "CY_MOCK=1 npm run cypress:run -- ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"cypress:run:mock": "CY_MOCK=1 npm run cypress:run -- ", | |
"cypress:run:mock": "CY_MOCK=1 npm run cypress:run -- ", | |
"cypress:run": "cypress run -b chrome --project src/__tests__/cypress", | |
"cypress:open": "cypress open --project src/__tests__/cypress", |
Can we add cypress:open
too, to have the cypress dashboard? It's quite handy and works really great to debut stuff, if you like that, we can add it to the testing docs too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the dashboard docs:
There are two commands to run Cypress mock tests (always use the `:mock` variants).
- `open`: Open the Cypress GUI
\`\`\`bash
npm run cypress:open:mock
\`\`\`
- `run`: Run all Cypress tests or a specific test headless
\`\`\`bash
npm run cypress:run:mock
npm run cypress:run:mock -- --spec "**/testfile.cy.ts"
\`\`\`
Signed-off-by: Griffin-Sullivan <gsulliva@redhat.com>
de49516
to
7e45812
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
@lucferbux: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test |
/approve |
/lgtm |
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on #234 (comment)
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ederign, lucferbux, tarilabs The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
This PR adds all of the setup and configuration for running Cypress mock tests. I've also included some changes that will account for adding things like code coverage and e2e testing in the future. At the moment, I wrote one small test to show that the tests are working which checks that the home page loads and the 404 page loads. I also removed a unit test file, as we are planning to add unit tests in a future PR and figured it'd be better to start with a clean slate.
How Has This Been Tested?
So far I have been
npm run
commands in the./clients/ui/frontend
directory. Making sure the commands I added topackage.json
work like building, serving, and running mock tests.To test the changes you can:
cd clients/ui/frontend
npm install
npm run cypress:run:mock
Merge criteria: