From 08a306f198479c863d741f970ec9b30f744edc57 Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Mon, 17 Aug 2026 11:08:33 -0700 Subject: [PATCH] test(access-groups): build the pending-save fixture with Promise.withResolvers The dismiss-while-pending test seeded its deferred promise by declaring the resolver with let and reassigning it inside the executor. Promise.withResolvers gives the same handle without the reassignment, and the assertions are unchanged. --- .../access-group-edit/AccessGroupEditDialog.test.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-edit/AccessGroupEditDialog.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-edit/AccessGroupEditDialog.test.tsx index 2c2d08a49c9..318c541e052 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-edit/AccessGroupEditDialog.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/access-groups/_components/access-group-edit/AccessGroupEditDialog.test.tsx @@ -231,13 +231,8 @@ describe("AccessGroupEditDialog", () => { it("cannot be dismissed while a save is pending, then closes once on success", async () => { const user = userEvent.setup(); - let resolveSave: (value: AccessGroupResponse | undefined) => void = () => {}; - const patchAccessGroup = vi.fn().mockImplementation( - () => - new Promise((resolve) => { - resolveSave = resolve; - }), - ); + const { promise: pendingSave, resolve: resolveSave } = Promise.withResolvers(); + const patchAccessGroup = vi.fn().mockReturnValue(pendingSave); renderDialog({ patchAccessGroup }); await user.clear(screen.getByLabelText("Description"));