-
Notifications
You must be signed in to change notification settings - Fork 94
Improve E2e test documentation #3736
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
base: integration
Are you sure you want to change the base?
Changes from all commits
e976a9a
712e6c6
f3cc680
e758479
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -206,27 +206,52 @@ If you are unable to use Docker, please contact a core team member to get instru | |
|
|
||
| # Testing | ||
|
|
||
| ## api | ||
| ## WebApp E2e tests | ||
|
|
||
| When running Cypress E2E tests, it's recommended to use a dedicated test database. This helps keep your main development database free from testing data. | ||
|
|
||
| ### Setup | ||
|
|
||
| 1. Start the dedicated test database container with `docker compose --profile testing up testing-db` | ||
| 1. Run the `dev` migrations `npm run migrate:dev:db` from `packages/api`. | ||
| 1. Go to `packages/end-to-end` directory. | ||
| 1. Install the E2e test dependencies`npm i`. | ||
|
|
||
| ### Execution | ||
|
|
||
| 1. Run the tests `npx cypress run`. | ||
|
|
||
| As result videos and logs are going to be stored in the directories prompted by the shell. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My shell didn't prompt me! Did it prompt you?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it does ! maybe you need to scroll a bit. |
||
|
|
||
| ## API Integration tests | ||
|
|
||
| To run [ESLint](https://eslint.org/) checks execute `npm run lint` | ||
|
|
||
| The [chai.js](https://www.chaijs.com/) and [jest](https://jestjs.io/) libraries automate tests that run real database operations using a dedicated database named `test_farm`, distinct from the `pg-litefarm` database that the app normally uses. | ||
|
|
||
| You'll want to confirm that you have an empty `test_farm` database (otherwise use your preferred database client to create one) before continuing with the following: | ||
|
|
||
| ### Setup | ||
|
|
||
| 1. In a terminal, navigate to the `packages/api` folder. | ||
| 2. Execute `npm run migrate:testing:db` to set up the test database. | ||
| 3. Execute `npm test` to launch the tests. Or, to generate test coverage information, run `npm test -- --coverage .` and then see the `coverage/index.html` file. | ||
| 1. Execute `npm run migrate:testing:db` to set up the test database. | ||
|
|
||
| ### Execution | ||
|
|
||
| 1. Execute `npm test` to launch the tests. | ||
| 1. (Optionally) to generate test coverage information, run `npm test -- --coverage .` and then see the `coverage/index.html` file. | ||
|
|
||
| While the tests do attempt to clean up after themselves, it's a good idea to periodically use `psql` or your database client to `DROP` and `CREATE` the `test_farm` database, followed by the migrations from step 2 above. | ||
|
|
||
| ## webapp | ||
| ## WebApp testing | ||
|
|
||
| To run [ESLint](https://eslint.org/) checks execute `pnpm lint` | ||
|
|
||
| Since this is a mobile web application, webapp should be viewed in a mobile view in the browser. | ||
|
|
||
| You can also test LiteFarm on your actual mobile device using the network adddress returned by `vite --host` when you start the webapp in development mode. To do this, also update `VITE_API_URL` in your `webapp/.env` file from localhost to that address (or your computer's network name) and the appropriate API port. Most of LiteFarm can be tested like this, but please note that Google SSO and some other functionality will not work over the local network. | ||
| You can also test LiteFarm on your actual mobile device using the network adddress returned by `vite --host` when you start the webapp in development mode. | ||
| To do this, also update `VITE_API_URL` in your `webapp/.env` file from localhost to that address (or your computer's network name) and the appropriate API port. | ||
| Most of LiteFarm can be tested like this, but please note that Google SSO and some other functionality will not work over the local network. | ||
|
|
||
| # ngrok | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,28 @@ services: | |
| volumes: | ||
| - ./initdb.d:/docker-entrypoint-initdb.d | ||
| - postgres-data:/var/lib/postgresql/data | ||
|
|
||
| testing-db: | ||
| container_name: litefarm-test-db | ||
| image: postgres:13 | ||
| ports: | ||
| - "5434:5432" | ||
| environment: | ||
| POSTGRES_DB: "test_farm" | ||
| POSTGRES_USER: "postgres" | ||
| POSTGRES_PASSWORD: "postgres" | ||
| POSTGRES_HOST: postgres | ||
| POSTGRES_PORT: 5432 | ||
| volumes: | ||
| - ./initdb.d:/docker-entrypoint-initdb.d | ||
| healthcheck: | ||
| test: ["CMD", "pg_isready", "-U", "postgres"] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 5 | ||
| profiles: | ||
| - testing | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you put this on a profile (e.g.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed ! |
||
| minio: | ||
| image: minio/minio:RELEASE.2023-06-09T07-32-12Z | ||
| restart: unless-stopped | ||
|
|
@@ -60,8 +82,8 @@ services: | |
| image: litefarm/node-awscli:latest | ||
| restart: unless-stopped | ||
| volumes: | ||
| - ./packages/api:/packages/api | ||
| - ./packages/webapp/public/locales:/packages/webapp/public/locales | ||
| - ./packages/api:/packages/api:Z | ||
| - ./packages/webapp/public/locales:/packages/webapp/public/locales:Z | ||
| - export-node-modules:/packages/api/node_modules | ||
| working_dir: /packages/api | ||
| entrypoint: ./dev.export.sh | ||
|
|
||

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'm not sure why your numbers are all "1" 😂
Also the migration scripts all live in
packages/apinot inpackages/end-to-endThere 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.
the "1's" is one of the best tricks Markdown has 😂 this way you avoid editing the numbers whenever there's a change in the order and they will render in the browser properly, for instance .