test(ui): cover a negative policy attachment priority typed keystroke by keystroke

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yucheng 2026-09-17 07:56:43 +00:00
parent 669a66499c
commit 8164189237

View file

@ -210,6 +210,23 @@ describe("AddAttachmentForm", () => {
});
});
it("sends a negative priority typed one keystroke at a time", async () => {
const user = userEvent.setup();
const createAttachment = vi.fn().mockResolvedValue({});
renderWithProviders(<AddAttachmentForm {...defaultProps} createAttachment={createAttachment} />);
await selectPolicy(user, "policy-alpha");
const priority = screen.getByLabelText("Priority");
await user.type(priority, "-5");
expect(priority).toHaveValue(-5);
await submit(user);
await waitFor(() => expect(createAttachment).toHaveBeenCalledTimes(1));
expect(createAttachment).toHaveBeenCalledWith("test-token", {
policy_name: "policy-alpha",
scope: "*",
priority: -5,
});
});
it("omits priority from the attachment when the field is left blank", async () => {
const user = userEvent.setup();
const createAttachment = vi.fn().mockResolvedValue({});