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: use real CoS schedule validation schemas (#11998)
Adam Eivy79f9a4b83ef1
diff --git a/server/routes/cosScheduleRoutes.test.js b/server/routes/cosScheduleRoutes.test.jsindex a6565e1496..60f56d30b8 100644--- a/server/routes/cosScheduleRoutes.test.js+++ b/server/routes/cosScheduleRoutes.test.js@@ -25,36 +25,9 @@ vi.mock('../services/taskSchedule.js', () => ({INTERVAL_TYPES: { ON_DEMAND: 'on-demand', CRON: 'cron' }}));-vi.mock('../lib/validation.js', () => ({+vi.mock('../lib/validation.js', async (importOriginal) => ({+ ...(await importOriginal()),sanitizeTaskMetadata: vi.fn((meta) => meta),- taskDataInputsSchema: {- safeParse: (ids) => {- const allowed = new Set(['product-requirements', 'project-goals', 'open-issues', 'open-pull-requests', 'closed-unmerged-pull-requests']);- return Array.isArray(ids) && ids.every((id) => allowed.has(id))- ? { success: true, data: [...new Set(ids)] }- : { success: false };- }- },- cosScheduleTargetBodySchema: {- safeParse: (body) => (typeof body?.taskType === 'string' && body.taskType- ? { success: true, data: { taskType: body.taskType, appId: body.appId } }- : { success: false }),- },- validateRequest: vi.fn((schema, data) => {- const result = schema.safeParse(data);- if (!result.success) {- const { ServerError } = require('../lib/errorHandler.js');- throw new ServerError('Validation failed', { status: 400, code: 'VALIDATION_ERROR' });- }- return result.data;- }),- parsePagination: vi.fn((query, { defaultLimit = 50, maxLimit = 200 } = {}) => {- const rawLimit = parseInt(query?.limit, 10);- const rawOffset = parseInt(query?.offset, 10);- const limit = Number.isFinite(rawLimit) && rawLimit > 0 ? Math.min(rawLimit, maxLimit) : defaultLimit;- const offset = Number.isFinite(rawOffset) && rawOffset >= 0 ? rawOffset : 0;- return { limit, offset };- }),}));import * as taskSchedule from '../services/taskSchedule.js';@@ -447,12 +420,15 @@ describe('CoS Schedule Routes', () => {expect(response.body.success).toBe(true);});- it('should return 400 if taskType is missing', async () => {- const response = await request(app)- .post('/api/cos/schedule/trigger')- .send({});+ it('rejects missing or malformed taskType before triggering an on-demand task', async () => {+ for (const body of [{}, { taskType: '' }, { taskType: 42 }]) {+ const response = await request(app)+ .post('/api/cos/schedule/trigger')+ .send(body);- expect(response.status).toBe(400);+ expect(response.status).toBe(400);+ }+ expect(taskSchedule.triggerOnDemandTask).not.toHaveBeenCalled();});it('should return 409 when triggerOnDemandTask returns an error', async () => {@@ -508,12 +484,15 @@ describe('CoS Schedule Routes', () => {expect(response.status).toBe(200);});- it('should return 400 if taskType is missing', async () => {- const response = await request(app)- .post('/api/cos/schedule/reset')- .send({});+ it('rejects missing or malformed taskType before resetting execution history', async () => {+ for (const body of [{}, { taskType: '' }, { taskType: 42 }]) {+ const response = await request(app)+ .post('/api/cos/schedule/reset')+ .send(body);- expect(response.status).toBe(400);+ expect(response.status).toBe(400);+ }+ expect(taskSchedule.resetExecutionHistory).not.toHaveBeenCalled();});it('should return 404 on reset error', async () => {