fix: focusable element when webcam expanded with no devices, add error test
- LaunchWindow: render sr-only <select> when webcamExpanded but cameraDevices.length === 0 (loading/error/empty), so keyboard users always have a focusable element even in no-camera states - useCameraDevices.test: add error-branch test asserting error message, empty devices array and isLoading=false when enumerateDevices rejects
This commit is contained in:
@@ -365,7 +365,7 @@ export function LaunchWindow() {
|
||||
/>
|
||||
</>
|
||||
))}
|
||||
{!webcamExpanded && (
|
||||
{(!webcamExpanded || cameraDevices.length === 0) && (
|
||||
<select
|
||||
value={webcamDeviceId || selectedCameraId}
|
||||
onChange={(e) => {
|
||||
|
||||
@@ -71,6 +71,19 @@ describe("useCameraDevices", () => {
|
||||
expect(mockGetUserMedia).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should set error state when enumeration fails", async () => {
|
||||
mockEnumerateDevices.mockRejectedValueOnce(new Error("Permission denied"));
|
||||
|
||||
const { result } = renderHook(() => useCameraDevices(true));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toBe("Permission denied");
|
||||
});
|
||||
|
||||
expect(result.current.devices).toHaveLength(0);
|
||||
expect(result.current.isLoading).toBe(false);
|
||||
});
|
||||
|
||||
it("should fall back to first available device when selected device is unplugged", async () => {
|
||||
const { result } = renderHook(() => useCameraDevices(true));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user