When you change keyboard handling or interactive UI elements, update tests to lock in the user-visible interaction contract—not just internal logic.
Concretely:
<button type="button">) and assert in tests that the correct semantic element is rendered.Example (React Testing Library style):
import { render, fireEvent } from "@testing-library/react";
test("quit keydown does not reach textarea handler", () => {
const onTextareaKeyDown = jest.fn();
const { getByRole } = render(
<textarea onKeyDown={onTextareaKeyDown} />
);
fireEvent.keyDown(window, { key: "q", metaKey: true });
expect(onTextareaKeyDown).not.toHaveBeenCalled();
});
test("images unsupported notice uses a native button", () => {
const { getByTestId } = render(/* component */);
const el = getByTestId("images-unsupported-choose-model");
expect(el.tagName.toLowerCase()).toBe("button");
});
This prevents regressions where keyboard shortcuts or activation behavior subtly breaks inputs or accessibility expectations.