mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-27 11:42:52 +00:00
Touch users had no way to reach what Cmd/Ctrl+Enter does: queue when Default send is Steer or Interrupt, send now when it is Queue. Holding the Send button now runs that same action on every platform, with a haptic on native and an accessibility hint naming it. Tapping is unchanged. Both paths go through runAlternateSendAction, which now falls back to the default send when no turn is running, so holding Send while idle still sends and the keyboard path no longer carries its own gate. Co-authored-by: bjspi <43368639+bjspi@users.noreply.github.com>
188 lines
5.2 KiB
TypeScript
188 lines
5.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
resolveSendTooltipLabel,
|
|
resolveSubmitAccessibilityHint,
|
|
resolveSubmitAccessibilityLabel,
|
|
resolveVoiceAccessibilityLabel,
|
|
resolveVoiceTooltipText,
|
|
} from "./labels";
|
|
|
|
const translations: Record<string, string> = {
|
|
"composer.input.interruptAgent": "Interrupt agent",
|
|
"composer.input.queueMessage": "Queue message",
|
|
"composer.input.sendAndInterrupt": "Send and interrupt",
|
|
"composer.input.sendAndSteer": "Send and steer",
|
|
"composer.input.sendMessage": "Send message",
|
|
"composer.input.longPressToQueue": "Long press to queue",
|
|
"composer.input.longPressToSendNow": "Long press to send now",
|
|
"composer.input.queue": "Queue",
|
|
"composer.input.send": "Send",
|
|
"composer.voice.unmuteVoiceMode": "Unmute Voice mode",
|
|
"composer.voice.muteVoiceMode": "Mute Voice mode",
|
|
"composer.voice.stopDictation": "Stop dictation",
|
|
"composer.voice.startDictation": "Start dictation",
|
|
"composer.voice.unmuteVoice": "Unmute voice",
|
|
"composer.voice.muteVoice": "Mute voice",
|
|
"composer.voice.dictation": "Dictation",
|
|
};
|
|
|
|
const t = ((key: string) => translations[key] ?? key) as never;
|
|
|
|
describe("composer input labels", () => {
|
|
it("names the long-press action in the submit hint only when one exists", () => {
|
|
expect(
|
|
resolveSubmitAccessibilityHint({
|
|
canPressLoadingButton: false,
|
|
alternateSendAction: "queue",
|
|
t,
|
|
}),
|
|
).toBe("Long press to queue");
|
|
expect(
|
|
resolveSubmitAccessibilityHint({
|
|
canPressLoadingButton: false,
|
|
alternateSendAction: "send",
|
|
t,
|
|
}),
|
|
).toBe("Long press to send now");
|
|
expect(
|
|
resolveSubmitAccessibilityHint({
|
|
canPressLoadingButton: false,
|
|
alternateSendAction: null,
|
|
t,
|
|
}),
|
|
).toBeUndefined();
|
|
expect(
|
|
resolveSubmitAccessibilityHint({
|
|
canPressLoadingButton: true,
|
|
alternateSendAction: "queue",
|
|
t,
|
|
}),
|
|
).toBeUndefined();
|
|
});
|
|
|
|
it("resolves submit accessibility labels from translations", () => {
|
|
expect(
|
|
resolveSubmitAccessibilityLabel({
|
|
submitButtonAccessibilityLabel: undefined,
|
|
canPressLoadingButton: true,
|
|
defaultActionQueues: false,
|
|
defaultSendBehavior: "interrupt",
|
|
isAgentRunning: true,
|
|
t,
|
|
}),
|
|
).toBe("Interrupt agent");
|
|
expect(
|
|
resolveSubmitAccessibilityLabel({
|
|
submitButtonAccessibilityLabel: undefined,
|
|
canPressLoadingButton: false,
|
|
defaultActionQueues: true,
|
|
defaultSendBehavior: "queue",
|
|
isAgentRunning: true,
|
|
t,
|
|
}),
|
|
).toBe("Queue message");
|
|
expect(
|
|
resolveSubmitAccessibilityLabel({
|
|
submitButtonAccessibilityLabel: undefined,
|
|
canPressLoadingButton: false,
|
|
defaultActionQueues: false,
|
|
defaultSendBehavior: "interrupt",
|
|
isAgentRunning: true,
|
|
t,
|
|
}),
|
|
).toBe("Send and interrupt");
|
|
expect(
|
|
resolveSubmitAccessibilityLabel({
|
|
submitButtonAccessibilityLabel: undefined,
|
|
canPressLoadingButton: false,
|
|
defaultActionQueues: false,
|
|
defaultSendBehavior: "steer",
|
|
isAgentRunning: true,
|
|
t,
|
|
}),
|
|
).toBe("Send and steer");
|
|
expect(
|
|
resolveSubmitAccessibilityLabel({
|
|
submitButtonAccessibilityLabel: undefined,
|
|
canPressLoadingButton: false,
|
|
defaultActionQueues: false,
|
|
defaultSendBehavior: "interrupt",
|
|
isAgentRunning: false,
|
|
t,
|
|
}),
|
|
).toBe("Send message");
|
|
});
|
|
|
|
it("keeps explicit submit labels untouched", () => {
|
|
expect(
|
|
resolveSubmitAccessibilityLabel({
|
|
submitButtonAccessibilityLabel: "Run now",
|
|
canPressLoadingButton: false,
|
|
defaultActionQueues: false,
|
|
defaultSendBehavior: "interrupt",
|
|
isAgentRunning: false,
|
|
t,
|
|
}),
|
|
).toBe("Run now");
|
|
});
|
|
|
|
it("resolves voice labels from translations", () => {
|
|
expect(
|
|
resolveVoiceAccessibilityLabel({
|
|
isRealtimeVoiceForCurrentAgent: true,
|
|
isMuted: true,
|
|
isDictating: false,
|
|
t,
|
|
}),
|
|
).toBe("Unmute Voice mode");
|
|
expect(
|
|
resolveVoiceAccessibilityLabel({
|
|
isRealtimeVoiceForCurrentAgent: true,
|
|
isMuted: false,
|
|
isDictating: false,
|
|
t,
|
|
}),
|
|
).toBe("Mute Voice mode");
|
|
expect(
|
|
resolveVoiceAccessibilityLabel({
|
|
isRealtimeVoiceForCurrentAgent: false,
|
|
isMuted: false,
|
|
isDictating: true,
|
|
t,
|
|
}),
|
|
).toBe("Stop dictation");
|
|
expect(
|
|
resolveVoiceAccessibilityLabel({
|
|
isRealtimeVoiceForCurrentAgent: false,
|
|
isMuted: false,
|
|
isDictating: false,
|
|
t,
|
|
}),
|
|
).toBe("Start dictation");
|
|
});
|
|
|
|
it("resolves tooltip labels from translations", () => {
|
|
expect(
|
|
resolveVoiceTooltipText({
|
|
isRealtimeVoiceForCurrentAgent: false,
|
|
isMuted: false,
|
|
t,
|
|
}),
|
|
).toBe("Dictation");
|
|
expect(
|
|
resolveSendTooltipLabel({
|
|
submitButtonAccessibilityLabel: undefined,
|
|
defaultActionQueues: true,
|
|
t,
|
|
}),
|
|
).toBe("Queue");
|
|
expect(
|
|
resolveSendTooltipLabel({
|
|
submitButtonAccessibilityLabel: undefined,
|
|
defaultActionQueues: false,
|
|
t,
|
|
}),
|
|
).toBe("Send");
|
|
});
|
|
});
|