fix(webui): detect Chrome voice recording support (#5027)
This commit is contained in:
@@ -439,6 +439,49 @@ describe("ThreadComposer", () => {
|
||||
await waitFor(() => expect(screen.getByLabelText("Message input")).toHaveValue("one recording"));
|
||||
});
|
||||
|
||||
it("distinguishes a missing microphone from a blocked permission", async () => {
|
||||
const { getUserMedia } = mockVoiceRecorder();
|
||||
getUserMedia.mockRejectedValue(Object.assign(new Error("no microphone"), {
|
||||
name: "NotFoundError",
|
||||
}));
|
||||
render(
|
||||
<ThreadComposer
|
||||
onSend={vi.fn()}
|
||||
onTranscribeAudio={vi.fn(async () => "unused")}
|
||||
placeholder="Type your message..."
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Voice input" }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("No microphone was found. Connect a microphone and try again.")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("clears a previous voice error when retrying microphone access", async () => {
|
||||
const { getUserMedia } = mockVoiceRecorder();
|
||||
getUserMedia.mockRejectedValueOnce(new Error("permission denied"));
|
||||
const onTranscribeAudio = vi.fn(async () => "voice retry");
|
||||
render(
|
||||
<ThreadComposer
|
||||
onSend={vi.fn()}
|
||||
onTranscribeAudio={onTranscribeAudio}
|
||||
placeholder="Type your message..."
|
||||
/>,
|
||||
);
|
||||
|
||||
const voiceButton = screen.getByRole("button", { name: "Voice input" });
|
||||
fireEvent.click(voiceButton);
|
||||
await waitFor(() => expect(screen.getByText("Allow microphone access in the address bar, then retry.")).toBeInTheDocument());
|
||||
|
||||
fireEvent.click(voiceButton);
|
||||
|
||||
await waitFor(() => expect(screen.queryByText("Allow microphone access in the address bar, then retry.")).not.toBeInTheDocument());
|
||||
expect(await screen.findByLabelText("Recording 0:00")).toBeInTheDocument();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Stop recording" }));
|
||||
});
|
||||
|
||||
it("supports press-and-hold voice recording", async () => {
|
||||
mockVoiceRecorder();
|
||||
const onSend = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user