forgejo/tests/e2e
Solomon Victorino 829e661c39 test: assert navigation URLs in release E2E test
- last one waits for release deletion before the next browser run
- disambiguates failures due to error responses
2024-09-01 10:33:29 -06:00
..
shared feat(i18n): Branch protection improvements 2024-08-22 22:05:12 +02:00
.eslintrc.yaml Playwright testing for commit diffs 2024-08-26 13:57:42 +02:00
actions.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
commit-graph-branch-selector.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
dashboard-ci-status.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
debugserver_test.go Playwright testing for commit diffs 2024-08-26 13:57:42 +02:00
declare_repos_test.go Playwright testing for commit diffs 2024-08-26 13:57:42 +02:00
e2e_test.go Playwright testing for commit diffs 2024-08-26 13:57:42 +02:00
edit-comment.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
example.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
explore.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
issue-sidebar.test.e2e.js fix: WIP toggle by reducing max issue title 2024-08-29 01:36:58 +02:00
markdown-editor.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
markup.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
org-settings.test.e2e.js Implement CSS-only input toggling, refactor related forms 2024-08-21 15:03:19 +02:00
profile_actions.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
reaction-selectors.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
README.md docs(e2e): explain how to use VSCodium or VSCode 2024-07-16 17:22:39 +02:00
release.test.e2e.js test: assert navigation URLs in release E2E test 2024-09-01 10:33:29 -06:00
repo-code.test.e2e.js Playwright testing for commit diffs 2024-08-26 13:57:42 +02:00
repo-migrate.test.e2e.js fix(ui): prevent exceptions on other users' repo migration pages 2024-08-21 19:57:08 +00:00
repo-settings.test.e2e.js feat(i18n): Branch protection improvements 2024-08-22 22:05:12 +02:00
right-settings-button.test.e2e.js test: fail on unhandled JS exceptions 2024-08-14 15:35:20 -06:00
utils_e2e.js fix: WIP toggle by reducing max issue title 2024-08-29 01:36:58 +02:00
utils_e2e_test.go Playwright testing for commit diffs 2024-08-26 13:57:42 +02:00
webauthn.test.e2e.js [FEAT] Add support for webauthn credential level 3 2024-08-29 10:05:03 +02:00

End to end tests

E2e tests largely follow the same syntax as integration tests. Whereas integration tests are intended to mock and stress the back-end, server-side code, e2e tests the interface between front-end and back-end, as well as visual regressions with both assertions and visual comparisons. They can be run with make commands for the appropriate backends, namely:

make test-sqlite
make test-pgsql
make test-mysql

Make sure to perform a clean front-end build before running tests:

make clean frontend

Install playwright system dependencies

npx playwright install-deps

Interactive testing

You can make use of Playwright's integrated UI mode to run individual tests, get feedback and visually trace what your browser is doing.

To do so, launch the debugserver using:

make test-e2e-debugserver

Then launch the Playwright UI:

npx playwright test --ui

You can also run individual tests while the debugserver using:

npx playwright test actions.test.e2e.js:9

First, specify the complete test filename, and after the colon you can put the linenumber where the test is defined.

Run all tests via local act_runner

act_runner exec -W ./.github/workflows/pull-e2e-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest

Run sqlite e2e tests

Start tests

make test-e2e-sqlite

Run MySQL e2e tests

Setup a MySQL database inside docker

docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:latest #(just ctrl-c to stop db and clean the container)
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --rm --name elasticsearch elasticsearch:7.6.0 #(in a second terminal, just ctrl-c to stop db and clean the container)

Start tests based on the database container

TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-e2e-mysql

Run pgsql e2e tests

Setup a pgsql database inside docker

docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:latest #(just ctrl-c to stop db and clean the container)

Start tests based on the database container

TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-e2e-pgsql

Running individual tests

Example command to run example.test.e2e.js test file:

Note: unlike integration tests, this filtering is at the file level, not function

For SQLite:

make test-e2e-sqlite#example

For PostgreSQL databases(replace mysql to pgsql):

TEST_MYSQL_HOST=localhost:1433 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=sa TEST_MYSQL_PASSWORD=MwantsaSecurePassword1 make test-e2e-mysql#example

Visual testing

Although the main goal of e2e is assertion testing, we have added a framework for visual regress testing. If you are working on front-end features, please use the following:

  • Check out main, make clean frontend, and run e2e tests with VISUAL_TEST=1 to generate outputs. This will initially fail, as no screenshots exist. You can run the e2e tests again to assert it passes.
  • Check out your branch, make clean frontend, and run e2e tests with VISUAL_TEST=1. You should be able to assert you front-end changes don't break any other tests unintentionally.

VISUAL_TEST=1 will create screenshots in tests/e2e/test-snapshots. The test will fail the first time this is enabled (until we get visual test image persistence figured out), because it will be testing against an empty screenshot folder.

ACCEPT_VISUAL=1 will overwrite the snapshot images with new images.

With VSCodium or VSCode

To debug a test, you can use "Playwright Test" for VScodium or VSCode. Before doing that you will need to manually start a Forgejo instance and populate it with data from models/fixtures by running:

make TAGS='sqlite sqlite_unlock_notify' 'test-e2e-debugserver'