Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bbe90a1
fix(seeders): skip terminated campaigns in fakes
claude Nov 27, 2026
aa4ca05
test: add Playwright E2E infrastructure
claude Nov 27, 2026
a382194
test(e2e): cover setup wizard, settings, root user
claude Nov 27, 2026
0c2d482
ci: run E2E tests on SQLite, MySQL and PostgreSQL
claude Nov 27, 2026
2e46bfd
docs: explain how to run the E2E tests [skip ci]
claude Nov 27, 2026
486af07
ci: drop PostgreSQL from the E2E matrix
claude Nov 27, 2026
b845c35
test(e2e): let parallel writers share SQLite
claude Nov 27, 2026
1b5247c
test(e2e): cover public pages, login, profile, dashboard
claude Nov 27, 2026
c5fc492
test(e2e): cover users, roles, access and the API
claude Nov 27, 2026
e9e4779
test(e2e): cover territories, assignments, campaigns
claude Nov 27, 2026
6e9d61f
test(e2e): hide the request log of the test servers
claude Nov 27, 2026
1885821
Merge remote-tracking branch 'origin/main' into claude/sweet-newton-d…
claude Nov 27, 2026
49173c5
test(e2e): use male names for responsibility roles
claude Nov 27, 2026
1059363
test(e2e): cover publications, posters and tags
claude Nov 27, 2026
cd49569
ci: record failed E2E tests for debugging
claude Nov 27, 2026
a763500
test(e2e): find the artisan token of the seeded instance
claude Nov 27, 2026
4efe546
ci: report why the E2E test servers stop
claude Nov 27, 2026
56a1f01
fix(e2e): turn off the OPcache JIT of the test servers
claude Nov 27, 2026
eda13ed
test(e2e): wait for the settings to be saved
claude Nov 27, 2026
8cea1cd
ci: name the Pest and E2E test workflows
claude Nov 27, 2026
f37fafa
docs(claude): keep the E2E tests in sync with the UI [skip ci]
claude Nov 27, 2026
1916a18
test(e2e): find an email among the others of a user
claude Nov 27, 2026
fac2096
test(e2e): cover the whole workflows of the users
claude Nov 27, 2026
687db16
docs(changelog): note the E2E tests
claude Nov 27, 2026
6296aef
fix(e2e): ignore a cached config of development
claude Nov 27, 2026
2335c6d
test(e2e): hide the cut lines of the server log
claude Nov 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ php artisan tinker

The application includes GitHub Actions workflows in `.github/workflows/`:
- `deploy-preview.yml` - PR previews, `deploy-nightly.yml` - nightly build of `main`, and `upload-altervista-reusable.yml` - deployments, called by other repositories
- `run-tests.yml` - Test execution with coverage
- `run-pest-tests.yml` - Pest tests (unit and feature), with coverage
- `run-e2e-tests.yml` - Playwright end-to-end tests (`tests/e2e`), on SQLite and MySQL
- `check-translations.yml` - Translation validation

- **PR previews** (`deploy-preview.yml`): the `PREVIEW_MODE` repository variable sets which PRs get a preview
Expand Down
194 changes: 194 additions & 0 deletions .github/workflows/run-e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
name: E2E tests

on:
# Every pull request (forks included), and what lands on main
push:
branches:
- main
pull_request:
workflow_dispatch: # Manually trigger a workflow run

permissions:
contents: read

env:
# Same major version installed in the Sail image (see docker-compose.yml)
node_version: "24.x"
php_extensions: >-
bcmath,calendar,ctype,curl,date,dom,exif,fileinfo,filter
,gd,gettext,gmp,hash,iconv,imagick,intl,json,libxml,mbstring
,mysqli,mysqlnd,openssl,pcre,PDO,pdo_mysql,pdo_sqlite
,Phar,random,Reflection,session,SimpleXML,SPL,sqlite3,standard
,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib

jobs:
run-e2e-tests:
name: E2E (${{ matrix.database }})
runs-on: ubuntu-latest
timeout-minutes: 45

# The application supports these databases: each one runs the whole suite, the setup wizard included (which
# configures the database of its run, see `tests/e2e/setup-wizard.spec.ts`). PostgreSQL is not supported yet.
strategy:
fail-fast: false
matrix:
database: [sqlite, mysql]
include:
- database: sqlite
mysql_image: ""
- database: mysql
# Same version as docker-compose.yml
mysql_image: mysql:8.0
port: 3306
username: root

# A service with an empty image is not started: only the runs on MySQL have it
services:
mysql:
image: ${{ matrix.mysql_image }}
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent --host=127.0.0.1 -uroot -ppassword"
--health-interval=5s --health-timeout=5s --health-retries=30

env:
# Read by `tests/e2e/support/serve.sh` and the setup wizard test
E2E_DB_CONNECTION: ${{ matrix.database }}
E2E_DB_HOST: 127.0.0.1
E2E_DB_PORT: ${{ matrix.port }}
E2E_DB_USERNAME: ${{ matrix.username }}
E2E_DB_PASSWORD: password

steps:
- name: Checkout code
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Setup PHP and Composer
uses: shivammathur/setup-php@v2
with:
# The version of the platform of composer.json
php-version: "8.2"
extensions: ${{ env.php_extensions }}
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
fail-fast: true

- name: Print the OPcache settings of PHP
run: php -i | grep -E "^opcache\.(enable|enable_cli|jit|jit_buffer_size) " || echo "OPcache is not loaded"

- name: Setup NodeJS
uses: actions/setup-node@v7
with:
node-version: ${{ env.node_version }}
cache: npm

- name: Cache Composer dependencies
uses: actions/cache@v6
with:
path: vendor
key: composer-${{ hashFiles('**/composer.lock') }}
restore-keys: composer-

- name: Install Composer dependencies
run: composer install --no-ansi --no-interaction --no-progress --no-scripts --optimize-autoloader

# The assets must be built after the Composer dependencies are installed, since the Filament themes import CSS
# from `vendor`
- name: Install NodeJS dependencies
run: npm ci

- name: Build front-end assets
run: npm run build

- name: Get Playwright version
id: playwright
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> "$GITHUB_OUTPUT"

- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v6
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.version }}

- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps chromium

- name: Install Playwright system dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps chromium

- name: Run E2E tests
run: |
# Note when the app server stops answering, with its processes and the memory at that moment (printed by
# the "Print the state of the test servers" step)
(
up=""
while true; do
if curl -s -o /dev/null --max-time 10 http://127.0.0.1:8010/up; then now=yes; else now=no; fi
if [[ "$now" != "$up" ]]; then
echo "$(date -u +%T) answering: ${now}"
ps -eo pid,ppid,etime,rss,args | grep -E "[p]hp .*-S " || echo "No PHP server is running"
free -m | head -2
up="$now"
fi
sleep 5
done
) > "${RUNNER_TEMP}/server-watch.log" 2>&1 &

npx playwright test

# Printed at the end of the log (the earlier lines of a long log can be hard to reach): why the test servers may
# have stopped, e.g. a crash or the kernel killing them for lack of memory
- name: Print the state of the test servers
if: failure()
run: |
echo "::group::When the app server answered (checked every 5 seconds)"
cat "${RUNNER_TEMP}/server-watch.log" || true
echo "::endgroup::"
echo "::group::Errors of the test servers"
tail -n 200 storage/e2e/*/logs/server.log || true
echo "::endgroup::"
echo "::group::Last errors of the application"
grep -h "\.ERROR:" storage/e2e/*/logs/laravel.log | cut -c1-400 | tail -n 50 || true
echo "::endgroup::"
echo "::group::Processes killed by the kernel"
sudo dmesg 2>/dev/null | grep -iE "killed process|out of memory|segfault" | tail -n 20 || true
echo "::endgroup::"
echo "::group::Memory and PHP servers"
free -m
ps -eo pid,ppid,etime,rss,args | grep -E "[p]hp .*-S " || echo "No PHP server is running"
echo "::endgroup::"

- name: Upload test report
if: failure()
uses: actions/upload-artifact@v7
with:
name: playwright-report-${{ matrix.database }}
path: |
playwright-report/
test-results/
storage/e2e/*/logs/
retention-days: 14

- name: Explain how to debug the failed tests
if: failure()
env:
DATABASE: ${{ matrix.database }}
run: |
{
echo "### Debugging the failed E2E tests (${DATABASE})"
echo
echo "Download the \`playwright-report-${DATABASE}\` artifact of this run, unzip it, then:"
echo
echo "- \`npx playwright show-report playwright-report\`: the report, with the screenshot, the video and the trace of each failed test;"
echo "- \`npx playwright show-trace test-results/<test>/trace.zip\` (or drop the file on https://trace.playwright.dev) to replay a test step by step, with the page, the network and the console;"
echo "- \`storage/e2e/<instance>/logs/laravel.log\`: the errors of the application."
} >> "$GITHUB_STEP_SUMMARY"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run tests
name: Pest tests

on:
# Every pull request (forks included), and what lands on main
Expand Down Expand Up @@ -26,8 +26,8 @@ env:
sail_image_max_age_days: 7

jobs:
run-tests:
name: Run tests (prefixed=${{ matrix.db-prefix != '' && 'yes' || 'no' }})
run-pest-tests:
name: Pest (prefixed=${{ matrix.db-prefix != '' && 'yes' || 'no' }})
runs-on: ubuntu-latest

# The PR previews share one database, prefixing their tables with `p<N>_` (`DB_PREFIX`): the suite also runs with
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ _ide_helper_models.php
.secrets.*
.vars
.vars.*

# End-to-end tests (see `playwright.config.ts`)
/storage/e2e
/tests/e2e/.auth
/test-results
/playwright-report
/blob-report
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
confirmation (from the territories list and the campaign assignments); the bulk assignment skips such territories
unless asked to include them, and the AI assistants ask the user before assigning it again
([#114](https://github.com/OpenCHelper/OpenCongregationHelper/pull/114)).
- **End-to-end tests**: browser tests of every feature of the app and of the main workflows (e.g. a zone, then a
territory in it, assigned and returned), run on every pull request on SQLite and MySQL; a failed test keeps a video
and a trace to replay it ([#116](https://github.com/OpenCHelper/OpenCongregationHelper/pull/116)).
- The busy timeout and the journal mode of SQLite can be set with `DB_BUSY_TIMEOUT` and `DB_JOURNAL_MODE`
([#116](https://github.com/OpenCHelper/OpenCongregationHelper/pull/116)).

### Changed

Expand Down Expand Up @@ -150,6 +155,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **AI assistants**: the deployments of the environments that keep their database (e.g. TEST) keep the keys signing
the tokens of the assistants, which were replaced on every deployment, disconnecting every assistant
([#112](https://github.com/OpenCHelper/OpenCongregationHelper/pull/112)).
- The fake data (`FakeDataSeeder`, used by the PR previews) could fail to seed when an assignment picked a campaign that
had already ended ([#116](https://github.com/OpenCHelper/OpenCongregationHelper/pull/116)).

### Security

Expand Down
14 changes: 14 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@
- Never put screenshots meant only for an issue or a PR in a temporary branch or anywhere else public (other branches,
gists, image hosts) unless explicitly asked: send them to the user instead;

## E2E tests

- The Playwright tests in `tests/e2e/` (one spec per feature area, run by `run-e2e-tests.yml`) must always follow the
UI: every change that adds, changes or removes something in the UI (a page, field, action, filter, label, navigation
item, permission) updates, adds or removes the E2E tests that cover it, in the same change;
- They document what a user does and check that it works end to end: beside the single features, cover the whole
workflows that chain them (e.g. creating a zone, then a territory in it, then assigning the territory and returning
it), so that the tests read as the steps a user follows;
- Prefer the helpers of `tests/e2e/support/` (`filament.ts`, `fixtures.ts`, `artisan.ts`, `mail.ts`) and give the
records unique names (`uniqueName()`), since the tests run in parallel on one database; tests that change the whole
app (settings, root user) go in `tests/e2e/global-state/`;
- A bug found by an E2E test that is not fixed in the same change stays visible as a `test.fixme` explaining it, never
as a removed or weakened test.

## CI/CD

- **PR previews** (`deploy-preview.yml`): the `PREVIEW_MODE` repository variable sets which PRs get a preview
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,28 @@ The preferred way of developing is by using **Docker Compose** to build the cont
sail npm install && sail npm run dev
```

### End-to-end tests

The browser tests in [`tests/e2e`](./tests/e2e) use [Playwright](https://playwright.dev) on two instances of the
application, each with its own `.env.e2e-*` file, storage (`storage/e2e/`) and database, so they never touch the
development ones: `app`, installed and seeded with `E2eSeeder` (a user for each role, password `password`), and
`setup`, empty, for the setup wizard. They are served by
[`tests/e2e/support/serve.sh`](./tests/e2e/support/serve.sh) on the ports 8010 and 8011.

1. Build the frontend assets and install Chromium (once):
```shell
npm run build && npx playwright install chromium
```
2. Run the tests (`npm run test:e2e:ui` opens the interactive runner):
```shell
npm run test:e2e
```

They use SQLite by default: set `E2E_DB_CONNECTION` (`mysql`, `mariadb` or `pgsql`) and `E2E_DB_HOST`, `E2E_DB_PORT`,
`E2E_DB_USERNAME`, `E2E_DB_PASSWORD` to run them on another database (the databases `e2e_app` and `e2e_setup` are
created). Outside of CI, servers already running on the ports are reused: stop them to start from fresh data. The
`E2E tests` workflow (`run-e2e-tests.yml`) runs them on SQLite and MySQL.

### Run workflows locally

You can run the Github Action workflows locally using [`nektos/act`](https://github.com/nektos/act) (already included in the [DevContainer](./.devcontainer/devcontainer.json)).
Expand Down
5 changes: 3 additions & 2 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => env('DB_PREFIX', ''),
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
'busy_timeout' => null,
'journal_mode' => null,
// E.g. `DB_BUSY_TIMEOUT=10000` and `DB_JOURNAL_MODE=wal` for concurrent writers (the end-to-end tests)
'busy_timeout' => env('DB_BUSY_TIMEOUT'),
'journal_mode' => env('DB_JOURNAL_MODE'),
'synchronous' => null,
],

Expand Down
Loading
Loading