fix: address release v2 reviews

This commit is contained in:
ajnart committed 2026-08-14 02:18:46 +02:00
1 parent 4905ea6738
commit 32732680e5
55 files changed
+925 -294

No files matched your search

@@ -68,4 +68,41 @@ describe("ConfirmModal", () => {
expect(confirmButton.disabled).toBe(false);
expect(closeModal).not.toHaveBeenCalled();
});
test("waits for a rejecting confirmation button callback", async () => {
const closeModal = vi.fn();
const onConfirm = vi.fn();
let rejectClick!: (error: Error) => void;
const onClick = vi.fn(
() =>
new Promise<void>((_resolve, reject) => {
rejectClick = reject;
}),
);
await act(async () =>
root.render(
<MantineProvider>
<ConfirmModalComponent
actions={{ closeModal }}
innerProps={{ children: "Remove containers?", confirmProps: { onClick }, onConfirm }}
/>
</MantineProvider>,
),
);
const confirmButton = host.querySelectorAll("button").item(1);
await act(async () => confirmButton.click());
expect(confirmButton.disabled).toBe(true);
expect(onConfirm).not.toHaveBeenCalled();
await act(async () => {
rejectClick(new Error("Callback failed"));
await Promise.resolve();
});
expect(confirmButton.disabled).toBe(false);
expect(onConfirm).not.toHaveBeenCalled();
expect(closeModal).not.toHaveBeenCalled();
});
});
+1 -1
View File
@@ -61,7 +61,7 @@ export const ConfirmModal = createModal<Omit<ConfirmModalProps, "title">>(({ act
setLoading(true);
try {
if (typeof confirmProps?.onClick === "function") {
confirmProps.onClick(event);
await confirmProps.onClick(event);
}
if (typeof onConfirm === "function") {