From 7da8a3bef505b05dbc95d0885cee8a2fc6f22549 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Fri, 14 Aug 2026 10:43:15 -0700 Subject: [PATCH] test(ui): build the deferred removal with Promise.withResolvers The pending-state test seeded its deferred promise by declaring the resolver with let and reassigning it inside the executor. Promise.withResolvers is the standard way to get the same handle without the reassignment, and the assertions are unchanged. --- .../_components/cost_tracking_settings.test.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/cost_tracking_settings.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/cost_tracking_settings.test.tsx index 716654e914c..03cef2a66b8 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/cost_tracking_settings.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/cost-tracking/_components/cost_tracking_settings.test.tsx @@ -199,12 +199,8 @@ describe("CostTrackingSettings", () => { it("should hold the confirmation open while the removal is still in flight", async () => { mockDiscountConfig.mockReturnValue({ openai: 0.05 }); - let settleRemoval: () => void = () => {}; - mockRemoveDiscount.mockReturnValue( - new Promise((resolve) => { - settleRemoval = resolve; - }), - ); + const { promise, resolve: settleRemoval } = Promise.withResolvers(); + mockRemoveDiscount.mockReturnValue(promise); const user = await expandAndRemove("Provider Discounts", "Remove discount for openai"); await user.click(await screen.findByRole("button", { name: "Remove" }));