Files
rose-ash/lib/host/playwright/run-picker-check.sh
giles bbb8528352
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s
tooling+plan: harness SX_SERVING_JIT=1 fix, conformance timeout bump, specialised editors
- live-check.sh + run-picker-check.sh now set SX_SERVING_JIT=1 to MATCH THE CONTAINER:
  that env gates the http-listen IO resolver, so without it perform-heavy paths (the is-a/
  tags picker's reach-down BFS) falsely raise VmSuspended -> 500 in the harness while the
  live site is fine (confirmed live is-a picker = 200). Harness must mirror what the
  container runs.
- conformance.sh: 600s -> 1200s cap (overridable via SX_CONF_TIMEOUT). A sibling loop at
  load ~6 pushed the Datalog-heavy blog suite past 600s -> false 'no suite results parsed'.
- plan: types can specify SPECIALISED EDITORS — a type's :editor slot = a content-addressed
  editor component (WYSIWYG, map picker) shipped to the client like ~relate-picker. Generic
  form is the default, not the ceiling; spectrum = generic -> per-field widget -> :editor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 12:18:34 +00:00

73 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Browser check for the relate picker. Spins up an EPHEMERAL host server (this
# worktree's binary + lib, a temp persist dir), seeds a host post + 25 candidates,
# runs lib/host/playwright/relate-picker.spec.js in the main worktree's Playwright,
# then tears everything down. No live-site dependency, no live-data pollution.
#
# bash lib/host/playwright/run-picker-check.sh
#
# Requires: the OCaml binary built (hosts/ocaml/_build/default/bin/sx_server.exe)
# and Playwright + chromium in /root/rose-ash (the architecture worktree).
set -uo pipefail
cd "$(git rev-parse --show-toplevel)"
ROOT=$(pwd)
PORT="${PICKER_PORT:-8912}"
PW_DIR="${PW_DIR:-/root/rose-ash}" # worktree that has node_modules + chromium
USER="admin"
PASS="picker-check-pw"
SECRET="picker-check-secret"
PDIR=$(mktemp -d)
JAR=$(mktemp)
SPEC_SRC="lib/host/playwright/relate-picker.spec.js"
SPEC_DST="$PW_DIR/tests/playwright/_picker-check.spec.js"
SERVE_LOG=$(mktemp)
cleanup() {
[ -n "${SVPID:-}" ] && kill "$SVPID" 2>/dev/null
# kill whatever is still bound to the port (serve.sh re-parents via `| exec`)
local pid
pid=$(ss -lptn "sport = :$PORT" 2>/dev/null | grep -oE 'pid=[0-9]+' | head -1 | cut -d= -f2)
[ -n "$pid" ] && kill "$pid" 2>/dev/null
rm -f "$SPEC_DST" "$JAR" "$SERVE_LOG"
rm -rf "$PDIR"
}
trap cleanup EXIT
echo "== starting ephemeral host server on :$PORT (persist=$PDIR) =="
# SX_SERVING_JIT=1 matches the live container (gates the http-listen IO resolver);
# without it, perform-heavy paths (e.g. the is-a/tags picker's reach-down) falsely 500.
SX_SERVING_JIT=1 HOST_PORT="$PORT" SX_PERSIST_DIR="$PDIR" \
SX_ADMIN_USER="$USER" SX_ADMIN_PASSWORD="$PASS" SX_SESSION_SECRET="$SECRET" \
bash lib/host/serve.sh >"$SERVE_LOG" 2>&1 &
SVPID=$!
for i in $(seq 1 60); do
curl -sf -o /dev/null "http://127.0.0.1:$PORT/health" 2>/dev/null && break
sleep 1
[ "$i" = "60" ] && { echo "server never came up:"; cat "$SERVE_LOG"; exit 1; }
done
echo "== server up =="
echo "== seeding 1 host post + 25 candidates =="
curl -s -c "$JAR" -o /dev/null -X POST "http://127.0.0.1:$PORT/login" \
--data "username=$USER&password=$PASS"
curl -s -b "$JAR" -o /dev/null -X POST "http://127.0.0.1:$PORT/new" \
--data 'title=Picker Host&sx_content=(p "host")&status=published'
for n in $(seq -w 1 25); do
curl -s -b "$JAR" -o /dev/null -X POST "http://127.0.0.1:$PORT/new" \
--data "title=Picker Item $n&sx_content=(p \"item $n\")&status=published"
done
echo "== seeded ($(curl -s "http://127.0.0.1:$PORT/posts" | grep -o '"slug"' | wc -l) posts) =="
echo "== running Playwright =="
cp "$ROOT/$SPEC_SRC" "$SPEC_DST"
cd "$PW_DIR"
SX_TEST_URL="http://127.0.0.1:$PORT" SX_ADMIN_USER="$USER" SX_ADMIN_PASSWORD="$PASS" \
node_modules/.bin/playwright test _picker-check.spec.js --workers=1 \
--config tests/playwright/playwright.config.js
RC=$?
echo "== done (exit $RC) =="
exit $RC