2.5 KiB
2.5 KiB
End-to-End and Unit Testing Documentation for Home Monitor
Test Description
The Home Monitor project uses Cypress to automate both End-to-End (E2E) and unit tests. These tests ensure that the main features of the application work correctly, both from the user’s and the developer’s perspectives.
Types of Tests
- End-to-End (E2E) Tests: Simulate real user behavior on the web interface. They check critical user flows, data display, error handling, and the responsiveness of the application.
- Unit Tests: Verify the correct functioning of TypeScript components and functions in isolation.
Test Structure
- E2E tests are located in
web-app/cypress/e2e/ - Unit tests are located in
web-app/cypress/unit/ - Custom commands and global setup are in
web-app/cypress/support/ - Cypress configuration is in
web-app/cypress.config.ts
How to Run the Tests
Install Dependencies
cd ./web-app
npm install --inlude=dev
Run unit Tests
npm run test:unit
Run E2E Tests
npm run test:e2e
Run All Tests
npm run test
Note
The cypress GUI can be launched with the command:
npx cypress open
Test Coverage
End-to-End (E2E) Tests
- Fetch Measurements Button:
- Verifies that the "Fetch Measurements" button is visible and functional on the main page.
- Tests fetching timeseries data with a valid user-room-device selection, ensuring the main chart is displayed and no "no data" message appears.
- Tests fetching timeseries data with an invalid user-room-device selection (e.g., changing the user to "Sylvan"), ensuring the main chart is not displayed and the "no data" message is shown.
Important Notes
The E2E tests use a web-app development image deployed on https://app.mse.kb28.ch/ for the moment. Because there is a problem with the service image in the CI. The environment variables cannot be set correctly to the job's service. An issue is opened to fix this problem: [#37].
Unit Tests
- Serie Component:
- Checks that a
Serieinstance initializes with the correct properties. - Validates that the correct label is returned for temperature and humidity types.
- Ensures the label "Unknown" is returned for unknown types.
- Verifies that temperature and humidity data are formatted correctly by
getSerie(), including label, color, and data structure. - Ensures unknown types are handled appropriately in
getSerie(), defaulting to the correct color and axis.
- Checks that a