snezhig_obsidian-front-matt.../dnode-e2e.sh
snezhig afcfcaf669 Add headless e2e harness on real Obsidian (Phase 5)
End-to-end tests that launch the actual downloaded Obsidian (Electron) under
Xvfb, fully inside Docker — automated regression on the server without the
local PC, and an automated baseline. Confirms the plugin boots and the
Explorer feature works on Obsidian 1.12.7.

- Dockerfile.e2e: node:20 + Xvfb + the system libs Electron needs.
- dnode-e2e.sh: builds the image, starts Xvfb, runs the suite in-container
  (security rule preserved: node/electron never touch the host).
- wdio.conf.mts: wdio-obsidian-service against browserVersion "latest",
  plugins ["."], the seeded test vault, Electron flags for containers
  (--no-sandbox/--disable-gpu/--disable-dev-shm-usage).
- test/vaults/simple: a Zettelkasten-named note with a frontmatter title and a
  seeded plugin data.json (Explorer/Tab enabled, no boot delay).
- test/e2e/smoke.e2e.ts: plugin loads without crashing, the frontmatter title
  replaces the filename in the file explorer, and the resolve API is exercised.
- npm run test:e2e; .obsidian-cache (downloaded Obsidian) gitignored.
2026-06-23 15:14:20 +03:00

22 lines
776 B
Bash
Executable file

#!/bin/sh
# Headless e2e wrapper (SECURITY: still inside Docker, never on the host).
# Builds the Dockerfile.e2e image, starts Xvfb, and runs the given command
# (defaults to the e2e suite). .obsidian-cache is mounted via the repo volume
# so the downloaded Obsidian binaries persist between runs.
# Usage: ./dnode-e2e.sh (runs npm run test:e2e)
# ./dnode-e2e.sh <cmd...>
set -e
IMAGE=ofmt-e2e
docker build -f Dockerfile.e2e -t "$IMAGE" .
if [ "$#" -eq 0 ]; then
set -- npm run test:e2e
fi
exec docker run --rm -i \
-u "$(id -u):$(id -g)" -e HOME=/tmp \
--shm-size=1g \
-w /app -v "$(pwd)":/app \
"$IMAGE" \
sh -ec 'Xvfb :99 -screen 0 1280x1024x24 -nolisten tcp >/tmp/xvfb.log 2>&1 & export DISPLAY=:99; sleep 2; exec "$@"' _ "$@"