Files
webmail/integration/run-tests.sh
T
Linus Rath fe61bd8e88 test: let the Stalwart integration suite run against other Stalwart images
The integration server was pinned to `stalwartlabs/stalwart:v0.16`. The
image is now the `STALWART_IMAGE` build argument (same default), passed
through `docker-compose.yml` and `integration/run-tests.sh`.

Stalwart 1.0 answers Principal/query with `forbidden` unless the Sharing
setting `allowDirectoryQueries` is on, which would stop the shared-folder
specs in their setup. The account plan turns it on (0.16 has the same
setting), and `principalIdByEmail` reports such a refusal clearly instead
of failing on an undefined list.
2026-09-25 19:33:37 +02:00

51 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run the Playwright integration suite.
#
# Playwright's browser download host is often unreachable (and some host OSes
# aren't supported by the browser bundles), so the tests run inside the official
# Playwright container, which ships the browsers. The container uses host
# networking to reach the published stack ports (webmail :3000, Stalwart :8025).
#
# The docker stack itself is brought up here (on the host) and the in-container
# run is told to skip its own docker management via IT_NO_DOCKER=1.
#
# Usage:
# integration/run-tests.sh # whole suite
# integration/run-tests.sh 01-login # a single spec (grep on file name)
#
# Env:
# IT_VIDEO=on record a video.webm for every test (not just failures);
# also: off | retain-on-failure (default) | on-first-retry.
# e.g. IT_VIDEO=on integration/run-tests.sh 01-login
# STALWART_IMAGE=<image>
# the Stalwart image the test server is built on (default
# stalwartlabs/stalwart:v0.16), e.g. one built from the 1.0
# branch. Switching releases needs fresh volumes: run
# `docker compose down -v` in integration/ first (1.0 cannot
# open a 0.16 data directory).
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
INTEGRATION_DIR="${REPO_ROOT}/integration"
PW_IMAGE="mcr.microsoft.com/playwright:v1.59.1-noble"
# Read by docker-compose.yml as the stalwart build argument.
export STALWART_IMAGE="${STALWART_IMAGE:-stalwartlabs/stalwart:v0.16}"
cd "${INTEGRATION_DIR}"
[ -f .env ] || cp .env.example .env
echo "== bringing up stack (Stalwart image ${STALWART_IMAGE}) =="
bash stalwart/prepare-stalwart-cli.sh
docker compose --env-file .env up -d --build --wait --wait-timeout 300
echo "== running Playwright in ${PW_IMAGE} =="
FILTER="${1:-}"
docker run --rm --network host \
--user "$(id -u):$(id -g)" \
-v "${REPO_ROOT}":/work -w /work \
-e IT_NO_DOCKER=1 \
-e HOME=/tmp \
-e IT_VIDEO="${IT_VIDEO:-}" \
"${PW_IMAGE}" \
npx playwright test -c playwright.integration.config.ts ${FILTER:+"$FILTER"}