Files
TuxDMX-WebUI/frontend/tests/App.test.tsx
T
thomas 1f110866f5
CI / backend (pull_request) Canceled after 0s
CI / shell (pull_request) Canceled after 0s
CI / frontend (pull_request) Canceled after 0s
CI / arm64-smoke (pull_request) Canceled after 0s
CI / backend (push) Canceled after 0s
CI / shell (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / arm64-smoke (push) Canceled after 0s
Update docs and screenshots
2026-07-25 10:26:29 +02:00

124 lines
3.5 KiB
TypeScript

import { render, screen } from "@testing-library/react";
import { test, vi } from "vitest";
import App from "../src/App";
vi.stubGlobal(
"fetch",
vi.fn((url: string) => {
let payload: Record<string, unknown> = { items: [] };
if (url.includes("/system/status")) {
payload = {
app: "TuxDMX",
setup_required: false,
engine: {
backend: "simulator",
connected: true,
degraded: false,
last_error: null,
blackout: false,
fps: 30,
master: 255,
frame: Array.from({ length: 512 }, () => 0),
source_map: Array.from({ length: 512 }, () => "idle")
},
telemetry: {
uptime_seconds: 10,
cpu_percent: 20,
ram_percent: 30,
temperature_c: null,
queue_depth: 0,
reconnect_count: 0,
last_error: null,
events: []
},
bpm: {
mode: "manual",
bpm: 120,
confidence: 1,
devices: [],
device_details: [],
current_device: "alsa:auto",
selected_device: "alsa:auto",
recommended_device: "alsa:auto",
audio_connected: false,
last_error: null,
input_level: 0,
peak_level: 0,
clipping: false,
sample_rate: 44100,
channels: 1,
format: "S16_LE"
}
};
} else if (url.includes("/dmx/config")) {
payload = {
backend: "simulator",
universe: 1,
output_port: "simulator",
target_host: "",
artnet_nodes: []
};
} else if (url.includes("/dmx/devices")) {
payload = {
devices: [
{
name: "Simulator universe 1",
backend: "simulator",
connected: true,
output_port: "simulator",
universe: 1
}
]
};
} else if (url.includes("/integrations/home-assistant/config")) {
payload = {
enabled: false,
base_url: "",
default_universe: 10,
has_token: false,
token_mask: "",
mapping_count: 0,
dispatch_count: 0,
error_count: 0,
last_error: null,
last_successful_call_at: null,
last_connection_success_at: null,
last_connection_error: null,
ha_version: null,
auth_ok: false,
reachable: false
};
} else if (url.includes("/integrations/home-assistant/mappings")) {
payload = { items: [] };
} else if (url.includes("/integrations/midi/bridges")) {
payload = { items: [] };
} else if (url.includes("/integrations/midi/mappings")) {
payload = { items: [] };
} else if (url.includes("/integrations/midi/tokens")) {
payload = { items: [] };
} else if (url.includes("/integrations/midi/learn")) {
payload = { active: false, allow_passthrough: false, expires_at: null, captured_event: null };
} else if (url.includes("/bpm/devices")) {
payload = { devices: [] };
}
return Promise.resolve({
ok: true,
json: () => Promise.resolve(payload)
});
})
);
class MockWebSocket {
onmessage: ((event: { data: string }) => void) | null = null;
close() {}
}
vi.stubGlobal("WebSocket", MockWebSocket);
test("viser dashboard shell", async () => {
render(<App />);
expect(await screen.findByText("TuxDMX")).toBeInTheDocument();
expect(await screen.findByText("Operations-dashboard")).toBeInTheDocument();
});