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
address review (claude): pin regression coverage for scoped Morse types, guard AudioContext mock cleanup
Adam Eivy4ea2b15c702e
diff --git a/client/src/components/meatspace/post/MorseTrainer.test.jsx b/client/src/components/meatspace/post/MorseTrainer.test.jsxindex 1a5cfd3585..4128d85b0e 100644--- a/client/src/components/meatspace/post/MorseTrainer.test.jsx+++ b/client/src/components/meatspace/post/MorseTrainer.test.jsx@@ -1,4 +1,4 @@-import { describe, it, expect, vi, beforeEach } from 'vitest';+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';import { render, screen, fireEvent, waitFor } from '@testing-library/react';import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';@@ -148,33 +148,43 @@ describe('MorseTrainer training log integration', () => {expect(container.textContent).toContain('80% avg');});- it('logs a completed Head Copy round to the training log with the right payload shape', async () => {- window.AudioContext = MockAudioContext;- renderMorse({ mode: 'head-copy', onSelectMode: vi.fn(), onExitMode: vi.fn() });+ describe('round completion', () => {+ // Scoped to just this test — install/teardown live in beforeEach/afterEach+ // (not inline in the test body) so a failed assertion above the cleanup+ // line can't leak the mock AudioContext onto `window` for later tests.+ beforeEach(() => {+ window.AudioContext = MockAudioContext;+ });+ afterEach(() => {+ delete window.AudioContext;+ });- fireEvent.click(await screen.findByRole('button', { name: /Start Round/i }));-- // 10-question round (ROUND_SIZE): submit a deliberately wrong guess each- // time so correctCount is deterministic (0), then advance past feedback.- for (let i = 0; i < 10; i++) {- const input = await screen.findByPlaceholderText('????');- fireEvent.change(input, { target: { value: 'ZZZZZ' } });- fireEvent.keyDown(input, { key: 'Enter' });- if (i < 9) {- const nextButton = await screen.findByRole('button', { name: /Next/i });- fireEvent.click(nextButton);+ it('logs a completed Head Copy round to the training log with the right payload shape', async () => {+ renderMorse({ mode: 'head-copy', onSelectMode: vi.fn(), onExitMode: vi.fn() });++ fireEvent.click(await screen.findByRole('button', { name: /Start Round/i }));++ // 10-question round (ROUND_SIZE): submit a deliberately wrong guess each+ // time so correctCount is deterministic (0), then advance past feedback.+ for (let i = 0; i < 10; i++) {+ const input = await screen.findByPlaceholderText('????');+ fireEvent.change(input, { target: { value: 'ZZZZZ' } });+ fireEvent.keyDown(input, { key: 'Enter' });+ if (i < 9) {+ const nextButton = await screen.findByRole('button', { name: /Next/i });+ fireEvent.click(nextButton);+ }}- }- await waitFor(() => {- expect(submitTrainingEntry).toHaveBeenCalledWith(expect.objectContaining({- module: 'morse',- drillType: 'morse-head-copy',- questionCount: 10,- correctCount: 0,- }));+ await waitFor(() => {+ expect(submitTrainingEntry).toHaveBeenCalledWith(expect.objectContaining({+ module: 'morse',+ drillType: 'morse-head-copy',+ questionCount: 10,+ correctCount: 0,+ }));+ });});- delete window.AudioContext;});});diff --git a/server/lib/postValidation.test.js b/server/lib/postValidation.test.jsindex a0b46edd87..21934952b4 100644--- a/server/lib/postValidation.test.js+++ b/server/lib/postValidation.test.js@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest';-import { postLlmScoreRequestSchema, postConfigUpdateSchema, LLM_DRILL_TYPES } from './postValidation.js';+import { postLlmScoreRequestSchema, postConfigUpdateSchema, postSessionSubmitSchema, postDrillRequestSchema, trainingEntrySchema, LLM_DRILL_TYPES } from './postValidation.js';describe('postConfigUpdateSchema llmDrills', () => {// Regression: the config UI (PostDrillConfig.jsx) exposed only 5 of the 14@@ -57,6 +57,36 @@ describe('postConfigUpdateSchema llmDrills', () => {});});+describe('Morse drill types stay scoped to the training log', () => {+ // Regression: MORSE_DRILL_TYPES must never be spliced into the shared+ // DRILL_TYPES array — that array also backs the *scored* session submit+ // schema (postSessionSubmitSchema.tasks[].type) and server-side drill+ // generation (postDrillRequestSchema.type). meatspacePost.js's scoring+ // dispatch only special-cases LLM/MEMORY/COGNITIVE types and falls through+ // everything else to the math-expression scorer — a Morse type would pass+ // validation there but silently mis-score as a failed math drill instead of+ // being rejected. Morse only ever posts through trainingEntrySchema.+ it('rejects a Morse type on the scored-session task schema', () => {+ expect(() => postSessionSubmitSchema.parse({+ modules: ['morse'],+ tasks: [{ module: 'morse', type: 'morse-copy', totalMs: 1000 }]+ })).toThrow();+ });++ it('rejects a Morse type on the server-side drill-generation request schema', () => {+ expect(() => postDrillRequestSchema.parse({ type: 'morse-copy' })).toThrow();+ });++ it('accepts every Morse drill type on the training-log entry schema', () => {+ for (const drillType of ['morse-copy', 'morse-head-copy', 'morse-send']) {+ const parsed = trainingEntrySchema.parse({+ module: 'morse', drillType, questionCount: 10, correctCount: 8, totalMs: 5000+ });+ expect(parsed.drillType).toBe(drillType);+ }+ });+});+describe('postLlmScoreRequestSchema', () => {// Regression: Zod's default strip mode dropped `questionIndex` from each// response, so the server scorer fell back to the response-array index