feat(driver-pwa): payment screen + auto status polling
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
1 parent
372dc0ede7
commit
0a164634f8
3 files changed
+81
-1
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { MemoryRouter, Routes, Route } from "react-router-dom";
|
||||
|
||||
const states = ["FORM", "PAID"];
|
||||
vi.mock("@/api/driver", () => ({
|
||||
getPaymentState: vi.fn(async () => ({ order_id: "o9", status: states.shift() ?? "PAID" })),
|
||||
}));
|
||||
import { PaymentPage } from "./PaymentPage";
|
||||
|
||||
function wrap() {
|
||||
const qc = new QueryClient();
|
||||
return render(
|
||||
<QueryClientProvider client={qc}>
|
||||
<MemoryRouter initialEntries={[{ pathname: "/pay/o9", state: { payUrl: "https://qr.nspk.ru/x", total: 1052, bucket: "Долг аренда", base: 1000 } }]}>
|
||||
<Routes><Route path="/pay/:orderId" element={<PaymentPage />} /></Routes>
|
||||
</MemoryRouter>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
describe("PaymentPage", () => {
|
||||
it("shows pay button and flips to success on PAID", async () => {
|
||||
wrap();
|
||||
expect(screen.getByRole("link", { name: /Оплатить/i })).toHaveAttribute("href", "https://qr.nspk.ru/x");
|
||||
await waitFor(() => expect(screen.getByText(/Оплачено/i)).toBeInTheDocument(), { timeout: 3000 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user