Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
54 lines
2.3 KiB
TypeScript
54 lines
2.3 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
import { ReceiptDialog } from "./ReceiptDialog";
|
|
|
|
// redesign-pos-sale-flow (BABYBOO-38): after a sale, "Payment complete" with the receipt, the
|
|
// collection, and Start new sale as the only way out.
|
|
|
|
function renderDialog() {
|
|
const onNewSale = vi.fn();
|
|
render(
|
|
<ReceiptDialog open documentNo="IN00000042" total={194} collection="Pick up at HQ" onNewSale={onNewSale}>
|
|
<p>receipt lines</p>
|
|
</ReceiptDialog>,
|
|
);
|
|
return onNewSale;
|
|
}
|
|
|
|
describe("ReceiptDialog", () => {
|
|
it("says the payment is complete, with the sale number and total", () => {
|
|
renderDialog();
|
|
expect(screen.getByRole("dialog", { name: "Payment complete" })).toBeInTheDocument();
|
|
expect(screen.getByText("Sale IN00000042 · RM 194.00")).toBeInTheDocument();
|
|
// A long/UUID document number must wrap inside the narrow dialog (class-level; jsdom has no layout).
|
|
expect(screen.getByText("Sale IN00000042 · RM 194.00")).toHaveClass("[overflow-wrap:anywhere]");
|
|
});
|
|
|
|
it("shows the collection and the receipt", () => {
|
|
renderDialog();
|
|
expect(screen.getByTestId("receipt-collection")).toHaveTextContent("Pick up at HQ");
|
|
expect(screen.getByText("receipt lines")).toBeInTheDocument();
|
|
});
|
|
|
|
it("Start new sale starts the next sale", () => {
|
|
const onNewSale = renderDialog();
|
|
fireEvent.click(screen.getByRole("button", { name: "Start new sale" }));
|
|
expect(onNewSale).toHaveBeenCalled();
|
|
});
|
|
|
|
it("cannot be dismissed any other way", () => {
|
|
const onNewSale = renderDialog();
|
|
expect(screen.queryByRole("button", { name: "Close" })).not.toBeInTheDocument();
|
|
fireEvent.keyDown(screen.getByRole("dialog"), { key: "Escape" });
|
|
expect(onNewSale).not.toHaveBeenCalled();
|
|
expect(screen.getByRole("dialog", { name: "Payment complete" })).toBeInTheDocument();
|
|
});
|
|
|
|
// BABYBOO-39: a long product name made the grid dialog's content wider than the dialog. jsdom has no layout,
|
|
// so this pins the classes that fix it (verified visually on dev-adm), not the rendered width.
|
|
it("lets its children shrink below content width so wide receipts scroll instead of overflowing", () => {
|
|
renderDialog();
|
|
expect(screen.getByRole("dialog").className).toContain("[&>*]:min-w-0");
|
|
});
|
|
});
|