feat(pwa): тумблер боевой оплаты в отладке
Выключен по умолчанию: пополнение под просмотром открывает учебный экран. Включён — платёж уходит в банк, и над кнопкой «Оплатить» появляется предупреждение, что деньги спишутся по-настоящему и зачислятся водителю. Режим гаснет вместе с выходом из учётки сотрудника: следующий раз он включается осознанно, а не достаётся по наследству. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7342a6c9d5
commit
9aa71d6ca7
5 files changed
+74
-8
No files matched your search
@@ -5,7 +5,8 @@ import { MemoryRouter } from "react-router-dom";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
|
||||
vi.mock("@/api/driver", () => ({
|
||||
topup: vi.fn(async () => ({ order_id: "o9", pay_url: "https://qr.nspk.ru/x", commission: 52, total: 1052 })),
|
||||
topup: vi.fn(async () => ({ order_id: "o9", pay_url: "https://qr.nspk.ru/x", commission: 52,
|
||||
total: 1052, mock: false })),
|
||||
getCommission: vi.fn(async () => ({ rate: 0.052 })),
|
||||
getBuckets: vi.fn(async () => ({
|
||||
buckets: ["Долг аренда", "Долг по штрафам"], with_debt: ["Долг аренда"],
|
||||
@@ -34,7 +35,7 @@ describe("TopupPage", () => {
|
||||
expect(screen.getByTestId("amount").textContent).toBe("1 000 ₽");
|
||||
expect(screen.getByTestId("total").textContent).toContain("1 052");
|
||||
await userEvent.click(screen.getByRole("button", { name: /Оплатить/i }));
|
||||
expect(driver.topup).toHaveBeenCalledWith("Долг аренда", 1000, "qr");
|
||||
expect(driver.topup).toHaveBeenCalledWith("Долг аренда", 1000, "qr", false);
|
||||
});
|
||||
|
||||
it("decimal key builds kopecks and they reach the backend", async () => {
|
||||
@@ -46,7 +47,7 @@ describe("TopupPage", () => {
|
||||
}
|
||||
expect(screen.getByTestId("amount").textContent).toBe("100,52 ₽");
|
||||
await userEvent.click(screen.getByRole("button", { name: /Оплатить/i }));
|
||||
expect(driver.topup).toHaveBeenCalledWith("Долг аренда", 100.52, "qr");
|
||||
expect(driver.topup).toHaveBeenCalledWith("Долг аренда", 100.52, "qr", false);
|
||||
});
|
||||
|
||||
it("lets the driver choose the debt category instead of hardcoding rent", async () => {
|
||||
@@ -57,6 +58,32 @@ describe("TopupPage", () => {
|
||||
await userEvent.click(screen.getByRole("button", { name: "0" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: "0" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: /Оплатить/i }));
|
||||
expect(driver.topup).toHaveBeenCalledWith("Долг по штрафам", 500, "qr");
|
||||
expect(driver.topup).toHaveBeenCalledWith("Долг по штрафам", 500, "qr", false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("боевая оплата под просмотром", () => {
|
||||
it("по умолчанию платёж учебный — флаг в запрос уходит выключенным", async () => {
|
||||
const { useStaff } = await import("@/store/staff");
|
||||
useStaff.getState().clear();
|
||||
wrap();
|
||||
await userEvent.click(screen.getByRole("button", { name: "5" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: "0" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: "0" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: /Оплатить/i }));
|
||||
expect(driver.topup).toHaveBeenLastCalledWith("Долг аренда", 500, "qr", false);
|
||||
});
|
||||
|
||||
it("включённая боевая оплата предупреждает и уходит с флагом", async () => {
|
||||
const { useStaff } = await import("@/store/staff");
|
||||
useStaff.getState().setLivePay(true);
|
||||
wrap();
|
||||
expect(screen.getByText(/деньги спишутся по-настоящему/i)).toBeInTheDocument();
|
||||
await userEvent.click(screen.getByRole("button", { name: "5" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: "0" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: "0" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: /Оплатить/i }));
|
||||
expect(driver.topup).toHaveBeenLastCalledWith("Долг аренда", 500, "qr", true);
|
||||
useStaff.getState().clear();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user