This commit is contained in:
2026-06-23 22:03:26 -07:00
parent 2e3c1e3646
commit e8cbd2760c
7 changed files with 110 additions and 45 deletions

View File

@@ -194,6 +194,22 @@
:body (cheshire.core/generate-string
{:mode mode})}))
(defn reset-test-data! []
"Recreate and re-seed the in-memory test database, returning to the same
baseline the server starts with. Used by the /test-reset endpoint so each
browser test can start from a clean, deterministic dataset."
(reset! test-identity-mode :single-client)
(let [conn (create-test-db)
tx-id (seed-test-data conn)]
(reset! test-transaction-id tx-id)
tx-id))
(defn test-reset-handler [_request]
{:status 200
:headers {"Content-Type" "application/json"}
:body (cheshire.core/generate-string {:ok true
:transactionId (reset-test-data!)})})
(defn wrap-test-info [handler]
(fn [request]
(cond
@@ -201,6 +217,8 @@
(test-info-handler request)
(= "/test-set-client-mode" (:uri request))
(test-set-client-mode-handler request)
(= "/test-reset" (:uri request))
(test-reset-handler request)
:else
(handler request))))