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.
This commit is contained in:
ryan-crabbe-berri 2026-08-17 11:08:33 -07:00
parent 1e4f66f0fc
commit 08a306f198

View file

@ -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<AccessGroupResponse | undefined>();
const patchAccessGroup = vi.fn().mockReturnValue(pendingSave);
renderDialog({ patchAccessGroup });
await user.clear(screen.getByLabelText("Description"));