From 76001b50de3b393d99be269e0b2d099f62503924 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 18 Feb 2026 13:04:01 +0000 Subject: [PATCH] test: verify app startup from persisted engine snapshot --- test/app.test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/app.test.js b/test/app.test.js index 651d5c1..ee3361b 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -249,6 +249,36 @@ test("emits persistence snapshots on mutating actions", () => { assert.equal(typeof latest.engine, "object"); }); +test("can boot app from previously persisted state snapshot", () => { + const snapshots = []; + const app1 = createApp({ + onMutation(state) { + snapshots.push(state); + }, + }); + + call(app1, { + method: "POST", + path: "/app/actions/topup", + headers: { cookie: "xartaudio_user=restart-user" }, + body: "amount=6", + }); + + const persistedState = snapshots[snapshots.length - 1]; + const app2 = createApp({ + initialState: persistedState, + }); + + const wallet = call(app2, { + method: "GET", + path: "/api/me/wallet", + headers: { cookie: "xartaudio_user=restart-user" }, + }); + + assert.equal(wallet.status, 200); + assert.equal(JSON.parse(wallet.body).balance, 6); +}); + test("rate limits repeated webhook calls", () => { const app = createApp({ config: {