Tests navigateur : accueil, tutoriel, aide, installation, mise à jour ; plan : résultat

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pierre MARTIN
2026-11-09 15:35:00 +01:00
co-authored by Claude Opus 5.5
parent 441bca1bd7
commit 5fdca812d9
7 changed files with 644 additions and 30 deletions
+34 -4
View File
@@ -2,7 +2,11 @@
# Joue une partie complète par l'interface dans Chromium et Firefox sans
# écran (tests/browser/play.mjs), sur le site servi par l'image de production
# construite en local, comme tests/test_site.sh. Les captures d'écran vont
# dans build/browser-shots/.
# dans build/browser-shots/. Puis l'accueil, le tutoriel, l'aide,
# l'installation et la mise à jour (tests/browser/accueil.mjs), avec leurs
# captures dans build/browser-shots/accueil-tutoriel/.
#
# BROWSERS=chromium et SCRIPTS=accueil (ou play) restreignent le test.
#
# Outils : l'image de Playwright (navigateurs) et le paquet playwright,
# installé une fois par npm dans build/browser-tools/ (réseau nécessaire la
@@ -14,6 +18,8 @@ cd "$(dirname "$0")/.."
image="${PLAYWRIGHT_IMAGE:?lancer via make test-browser}"
browsers="${BROWSERS:-chromium firefox}"
# Les scripts à lancer (tests/browser/<nom>.mjs), tous par défaut.
scripts="${SCRIPTS:-play accueil}"
unset MAKEFLAGS MFLAGS MAKELEVEL
make -s package >/dev/null
@@ -33,15 +39,39 @@ if [ ! -f "$tools/node_modules/playwright/package.json" ]; then
"$image" npm install --no-audit --no-fund --save-exact "playwright@$version" >/dev/null
fi
# Pour la mise à jour de l'application (tests/browser/accueil.mjs) : une
# copie du site, servie par la même image mais depuis un dossier que le test
# modifie, pour publier une deuxième version sur la même adresse.
updates=build/browser-site
rm -rf "$updates"
cp -r build/site "$updates"
update_container="$(docker run -d --rm -p 127.0.0.1::80 -v "$PWD/$updates:/srv:ro" "$site_image")"
update_cleanup() {
docker rm -f "$update_container" >/dev/null 2>&1 || true
site_cleanup
}
trap update_cleanup EXIT
update_port="$(docker port "$update_container" 80/tcp | head -n1 | sed 's/.*://')"
rm -rf build/browser-shots
mkdir -p build/browser-shots
cp tests/browser/play.mjs "$tools/"
cp tests/browser/play.mjs tests/browser/accueil.mjs "$tools/"
status=0
for browser in $browsers; do
# Réseau de l'hôte : le site est sur 127.0.0.1. Le service worker
# demande un contexte sûr, ce qu'est localhost.
if [[ " $scripts " == *" play "* ]]; then
docker run --rm --init --ipc=host --network host --user "$(id -u):$(id -g)" -e HOME=/tmp \
-e TRACE -v "$PWD/$tools:/tools" -v "$PWD/build/browser-shots:/shots" -w /tools "$image" \
node play.mjs "http://localhost:$port/" "$browser" /shots || status=1
fi
[[ " $scripts " == *" accueil "* ]] || continue
# Accueil, tutoriel, aide, installation et mise à jour ; captures de la
# recette dans build/browser-shots/accueil-tutoriel/.
docker run --rm --init --ipc=host --network host --user "$(id -u):$(id -g)" -e HOME=/tmp \
-e TRACE -v "$PWD/$tools:/tools" -v "$PWD/build/browser-shots:/shots" -w /tools "$image" \
node play.mjs "http://localhost:$port/" "$browser" /shots || status=1
-v "$PWD/$tools:/tools" -v "$PWD/build/browser-shots:/shots" -v "$PWD/$updates:/site" \
-w /tools "$image" \
node accueil.mjs "http://localhost:$port/" "$browser" /shots \
"http://localhost:$update_port/" /site || status=1
done
exit "$status"