phase-10.5: test case fixes and updated postman collection

This commit is contained in:
saikiranvella
2026-06-12 00:47:41 -04:00
parent 65907a9b8d
commit 6cb4c93a0e
8 changed files with 524 additions and 668 deletions
+8 -3
View File
@@ -13,6 +13,11 @@ const MOCK_LLM_RESPONSE = JSON.stringify({
const mockDb = new MockDatabaseConnection() as never;
// Stub catalyst cache — no live Yahoo news fetches in tests (fast + offline)
const stubCatalystCache = {
get: async () => ({ tickers: [] as string[], stories: [] }),
} as never;
test('POST /api/analyze', async (t) => {
// Spy on AnthropicClient.prototype.complete before buildApp wires it up.
// This prevents any real API calls during tests.
@@ -26,7 +31,7 @@ test('POST /api/analyze', async (t) => {
mock.method(AnthropicClient.prototype, 'isAvailable', () => true, { getter: true });
await t.test('returns analysis when stories match tickers', async () => {
const app = await buildApp({ logger: false, db: mockDb });
const app = await buildApp({ logger: false, db: mockDb, catalystCache: stubCatalystCache });
const response = await app.inject({
method: 'POST',
@@ -47,7 +52,7 @@ test('POST /api/analyze', async (t) => {
// Reset the isAvailable mock to simulate no API key
mock.method(AnthropicClient.prototype, 'isAvailable', () => false, { getter: true });
const app = await buildApp({ logger: false, db: mockDb });
const app = await buildApp({ logger: false, db: mockDb, catalystCache: stubCatalystCache });
const response = await app.inject({
method: 'POST',
@@ -68,7 +73,7 @@ test('POST /api/analyze', async (t) => {
mock.method(AnthropicClient.prototype, 'isAvailable', () => true, { getter: true });
const callsBefore = completeSpy.mock.calls.length;
const app = await buildApp({ logger: false, db: mockDb });
const app = await buildApp({ logger: false, db: mockDb, catalystCache: stubCatalystCache });
await app.inject({
method: 'POST',