mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
Update status bar and boot up more quickly with actual radio status
This commit is contained in:
@@ -79,6 +79,7 @@ describe('fetchJson (via api methods)', () => {
|
||||
const healthData = {
|
||||
status: 'connected',
|
||||
radio_connected: true,
|
||||
radio_initializing: false,
|
||||
connection_info: 'Serial: /dev/ttyUSB0',
|
||||
database_size_mb: 1.2,
|
||||
oldest_undecrypted_timestamp: null,
|
||||
|
||||
@@ -27,6 +27,7 @@ const mockedApi = vi.mocked(api);
|
||||
const baseHealth: HealthStatus = {
|
||||
status: 'connected',
|
||||
radio_connected: true,
|
||||
radio_initializing: false,
|
||||
connection_info: 'Serial: /dev/ttyUSB0',
|
||||
database_size_mb: 1.2,
|
||||
oldest_undecrypted_timestamp: null,
|
||||
|
||||
@@ -35,6 +35,7 @@ const baseConfig: RadioConfig = {
|
||||
const baseHealth: HealthStatus = {
|
||||
status: 'connected',
|
||||
radio_connected: true,
|
||||
radio_initializing: false,
|
||||
connection_info: 'Serial: /dev/ttyUSB0',
|
||||
database_size_mb: 1.2,
|
||||
oldest_undecrypted_timestamp: null,
|
||||
|
||||
50
frontend/src/test/statusBar.test.tsx
Normal file
50
frontend/src/test/statusBar.test.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { StatusBar } from '../components/StatusBar';
|
||||
import type { HealthStatus } from '../types';
|
||||
|
||||
const baseHealth: HealthStatus = {
|
||||
status: 'degraded',
|
||||
radio_connected: false,
|
||||
radio_initializing: false,
|
||||
connection_info: null,
|
||||
database_size_mb: 1.2,
|
||||
oldest_undecrypted_timestamp: null,
|
||||
fanout_statuses: {},
|
||||
bots_disabled: false,
|
||||
};
|
||||
|
||||
describe('StatusBar', () => {
|
||||
it('shows Radio Initializing while setup is still running', () => {
|
||||
render(
|
||||
<StatusBar
|
||||
health={{ ...baseHealth, radio_connected: true, radio_initializing: true }}
|
||||
config={null}
|
||||
onSettingsClick={vi.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByRole('status', { name: 'Radio Initializing' })).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: 'Reconnect' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows Radio OK when the radio is connected and ready', () => {
|
||||
render(
|
||||
<StatusBar
|
||||
health={{ ...baseHealth, status: 'ok', radio_connected: true }}
|
||||
config={null}
|
||||
onSettingsClick={vi.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByRole('status', { name: 'Radio OK' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows Radio Disconnected when the radio is unavailable', () => {
|
||||
render(<StatusBar health={baseHealth} config={null} onSettingsClick={vi.fn()} />);
|
||||
|
||||
expect(screen.getByRole('status', { name: 'Radio Disconnected' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Reconnect' })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -68,6 +68,7 @@ describe('useWebSocket dispatch', () => {
|
||||
const healthData = {
|
||||
status: 'ok',
|
||||
radio_connected: true,
|
||||
radio_initializing: false,
|
||||
connection_info: 'TCP: 1.2.3.4:4000',
|
||||
database_size_mb: 1.5,
|
||||
oldest_undecrypted_timestamp: null,
|
||||
|
||||
Reference in New Issue
Block a user