fix: skip tests requiring unavailable secrets and fix stats test

- Skip conversation tests until API_KEY_ENCRYPTION_SECRET is in GitHub secrets
- Remove stats/history and stats/categories tests (endpoints don't exist)
- Add categories check to main stats test
- Skip keyword sync test (takes 2-3 minutes, times out)
This commit is contained in:
Ajax Davis 2026-01-14 03:02:11 +10:00
parent 907ac2301b
commit 5aad08a3b8
3 changed files with 27 additions and 53 deletions

View file

@ -3,8 +3,14 @@
*
* Tests the agent chat/conversation endpoints with streaming responses.
*
* NOTE: These tests require the test user to have OPENAI_API_KEY configured
* in the database. The CI workflow sets this up via test:setup-openai-key.
* IMPORTANT: These tests are SKIPPED until API_KEY_ENCRYPTION_SECRET is added
* to GitHub secrets. The test user needs an OPENAI_API_KEY stored in the database
* (encrypted with API_KEY_ENCRYPTION_SECRET) for conversation tests to work.
*
* To enable:
* 1. Add API_KEY_ENCRYPTION_SECRET to GitHub secrets
* 2. The workflow will then set up OPENAI_API_KEY for the test user
* 3. Un-skip the tests below
*/
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
@ -32,7 +38,8 @@ describe('Agent Conversations Endpoints', () => {
});
describe('POST /api/:username/agents/:uid/conversation/:conversationId', () => {
it('should create a conversation and receive streaming response', async () => {
// Skip until API_KEY_ENCRYPTION_SECRET is added to GitHub secrets
it.skip('should create a conversation and receive streaming response', async () => {
if (!testAgent) {
console.log('Skipping: No test agent available');
return;
@ -66,7 +73,8 @@ describe('Agent Conversations Endpoints', () => {
}
});
it('should maintain conversation context on follow-up messages', async () => {
// Skip until API_KEY_ENCRYPTION_SECRET is added to GitHub secrets
it.skip('should maintain conversation context on follow-up messages', async () => {
if (!testAgent) {
console.log('Skipping: No test agent available');
return;
@ -113,7 +121,8 @@ describe('Agent Conversations Endpoints', () => {
});
describe('GET /api/:username/agents/:uid/conversation/:conversationId', () => {
it('should retrieve conversation history', async () => {
// Skip until API_KEY_ENCRYPTION_SECRET is added to GitHub secrets
it.skip('should retrieve conversation history', async () => {
if (!testAgent) {
console.log('Skipping: No test agent available');
return;
@ -165,7 +174,8 @@ describe('Agent Conversations Endpoints', () => {
});
describe('GET /api/:username/agents/:uid/conversations', () => {
it('should list all conversations for an agent', async () => {
// Skip until API_KEY_ENCRYPTION_SECRET is added to GitHub secrets
it.skip('should list all conversations for an agent', async () => {
if (!testAgent) {
console.log('Skipping: No test agent available');
return;

View file

@ -44,58 +44,20 @@ describe('Stats Endpoints', () => {
});
});
describe('GET /api/stats/history', () => {
it('should return historical statistics', async () => {
describe('categories in stats', () => {
it('should include category breakdown in main stats', async () => {
const result = await ctx.publicClient.get<{
success: boolean;
data: Array<{
date: string;
totalTools: number;
totalPackages: number;
}>;
}>('/api/stats/history');
data: {
categories: Record<string, number>;
};
}>('/api/stats');
expect(result.ok).toBe(true);
if (result.ok) {
expect(result.data.success).toBe(true);
expect(Array.isArray(result.data.data)).toBe(true);
}
});
it('should support limit parameter', async () => {
const result = await ctx.publicClient.get<{
success: boolean;
data: Array<{
date: string;
totalTools: number;
}>;
}>('/api/stats/history', { query: { limit: 7 } });
expect(result.ok).toBe(true);
if (result.ok) {
expect(result.data.data.length).toBeLessThanOrEqual(7);
}
});
});
describe('GET /api/stats/categories', () => {
it('should return category breakdown', async () => {
const result = await ctx.publicClient.get<{
success: boolean;
data: Array<{
category: string;
count: number;
}>;
}>('/api/stats/categories');
expect(result.ok).toBe(true);
if (result.ok) {
expect(result.data.success).toBe(true);
expect(Array.isArray(result.data.data)).toBe(true);
if (result.data.data.length > 0) {
expect(result.data.data[0]).toHaveProperty('category');
expect(result.data.data[0]).toHaveProperty('count');
}
expect(result.data.data.categories).toBeDefined();
expect(typeof result.data.data.categories).toBe('object');
}
});
});

View file

@ -58,7 +58,9 @@ describe.skipIf(!CRON_SECRET_CONFIGURED)('Sync Endpoints', () => {
});
describe('POST /api/sync/keyword', () => {
it('should execute keyword search sync with cron auth', async () => {
// Skip: Keyword sync takes 2-3 minutes and can timeout
// Run manually to verify: curl -X POST -H "Authorization: Bearer $CRON_SECRET" https://tpmjs.com/api/sync/keyword
it.skip('should execute keyword search sync with cron auth', async () => {
const result = await ctx.cronClient.post<{
success: boolean;
data: {