fix(a11y): restore native keyboard file selection
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React from "react";
|
||||
import "@testing-library/jest-dom";
|
||||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import Attachments from "./components/Attachments";
|
||||
@@ -23,11 +24,11 @@ async function expectNativeInputActivation(button: HTMLElement, input: HTMLInput
|
||||
const activated = jest.fn();
|
||||
input.addEventListener("click", activated);
|
||||
act(() => button.focus());
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await act(async () => { await userEvent.keyboard("{Enter}"); });
|
||||
expect(activated).toHaveBeenCalledTimes(1);
|
||||
await userEvent.keyboard(" ");
|
||||
await act(async () => { await userEvent.keyboard(" "); });
|
||||
expect(activated).toHaveBeenCalledTimes(2);
|
||||
userEvent.click(button);
|
||||
await act(async () => { userEvent.click(button); });
|
||||
expect(activated).toHaveBeenCalledTimes(3);
|
||||
expect(button).toHaveFocus();
|
||||
}
|
||||
@@ -85,7 +86,7 @@ test("attachment selection retains files and job ownership, disables activation
|
||||
expect(body.getAll("files")).toEqual(files);
|
||||
const activated = jest.fn();
|
||||
input.addEventListener("click", activated);
|
||||
userEvent.click(uploading);
|
||||
act(() => uploading.click());
|
||||
expect(activated).not.toHaveBeenCalled();
|
||||
finishUpload({ data: {} });
|
||||
await waitFor(() => expect(screen.getByRole("button", { name: "Upload" })).toBeEnabled());
|
||||
|
||||
Reference in New Issue
Block a user