Rooms Management System - E2E Testing Documentation¶
Overview¶
The app/frontend/cypress folder provides comprehensive end-to-end (E2E) testing coverage for the Rooms Management System, a web-based application for managing rooms, users, displays, roles, events, and tasks. The test suite uses Cypress to automate UI testing, form validation, CRUD operations, permissions, and user workflows across the entire application.
Project Purpose¶
The Rooms Management System is a multi-user application designed to manage smart room resources. This testing suite validates:
- User authentication and authorization
- Complete CRUD operations on all entities (Rooms, Users, Displays, Roles, Events, Tasks)
- Role-based access control and permissions
- UI navigation and interaction
- Form input validation
- Event triggers and task management
- Backend API read and write access
Core Functionality¶
Tested Entities¶
- Rooms - Manage physical room spaces with attributes (location, capacity, event schedule)
- Users - User management with email authentication and role assignment
- Displays - Hardware display registration and management (MAC address-based)
- Roles - Custom role creation with permission management
- Events - Event scheduling tied to rooms
- Tasks - Task creation and assignment for users and rooms
- Event Types & Task Types - Configurable entity classifications for distinguishing different Event and Task purposes
Test Coverage¶
The test suite includes:
- Env.cy.js - Core helper functions and API spies
- TestClick.cy.js - UI navigation and interaction testing
- TestFill.cy.js - Form input and validation testing
- TestCreate.cy.js - Complete CRUD operations and entity creation
- TestCreateDelete.cy.js - Create and delete workflows
- TestCreateEdit.cy.js - Create and edit workflows
- TestCRUD.cy.js - Full CRUD cycle testing
- TestPermissions.cy.js - Role-based access control validation
- TestUserLogin.cy.js - Authentication workflows
- Tables.cy.js - Table interaction utilities
Quick Start Guide¶
Prerequisites¶
- Node.js (v14 or higher)
- Docker with backend service running on port 8081
- Backend service container named
backend_devcontainerand database service namedbackend_devcontainer-postgres-1 - PostgreSQL database accessible to the backend service
Setup Instructions¶
1. Configure Environment¶
Create a .env file in the backend directory. Use .env copy as a reference template:
2. Start Backend Server¶
Ensure the backend API is running:
Verify backend is accessible at http://localhost:8081/v1/health/
3. Build and Serve Frontend¶
The frontend will be served at http://localhost:4173 (used by Cypress tests).
Make sure to use the production build so the server is run realistically.
4. Initialize Database Dump¶
Create an initial database snapshot for test isolation: (this is optional if cypress is used)
This creates dump.sql - the baseline database state for all tests.
Running Tests¶
Interactive Mode (Recommended for Development)¶
Open the Cypress Test Runner:
This launches an interactive browser where you can:
- Select individual tests to run
- View test execution in real-time
- Debug with browser DevTools
- Re-run tests with code changes
Using Firefox¶
Headless Mode (CI/CD)¶
Run all tests without opening the browser:
Run specific test file:
Run tests with Firefox:
Run with custom viewport:
Available Test Suites¶
1. TestClick.cy.js - UI Navigation & Interaction¶
Tests UI element interactions and sidebar navigation.
Tests:
- Login functionality with valid/invalid credentials
- Logout workflow
- Sidebar navigation to all main sections (Rooms, Users, Displays, Roles, Events, Tasks)
- Combobox and list interactions
- Button clicks across all pages
- Responsive menu toggle
Use Case: Validates that all UI elements are functional and navigation works correctly.
2. TestFill.cy.js - Form Validation & Input¶
Tests form input handling and field population.
Tests:
- Fill room creation forms with various input types
- Populate user registration fields
- Display registration form completion
- Role, event, and task form population
- Input validation and error handling
Use Case: Ensures all form fields accept input correctly and validation rules are enforced.
3. TestCreate.cy.js - Full CRUD Creation Workflows¶
Tests the complete entity creation process.
Tests:
- Create rooms with full specifications
- Create users with authentication credentials
- Register new displays with hardware details
- Create roles with permissions
- Create events and event types
- Create tasks and task types
Use Case: Validates that new entities can be created with all required fields and persist in the database.
4. TestCreateDelete.cy.js - Create & Delete Workflows¶
Tests creation followed by deletion of entities.
Tests:
- Create and delete rooms
- Create and delete users
- Create and delete displays
- Create and delete roles, events, tasks
Use Case: Ensures cleanup operations work and database consistency is maintained.
5. TestCreateEdit.cy.js - Create & Edit Workflows¶
Tests entity modification after creation.
Tests:
- Create entities with initial data
- Edit room properties
- Update user information
- Modify display settings
- Edit roles, events, and tasks
Use Case: Validates that entity updates persist correctly.
6. TestCRUD.cy.js - Complete CRUD Cycle¶
Full create-read-update-delete testing for all entities.
Tests:
- Complete lifecycle of each entity type
- Verify data persistence
- Confirm deletions
Use Case: Comprehensive testing of all data operations.
7. TestPermissions.cy.js - Role-Based Access Control¶
Tests permission enforcement for different user roles. According to the roles.md file
Tests:
- Admin user access
- Regular user restrictions
- Role-specific visibility
- Permission enforcement on operations
Use Case: Validates that role-based access control works correctly.
8. TestUserLogin.cy.js - Authentication¶
Tests user authentication flows with different credentials.
Tests:
- Login with admin account
- Login with different user roles
- Login failure scenarios
- Session management
Use Case: Ensures authentication is secure and role-based access is enforced.
Architecture & Components¶
Test File Organization¶
Helper Functions¶
Env.cy.js - Core Utilities¶
UI Interaction:
login(username, password)- Authenticate userlogout()- Sign outgetInputAndType(label, text)- Fill form inputsgetButtonAndClick(text, index)- Click buttonsgetComboboxAndClick(text)- Interact with dropdown menusgetCheckboxAndClick(label)- Toggle checkboxesgetSwitchAndClick(label)- Toggle switches
API & Network:
spyOnApi()- Intercept and spy on all API callswaitForApi(alias)- Wait for specific API requestinterceptAndWait(method, url, alias)- Custom API interception
Navigation:
getSidebarAndClick(item)- Navigate via sidebar menuclickMenuIcon()- Toggle responsive menuclickOutside()- Close modals/dropdowns
Database:
resetDatabase()- Reset database to initial state using dump file
Fill.cy.js - Form Population¶
Entity-specific form-filling functions:
fillRoom(action, name, location, capacity, ...)fillUser(action, email, username, name, role, password)fillDisplay(action, mac, type, resolution, room)fillRole(action, name, ...)fillEvent(action, ...)fillTask(action, ...)fillEventType(action, ...)fillTaskType(action, ...)
Tables.cy.js - Table Navigation¶
Table search and manipulation utilities:
roomsTableContains(name)- Find room in tableusersTableContains(username)- Find user in tabledisplayTableContains(mac)- Find display in tableeditEntryFromTable(callback, name)- Click edit actiondeleteEntryFromTable(callback, name)- Click delete action
Configuration¶
cypress.config.js settings:
Test Execution Workflow¶
1. Database Initialization¶
Each test run starts with a clean database:
The resetdb.sh script:
- Creates
dump.sql(PostgreSQL dump) if missing - Drops existing database
- Recreates database from dump file
- Ensures test isolation and consistency
2. Login & Setup¶
Every test:
- Calls
login()to authenticate - Calls
spyOnApi()to monitor API traffic - Navigates to required page
- Performs test actions
3. Action & Verification¶
Tests perform actions using helper functions:
4. Assertion & Cleanup¶
Tests verify outcomes:
- Check HTTP response status
- Verify data in UI tables
- Confirm error messages appear/disappear
- Database state before/after operations
API Integration¶
Intercepted Endpoints¶
Cypress intercepts all backend API calls for testing:
Rooms API:
GET /v1/rooms/- List all roomsPOST /v1/rooms/- Create roomGET /v1/rooms/{id}- Get specific roomPUT /v1/rooms/{id}- Update roomDELETE /v1/rooms/{id}- Delete room
Similar patterns for: Users, Displays, Roles, Events, Tasks, Event Types, Task Types
Monitoring API Calls¶
Test Database Management¶
Database Reset Workflow¶
Problem: Tests need isolation; running multiple tests on same database causes state conflicts.
Solution: resetdb.sh automatically resets database before each test run.
How It Works¶
1. Initial Setup:¶
Creates dump.sql containing clean database snapshot
2. Before Each Test:¶
3. Reset Process:¶
- Reads
resetdb.shscript - Executes via
cy.exec()in Docker container - Drops current database
- Restores from
dump.sql
4. Result: Each test starts with identical clean state¶
Create Fresh Dump¶
If database needs reset:
Troubleshooting¶
Issue: Backend Connection Failed¶
Problem: connect ECONNREFUSED 127.0.0.1:8081
Solution:
Issue: Frontend Not Loading¶
Problem: Tests fail to reach localhost:4173
Solution:
Issue: Database Reset Fails¶
Problem: resetdb.sh: command not found or permission denied
Solution:
Issue: Test Timeouts¶
Problem: Tests timeout waiting for API or elements
Solution:
- Increase Cypress timeout in
cypress.config.js - Verify backend API is responding
- Check network latency with browser DevTools
- Run tests individually to isolate issue
Issue: Created Users are not verified¶
Problem: Newly created users must be verified by their email
Solution:
- Check the given email and click the link to verifiy
- Use
verfifydb.shto verify the users directly with a database command - Currently the usernames
cypressuser1@example.comtocypressuser6@example.comare supported in this bash file
Issue: Flaky Tests¶
Problem: Tests pass sometimes, fail others
Solution:
- Add explicit waits:
waitForLoadingOverlay(),waitForApi() - Avoid hardcoded
cy.wait()- use proper waits - Ensure database is clean before running
- Check for race conditions in async operations
Issue: Cypress Tests Won’t Work after new patches¶
Problem: Cypress files are designed to describe the expected behaviour not if the code works fine
Solution:
- Identify which test case fails
- Open a cypress development browser with this test case, see section below
- Optionally: Mark this test with
describe.only(...)orit.only() - Run the test again and analyze which behaviour was described but not seen in the UI or API
Skipping Tests¶
To temporarily disable tests during development:
Development Workflows¶
Running Tests During Development¶
- Run all tests:
- Run specific test file:
- Run in interactive mode:
- Run with Firefox:
Adding New Tests¶
- Create new test file in
cypress/e2e/TestName.cy.js - Import helpers from
Env.cy.jsandFill.cy.js:
- Write test following existing patterns:
Adding New Helper Functions¶
- Add function to
Env.cy.jsorFill.cy.js - Export function for use in tests:
- Import in test files as needed
CI/CD Integration¶
GitLab CI/CD Pipeline Job¶
The cypress:test job in .gitlab-ci.yml runs Cypress end-to-end tests in the GitLab CI/CD pipeline:
Configuration:
- Image: cypress/browsers:25.0.0 - Pre-built Docker image with Cypress and Firefox/Chrome browsers
- Stage: test
- Trigger: Manual trigger only (when: manual)
- Branches: Runs only on branches named 01-cypress, 02-cypress, or 03-cypress
- Failure Handling: allow_failure: true - test failures won’t block the pipeline
- Runner Tags: Requires runners with the cypress-test tag
Job Steps:
1. Verifies internet connectivity to Google
2. Navigates to app/frontend directory
3. Installs dependencies with npm ci
4. Runs Cypress tests using Firefox: npx cypress run --browser firefox
Running Tests in Pipeline¶
Test Results¶
- Screenshots auto-saved to
cypress/screenshots/on failure - Videos can be enabled in
cypress.config.js - JSON reports available with appropriate reporters
Best Practices¶
- Isolation: Each test should be independent and work with clean database state
- Reusability: Use helper functions from
Env.cy.jsinstead of writing inline commands - Waits: Use explicit waits (
waitForApi(),waitForLoadingOverlay()) instead of hardcoded delays - Selectors: Prefer data attributes (
data-cy,data-test) over brittle selectors, otherwise use custom seletor wrappers - Cleanup: Database resets automatically at the beginning of a test file; no manual cleanup needed
- Debugging: Use Cypress browser DevTools for inspection during test failure
User Testing (NUTZERTESTS)¶
In addition to automated E2E testing, comprehensive user testing has been performed on the Rooms Management System. The user testing results and findings are documented in the app/frontend/cypress/ folder:
- NUTZERTEST_AUSWERTUNG - Detailed analysis and evaluation of the user testing results
- NUTZERTEST_NOTIZEN - Notes and observations from user testing sessions
These files contain valuable insights into user experience, usability findings, and feedback that complement the automated test suite.
Most feedback is already implemented but additional user test might give up-to-date insights.
Support & Documentation¶
- Cypress Official Docs: [https://docs.cypress.io/]
- Environment Variables: See
.env copyfor configuration template - Database Schema: See
roles.mdfor permission documentation ROLES.md - Backend API: Available at
http://localhost:8081/v1/health/when running
Summary¶
This E2E testing suite provides comprehensive coverage of the Rooms Management System, ensuring reliability across all user workflows and entity operations. Tests are well-organized, maintainable, and follow industry best practices for automated testing.
3. Open Cypress with npx cypress open
4. Select Firefox browser (optional, default is Chromium)
5. Choose and run your e2e tests
6. Tests will automatically use the database dump to reset between runs