Skip to content

Commit b9b2fa1

Browse files
committed
test(marketplace): cover source filtering
1 parent 6ae3d19 commit b9b2fa1

3 files changed

Lines changed: 57 additions & 2 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@ pro/admin/worker/
5050
/pro/llm_benchmark/content_benchmark/eval-runs/
5151
/pro/llm_benchmark/content_benchmark/.cache/
5252
.gstack/
53-
.gstack/

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/marketplace/test/pages/api/tool/list.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,60 @@ describe('/api/tool/list', () => {
136136
}
137137
});
138138
});
139+
140+
it('filters by source before pagination and keeps legacy tools as official', async () => {
141+
toolDataMocks.getToolList.mockResolvedValue([
142+
createTool({ toolId: 'legacy', id: 'legacy', pluginId: 'legacy', source: undefined }),
143+
createTool({ toolId: 'official', id: 'official', pluginId: 'official', source: 'official' }),
144+
createTool({ toolId: 'community', id: 'community', pluginId: 'community', source: 'community' })
145+
]);
146+
147+
const { default: handler } = await import('../../../../../src/pages/api/tool/list');
148+
const officialRes = createResponse();
149+
await handler(
150+
{
151+
method: 'POST',
152+
query: {},
153+
body: {
154+
pageNum: 1,
155+
pageSize: 10,
156+
source: 'official'
157+
}
158+
} as any,
159+
officialRes as any
160+
);
161+
162+
expect(officialRes.body).toMatchObject({
163+
code: 200,
164+
data: {
165+
total: 2,
166+
list: [
167+
{ toolId: 'legacy', downloadUrl: 'https://cdn.example.com/legacy.pkg' },
168+
{ toolId: 'official', downloadUrl: 'https://cdn.example.com/official.pkg' }
169+
]
170+
}
171+
});
172+
173+
const communityRes = createResponse();
174+
await handler(
175+
{
176+
method: 'POST',
177+
query: {},
178+
body: {
179+
pageNum: 1,
180+
pageSize: 10,
181+
source: 'community'
182+
}
183+
} as any,
184+
communityRes as any
185+
);
186+
187+
expect(communityRes.body).toMatchObject({
188+
code: 200,
189+
data: {
190+
total: 1,
191+
list: [{ toolId: 'community', downloadUrl: 'https://cdn.example.com/community.pkg' }]
192+
}
193+
});
194+
});
139195
});

0 commit comments

Comments
 (0)