Add category and tags granularity to company sync flows

This commit is contained in:
2026-03-03 23:10:08 -05:00
parent 717e747869
commit 610fce8db3
12 changed files with 415 additions and 29 deletions

View File

@@ -85,7 +85,8 @@ function applySqlMigrations(client: { exec: (query: string) => void }) {
'0000_cold_silver_centurion.sql',
'0001_glossy_statement_snapshots.sql',
'0002_workflow_task_projection_metadata.sql',
'0003_task_stage_event_timeline.sql'
'0003_task_stage_event_timeline.sql',
'0004_watchlist_company_taxonomy.sql'
];
for (const file of migrationFiles) {
@@ -215,6 +216,80 @@ if (process.env.RUN_TASK_WORKFLOW_E2E === '1') {
expect(tasks.every((task) => typeof task.workflow_run_id === 'string' && task.workflow_run_id.length > 0)).toBe(true);
});
it('persists watchlist category and tags and forwards them to auto sync task payload', async () => {
const created = await jsonRequest('POST', '/api/watchlist', {
ticker: 'shop',
companyName: 'Shopify Inc.',
sector: 'Technology',
category: 'core',
tags: ['growth', 'ecommerce', 'growth', ' ']
});
expect(created.response.status).toBe(200);
const createdBody = created.json as {
item: {
ticker: string;
category: string | null;
tags: string[];
};
autoFilingSyncQueued: boolean;
};
expect(createdBody.item.ticker).toBe('SHOP');
expect(createdBody.item.category).toBe('core');
expect(createdBody.item.tags).toEqual(['growth', 'ecommerce']);
expect(createdBody.autoFilingSyncQueued).toBe(true);
const tasksResponse = await jsonRequest('GET', '/api/tasks?limit=5');
expect(tasksResponse.response.status).toBe(200);
const task = (tasksResponse.json as {
tasks: Array<{
task_type: string;
payload: {
ticker?: string;
category?: string;
tags?: string[];
limit?: number;
};
}>;
}).tasks.find((entry) => entry.task_type === 'sync_filings');
expect(task).toBeTruthy();
expect(task?.payload.ticker).toBe('SHOP');
expect(task?.payload.limit).toBe(20);
expect(task?.payload.category).toBe('core');
expect(task?.payload.tags).toEqual(['growth', 'ecommerce']);
});
it('accepts category and comma-separated tags on manual filings sync payload', async () => {
const sync = await jsonRequest('POST', '/api/filings/sync', {
ticker: 'nvda',
limit: 15,
category: 'watch',
tags: 'semis, ai, semis'
});
expect(sync.response.status).toBe(200);
const task = (sync.json as {
task: {
task_type: string;
payload: {
ticker: string;
limit: number;
category?: string;
tags?: string[];
};
};
}).task;
expect(task.task_type).toBe('sync_filings');
expect(task.payload.ticker).toBe('NVDA');
expect(task.payload.limit).toBe(15);
expect(task.payload.category).toBe('watch');
expect(task.payload.tags).toEqual(['semis', 'ai']);
});
it('updates notification read and silenced state via patch endpoint', async () => {
const created = await jsonRequest('POST', '/api/filings/0000000000-26-000010/analyze');
const taskId = (created.json as { task: { id: string } }).task.id;