Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: cover extracted local model and video flows (#4905)
[._.]/ Adam Eivy50c1e985b2f8
diff --git a/client/src/components/settings/LocalLlmTab.test.jsx b/client/src/components/settings/LocalLlmTab.test.jsxindex 93e1163e68..f82773b910 100644--- a/client/src/components/settings/LocalLlmTab.test.jsx+++ b/client/src/components/settings/LocalLlmTab.test.jsx@@ -1,6 +1,6 @@import { describe, it, expect, vi, beforeEach } from 'vitest';import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react';-import { MemoryRouter } from 'react-router';+import { MemoryRouter, useLocation } from 'react-router';vi.mock('../../services/api', () => ({getLocalLlmStatus: vi.fn(),@@ -38,7 +38,13 @@ vi.mock('../ui/Toast', () => ({default: Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() }),}));-import { getLocalLlmStatus, getLocalLlmCatalog, patchSettingsSlice, installLocalLlmModel } from '../../services/api';+import {+ deleteLocalLlmModel,+ getLocalLlmStatus,+ getLocalLlmCatalog,+ patchSettingsSlice,+ installLocalLlmModel,+} from '../../services/api';import socket from '../../services/socket';import { LocalLlmTab } from './LocalLlmTab';@@ -46,10 +52,16 @@ import { LocalLlmTab } from './LocalLlmTab';// "hf.co/sja…" on a phone before the row was allowed to wrap.const LONG_ID = 'hf.co/example-org/Example-Long-Model-Name-34B-Instruct-GGUF:Q6_K';+const LocationProbe = () => {+ const location = useLocation();+ return <output data-testid="location">{location.pathname}{location.search}</output>;+};+const renderTab = async () => {render(<MemoryRouter><LocalLlmTab />+ <LocationProbe /></MemoryRouter>,);await waitFor(() => expect(screen.getByText(/Installed on Ollama/)).toBeTruthy());@@ -82,6 +94,7 @@ beforeEach(() => {});getLocalLlmCatalog.mockResolvedValue({ models: [] });patchSettingsSlice.mockResolvedValue({});+ deleteLocalLlmModel.mockResolvedValue({ success: true });});describe('LocalLlmTab backend disable state', () => {@@ -231,6 +244,42 @@ describe('LocalLlmTab installed models', () => {));});+ it('limits comparisons to six models and navigates with those targets', async () => {+ const models = Array.from({ length: 7 }, (_, index) => ({+ id: `example-model-${index + 1}`,+ name: `Example model ${index + 1}`,+ }));+ getLocalLlmStatus.mockResolvedValue({+ backend: 'ollama',+ ollama: { installed: true, available: true, modelCount: models.length, models },+ lmstudio: { installed: false, available: false, modelCount: 0, models: [] },+ });+ const toast = (await import('../ui/Toast')).default;++ await renderTab();+ for (const model of models.slice(0, 6)) {+ fireEvent.click(screen.getByRole('checkbox', { name: `Select ${model.name} for comparison` }));+ }+ fireEvent.click(screen.getByRole('checkbox', { name: `Select ${models[6].name} for comparison` }));+ expect(toast.error).toHaveBeenCalledWith('Compare up to 6 models at once');++ fireEvent.click(screen.getByRole('button', { name: /Compare selected/ }));+ const location = screen.getByTestId('location').textContent;+ expect(location).toMatch(/^\/local-llm\/playground\?/);+ const targets = JSON.parse(new URLSearchParams(location.split('?')[1]).get('targets'));+ expect(targets).toEqual(models.slice(0, 6).map((model) => ({ backend: 'ollama', modelId: model.id })));+ });++ it('requires inline confirmation before deleting an installed model', async () => {+ await renderTab();+ fireEvent.click(screen.getByRole('button', { name: `Delete ${LONG_ID}` }));+ expect(screen.getByText('Delete?')).toBeInTheDocument();+ expect(deleteLocalLlmModel).not.toHaveBeenCalled();++ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));+ await waitFor(() => expect(deleteLocalLlmModel).toHaveBeenCalledWith('ollama', LONG_ID));+ });+it('tags an LM Studio installed model with its quantization so redownload can evict that GGUF', async () => {installLocalLlmModel.mockResolvedValue({ success: true });getLocalLlmStatus.mockResolvedValue({diff --git a/client/src/hooks/useVideoGenSubmitFlow.js b/client/src/hooks/useVideoGenSubmitFlow.jsindex 7787fdfa6c..38fd47c9f1 100644--- a/client/src/hooks/useVideoGenSubmitFlow.js+++ b/client/src/hooks/useVideoGenSubmitFlow.js@@ -1,11 +1,14 @@-import { useCallback } from 'react';+import { useCallback, useRef } from 'react';import { buildVideoGenSubmission, envelopVideoPrompt } from '../lib/videoGenSubmission.js';/** Keeps request shaping behind one focused boundary for every VideoGen lane. */export function useVideoGenSubmitFlow(submissionState) {+ const submissionStateRef = useRef(submissionState);+ submissionStateRef.current = submissionState;+const buildGeneratePayload = useCallback(- () => buildVideoGenSubmission(submissionState),- [submissionState],+ () => buildVideoGenSubmission(submissionStateRef.current),+ [],);return {diff --git a/client/src/hooks/useVideoGenSubmitFlow.test.jsx b/client/src/hooks/useVideoGenSubmitFlow.test.jsxnew file mode 100644index 0000000000..f9c5c2b67b--- /dev/null+++ b/client/src/hooks/useVideoGenSubmitFlow.test.jsx@@ -0,0 +1,34 @@+import { renderHook } from '@testing-library/react';+import { describe, expect, it } from 'vitest';+import { useVideoGenSubmitFlow } from './useVideoGenSubmitFlow.js';++const submissionState = (prompt) => ({+ chainingActive: false,+ chunkPrompts: [],+ currentModel: { runtime: 'mlx_video' },+ disableAudio: false,+ icModeActive: false,+ icReferenceImageFiles: [],+ isGrok: false,+ keyframes: [],+ keyframesActive: false,+ mode: 'text',+ noMusic: false,+ prompt,+ selectedLoras: [],+});++describe('useVideoGenSubmitFlow', () => {+ it('keeps a stable submit callback that reads the latest form snapshot', () => {+ const { result, rerender } = renderHook(+ ({ prompt }) => useVideoGenSubmitFlow(submissionState(prompt)),+ { initialProps: { prompt: 'first prompt' } },+ );+ const build = result.current.buildGeneratePayload;+ expect(build().prompt).toBe('first prompt');++ rerender({ prompt: 'updated prompt' });+ expect(result.current.buildGeneratePayload).toBe(build);+ expect(build().prompt).toBe('updated prompt');+ });+});diff --git a/client/src/hooks/useVideoGenValidation.test.js b/client/src/hooks/useVideoGenValidation.test.jsnew file mode 100644index 0000000000..76ea453aae--- /dev/null+++ b/client/src/hooks/useVideoGenValidation.test.js@@ -0,0 +1,41 @@+import { describe, expect, it } from 'vitest';+import { validateVideoKeyframes } from './useVideoGenValidation.js';++const frame = (index, file = `frame-${index}.png`) => ({ file, index });+const validate = (overrides = {}) => validateVideoKeyframes({+ active: true,+ frames: 33,+ height: 512,+ keyframes: [frame(0), frame(32)],+ maxSafeFrames: 33,+ width: 768,+ ...overrides,+});++describe('validateVideoKeyframes', () => {+ it('requires between two and eight keyframes', () => {+ expect(validate({ keyframes: [frame(0)] })).toBe('Add at least 2 keyframes.');+ expect(validate({ keyframes: Array.from({ length: 9 }, (_, index) => frame(index)) }))+ .toBe('Use at most 8 keyframes.');+ });++ it.each([-1, 1.5])('rejects the invalid frame index %s', (index) => {+ expect(validate({ keyframes: [frame(index), frame(2)] }))+ .toBe('Keyframe 1 needs a frame index ≥ 0.');+ });++ it('rejects indices outside numFrames', () => {+ expect(validate({ frames: 17, keyframes: [frame(0), frame(17)], maxSafeFrames: 17 }))+ .toBe('Keyframe 2 frame 17 must be below numFrames (17).');+ });++ it('rejects indices outside the resolution-dependent pixel budget', () => {+ expect(validate({ keyframes: [frame(0), frame(24)], maxSafeFrames: 17 }))+ .toBe('Keyframe 2 frame 24 exceeds the 768×512 pixel budget (max frame 16). Lower the resolution or raise FFLF_LTX2_PIXEL_BUDGET.');+ });++ it('accepts the upper frame and cardinality boundaries', () => {+ const keyframes = Array.from({ length: 8 }, (_, index) => frame(index * 4));+ expect(validate({ keyframes })).toBeNull();+ });+});