|
|
@@ -32,7 +32,7 @@ const mockPrinter = {
|
|
|
};
|
|
|
|
|
|
// Custom render for CameraPage which needs specific route params
|
|
|
-function renderCameraPage(printerId: number) {
|
|
|
+function renderCameraPage(printerId: number, search = '') {
|
|
|
const queryClient = new QueryClient({
|
|
|
defaultOptions: {
|
|
|
queries: { retry: false, gcTime: 0 },
|
|
|
@@ -43,7 +43,7 @@ function renderCameraPage(printerId: number) {
|
|
|
return rtlRender(
|
|
|
<QueryClientProvider client={queryClient}>
|
|
|
<I18nextProvider i18n={i18n}>
|
|
|
- <MemoryRouter initialEntries={[`/cameras/${printerId}`]}>
|
|
|
+ <MemoryRouter initialEntries={[`/cameras/${printerId}${search}`]}>
|
|
|
<ThemeProvider>
|
|
|
<AuthProvider>
|
|
|
<ToastProvider>
|
|
|
@@ -177,6 +177,53 @@ describe('CameraPage', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ describe('fps URL parameter (#1131)', () => {
|
|
|
+ it('defaults to fps=15 when no query parameter is provided', async () => {
|
|
|
+ renderCameraPage(1);
|
|
|
+
|
|
|
+ await waitFor(() => {
|
|
|
+ const src = (document.querySelector('img') as HTMLImageElement | null)?.getAttribute('src') || '';
|
|
|
+ expect(src).toContain('fps=15');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('honors fps query parameter from URL', async () => {
|
|
|
+ renderCameraPage(1, '?fps=5');
|
|
|
+
|
|
|
+ await waitFor(() => {
|
|
|
+ const src = (document.querySelector('img') as HTMLImageElement | null)?.getAttribute('src') || '';
|
|
|
+ expect(src).toContain('fps=5');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('clamps fps above 30 to 30', async () => {
|
|
|
+ renderCameraPage(1, '?fps=60');
|
|
|
+
|
|
|
+ await waitFor(() => {
|
|
|
+ const src = (document.querySelector('img') as HTMLImageElement | null)?.getAttribute('src') || '';
|
|
|
+ expect(src).toContain('fps=30');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('clamps fps below 1 to 1', async () => {
|
|
|
+ renderCameraPage(1, '?fps=0');
|
|
|
+
|
|
|
+ await waitFor(() => {
|
|
|
+ const src = (document.querySelector('img') as HTMLImageElement | null)?.getAttribute('src') || '';
|
|
|
+ expect(src).toContain('fps=1');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('falls back to 15 for non-numeric fps', async () => {
|
|
|
+ renderCameraPage(1, '?fps=invalid');
|
|
|
+
|
|
|
+ await waitFor(() => {
|
|
|
+ const src = (document.querySelector('img') as HTMLImageElement | null)?.getAttribute('src') || '';
|
|
|
+ expect(src).toContain('fps=15');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe('invalid printer', () => {
|
|
|
it('shows invalid printer message for ID 0', async () => {
|
|
|
renderCameraPage(0);
|