chore: save pending changes

This commit is contained in:
2026-09-12 19:59:10 +03:00
parent 6b310db0b8
commit ae06f6e6e0
16 changed files with 403 additions and 42 deletions
@@ -14,6 +14,7 @@ const card: BankCard = {
name: "Основная",
bankName: "Банк",
lastFour: "1234",
paymentSystem: null,
openingBalance: { currency: "RUB", value: "100" },
balance: { currency: "RUB", value: "50" },
openingDate: "2026-01-01",
@@ -62,8 +63,30 @@ describe("BankCardForm", () => {
name: "Основная",
bankName: null,
lastFour: null,
paymentSystem: null,
});
});
it("loads and saves the selected payment system", async () => {
const close = setup({ ...card, paymentSystem: "mir" });
expect(
screen.getByRole("combobox", { name: /Платёжная система/ }),
).toHaveValue("МИР");
fireEvent.click(
screen.getByRole("combobox", { name: /Платёжная система/ }),
);
fireEvent.click(await screen.findByRole("option", { name: "Visa" }));
let body: unknown;
server.use(
http.patch("*/api/v1/bank-cards/a", async ({ request }) => {
body = await request.json();
return HttpResponse.json({ ...card, paymentSystem: "visa" });
}),
);
fireEvent.click(screen.getByRole("button", { name: "Сохранить" }));
await waitFor(() => expect(close).toHaveBeenCalled());
expect(body).toMatchObject({ paymentSystem: "visa" });
});
it("retains an invalid opening date draft and explains conflict with saved history", async () => {
const close = setup(card);
fireEvent.change(screen.getByLabelText(/Дата начала/), {