Skip to content

About

End2End tests of the webapp

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

webapp-e2e-tests

End-to-end tests for the VoteEasy web application.

Installation instructions

Get Cypress

npm install cypress --save-dev
npx cypress open

Get TypeScript support

npm install typescript --save-dev

Create a tsconfig.json file.

Running the tests

  1. Start a local VoteEasy instance with the required roles and initial meetings. Run the appropriate command from the VoteEasy application project:

    ./sh/cleanUpDBAndStartDocker.sh

    Alternatively, if the fresh database has already been prepared:

    ./mvnw -Pdevelopment spring-boot:run
  2. Copy the checked-in template once, then enter your local application URL, tenants and credentials in cypress.env.json:

    cp cypress.env.json.example cypress.env.json
  3. Install Firefox locally, then run the tests from this project:

    npx cypress run

    Alternatively, open the Cypress GUI:

    npx cypress open

Firefox is the default browser for both npx cypress run and npx cypress open. cypress.config.ts uses Cypress's detected browser list: it prefers stable Firefox (firefox) and automatically selects Firefox Developer Edition (firefox:dev) if only that channel is available, including on Linux. No OS-specific commands or configuration changes are needed.

Cypress does not install Firefox for you. If neither channel is detected, the Firefox default remains in place and Cypress reports the missing browser rather than silently switching to another browser. To override the default for a run, pass an explicit browser (this takes precedence over the automatic default):

npx cypress run --browser chrome

Running a single test

The application and local configuration must be prepared as described above. Use a dedicated test instance with a freshly initialised database for each run; database preparation is handled outside this project, not before each test.

To run just one spec file, use --spec:

npx cypress run --spec "cypress/e2e/voteeasy/00login_logout_spec.ts"

This runs all test cases in that file, not just one test case.

To run exactly one test case, temporarily add .only to a describe containing just that test. For example, in cypress/e2e/voteeasy/00login_logout_spec.ts, change the existing logout-message block to:

describe.only('VoteEasy Logout message', () => {
    voteEasyIt('Show login page with success message after logout', ['app_url'], (env) => {
        cy.visit(env.app_url + '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/login?lang=de&success')
        cy.get('.alert').contains('Sie haben sich erfolgreich abgemeldet')
    })
})

Then run the --spec command above. Only this test case runs; the other test cases in the file are skipped. If the chosen test belongs to a describe with multiple tests, temporarily wrap only its existing voteEasyIt(...) call in a new describe.only(...) block instead.

The project helper voteEasyIt does not expose .only; use the enclosing describe.only rather than voteEasyIt.only. For tests declared directly with it, it.only(...) is also available.

Remove .only and any temporary wrapper afterwards, and do not commit them. Keep --spec in the command: .only does not prevent other spec files from running. Tests that rely on data created by earlier tests may not work in isolation.

Local VoteEasy configuration

Copy the checked-in template once and enter your local application URL, tenants and credentials:

cp cypress.env.json.example cypress.env.json

A local configuration is required to run the VoteEasy tests. Create your own cypress.env.json from cypress.env.json.example and enter your local application URL, tenants and credentials before running the tests. Cypress displays a startup warning if the file is missing.

The warning does not block startup. If you supply configuration entirely via environment variables or --env, the file can be omitted, but all required configuration values must still be provided.

cypress.env.json is ignored by Git. Never commit real credentials to the example or cypress.config.ts. Cypress loads the local JSON file automatically; the VoteEasy tests read only their required values via cy.env() (Cypress 16) using the typed helper in cypress/support/voteeasy.ts. Test titles do not contain configured usernames, and configured passwords are not logged or included in value assertions. Missing or empty configuration values fail with a message containing only the key name.

All existing keys in cypress.env.json.example remain supported, including app_url. Values can be overridden with CYPRESS_ environment variables (e.g. CYPRESS_regular_user, CYPRESS_regular_pw) or Cypress's --env option. Use CI secrets/environment variables for passwords rather than CLI arguments. Precedence: config env < cypress.env.json < environment variables < --env.

The URL-parameter login test uses the configured regular account, with URL encoding for the parameter values. Negative tests intentionally retain invalid users/tokens, and tenant workflows create temporary accounts with their own test credentials. Cypress screenshots/videos and URLs may still contain sensitive data; do not publish artefacts without checking them.

Run the VoteEasy tests against the configured application using Firefox:

npx cypress run

These tests create, change and delete application data. Use a dedicated test instance with the necessary roles and initial meetings.

Check TypeScript and configuration loading without running browser tests or reading local secrets:

npm run typecheck
npm run test:config

The configuration regression tests use fake values and verify all nine specs, execution-time loading, required-key validation, password logging, URL encoding, the missing local configuration warning and automatic Firefox channel selection.

GitHub Actions

The workflow in .github/workflows/checks.yml runs on pushes and pull requests and can also be started manually. It uses Node.js 24 and runs the following commands, with dependencies installed from the committed lockfile:

npm ci
npm run typecheck
npm run test:config

It also checks committed changes for whitespace errors.

These checks do not require a running VoteEasy instance, a database, cypress.env.json or GitHub secrets. Cypress browser binary installation is skipped with CYPRESS_INSTALL_BINARY=0.

This workflow checks the test project, not application behaviour. Full browser E2E tests still run separately against the local installation prepared by the external Docker setup.

About

End2End tests of the webapp

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages