fix(test): close the test-entry leak into real trip content
A ui-test entry had survived into the active trip's dailies. Three independent failures had to line up for that, and all three were real: 1. cleanupEntry() used host-side fs.rmSync. Grav's Apache workers run as root, so every entry the form creates is root-owned and recursive removal needs write permission on that directory — which the host user lacks. Cleanup had never worked for form-created entries; it just threw inside a path nothing checked. It now falls back to `docker exec … rm -rf` in the container that actually serves USER_DIR. 2. globalTeardown's dailies sweep keyed off a `parent:` in post-form.md — a key deliberately removed (the write target comes from site.yaml active_trip, and CLAUDE.md forbids re-adding a static parent). The regex could never match, so dailiesDir was always null and the sweep silently did nothing. It now reuses helpers' own resolution instead of keeping a divergent copy. 3. Nothing pinned the suite to this checkout's server. playwright.config.js defaults to :8081, so a worktree run hit the MAIN checkout — entries created in one content tree while the specs asserted and cleaned up in another. test-ui now passes GRAV_BASE_URL from GRAV_PORT, and globalSetup hard-fails when the server's bind mount disagrees with the tree the specs read. Also fixed, found on the way to a green run: - test-account interpolated the password into an `sh -c` string, so a password containing a shell metacharacter was re-parsed by the container's shell (`sh: 2: <fragment>: not found`, no account, every UI run dead). It now travels via `docker exec -e`, making the recipe indifferent to its contents. - `make start` in a worktree always failed: travel-memories declares `env_file: .env` and worktree-new creates none. It degrades to start-grav there — a worktree with no server is what sent runs to :8081 in the first place. - test-form-config asserted a hero_image field that 8cf1145 deliberately removed; it had been failing ever since. Verified: config 22/22, post 6/6, location-override 20/20, and a full UI run now leaves zero ui-test entries behind. The remaining UI failures are pre-existing on main — site.yaml pins owner_username to a real account while the suite logs in as testrunner, so owner-only controls never render for it. Only trip-publish.spec.js patches that; delete-flow, edit-mode and anon-view do not. Left for a separate branch.
This commit is contained in:
@@ -54,9 +54,15 @@ $(foreach t,$(REMOTE_TARGETS),$(foreach e,$(ENVS),$(eval $(call make-env-target,
|
||||
GRAV_TEST_USER ?= testrunner
|
||||
GRAV_TEST_PASS ?= Testpass1234
|
||||
|
||||
# The password is handed to the container through `docker exec -e` (the bare
|
||||
# form, which forwards the already-exported variable) rather than interpolated
|
||||
# into the `sh -c` string. Interpolating it meant any shell-special character in
|
||||
# GRAV_TEST_PASS was re-parsed by the container's shell — a `.env` password
|
||||
# containing one produced `sh: 2: <fragment>: not found` and no test account.
|
||||
# The recipe is now indifferent to the password's contents.
|
||||
test-account:
|
||||
@docker exec $(GRAV_CONTAINER) sh -c 'test -f /var/www/html/user/accounts/$(GRAV_TEST_USER).yaml \
|
||||
|| php bin/plugin login new-user -u $(GRAV_TEST_USER) -p "$(GRAV_TEST_PASS)" \
|
||||
@docker exec -e GRAV_TEST_PASS $(GRAV_CONTAINER) sh -c 'test -f /var/www/html/user/accounts/$(GRAV_TEST_USER).yaml \
|
||||
|| php bin/plugin login new-user -u $(GRAV_TEST_USER) -p "$$GRAV_TEST_PASS" \
|
||||
-e $(GRAV_TEST_USER)@example.test -N "Test Runner" -P b --admin-type both -s enabled -n'
|
||||
|
||||
test-config:
|
||||
@@ -65,6 +71,13 @@ test-config:
|
||||
test-post: test-account
|
||||
@bash scripts/test-post.sh
|
||||
|
||||
# Pinned to THIS checkout's port, not playwright.config.js's :8081 default. In a
|
||||
# worktree that default silently pointed the suite at the main checkout's server,
|
||||
# so entries were created in main's user/ while the specs asserted and cleaned up
|
||||
# in the worktree's — leaving ui-test entries behind in real trip content.
|
||||
# tests/global-setup.js now also hard-fails on that mismatch.
|
||||
GRAV_BASE_URL ?= http://localhost:$(GRAV_PORT)
|
||||
|
||||
test-ui: test-account
|
||||
@npx playwright test
|
||||
|
||||
@@ -98,8 +111,18 @@ build-assets:
|
||||
-w /app node:20-alpine \
|
||||
sh -c "npm install && npm run build"
|
||||
|
||||
# In a worktree this degrades to start-grav. The travel-memories service declares
|
||||
# `env_file: .env`, and worktree-new does not create a .env, so a plain
|
||||
# `docker compose up -d` there dies with "env file ... not found" — leaving the
|
||||
# worktree with no server at all, which is how test runs ended up silently
|
||||
# targeting the main checkout.
|
||||
start:
|
||||
docker compose up -d
|
||||
@if [ -f .worktree-env ]; then \
|
||||
echo "→ worktree: starting the grav service only (travel-memories needs a .env, which worktrees have none)"; \
|
||||
docker compose up -d grav; \
|
||||
else \
|
||||
docker compose up -d; \
|
||||
fi
|
||||
|
||||
# Grav service only — used by `make worktree-new` (a worktree rarely needs the
|
||||
# travel-memories service, and this keeps its footprint minimal).
|
||||
@@ -185,6 +208,13 @@ demo-load:
|
||||
# Load every fixture trip under docs/demo/trips/ into the pages tree.
|
||||
# Source uses dailies/ + 04.stories/; dailies/ maps to 01.dailies/ on copy.
|
||||
# All copies are `|| true` so a fixture absent from an older user/ is skipped.
|
||||
#
|
||||
# ⚠️ A fixture whose folder name matches a REAL trip's slug is copied straight
|
||||
# over that live page — docs/demo/trips/italy-2025/ collides with the real
|
||||
# italy-2025 trip on purpose (the fixture supplies its GPX + dailies). So any
|
||||
# field the fixture's trip.md omits gets silently deleted from real content on
|
||||
# every test run: it had been dropping the trip's tagline that way. Keep a
|
||||
# colliding fixture's trip.md byte-identical to the live page.
|
||||
docker exec $(GRAV_CONTAINER) bash -c 'for src in /var/www/html/user/docs/demo/trips/*/; do \
|
||||
slug=$$(basename "$$src"); dst=/var/www/html/user/pages/01.trips/$$slug; \
|
||||
mkdir -p "$$dst/01.dailies" "$$dst/04.stories"; \
|
||||
|
||||
Reference in New Issue
Block a user