sc-theme-builder/test/runIntegration.sh
2026-07-01 20:07:28 -05:00

30 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Reproducible, SELF-CONTAINED in-process integration test for theme-builder.
# Spins up a throwaway SQLite DB under ./.test-state, runs Saltcorn migrations,
# then drives the real apiHandlers via test/integration.js. Touches no other
# instance and no shared plugins folder.
#
# ./test/runIntegration.sh
#
# @saltcorn/* are host-provided (this plugin declares no deps, per the
# dev-deploy/idp convention), so the harness gets them via NODE_PATH pointing at
# the upstream checkout's node_modules.
set -e
HERE="$(cd "$(dirname "$0")" && pwd)"
PLUGIN="$(dirname "$HERE")"
REPO="$(dirname "$PLUGIN")"
SC_BIN="$REPO/saltcorn/packages/saltcorn-cli/bin/saltcorn"
STATE="$PLUGIN/.test-state"
mkdir -p "$STATE/files"
export SQLITE_FILEPATH="$STATE/test.sqlite"
export SALTCORN_FILE_STORE="$STATE/files"
export SALTCORN_SESSION_SECRET="theme-builder-integration-test-secret"
export SALTCORN_NWORKERS=1
export NODE_PATH="$REPO/saltcorn/node_modules"
rm -f "$SQLITE_FILEPATH"
rm -rf "/tmp/$USER/saltcorn-tmp/temp_install/theme-builder" 2>/dev/null || true
node "$SC_BIN" reset-schema --force >/dev/null
exec node "$HERE/integration.js"