import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it, vi } from "vitest"; import { PaymentLaunchDialogs } from "../payment-launch-dialogs"; const hiddenLaunch = { handleEzpayCancel: vi.fn(), handleEzpayConfirm: vi.fn(), handleQrisClose: vi.fn(), handleStripeClose: vi.fn(), handleStripeConfirmed: vi.fn(), isConfirmingEzpay: false, qrisErrorMessage: null, qrisPayment: null, qrisStatus: null, shouldShowEzpayConfirmDialog: false, shouldShowQrisDialog: false, shouldShowStripeDialog: false, stripeClientSecret: null, }; describe("PaymentLaunchDialogs", () => { it("renders nothing when neither payment dialog is active", () => { expect( renderToStaticMarkup( , ), ).toBe(""); }); it("renders the shared Ezpay confirmation content", () => { const html = renderToStaticMarkup( , ); expect(html).toContain('role="alertdialog"'); expect(html).toContain("Continue to payment?"); expect(html).toContain("Your coffee order is ready."); expect(html).toContain("Order No. order-123"); expect(html).toContain('data-analytics-key="tip.external_checkout"'); expect(html).toContain("Opening..."); }); it("renders an accessible QRIS dialog with display cents and order status", () => { const html = renderToStaticMarkup( , ); expect(html).toContain('role="dialog"'); expect(html).toContain("Scan to pay with QRIS"); expect(html).toContain("QRIS payment QR code"); expect(html).toContain("Order No. order-id-qris"); expect(html).toContain("Rp"); expect(html).toContain("50.000"); expect(html).toContain("Waiting for payment"); }); it("shows QRIS failure state and handles empty QR data safely", () => { const html = renderToStaticMarkup( , ); expect(html).toContain("QRIS data is unavailable"); expect(html).toContain("Payment failed or was cancelled."); expect(html).toContain("Close"); }); });