chore: save pending changes
This commit is contained in:
@@ -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(/Дата начала/), {
|
||||
|
||||
Reference in New Issue
Block a user