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.
This commit is contained in:
Yuneng Jiang 2026-08-14 10:43:15 -07:00
parent 62b072dcf7
commit 7da8a3bef5
No known key found for this signature in database

View file

@ -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<void>((resolve) => {
settleRemoval = resolve;
}),
);
const { promise, resolve: settleRemoval } = Promise.withResolvers<void>();
mockRemoveDiscount.mockReturnValue(promise);
const user = await expandAndRemove("Provider Discounts", "Remove discount for openai");
await user.click(await screen.findByRole("button", { name: "Remove" }));