mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 04:33:11 +00:00
test(completion-docs): keep the dialog closed when a save finishes after closing
This commit is contained in:
parent
d5cd0659a2
commit
9c19287172
1 changed files with 22 additions and 0 deletions
|
|
@ -234,6 +234,28 @@ describe("Edit template", { timeout: 15_000 }, () => {
|
|||
await within(dialog).findByText("Created by Jane Doe · Updated Sep 25, 2026"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("stays closed when the user closes it while a save is still in flight", async () => {
|
||||
let finishSave: (value: unknown) => void = () => undefined;
|
||||
api.apiPut.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise((resolve) => {
|
||||
finishSave = resolve;
|
||||
}),
|
||||
);
|
||||
const dialog = await openTemplate("Backflow Test Report");
|
||||
await user.click(within(dialog).getByRole("button", { name: /Edit/ }));
|
||||
await user.type(within(dialog).getByRole("textbox", { name: /Document Title/ }), " v2");
|
||||
await user.click(within(dialog).getByRole("button", { name: /Save changes/ }));
|
||||
await waitFor(() => expect(api.apiPut).toHaveBeenCalled());
|
||||
|
||||
await user.click(within(dialog).getByRole("button", { name: "Close" }));
|
||||
await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
|
||||
finishSave({ ...BACKFLOW, name: "Backflow Test Report v2" });
|
||||
|
||||
await waitFor(() => expect(toast.success).toHaveBeenCalledWith("Template updated"));
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Delete template", { timeout: 15_000 }, () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue