Repository Public
1#!/bin/bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : Sheet8# File : scripts/e2e.sh9# Module : scripts10# Repository : https://git.spboucher.ai/sheet11# Project Website : https://sheet.spboucher.ai12# Created : 2026-11-1713# Last Modified : 2026-11-1714#15# Author : Simon-Pierre Boucher16# Position : Professor of Finance17# Institution : Université du Québec en Outaouais (UQO)18# Organization : SP Boucher19# Website : https://spboucher.ai20# Git : https://git.spboucher.ai21#22# Preferred Contact: contact@spboucher.ai23# Technical Contact: dev@spboucher.ai24# Security/Admin : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License : None specified (no license file in this repository)33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041# Browser tests (Playwright): the real studio and public site in Chromium (with a virtual passkey authenticator),42# plus the public pages in WebKit with an iPhone profile. Fresh database; Anthropic replaced by the local stand-in.43# scripts/e2e.sh (SKIP_BUILD=1 reuses .next) screenshots → e2e/screenshots/44set -euo pipefail45cd "$(dirname "$0")/.."46export PATH="/opt/homebrew/opt/postgresql@17/bin:/opt/homebrew/bin:$PATH"47PORT="${E2E_PORT:-8702}"; FAKE_PORT="${FAKE_ANTHROPIC_PORT:-8798}"48ROOT="$(mktemp -d /tmp/sheet-e2e.XXXXXX)"; DB="sheet_e2e"49export NODE_ENV=production NEXT_TELEMETRY_DISABLED=150# WebAuthn treats http://localhost as a secure context; the RP ID is then "localhost".51export APP_URL="http://localhost:$PORT" E2E_BASE_URL="http://localhost:$PORT" INTERNAL_URL="http://127.0.0.1:$PORT"52export APP_SECRET="e2e-secret-e2e-secret-e2e-secret-0123456789abc" ADMIN_EMAIL="admin@example.test" ADMIN_NAME="Simon-Pierre Boucher"53export DATABASE_URL="postgres://127.0.0.1:5432/$DB" STORAGE_ROOT="$ROOT/storage" SETUP_URL_FILE="$ROOT/setup-url.txt"54export ANTHROPIC_API_KEY="sk-ant-test-fake-key" ANTHROPIC_BASE_URL="http://127.0.0.1:$FAKE_PORT" FAKE_ANTHROPIC_PORT="$FAKE_PORT"55unset WEBAUTHN_RP_ID CLAMD_SOCKET ANTHROPIC_MODEL CHROMIUM_PATH || true56dropdb --if-exists "$DB"; createdb "$DB"57node_modules/.bin/tsx scripts/migrate.ts; node_modules/.bin/tsx scripts/bootstrap.ts; node_modules/.bin/tsx scripts/seed.ts --publish-examples58[ "${SKIP_BUILD:-}" = 1 ] && [ -d .next ] || node_modules/.bin/next build >/dev/null59PIDS=()60node node_modules/tsx/dist/cli.mjs tests/fake-anthropic.ts > "$ROOT/fake.log" 2>&1 & PIDS+=($!)61PORT="$PORT" HOST=127.0.0.1 node node_modules/tsx/dist/cli.mjs server.ts > "$ROOT/web.log" 2>&1 & PIDS+=($!)62node node_modules/tsx/dist/cli.mjs src/worker/index.ts > "$ROOT/worker.log" 2>&1 & PIDS+=($!)63trap 'for p in "${PIDS[@]}"; do kill "$p" 2>/dev/null || true; done; wait 2>/dev/null || true; echo "logs kept in $ROOT"' EXIT64for _ in $(seq 1 80); do curl -fsS "http://localhost:$PORT/api/health" >/dev/null 2>&1 && break; sleep 0.5; done65node_modules/.bin/playwright test -c e2e/playwright.config.ts --output "$ROOT/results" "$@"66