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(lib): add coverage for 5 untested validation/util modules
Adam Eivyd437a6b4ba05
diff --git a/server/lib/genomeValidation.test.js b/server/lib/genomeValidation.test.jsnew file mode 100644index 0000000000..2420e9a6d5--- /dev/null+++ b/server/lib/genomeValidation.test.js@@ -0,0 +1,208 @@+import { describe, it, expect } from 'vitest';+import {+ genomeUploadSchema,+ genomeSearchSchema,+ genomeSaveMarkerSchema,+ genomeUpdateNotesSchema,+ epigeneticAddInterventionSchema,+ epigeneticLogEntrySchema,+ epigeneticUpdateInterventionSchema+} from './genomeValidation.js';++describe('genomeValidation', () => {+ describe('genomeUploadSchema', () => {+ it('accepts content of at least 100 chars and a filename', () => {+ const r = genomeUploadSchema.safeParse({+ content: 'a'.repeat(100),+ filename: 'genome.txt'+ });+ expect(r.success).toBe(true);+ });++ it('rejects content under the 100-char minimum', () => {+ const r = genomeUploadSchema.safeParse({+ content: 'short',+ filename: 'g.txt'+ });+ expect(r.success).toBe(false);+ });++ it('rejects empty filename', () => {+ const r = genomeUploadSchema.safeParse({+ content: 'a'.repeat(200),+ filename: ''+ });+ expect(r.success).toBe(false);+ });+ });++ describe('genomeSearchSchema', () => {+ it('accepts a well-formed rsid', () => {+ expect(genomeSearchSchema.safeParse({ rsid: 'rs1234' }).success).toBe(true);+ expect(genomeSearchSchema.safeParse({ rsid: 'rs7412' }).success).toBe(true);+ });++ it('rejects non-rsid strings', () => {+ expect(genomeSearchSchema.safeParse({ rsid: '1234' }).success).toBe(false);+ expect(genomeSearchSchema.safeParse({ rsid: 'snp1234' }).success).toBe(false);+ expect(genomeSearchSchema.safeParse({ rsid: 'rs' }).success).toBe(false);+ expect(genomeSearchSchema.safeParse({ rsid: 'rsABC' }).success).toBe(false);+ });+ });++ describe('genomeSaveMarkerSchema', () => {+ it('accepts a minimal marker with required fields', () => {+ const r = genomeSaveMarkerSchema.safeParse({+ rsid: 'rs1234',+ name: 'Test Marker',+ category: 'metabolism'+ });+ expect(r.success).toBe(true);+ // optional fields should default to safe values+ expect(r.data.gene).toBe('');+ expect(r.data.description).toBe('');+ expect(r.data.implications).toBe('');+ expect(r.data.status).toBe('typical');+ expect(r.data.notes).toBe('');+ expect(r.data.references).toEqual([]);+ });++ it('accepts a fully-populated marker', () => {+ const r = genomeSaveMarkerSchema.safeParse({+ rsid: 'rs429358',+ genotype: 'CT',+ chromosome: '19',+ position: '45411941',+ name: 'APOE',+ category: 'longevity',+ gene: 'APOE',+ description: 'Apolipoprotein E variant',+ implications: 'Cardio risk',+ status: 'concern',+ notes: 'Follow up annually',+ references: ['https://snpedia.com/index.php/Rs429358']+ });+ expect(r.success).toBe(true);+ expect(r.data.status).toBe('concern');+ });++ it('rejects unknown status values', () => {+ const r = genomeSaveMarkerSchema.safeParse({+ rsid: 'rs1',+ name: 'X',+ category: 'c',+ status: 'unknown_status'+ });+ expect(r.success).toBe(false);+ });++ it('rejects non-URL references', () => {+ const r = genomeSaveMarkerSchema.safeParse({+ rsid: 'rs1',+ name: 'X',+ category: 'c',+ references: ['not-a-url']+ });+ expect(r.success).toBe(false);+ });++ it('rejects rsid that does not match the pattern', () => {+ const r = genomeSaveMarkerSchema.safeParse({+ rsid: 'foo',+ name: 'X',+ category: 'c'+ });+ expect(r.success).toBe(false);+ });+ });++ describe('genomeUpdateNotesSchema', () => {+ it('accepts notes within length cap', () => {+ expect(genomeUpdateNotesSchema.safeParse({ notes: '' }).success).toBe(true);+ expect(genomeUpdateNotesSchema.safeParse({ notes: 'hi' }).success).toBe(true);+ });++ it('rejects notes above 5000 chars', () => {+ expect(genomeUpdateNotesSchema.safeParse({ notes: 'x'.repeat(5001) }).success).toBe(false);+ });+ });++ describe('epigeneticAddInterventionSchema', () => {+ it('accepts the minimum input and applies defaults', () => {+ const r = epigeneticAddInterventionSchema.safeParse({ name: 'Vitamin D' });+ expect(r.success).toBe(true);+ expect(r.data.category).toBe('custom');+ expect(r.data.frequency).toBe('daily');+ expect(r.data.trackingUnit).toBe('dose');+ expect(r.data.dosage).toBe('');+ expect(r.data.notes).toBe('');+ });++ it('accepts known categories and frequencies', () => {+ expect(epigeneticAddInterventionSchema.safeParse({+ name: 'Run', category: 'lifestyle', frequency: 'weekly'+ }).success).toBe(true);+ expect(epigeneticAddInterventionSchema.safeParse({+ name: 'Magnesium', category: 'supplement', frequency: 'as_needed'+ }).success).toBe(true);+ });++ it('rejects unknown category', () => {+ const r = epigeneticAddInterventionSchema.safeParse({+ name: 'X', category: 'mystery'+ });+ expect(r.success).toBe(false);+ });++ it('rejects unknown frequency', () => {+ const r = epigeneticAddInterventionSchema.safeParse({+ name: 'X', frequency: 'monthly'+ });+ expect(r.success).toBe(false);+ });++ it('rejects empty name', () => {+ expect(epigeneticAddInterventionSchema.safeParse({ name: '' }).success).toBe(false);+ });+ });++ describe('epigeneticLogEntrySchema', () => {+ it('accepts a positive amount with no date (date is optional)', () => {+ const r = epigeneticLogEntrySchema.safeParse({ amount: 1 });+ expect(r.success).toBe(true);+ expect(r.data.notes).toBe('');+ });++ it('accepts amount 0', () => {+ expect(epigeneticLogEntrySchema.safeParse({ amount: 0 }).success).toBe(true);+ });++ it('rejects negative amount', () => {+ expect(epigeneticLogEntrySchema.safeParse({ amount: -1 }).success).toBe(false);+ });++ it('accepts a YYYY-MM-DD date', () => {+ expect(epigeneticLogEntrySchema.safeParse({ amount: 1, date: '2026-05-03' }).success).toBe(true);+ });++ it('rejects malformed dates', () => {+ expect(epigeneticLogEntrySchema.safeParse({ amount: 1, date: '5/3/2026' }).success).toBe(false);+ expect(epigeneticLogEntrySchema.safeParse({ amount: 1, date: '2026-5-3' }).success).toBe(false);+ });+ });++ describe('epigeneticUpdateInterventionSchema', () => {+ it('accepts an empty object (all fields optional)', () => {+ expect(epigeneticUpdateInterventionSchema.safeParse({}).success).toBe(true);+ });++ it('accepts a partial update', () => {+ expect(epigeneticUpdateInterventionSchema.safeParse({ active: false }).success).toBe(true);+ expect(epigeneticUpdateInterventionSchema.safeParse({ name: 'New Name' }).success).toBe(true);+ });++ it('rejects invalid frequency value', () => {+ expect(epigeneticUpdateInterventionSchema.safeParse({ frequency: 'monthly' }).success).toBe(false);+ });+ });+});diff --git a/server/lib/httpsState.test.js b/server/lib/httpsState.test.jsnew file mode 100644index 0000000000..459582219c--- /dev/null+++ b/server/lib/httpsState.test.js@@ -0,0 +1,48 @@+import { describe, it, expect, beforeEach } from 'vitest';+import { setHttpsEnabledAtBoot, getHttpsEnabledAtBoot } from './httpsState.js';++describe('httpsState', () => {+ // Module state is shared — reset to a known starting point for each case.+ beforeEach(() => {+ setHttpsEnabledAtBoot(false);+ });++ it('reports the current value after being set true', () => {+ setHttpsEnabledAtBoot(true);+ const state = getHttpsEnabledAtBoot();+ expect(state.value).toBe(true);+ expect(state.initialized).toBe(true);+ });++ it('reports the current value after being set false', () => {+ setHttpsEnabledAtBoot(false);+ const state = getHttpsEnabledAtBoot();+ expect(state.value).toBe(false);+ expect(state.initialized).toBe(true);+ });++ it('coerces truthy non-boolean inputs to true', () => {+ setHttpsEnabledAtBoot('yes');+ expect(getHttpsEnabledAtBoot().value).toBe(true);++ setHttpsEnabledAtBoot(1);+ expect(getHttpsEnabledAtBoot().value).toBe(true);+ });++ it('coerces falsy non-boolean inputs to false', () => {+ setHttpsEnabledAtBoot(true); // start true so we can verify the flip+ setHttpsEnabledAtBoot(0);+ expect(getHttpsEnabledAtBoot().value).toBe(false);++ setHttpsEnabledAtBoot(true);+ setHttpsEnabledAtBoot(null);+ expect(getHttpsEnabledAtBoot().value).toBe(false);+ });++ it('marks initialized as true after any setHttpsEnabledAtBoot call', () => {+ // Note: by the time this test runs, beforeEach has already called the+ // setter at least once, so `initialized` is observably true here.+ setHttpsEnabledAtBoot(false);+ expect(getHttpsEnabledAtBoot().initialized).toBe(true);+ });+});diff --git a/server/lib/notesValidation.test.js b/server/lib/notesValidation.test.jsnew file mode 100644index 0000000000..ac58e1a80a--- /dev/null+++ b/server/lib/notesValidation.test.js@@ -0,0 +1,159 @@+import { describe, it, expect } from 'vitest';+import {+ vaultInputSchema,+ vaultUpdateSchema,+ notePathSchema,+ createNoteSchema,+ updateNoteSchema,+ searchQuerySchema,+ scanQuerySchema+} from './notesValidation.js';++describe('notesValidation', () => {+ describe('notePathSchema (safeRelativePath)', () => {+ it('accepts a simple forward-slash relative path', () => {+ expect(notePathSchema.safeParse({ path: 'folder/file.md' }).success).toBe(true);+ });++ it('accepts a single filename', () => {+ expect(notePathSchema.safeParse({ path: 'file.md' }).success).toBe(true);+ });++ it('accepts filenames containing dots that are not traversal segments', () => {+ // `notes..md` is a single segment, not a `..` segment; it must be allowed.+ expect(notePathSchema.safeParse({ path: 'notes..md' }).success).toBe(true);+ expect(notePathSchema.safeParse({ path: 'v1..v2.md' }).success).toBe(true);+ expect(notePathSchema.safeParse({ path: 'folder/notes..md' }).success).toBe(true);+ });++ it('rejects parent-directory traversal segments', () => {+ expect(notePathSchema.safeParse({ path: '../secret' }).success).toBe(false);+ expect(notePathSchema.safeParse({ path: 'folder/../secret' }).success).toBe(false);+ expect(notePathSchema.safeParse({ path: '..' }).success).toBe(false);+ });++ it('rejects current-directory segments', () => {+ expect(notePathSchema.safeParse({ path: './file.md' }).success).toBe(false);+ expect(notePathSchema.safeParse({ path: 'folder/./file.md' }).success).toBe(false);+ });++ it('rejects posix absolute paths', () => {+ expect(notePathSchema.safeParse({ path: '/etc/passwd' }).success).toBe(false);+ });++ it('rejects backslashes (UNC and Windows separators)', () => {+ expect(notePathSchema.safeParse({ path: 'folder\\file.md' }).success).toBe(false);+ expect(notePathSchema.safeParse({ path: '\\\\host\\share' }).success).toBe(false);+ });++ it('rejects Windows drive-letter prefixes', () => {+ expect(notePathSchema.safeParse({ path: 'C:/Users' }).success).toBe(false);+ expect(notePathSchema.safeParse({ path: 'd:foo' }).success).toBe(false);+ });++ it('rejects empty paths', () => {+ expect(notePathSchema.safeParse({ path: '' }).success).toBe(false);+ });++ it('rejects paths longer than 1000 characters', () => {+ const tooLong = 'a'.repeat(1001);+ expect(notePathSchema.safeParse({ path: tooLong }).success).toBe(false);+ });+ });++ describe('vaultInputSchema', () => {+ it('accepts path alone (name optional)', () => {+ expect(vaultInputSchema.safeParse({ path: '/Users/me/Notes' }).success).toBe(true);+ });++ it('accepts path + name', () => {+ const r = vaultInputSchema.safeParse({ path: '/x', name: 'Personal' });+ expect(r.success).toBe(true);+ });++ it('rejects missing path', () => {+ expect(vaultInputSchema.safeParse({ name: 'Personal' }).success).toBe(false);+ });++ it('vaultUpdateSchema accepts an empty object', () => {+ expect(vaultUpdateSchema.safeParse({}).success).toBe(true);+ });+ });++ describe('createNoteSchema', () => {+ it('defaults content to an empty string', () => {+ const r = createNoteSchema.safeParse({ path: 'a/b.md' });+ expect(r.success).toBe(true);+ expect(r.data.content).toBe('');+ });++ it('accepts explicit content', () => {+ const r = createNoteSchema.safeParse({ path: 'a/b.md', content: '# Hello' });+ expect(r.success).toBe(true);+ expect(r.data.content).toBe('# Hello');+ });++ it('rejects content above the 500000 char cap', () => {+ const huge = 'x'.repeat(500001);+ expect(createNoteSchema.safeParse({ path: 'a.md', content: huge }).success).toBe(false);+ });++ it('inherits safeRelativePath rules on the path field', () => {+ expect(createNoteSchema.safeParse({ path: '../escape', content: '' }).success).toBe(false);+ });+ });++ describe('updateNoteSchema', () => {+ it('requires a content string', () => {+ expect(updateNoteSchema.safeParse({}).success).toBe(false);+ expect(updateNoteSchema.safeParse({ content: '' }).success).toBe(true);+ expect(updateNoteSchema.safeParse({ content: 'updated' }).success).toBe(true);+ });+ });++ describe('searchQuerySchema', () => {+ it('defaults limit to 50', () => {+ const r = searchQuerySchema.safeParse({ q: 'hello' });+ expect(r.success).toBe(true);+ expect(r.data.limit).toBe(50);+ });++ it('coerces a numeric string to a number', () => {+ const r = searchQuerySchema.safeParse({ q: 'hello', limit: '25' });+ expect(r.success).toBe(true);+ expect(r.data.limit).toBe(25);+ });++ it('rejects empty query strings', () => {+ expect(searchQuerySchema.safeParse({ q: '' }).success).toBe(false);+ });++ it('rejects limit above the 200 cap', () => {+ expect(searchQuerySchema.safeParse({ q: 'x', limit: 999 }).success).toBe(false);+ });+ });++ describe('scanQuerySchema', () => {+ it('applies sane defaults', () => {+ const r = scanQuerySchema.safeParse({});+ expect(r.success).toBe(true);+ expect(r.data.limit).toBe(500);+ expect(r.data.offset).toBe(0);+ });++ it('coerces numeric strings to numbers', () => {+ const r = scanQuerySchema.safeParse({ limit: '100', offset: '20' });+ expect(r.success).toBe(true);+ expect(r.data.limit).toBe(100);+ expect(r.data.offset).toBe(20);+ });++ it('rejects negative offset', () => {+ expect(scanQuerySchema.safeParse({ offset: -1 }).success).toBe(false);+ });++ it('rejects limit above the 1000 cap', () => {+ expect(scanQuerySchema.safeParse({ limit: 1001 }).success).toBe(false);+ });+ });+});diff --git a/server/lib/peerUrl.test.js b/server/lib/peerUrl.test.jsnew file mode 100644index 0000000000..ddcdb9eb95--- /dev/null+++ b/server/lib/peerUrl.test.js@@ -0,0 +1,24 @@+import { describe, it, expect } from 'vitest';+import { peerBaseUrl } from './peerUrl.js';++describe('peerBaseUrl', () => {+ it('builds an https URL when peer.host is present', () => {+ expect(peerBaseUrl({ host: 'box.tail-net.ts.net', port: 5555 }))+ .toBe('https://box.tail-net.ts.net:5555');+ });++ it('falls back to http with peer.address when host is absent', () => {+ expect(peerBaseUrl({ address: '100.64.0.1', port: 5555 }))+ .toBe('http://100.64.0.1:5555');+ });++ it('prefers host over address when both are set', () => {+ expect(peerBaseUrl({ host: 'box.example', address: '10.0.0.1', port: 80 }))+ .toBe('https://box.example:80');+ });++ it('uses http when host is empty string (falsy)', () => {+ expect(peerBaseUrl({ host: '', address: '10.0.0.2', port: 5555 }))+ .toBe('http://10.0.0.2:5555');+ });+});diff --git a/server/lib/socketValidation.test.js b/server/lib/socketValidation.test.jsnew file mode 100644index 0000000000..8330d9477a--- /dev/null+++ b/server/lib/socketValidation.test.js@@ -0,0 +1,205 @@+import { describe, it, expect, vi } from 'vitest';+import {+ detectStartSchema,+ standardizeStartSchema,+ logsSubscribeSchema,+ errorRecoverSchema,+ shellInputSchema,+ shellResizeSchema,+ shellSessionIdSchema,+ shellStopSchema,+ appUpdateSchema,+ appStandardizeSchema,+ appDeploySchema,+ validateSocketData+} from './socketValidation.js';++describe('socketValidation schemas', () => {+ describe('detectStartSchema', () => {+ it('accepts a non-empty path', () => {+ expect(detectStartSchema.safeParse({ path: '/repos/foo' }).success).toBe(true);+ });++ it('rejects an empty or missing path', () => {+ expect(detectStartSchema.safeParse({ path: '' }).success).toBe(false);+ expect(detectStartSchema.safeParse({}).success).toBe(false);+ });+ });++ describe('standardizeStartSchema', () => {+ it('accepts repoPath alone', () => {+ expect(standardizeStartSchema.safeParse({ repoPath: '/x' }).success).toBe(true);+ });++ it('accepts repoPath with optional providerId', () => {+ const result = standardizeStartSchema.safeParse({ repoPath: '/x', providerId: 'openai' });+ expect(result.success).toBe(true);+ });++ it('rejects empty repoPath', () => {+ expect(standardizeStartSchema.safeParse({ repoPath: '' }).success).toBe(false);+ });++ it('rejects empty providerId when supplied', () => {+ expect(standardizeStartSchema.safeParse({ repoPath: '/x', providerId: '' }).success).toBe(false);+ });+ });++ describe('logsSubscribeSchema', () => {+ it('defaults lines to 100 when only processName is supplied', () => {+ const result = logsSubscribeSchema.safeParse({ processName: 'portos' });+ expect(result.success).toBe(true);+ expect(result.data.lines).toBe(100);+ });++ it('accepts a custom positive integer for lines', () => {+ const result = logsSubscribeSchema.safeParse({ processName: 'portos', lines: 250 });+ expect(result.success).toBe(true);+ expect(result.data.lines).toBe(250);+ });++ it('rejects lines above the 10000 cap', () => {+ expect(logsSubscribeSchema.safeParse({ processName: 'p', lines: 99999 }).success).toBe(false);+ });++ it('rejects non-integer or non-positive lines', () => {+ expect(logsSubscribeSchema.safeParse({ processName: 'p', lines: 0 }).success).toBe(false);+ expect(logsSubscribeSchema.safeParse({ processName: 'p', lines: -1 }).success).toBe(false);+ expect(logsSubscribeSchema.safeParse({ processName: 'p', lines: 1.5 }).success).toBe(false);+ });+ });++ describe('errorRecoverSchema', () => {+ it('accepts a code with default empty context', () => {+ const result = errorRecoverSchema.safeParse({ code: 'E_FOO' });+ expect(result.success).toBe(true);+ expect(result.data.context).toEqual({});+ });++ it('accepts an arbitrary record context', () => {+ const result = errorRecoverSchema.safeParse({ code: 'E_FOO', context: { extra: 1, msg: 'x' } });+ expect(result.success).toBe(true);+ expect(result.data.context).toEqual({ extra: 1, msg: 'x' });+ });++ it('rejects empty code', () => {+ expect(errorRecoverSchema.safeParse({ code: '' }).success).toBe(false);+ });+ });++ describe('shell schemas', () => {+ it('shellInputSchema accepts sessionId + data string', () => {+ expect(shellInputSchema.safeParse({ sessionId: 's1', data: 'ls\n' }).success).toBe(true);+ });++ it('shellInputSchema allows empty data string', () => {+ expect(shellInputSchema.safeParse({ sessionId: 's1', data: '' }).success).toBe(true);+ });++ it('shellInputSchema rejects missing sessionId', () => {+ expect(shellInputSchema.safeParse({ data: 'ls' }).success).toBe(false);+ });++ it('shellResizeSchema accepts a valid resize payload', () => {+ expect(shellResizeSchema.safeParse({ sessionId: 's1', cols: 80, rows: 24 }).success).toBe(true);+ });++ it('shellResizeSchema rejects cols/rows beyond the 500 cap', () => {+ expect(shellResizeSchema.safeParse({ sessionId: 's1', cols: 501, rows: 24 }).success).toBe(false);+ expect(shellResizeSchema.safeParse({ sessionId: 's1', cols: 80, rows: 999 }).success).toBe(false);+ });++ it('shellResizeSchema rejects zero or negative dimensions', () => {+ expect(shellResizeSchema.safeParse({ sessionId: 's1', cols: 0, rows: 24 }).success).toBe(false);+ expect(shellResizeSchema.safeParse({ sessionId: 's1', cols: 80, rows: -1 }).success).toBe(false);+ });++ it('shellSessionIdSchema and shellStopSchema accept the same shape', () => {+ expect(shellSessionIdSchema.safeParse({ sessionId: 'abc' }).success).toBe(true);+ expect(shellStopSchema.safeParse({ sessionId: 'abc' }).success).toBe(true);+ });+ });++ describe('app schemas', () => {+ it('appUpdateSchema and appStandardizeSchema require appId', () => {+ expect(appUpdateSchema.safeParse({ appId: 'foo' }).success).toBe(true);+ expect(appStandardizeSchema.safeParse({ appId: 'foo' }).success).toBe(true);+ expect(appUpdateSchema.safeParse({}).success).toBe(false);+ expect(appStandardizeSchema.safeParse({}).success).toBe(false);+ });++ it('appDeploySchema defaults flags to an empty array', () => {+ const result = appDeploySchema.safeParse({ appId: 'foo' });+ expect(result.success).toBe(true);+ expect(result.data.flags).toEqual([]);+ });++ it('appDeploySchema accepts whitelisted deploy flags', () => {+ const result = appDeploySchema.safeParse({ appId: 'foo', flags: ['--ios', '--skip-tests'] });+ expect(result.success).toBe(true);+ expect(result.data.flags).toEqual(['--ios', '--skip-tests']);+ });++ it('appDeploySchema rejects unknown flags', () => {+ const result = appDeploySchema.safeParse({ appId: 'foo', flags: ['--rm-rf-everything'] });+ expect(result.success).toBe(false);+ });++ it('appDeploySchema rejects more than 20 flags', () => {+ const tooMany = Array(21).fill('--ios');+ expect(appDeploySchema.safeParse({ appId: 'foo', flags: tooMany }).success).toBe(false);+ });+ });+});++describe('validateSocketData helper', () => {+ function makeSocket() {+ return { emit: vi.fn() };+ }++ it('returns parsed data on success and does not emit', () => {+ const socket = makeSocket();+ const data = validateSocketData(detectStartSchema, { path: '/x' }, socket, 'detect:start');+ expect(data).toEqual({ path: '/x' });+ expect(socket.emit).not.toHaveBeenCalled();+ });++ it('applies schema defaults to the returned data', () => {+ const socket = makeSocket();+ const data = validateSocketData(+ logsSubscribeSchema,+ { processName: 'portos' },+ socket,+ 'logs:subscribe'+ );+ expect(data.lines).toBe(100);+ expect(socket.emit).not.toHaveBeenCalled();+ });++ it('returns null and emits a structured error on failure', () => {+ const socket = makeSocket();+ const result = validateSocketData(detectStartSchema, { path: '' }, socket, 'detect:start');+ expect(result).toBeNull();+ expect(socket.emit).toHaveBeenCalledTimes(1);+ const [event, payload] = socket.emit.mock.calls[0];+ expect(event).toBe('detect:start:error');+ expect(payload.message).toBe('Validation failed');+ expect(Array.isArray(payload.details)).toBe(true);+ expect(payload.details[0]).toEqual(+ expect.objectContaining({ path: 'path', message: expect.any(String) })+ );+ });++ it('includes nested field paths in error details', () => {+ const socket = makeSocket();+ const result = validateSocketData(+ shellResizeSchema,+ { sessionId: 's1', cols: 80, rows: 9999 },+ socket,+ 'shell:resize'+ );+ expect(result).toBeNull();+ const [, payload] = socket.emit.mock.calls[0];+ expect(payload.details.some(d => d.path === 'rows')).toBe(true);+ });+});