mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-06 01:42:11 +02:00
Cull a bunch of unused functions
This commit is contained in:
@@ -4,8 +4,14 @@ const BASE_URL = 'http://localhost:8001';
|
||||
const MAX_RETRIES = 10;
|
||||
const RETRY_DELAY_MS = 2000;
|
||||
|
||||
interface HealthStatus {
|
||||
radio_connected: boolean;
|
||||
radio_initializing: boolean;
|
||||
connection_info: string | null;
|
||||
}
|
||||
|
||||
export default async function globalSetup(_config: FullConfig) {
|
||||
// Wait for the backend to be fully ready and radio connected
|
||||
// Wait for the backend to be fully ready and radio setup complete
|
||||
let lastError: Error | null = null;
|
||||
|
||||
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
||||
@@ -14,7 +20,7 @@ export default async function globalSetup(_config: FullConfig) {
|
||||
if (!res.ok) {
|
||||
throw new Error(`Health check returned ${res.status}`);
|
||||
}
|
||||
const health = (await res.json()) as { radio_connected: boolean; connection_info: string | null };
|
||||
const health = (await res.json()) as HealthStatus;
|
||||
|
||||
if (!health.radio_connected) {
|
||||
throw new Error(
|
||||
@@ -22,8 +28,11 @@ export default async function globalSetup(_config: FullConfig) {
|
||||
'Set MESHCORE_SERIAL_PORT if auto-detection fails.'
|
||||
);
|
||||
}
|
||||
if (health.radio_initializing) {
|
||||
throw new Error('Radio connected but still initializing');
|
||||
}
|
||||
|
||||
console.log(`Radio connected on ${health.connection_info}`);
|
||||
console.log(`Radio ready on ${health.connection_info}`);
|
||||
return;
|
||||
} catch (err) {
|
||||
lastError = err instanceof Error ? err : new Error(String(err));
|
||||
|
||||
@@ -21,6 +21,7 @@ async function fetchJson<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
|
||||
export interface HealthStatus {
|
||||
radio_connected: boolean;
|
||||
radio_initializing: boolean;
|
||||
connection_info: string | null;
|
||||
}
|
||||
|
||||
@@ -267,7 +268,7 @@ export async function ensureFlightlessChannel(): Promise<Channel> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for health to show radio_connected, polling with retries.
|
||||
* Wait for health to show a fully ready radio, polling with retries.
|
||||
*/
|
||||
export async function waitForRadioConnected(
|
||||
timeoutMs: number = 30_000,
|
||||
@@ -277,19 +278,13 @@ export async function waitForRadioConnected(
|
||||
while (Date.now() < deadline) {
|
||||
try {
|
||||
const health = await getHealth();
|
||||
if (health.radio_connected) return;
|
||||
if (health.radio_connected && !health.radio_initializing) return;
|
||||
} catch {
|
||||
// Backend might be restarting
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, intervalMs));
|
||||
}
|
||||
throw new Error(`Radio did not reconnect within ${timeoutMs}ms`);
|
||||
}
|
||||
|
||||
// --- Contacts sync ---
|
||||
|
||||
export function syncContacts(): Promise<{ synced: number }> {
|
||||
return fetchJson('/contacts/sync', { method: 'POST' });
|
||||
throw new Error(`Radio did not finish reconnect/setup within ${timeoutMs}ms`);
|
||||
}
|
||||
|
||||
// --- Packets / Historical decryption ---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { syncContacts, getContacts, type Contact } from '../helpers/api';
|
||||
import { getContacts, type Contact } from '../helpers/api';
|
||||
|
||||
/** Escape special regex characters in a string. */
|
||||
function escapeRegex(s: string): string {
|
||||
@@ -12,10 +12,6 @@ function findChatContact(contacts: Contact[]): Contact | undefined {
|
||||
}
|
||||
|
||||
test.describe('Contacts sidebar & info pane', () => {
|
||||
test.beforeAll(async () => {
|
||||
await syncContacts();
|
||||
});
|
||||
|
||||
test('contacts appear in sidebar and clicking opens conversation', async ({ page }) => {
|
||||
const contacts = await getContacts();
|
||||
const named = findChatContact(contacts);
|
||||
|
||||
Reference in New Issue
Block a user