test: e2e smoke; docs: README; ci: release workflow
Co-Authored-By: Claude
This commit is contained in:
63
scripts/e2e.sh
Executable file
63
scripts/e2e.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# End-to-end test driver: builds the plugin, provisions an isolated Obsidian
|
||||
# vault + config with the plugin installed and enabled, then runs the Playwright
|
||||
# spec against the real Obsidian binary under a virtual X display.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
CACHE="${OBSIDIAN_CACHE:-$HOME/.cache/obsidian-e2e}"
|
||||
APPIMAGE="$CACHE/Obsidian.AppImage"
|
||||
SQUASHFS="$CACHE/squashfs-root"
|
||||
E2E_DIR="$ROOT/.obsidian-e2e"
|
||||
VAULT="$E2E_DIR/vault"
|
||||
CONFIG_HOME="$E2E_DIR/config"
|
||||
|
||||
if [[ ! -f "$APPIMAGE" ]]; then
|
||||
echo "Obsidian AppImage not found at $APPIMAGE." >&2
|
||||
echo "Download it from https://obsidian.md/download and place it there." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract the AppImage once so we can launch the inner Electron binary directly.
|
||||
if [[ ! -x "$SQUASHFS/obsidian" ]]; then
|
||||
echo "==> Extracting Obsidian AppImage"
|
||||
( cd "$CACHE" && "$APPIMAGE" --appimage-extract >/dev/null )
|
||||
fi
|
||||
export OBSIDIAN_BIN="$SQUASHFS/obsidian"
|
||||
|
||||
echo "==> Building plugin"
|
||||
npm run build >/dev/null
|
||||
|
||||
echo "==> Provisioning isolated vault + config at $E2E_DIR"
|
||||
rm -rf "$E2E_DIR"
|
||||
PLUGIN_DIR="$VAULT/.obsidian/plugins/jekyll-publish"
|
||||
mkdir -p "$PLUGIN_DIR" "$CONFIG_HOME/obsidian"
|
||||
|
||||
cp dist/main.js dist/manifest.json dist/styles.css "$PLUGIN_DIR/"
|
||||
# Enable our community plugin (and disable Obsidian's first-run restricted mode prompt).
|
||||
printf '["jekyll-publish"]\n' > "$VAULT/.obsidian/community-plugins.json"
|
||||
|
||||
# Create a test note so the publish command has an active file.
|
||||
cat > "$VAULT/Test.md" <<'MD'
|
||||
---
|
||||
title: E2E Test Post
|
||||
date: 2024-01-01
|
||||
---
|
||||
|
||||
# E2E Test Post
|
||||
|
||||
This is a test note for the E2E smoke test.
|
||||
MD
|
||||
|
||||
# Register the vault and mark it open so Obsidian boots straight into it.
|
||||
VAULT_ESCAPED=$(printf '%s' "$VAULT" | sed 's/[\/&]/\\&/g')
|
||||
cat > "$CONFIG_HOME/obsidian/obsidian.json" <<JSON
|
||||
{"vaults":{"e2e0000000000000":{"path":"$VAULT_ESCAPED","ts":1700000000000,"open":true}}}
|
||||
JSON
|
||||
|
||||
export XDG_CONFIG_HOME="$CONFIG_HOME"
|
||||
|
||||
echo "==> Running Playwright (xvfb + real Obsidian)"
|
||||
xvfb-run -a --server-args="-screen 0 1280x900x24" npx playwright test "$@"
|
||||
Reference in New Issue
Block a user