mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-07 09:13:04 +02:00
Tweak send no-response handling
This commit is contained in:
@@ -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.',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user