mirror of
https://github.com/ruvnet/RuView
synced 2026-08-03 19:21:42 +00:00
d4fb7d30d3
The web UI had persistent 404 errors on model, recording, and training endpoints, and the sensing WebSocket never connected on Dashboard/Live Demo tabs because sensingService.start() was only called lazily on Sensing tab visit. Server (main.rs): - Add 14 fully-functional Axum handlers: model CRUD (7), recording lifecycle (4), training control (3) - Scan data/models/ and data/recordings/ at startup - Recording writes CSI frames to .jsonl via tokio background task - Model load/unload lifecycle with state tracking Web UI (app.js): - Import and start sensingService early in initializeServices() so Dashboard and Live Demo tabs connect to /ws/sensing immediately Mobile (ws.service.ts): - Fix WebSocket URL builder to use same-origin port instead of hardcoded port 3001 Mobile (jest.config.js): - Fix testPathIgnorePatterns that was ignoring the entire test directory Mobile (25 test files): - Replace all it.todo() placeholder tests with real implementations covering components, services, stores, hooks, screens, and utils ADR-043 documents all changes.
99 lines
2.5 KiB
TypeScript
99 lines
2.5 KiB
TypeScript
import React from 'react';
|
|
import { render, screen } from '@testing-library/react-native';
|
|
import { ThemeProvider } from '@/theme/ThemeContext';
|
|
import { usePoseStore } from '@/stores/poseStore';
|
|
|
|
jest.mock('react-native-svg', () => {
|
|
const { View } = require('react-native');
|
|
return {
|
|
__esModule: true,
|
|
default: View,
|
|
Svg: View,
|
|
Circle: View,
|
|
G: View,
|
|
Text: View,
|
|
Rect: View,
|
|
Line: View,
|
|
Path: View,
|
|
};
|
|
});
|
|
|
|
// Mock the subcomponents that may have heavy dependencies
|
|
jest.mock('@/screens/ZonesScreen/FloorPlanSvg', () => {
|
|
const { View } = require('react-native');
|
|
return {
|
|
FloorPlanSvg: (props: any) => require('react').createElement(View, { testID: 'floor-plan', ...props }),
|
|
};
|
|
});
|
|
|
|
jest.mock('@/screens/ZonesScreen/ZoneLegend', () => {
|
|
const { View } = require('react-native');
|
|
return {
|
|
ZoneLegend: () => require('react').createElement(View, { testID: 'zone-legend' }),
|
|
};
|
|
});
|
|
|
|
jest.mock('@/screens/ZonesScreen/useOccupancyGrid', () => ({
|
|
useOccupancyGrid: () => ({
|
|
gridValues: new Array(400).fill(0),
|
|
personPositions: [],
|
|
}),
|
|
}));
|
|
|
|
describe('ZonesScreen', () => {
|
|
beforeEach(() => {
|
|
usePoseStore.getState().reset();
|
|
});
|
|
|
|
it('module exports ZonesScreen component', () => {
|
|
const mod = require('@/screens/ZonesScreen');
|
|
expect(mod.ZonesScreen).toBeDefined();
|
|
expect(typeof mod.ZonesScreen).toBe('function');
|
|
});
|
|
|
|
it('default export is also available', () => {
|
|
const mod = require('@/screens/ZonesScreen');
|
|
expect(mod.default).toBeDefined();
|
|
});
|
|
|
|
it('renders without crashing', () => {
|
|
const { ZonesScreen } = require('@/screens/ZonesScreen');
|
|
const { toJSON } = render(
|
|
<ThemeProvider>
|
|
<ZonesScreen />
|
|
</ThemeProvider>,
|
|
);
|
|
expect(toJSON()).not.toBeNull();
|
|
});
|
|
|
|
it('renders the floor plan heading', () => {
|
|
const { ZonesScreen } = require('@/screens/ZonesScreen');
|
|
render(
|
|
<ThemeProvider>
|
|
<ZonesScreen />
|
|
</ThemeProvider>,
|
|
);
|
|
expect(screen.getByText(/Floor Plan/)).toBeTruthy();
|
|
});
|
|
|
|
it('renders occupancy count', () => {
|
|
const { ZonesScreen } = require('@/screens/ZonesScreen');
|
|
render(
|
|
<ThemeProvider>
|
|
<ZonesScreen />
|
|
</ThemeProvider>,
|
|
);
|
|
expect(screen.getByText(/0 persons detected/)).toBeTruthy();
|
|
});
|
|
|
|
it('renders last update text', () => {
|
|
const { ZonesScreen } = require('@/screens/ZonesScreen');
|
|
render(
|
|
<ThemeProvider>
|
|
<ZonesScreen />
|
|
</ThemeProvider>,
|
|
);
|
|
expect(screen.getByText(/Last update: N\/A/)).toBeTruthy();
|
|
});
|
|
});
|