From 5db71998eb0fe8b34185199d970191b085ace44c Mon Sep 17 00:00:00 2001 From: Do Siki Date: Wed, 19 Aug 2026 14:15:33 +0200 Subject: [PATCH] feat(test): comprehensive pre-deploy test suite as single entry point MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/pre-deploy-tests.sh runs every local test group before a deploy: proto unit (jest), content schema validation, all CMS integration suites (security, serializer, save, optimistic lock, versions, logo, login, logout, guide, bottom bar), publish command/integration and plane sync unit tests. Per-group PASS/FAIL summary; non-zero exit on any failure. deploy_to_stage_on_local.sh now runs the full suite as step 1 — a failing group aborts the release before push. Deploy workflow docs updated. Closes MITHOME-70 --- .agent/workflows/deploy.md | 4 +-- scripts/deploy_to_stage_on_local.sh | 6 ++-- scripts/pre-deploy-tests.sh | 53 +++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 5 deletions(-) create mode 100755 scripts/pre-deploy-tests.sh diff --git a/.agent/workflows/deploy.md b/.agent/workflows/deploy.md index db3dcb4..37c3a44 100644 --- a/.agent/workflows/deploy.md +++ b/.agent/workflows/deploy.md @@ -13,7 +13,7 @@ description: Deployment munkafolyamata — lokális teszttől a stagingen át a ## Előfeltételek -- Unit tesztek zöldek: `cd proto && npm test` +- **Teljes pre-deploy tesztkészlet zöld**: `scripts/pre-deploy-tests.sh` (proto unit, content séma, mind a CMS/infra tesztcsoport; hiba esetén nem-nulla exit — a deploy-script 1. lépésként futtatja, és megszakítja a kiadást) - Lint: `cd proto && npm run lint` (nincs új hiba) - `TODO.md` és Plane szinkronban @@ -28,7 +28,7 @@ description: Deployment munkafolyamata — lokális teszttől a stagingen át a A script (részletek: `docs/helyi-staging-deploy.md`): 1. Ellenőrzi, hogy a helyi `main` ág tiszta-e és a munkakönyvtár megfelelő-e. -2. `proto/`-ban `npm ci` + `npm run test:unit` — sikertelen teszt esetén **nincs push**. +2. `npm ci` + `scripts/pre-deploy-tests.sh` (teljes készlet) — sikertelen teszt esetén **nincs push**. 3. Push a Gitea `origin/main`-re. 4. SSH a staging hostra (`sadmin@llmdev.mozdit.hu`, `/home/sadmin/websitedev`): `git pull --ff-only` + `./deploy.sh staging`. 5. Playwright smoke tesztek a `https://stage.mozdit.hu` ellen (`npm run test:smoke:staging`). diff --git a/scripts/deploy_to_stage_on_local.sh b/scripts/deploy_to_stage_on_local.sh index e65269e..0235b25 100755 --- a/scripts/deploy_to_stage_on_local.sh +++ b/scripts/deploy_to_stage_on_local.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Helyi, kézi staging kiadás: unit teszt -> push -> szerveroldali deploy -> staging smoke teszt. +# Helyi, kézi staging kiadás: teljes pre-deploy tesztkészlet -> push -> szerveroldali deploy -> staging smoke teszt. set -Eeuo pipefail @@ -31,12 +31,12 @@ cd "${PROJECT_ROOT}" [[ "$(git branch --show-current)" == "${DEPLOY_BRANCH}" ]] || fail "A kiadás csak a ${DEPLOY_BRANCH} ágról engedélyezett." ensure_clean_worktree -printf '1/4 Függőségek és unit tesztek…\n' +printf '1/4 Függőségek és teljes pre-deploy tesztkészlet…\n' ( cd "${APP_ROOT}" npm ci - npm run test:unit ) +"${PROJECT_ROOT}/scripts/pre-deploy-tests.sh" # A tesztek nem módosíthatják a kiadandó commitot. ensure_clean_worktree diff --git a/scripts/pre-deploy-tests.sh b/scripts/pre-deploy-tests.sh new file mode 100755 index 0000000..e9ad1ac --- /dev/null +++ b/scripts/pre-deploy-tests.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# Teljeskörű pre-deploy tesztkészlet — minden deploy előtt futtatandó. +# Összefogja a proto (weboldal) és a gyökér (CMS/infra) lokális tesztjeit; +# csoportonkénti PASS/FAIL összegzéssel, hiba esetén nem-nulla exit kód. +# +# Használat: scripts/pre-deploy-tests.sh +# A deploy_to_stage_on_local.sh 1. lépésként futtatja. + +set -uo pipefail + +readonly ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +FAILED=() + +run() { + local name="$1"; shift + printf '\n── %s\n' "$name" + if "$@"; then + printf '✅ %s\n' "$name" + else + printf '❌ %s\n' "$name" + FAILED+=("$name") + fi +} + +# ── Weboldal (proto) ───────────────────────────────────────────────────────── +run "proto: unit tesztek (jest, 60+)" bash -c "cd '${ROOT}/proto' && npm test --silent" + +# ── Tartalom ───────────────────────────────────────────────────────────────── +run "content: séma-validáció (minden JSON)" node "${ROOT}/scripts/test-content-schema.js" + +# ── CMS (content-editor) ───────────────────────────────────────────────────── +run "cms: security guard (auth, CSRF, XFF)" node "${ROOT}/scripts/test-content-editor-security.js" +run "cms: serializer regresszió (collect/reindex)" node "${ROOT}/scripts/test-content-editor-serializer.js" +run "cms: atomikus mentés + backup" node "${ROOT}/scripts/test-content-editor-save.js" +run "cms: optimista zárolás (409, hash-frissítés)" node "${ROOT}/scripts/test-content-editor-conflict.js" +run "cms: verziók panel (diff, restore)" node "${ROOT}/scripts/test-content-editor-versions.js" +run "cms: logó feltöltés (PNG, backup, audit)" node "${ROOT}/scripts/test-content-editor-logo.js" +run "cms: login flow (session, Safari-scenariok)" node "${ROOT}/scripts/test-content-editor-login.js" +run "cms: logout + rate-limit" node "${ROOT}/scripts/test-content-editor-logout.js" +run "cms: guide endpoint + renderer" node "${ROOT}/scripts/test-content-editor-guide.js" +run "cms: alsó sáv layout guard" node "${ROOT}/scripts/test-content-editor-bottombar.js" +run "cms: publish parancs + integráció" node "${ROOT}/scripts/test-cms-publish.js" + +# ── Infra ──────────────────────────────────────────────────────────────────── +run "plane: sync unit tesztek" node --test "${ROOT}/scripts/plane/plane-sync.test.js" + +# ── Összegzés ──────────────────────────────────────────────────────────────── +printf '\n────────────────────────────────────────\n' +if [ "${#FAILED[@]}" -gt 0 ]; then + printf '❌ %d tesztcsoport HIBÁS: %s\n' "${#FAILED[@]}" "${FAILED[*]}" + exit 1 +fi +printf '✅ Minden pre-deploy teszt zöld.\n'