mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-28 06:59:42 +00:00
* badges: webapp (#7433) * badges: service migrations, store and catalog * badges: BTCPay provider and settlement poller * badges: web listener and /api endpoints * web: checkout single-page app * badges: tests and BTCPay fixtures * badges: README and ini reference * badges: fix hex16 build on GHC 8.10.7 * badges: Stripe card lane * badges: fix Stripe card checkout, add theming * badges: add a discount row to the order summary * badges: site navbar, embedding, theme, Forget move * badges: use SB code prefix in web checkout * badges: rename sxb app namespace to sb * badges: embed checkout nav via site; keep original app navbar * badges: post iframe height, apply site background when embedded * badges: embed dark surfaces, steadier iframe height * badges: hide app footer when embedded * badges: size embedded body to content, not viewport * badges: declare color-scheme to stop reload flash * badges: fade shell in on load, no reload blank * badges: prerender app shell into index.html * badges: pre-paint theme, hide shell on deep reload * badges: logo returns to landing client-side * badges: embedded wizard back, buy-a-code, resume * badges: signal app-managed screens, resume across reload * badges: rebuild wizard history on deep load so Back walks it * badges: carry welcome-page height as the iframe floor * badges: keep selection on Buy a code; rename to Your codes * badges: read web shell as UTF-8, not locale * badges: resume the exact paid order after Stripe card redirect * badges: move docker deploy under scripts * badges: add serve_webapp toggle and webapp export * badges: wire split webapp deploy in docker config * badges: quiet agent logs by default * badges: resume card redirect in the embedded frame * badges: migrate Stripe adapter to PaymentIntents * badges: correct Stripe restricted key scopes in ini example * badges: card via Payment Element and PaymentIntents * badges: fix stale Checkout Session wording in Stripe adapter * badges: fix stale CheckoutActions reference in card comment * badges: order shell stylesheet before bootstrap script * badges: remove development card stand-in * badges: theme the Stripe card form with the site palette * badges: exclude web from the Haskell build stage * badges: unify invoice cancel and mark canceled * badges: default log level to info * badges: unify closed-invoice buy-again button * badges: mute agent connection logs at info level * badges: show purchase time in local timezone in Your codes * badges: log service events on own channel, quiet agent * badges: fold service migrations into one baseline * badges: run compose on postgres over host network * badges: use high-res hero art * badges: add web CI to catch stale builds * badges: rebuild web shell from committed source * badges: normalize invoice-code link and columns * badges: drop unused columns, rename index * badges: note deferred receipt_hash in migrations * badges: apply code-review fixes * badges: reduce comments across service and web --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com> Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com> * badges: improve web page (#7546) * badges: improve web page * improve layout * improve layout * fix * small changes --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com> * badges: read one issuer key from the ini * badges: move and group the service tests * badges: service fixes (#7567) * badges: match the redeem error wording in tests * badges: drop unused imports in the bot tests * badges: cancel Stripe orders when they expire * badges: correct the Stripe config and docs * badges: refuse to revoke a redeemed code * badges: make the fake Stripe cancel like Stripe * badges: limit replayed webhook deliveries --------- Co-authored-by: sh <37271604+shumvgolove@users.noreply.github.com> Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com> Co-authored-by: shum <github.shum@liber.li> Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
71 lines
3.4 KiB
TypeScript
71 lines
3.4 KiB
TypeScript
import { timedTest } from "./boot.js";
|
|
import assert from "node:assert/strict";
|
|
import { resolveLoad, screenForOpenOrder } from "../src/routing.js";
|
|
import { type OrderRecord } from "../src/domain.js";
|
|
import { Store } from "../src/store.js";
|
|
|
|
const routingTest = timedTest(2000);
|
|
|
|
class MemoryStorage {
|
|
map = new Map<string, string>();
|
|
getItem(k: string) { return this.map.get(k) ?? null; }
|
|
setItem(k: string, v: string) { this.map.set(k, v); }
|
|
removeItem(k: string) { this.map.delete(k); }
|
|
}
|
|
|
|
const o = (over: Partial<OrderRecord>): OrderRecord => ({
|
|
orderId: "abc", badgeType: "legend", months: 12,
|
|
createdAt: "2026-08-24T11:02:19Z", status: "open", ...over,
|
|
});
|
|
|
|
routingTest("routing: ?order= wins over the hash and the store", () => {
|
|
const r = resolveLoad({ search: "?order=abc" }, o({ orderId: "different" }));
|
|
assert.deepEqual(r, { kind: "order", orderId: "abc" });
|
|
});
|
|
|
|
routingTest("routing: a bare load resumes the newest open order, not the newest order of any status or the oldest open one", () => {
|
|
const store = new Store(new MemoryStorage());
|
|
store.saveOrder(o({ orderId: "open-oldest", status: "open", createdAt: "2026-08-20T00:00:00Z" }));
|
|
store.saveOrder(o({ orderId: "open-newest", status: "open", createdAt: "2026-08-25T00:00:00Z" }));
|
|
store.saveOrder(o({ orderId: "expired-newest-overall", status: "expired", createdAt: "2026-08-26T00:00:00Z" }));
|
|
const r = resolveLoad({ search: "" }, store.newestOpen());
|
|
assert.deepEqual(r, { kind: "order", orderId: "open-newest" });
|
|
});
|
|
|
|
routingTest("routing: with no open order it is the wizard, and the hash says which panel", () => {
|
|
assert.deepEqual(resolveLoad({ search: "" }, undefined), { kind: "step" });
|
|
});
|
|
|
|
routingTest("routing: an open order's screen follows the method and the card confirmation", () => {
|
|
assert.equal(screenForOpenOrder(o({ status: "open" }), "xmr"), "awaitingPayment");
|
|
assert.equal(screenForOpenOrder(o({ status: "open" }), "btc"), "awaitingPayment");
|
|
assert.equal(screenForOpenOrder(o({ status: "open" }), "card"), "cardForm");
|
|
assert.equal(screenForOpenOrder(o({ status: "open", submitted: true }), "card"), "awaitingConfirmation");
|
|
});
|
|
|
|
routingTest("routing: the flag is read off THE ORDER, so one order's confirm never speaks for another", () => {
|
|
const confirmed = o({ orderId: "inv_confirmed", status: "open", submitted: true });
|
|
const untouched = o({ orderId: "inv_other", status: "open" });
|
|
assert.equal(screenForOpenOrder(confirmed, "card"), "awaitingConfirmation");
|
|
assert.equal(screenForOpenOrder(untouched, "card"), "cardForm",
|
|
"an order with no confirm of its own is still payable");
|
|
});
|
|
|
|
routingTest("routing: the flag survives clearSession, a second order and a reload", () => {
|
|
const storage = new MemoryStorage();
|
|
const store = new Store(storage);
|
|
store.saveOrder(o({ orderId: "inv_confirmed", status: "open", createdAt: "2026-08-24T11:02:19Z" }));
|
|
assert.equal(store.markSubmitted("inv_confirmed"), true);
|
|
|
|
store.clearSession();
|
|
store.saveOrder(o({ orderId: "inv_second", status: "open", createdAt: "2026-08-24T12:00:00Z" }));
|
|
store.clearSession();
|
|
|
|
const reloaded = new Store(storage);
|
|
const kept = reloaded.order("inv_confirmed")!;
|
|
assert.equal(kept.submitted, true, "the flag is in the orders key, which nothing but Forget clears");
|
|
assert.equal(screenForOpenOrder(kept, "card"), "awaitingConfirmation");
|
|
assert.equal(reloaded.order("inv_second")!.submitted, undefined,
|
|
"and it did not spread to the order that followed it");
|
|
});
|