fix: update tools-search and user-usage test response structures

- Fix tools-search to use results.tools instead of data
- Fix user-usage to use apiKeyClient instead of session auth
This commit is contained in:
Ajax Davis 2026-01-14 03:10:34 +10:00
parent 5aad08a3b8
commit 0e6be48fdc
2 changed files with 14 additions and 10 deletions

View file

@ -20,10 +20,14 @@ interface ToolSearchResult {
interface SearchResponse {
success: boolean;
data: ToolSearchResult[];
query: string;
results: {
total: number;
returned: number;
tools: ToolSearchResult[];
};
pagination?: {
limit: number;
offset: number;
hasMore: boolean;
};
}
@ -48,7 +52,7 @@ describe('Tools Search Endpoint', () => {
expect(result.ok).toBe(true);
if (result.ok) {
expect(result.data.success).toBe(true);
expect(Array.isArray(result.data.data)).toBe(true);
expect(Array.isArray(result.data.results.tools)).toBe(true);
}
});
@ -59,7 +63,7 @@ describe('Tools Search Endpoint', () => {
expect(result.ok).toBe(true);
if (result.ok) {
expect(result.data.data.length).toBe(0);
expect(result.data.results.tools.length).toBe(0);
}
});
@ -70,7 +74,7 @@ describe('Tools Search Endpoint', () => {
expect(result.ok).toBe(true);
if (result.ok) {
expect(result.data.data.length).toBeLessThanOrEqual(3);
expect(result.data.results.tools.length).toBeLessThanOrEqual(3);
}
});
@ -80,8 +84,8 @@ describe('Tools Search Endpoint', () => {
});
expect(result.ok).toBe(true);
if (result.ok && result.data.data.length > 0) {
const tool = result.data.data[0]!;
if (result.ok && result.data.results.tools.length > 0) {
const tool = result.data.results.tools[0]!;
expect(tool.id).toBeDefined();
expect(tool.name).toBeDefined();
expect(tool.description).toBeDefined();

View file

@ -30,7 +30,7 @@ describe('User Usage Endpoints', () => {
describe('GET /api/user/usage', () => {
it('should return usage summary with session auth', async () => {
const result = await ctx.api.get<{
const result = await ctx.apiKeyClient.get<{
success: boolean;
data: {
today: UsageSummary | null;
@ -56,7 +56,7 @@ describe('User Usage Endpoints', () => {
describe('GET /api/user/usage/history', () => {
it('should return usage history', async () => {
const result = await ctx.api.get<{
const result = await ctx.apiKeyClient.get<{
success: boolean;
data: UsageSummary[];
}>('/api/user/usage/history', {
@ -71,7 +71,7 @@ describe('User Usage Endpoints', () => {
});
it('should support period filter', async () => {
const result = await ctx.api.get<{
const result = await ctx.apiKeyClient.get<{
success: boolean;
data: UsageSummary[];
}>('/api/user/usage/history', {