Some checks failed
Release / Bump version and tag (push) Successful in 4s
Sidecar Release / Bump sidecar version and tag (push) Failing after 3s
Tests / Python Backend Tests (push) Failing after 3s
Tests / Frontend Tests (push) Successful in 8s
Tests / Rust Sidecar Tests (push) Successful in 3m10s
Test suite covering all three layers: Python backend (25 tests): - AppController: state machine, start/stop, callbacks, settings reload - API server: REST endpoints, config CRUD, status, devices - Config: dot-notation get/set, persistence, nested paths - Main headless: ready event port format validation Svelte frontend (14 tests via Vitest): - Backend store: exported properties/methods, port derivation, URLs - Config store: method names (fetchConfig not loadConfig), defaults - Transcriptions store: add/clear/plaintext - File extension regression: ensures $state runes only in .svelte.ts Rust sidecar (24 tests via cargo test): - Platform/arch detection, asset name construction - Ready event deserialization (with extra fields tolerance) - Path construction, version read/write, old version cleanup - Zip extraction, SidecarManager lifecycle CI workflow (.gitea/workflows/test.yml): - Runs on push to main and PRs - Three parallel jobs: Python, Frontend, Rust Also fixes three bugs found during test planning: - Settings: /api/check-updates -> GET /api/check-update - Settings: /api/remote/login -> /api/login - Settings: /api/remote/register -> /api/register Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
78 lines
2.6 KiB
TypeScript
78 lines
2.6 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { backendStore } from "./backend.svelte.ts";
|
|
|
|
// Mock WebSocket globally so the store module can reference it
|
|
class MockWebSocket {
|
|
onopen: ((ev: Event) => void) | null = null;
|
|
onclose: ((ev: CloseEvent) => void) | null = null;
|
|
onmessage: ((ev: MessageEvent) => void) | null = null;
|
|
onerror: ((ev: Event) => void) | null = null;
|
|
close = vi.fn();
|
|
}
|
|
vi.stubGlobal("WebSocket", MockWebSocket);
|
|
|
|
// Mock fetch to prevent real network calls
|
|
vi.stubGlobal(
|
|
"fetch",
|
|
vi.fn(() =>
|
|
Promise.resolve({
|
|
ok: true,
|
|
json: () => Promise.resolve({}),
|
|
})
|
|
)
|
|
);
|
|
|
|
describe("backend store", () => {
|
|
beforeEach(() => {
|
|
backendStore.disconnect();
|
|
backendStore.setPort(8081);
|
|
});
|
|
|
|
it("test_exports_expected_properties", () => {
|
|
expect(backendStore).toHaveProperty("port");
|
|
expect(backendStore).toHaveProperty("connectionState");
|
|
expect(backendStore).toHaveProperty("connected");
|
|
expect(backendStore).toHaveProperty("appState");
|
|
expect(backendStore).toHaveProperty("stateMessage");
|
|
expect(backendStore).toHaveProperty("deviceInfo");
|
|
expect(backendStore).toHaveProperty("version");
|
|
expect(backendStore).toHaveProperty("lastError");
|
|
expect(backendStore).toHaveProperty("apiBaseUrl");
|
|
expect(backendStore).toHaveProperty("wsUrl");
|
|
expect(backendStore).toHaveProperty("obsUrl");
|
|
expect(backendStore).toHaveProperty("syncUrl");
|
|
});
|
|
|
|
it("test_exports_expected_methods", () => {
|
|
expect(typeof backendStore.setPort).toBe("function");
|
|
expect(typeof backendStore.connect).toBe("function");
|
|
expect(typeof backendStore.disconnect).toBe("function");
|
|
expect(typeof backendStore.apiUrl).toBe("function");
|
|
expect(typeof backendStore.apiFetch).toBe("function");
|
|
expect(typeof backendStore.apiGet).toBe("function");
|
|
expect(typeof backendStore.apiPost).toBe("function");
|
|
expect(typeof backendStore.apiPut).toBe("function");
|
|
});
|
|
|
|
it("test_obsUrl_derives_from_port", () => {
|
|
backendStore.setPort(8081);
|
|
expect(backendStore.obsUrl).toBe("http://localhost:8080");
|
|
});
|
|
|
|
it("test_apiBaseUrl_uses_port", () => {
|
|
backendStore.setPort(8081);
|
|
expect(backendStore.apiBaseUrl).toBe("http://localhost:8081");
|
|
});
|
|
|
|
it("test_wsUrl_uses_port", () => {
|
|
backendStore.setPort(8081);
|
|
expect(backendStore.wsUrl).toBe("ws://localhost:8081/ws/control");
|
|
});
|
|
|
|
it("test_initial_state", () => {
|
|
// After disconnect() in beforeEach, state should be disconnected
|
|
expect(backendStore.connectionState).toBe("disconnected");
|
|
expect(backendStore.appState).toBe("initializing");
|
|
});
|
|
});
|