test: verify app startup from persisted engine snapshot
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user