Tweak send no-response handling

This commit is contained in:
Jack Kingsman
2026-03-15 16:12:17 -07:00
parent 7cb84ea6c7
commit 29368961fc
35 changed files with 134 additions and 65 deletions
+26
View File
@@ -9,12 +9,18 @@ import { render, screen, fireEvent } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { MessageInput } from '../components/MessageInput';
import { toast } from '../components/ui/sonner';
// Mock sonner (toast)
vi.mock('../components/ui/sonner', () => ({
toast: { success: vi.fn(), error: vi.fn() },
}));
const mockToast = toast as unknown as {
success: ReturnType<typeof vi.fn>;
error: ReturnType<typeof vi.fn>;
};
const textEncoder = new TextEncoder();
function byteLen(s: string): number {
@@ -182,4 +188,24 @@ describe('MessageInput', () => {
expect(getSendButton()).toBeEnabled();
});
});
describe('send failure toasts', () => {
it('shows the radio no-response toast when the send outcome is unknown', async () => {
onSend.mockRejectedValueOnce(
new Error(
'Send command was issued to the radio, but no response was heard back. The message may or may not have sent successfully.'
)
);
renderInput({ conversationType: 'contact' });
fireEvent.change(getInput(), { target: { value: 'Hello' } });
fireEvent.click(getSendButton());
expect(await screen.findByDisplayValue('Hello')).toBeTruthy();
expect(mockToast.error).toHaveBeenCalledWith('Radio did not confirm send', {
description:
'Send command was issued to the radio, but no response was heard back. The message may or may not have sent successfully.',
});
});
});
});