mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-28 11:19:21 +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>
93 lines
4.3 KiB
TypeScript
93 lines
4.3 KiB
TypeScript
import { mock } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { headingOf, installPage, screenOf, settle, timedTest, until } from "./boot.js";
|
|
import { type StubElement } from "./stub-dom.js";
|
|
import { ADDRESS, HELD_CODE, NOW, openReply, ORDER_ID, seededStorage, storedOrder } from "./open-order.js";
|
|
import { CANCEL_INVOICE, CANCEL_FAILED, CANCEL_HAS_FUNDS, CANCEL_NOT_OPEN, CANCEL_STILL_OPEN } from "../src/screens.js";
|
|
|
|
const cancelTest = timedTest(3000);
|
|
|
|
const storage = seededStorage();
|
|
|
|
mock.timers.enable({ apis: ["setTimeout", "Date"], now: NOW });
|
|
|
|
const page = installPage({ storage, url: `/?order=${ORDER_ID}` });
|
|
const { app, fetches } = page;
|
|
// This answers the watch's first read; the ?wait= after it holds, as a real one does.
|
|
page.respondWith(openReply);
|
|
await import("../src/main.js");
|
|
|
|
function cancelControl(): StubElement | undefined {
|
|
return screenOf(app).all("button").find((b) => b.textContent === CANCEL_INVOICE);
|
|
}
|
|
|
|
cancelTest("main: a cancel the service refuses says so and keeps watching the order", async () => {
|
|
await until(() => headingOf(screenOf(app)).startsWith("Send"), "the payment screen");
|
|
page.confirmAnswer(true);
|
|
page.respondWith({ status: 500, body: { error: "internal" } });
|
|
const before = fetches.length;
|
|
|
|
cancelControl()?.click();
|
|
await settle();
|
|
await until(() => screenOf(app).textContent.includes(CANCEL_FAILED), "the failure is on screen");
|
|
// A count alone is satisfied by the cancel POST, so this checks for the read the restarted watch makes.
|
|
const after = fetches.slice(before).map((f) => f.url);
|
|
assert.ok(after.some((u) => u.startsWith(`/api/invoice/${ORDER_ID}`) && !u.endsWith("/cancel")),
|
|
`the watch must be reading again, not left dead: ${JSON.stringify(after)}`);
|
|
});
|
|
|
|
cancelTest("main: each cancel refusal says which of the two it is", async () => {
|
|
page.confirmAnswer(true);
|
|
page.respondWith({ status: 409, body: { error: "funded" } });
|
|
cancelControl()?.click();
|
|
await settle();
|
|
await until(() => screenOf(app).textContent.includes(CANCEL_HAS_FUNDS), "money is riding on it");
|
|
assert.ok(!screenOf(app).textContent.includes(CANCEL_FAILED), "never the generic wording");
|
|
|
|
// The reason must outlive the repaint the restarted watch makes, or the buyer never reads it.
|
|
page.setOffline(true);
|
|
await settle();
|
|
page.setOffline(false);
|
|
await settle();
|
|
assert.ok(screenOf(app).textContent.includes(CANCEL_HAS_FUNDS),
|
|
`a repaint must not take the reason away: ${screenOf(app).textContent.slice(0, 120)}`);
|
|
|
|
page.confirmAnswer(true);
|
|
page.respondWith({ status: 409, body: { error: "not_open" } });
|
|
cancelControl()?.click();
|
|
await settle();
|
|
await until(() => screenOf(app).textContent.includes(CANCEL_NOT_OPEN), "the invoice is simply gone");
|
|
assert.ok(!screenOf(app).textContent.includes(CANCEL_HAS_FUNDS),
|
|
"an empty expired invoice must not be described as holding a payment");
|
|
});
|
|
|
|
cancelTest("main: a cancel answered 200 but still open is not a done deal", async () => {
|
|
page.confirmAnswer(true);
|
|
// An open answer with nothing on it should not happen, but if it does the address is dead and 200 alone must not read as cancelled.
|
|
page.respondWith(openReply);
|
|
|
|
cancelControl()?.click();
|
|
await settle();
|
|
await until(() => screenOf(app).textContent.includes(CANCEL_STILL_OPEN),
|
|
"the buyer is told, not sent off to start a new purchase");
|
|
});
|
|
|
|
cancelTest("main: a cancelled order keeps its code and loses everything payable", async () => {
|
|
page.confirmAnswer(true);
|
|
page.respondWith({ status: 200, body: { status: "expired", amount: 42000, currency: "usd" } });
|
|
|
|
cancelControl()!.click();
|
|
await until(() => storedOrder(storage)!.status === "expired", "the answer is applied to the record");
|
|
|
|
const after = storedOrder(storage)!;
|
|
assert.equal(after.canceled, true, "the buyer's own cancel is recorded, so Your codes reads it as canceled");
|
|
assert.equal(after.code, HELD_CODE, "the code is the one thing this browser cannot get back");
|
|
for (const key of ["address", "cryptoAmount", "cryptoCurrency", "expiresAt"] as const) {
|
|
assert.equal(after[key], undefined, `${key} must go: the address stops accepting payment`);
|
|
}
|
|
assert.ok(!JSON.stringify(after).includes(ADDRESS), "and nothing anywhere still names it");
|
|
|
|
await until(() => headingOf(screenOf(app)) === "Support SimpleX",
|
|
"the landing screen, ready for a new purchase");
|
|
});
|