phase-10.5: test case fixes and updated postman collection
This commit is contained in:
+13
-8
@@ -6,15 +6,20 @@ import { MockDatabaseConnection } from './helpers/mockDb.js';
|
||||
// Inject mock DB so tests don't require the native better-sqlite3 binary
|
||||
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('App Bootstrap', async (t) => {
|
||||
await t.test('builds successfully without logger', async () => {
|
||||
const app = await buildApp({ logger: false, db: mockDb });
|
||||
const app = await buildApp({ logger: false, db: mockDb, catalystCache: stubCatalystCache });
|
||||
assert.ok(app);
|
||||
assert.ok(app.server);
|
||||
});
|
||||
|
||||
await t.test('health check endpoint returns 200', 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: 'GET',
|
||||
url: '/health',
|
||||
@@ -25,7 +30,7 @@ test('App Bootstrap', async (t) => {
|
||||
});
|
||||
|
||||
await t.test('POST /api/screen requires valid schema', 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',
|
||||
url: '/api/screen',
|
||||
@@ -36,7 +41,7 @@ test('App Bootstrap', async (t) => {
|
||||
});
|
||||
|
||||
await t.test('POST /api/screen rejects invalid payload', 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',
|
||||
url: '/api/screen',
|
||||
@@ -46,7 +51,7 @@ test('App Bootstrap', async (t) => {
|
||||
});
|
||||
|
||||
await t.test('GET /api/screen/catalysts returns results', 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: 'GET',
|
||||
url: '/api/screen/catalysts',
|
||||
@@ -58,7 +63,7 @@ test('App Bootstrap', async (t) => {
|
||||
});
|
||||
|
||||
await t.test('CORS is enabled for configured origin', 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: 'GET',
|
||||
url: '/health',
|
||||
@@ -70,7 +75,7 @@ test('App Bootstrap', async (t) => {
|
||||
});
|
||||
|
||||
await t.test('API key auth is optional (disabled by default)', 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: 'GET',
|
||||
url: '/health',
|
||||
@@ -80,7 +85,7 @@ test('App Bootstrap', async (t) => {
|
||||
});
|
||||
|
||||
await t.test('OPTIONS requests bypass auth check', 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: 'OPTIONS',
|
||||
url: '/api/screen',
|
||||
|
||||
Reference in New Issue
Block a user