From 4dce11dd267394c5e0c077957294186e291341fb Mon Sep 17 00:00:00 2001 From: "s0wlz (Matthias Puchstein)" Date: Wed, 29 Apr 2026 04:03:14 +0200 Subject: [PATCH] feat(tests): add test-env.sh, gitignore updates, package.json scripts --- .gitignore | 4 ++++ frontend/package.json | 5 ++++- frontend/tests/.auth/.gitignore | 1 + scripts/test-env.sh | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 frontend/tests/.auth/.gitignore create mode 100755 scripts/test-env.sh diff --git a/.gitignore b/.gitignore index 07f5bc4..c548652 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,7 @@ release/ *.db-journal *.db-shm *.db-wal + +# Test pipeline +data/test/ +frontend/test-results/ diff --git a/frontend/package.json b/frontend/package.json index 6db35d8..7209dd5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,9 +7,12 @@ "build": "vite build", "preview": "vite preview", "check": "svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch" + "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", + "test:e2e": "playwright test", + "test:e2e:ui": "playwright test --ui" }, "devDependencies": { + "@playwright/test": "^1.59.1", "@sveltejs/adapter-static": "latest", "@sveltejs/kit": "latest", "@sveltejs/vite-plugin-svelte": "latest", diff --git a/frontend/tests/.auth/.gitignore b/frontend/tests/.auth/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/frontend/tests/.auth/.gitignore @@ -0,0 +1 @@ +* diff --git a/scripts/test-env.sh b/scripts/test-env.sh new file mode 100755 index 0000000..41b016c --- /dev/null +++ b/scripts/test-env.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +TT_WORKTREE_ROOT="$(git rev-parse --show-toplevel)" + +# Deterministic port: 3100 + (sha1 of path) % 100 +_hash=$(echo -n "$TT_WORKTREE_ROOT" | sha1sum | cut -c1-8) +_dec=$(( 16#$_hash )) +TT_TEST_PORT=$(( 3100 + _dec % 100 )) + +# TT_TEST_PORT_RANDOM=1 → bind :0; backend writes actual port to data/test/.port +if [ "${TT_TEST_PORT_RANDOM:-0}" = "1" ]; then + TT_TEST_PORT=0 +fi + +TT_TEST_DB="${TT_WORKTREE_ROOT}/data/test/attendance.db" +TT_TEST_MODE=1 +TT_BASE_URL="http://127.0.0.1:${TT_TEST_PORT}" + +mkdir -p "${TT_WORKTREE_ROOT}/data/test" + +export TT_WORKTREE_ROOT TT_TEST_PORT TT_TEST_DB TT_TEST_MODE TT_BASE_URL + +cat > "${TT_WORKTREE_ROOT}/data/test/.env" <