Skip to content

Commit 8309b37

Browse files
test(e2e): mock gamma-api /teams endpoint (MMQA-1800)
The main merge brought in TeamsCache (app/components/UI/Predict/ providers/polymarket/TeamsCache.ts) which fetches gamma-api.polymarket.com/teams?league=...&abbreviation=... when rendering sports markets that have team metadata (NBA, NFL, etc.). Adds: - POLYMARKET_TEAMS_MOCKS function in polymarket-mocks.ts (returns []), wired into POLYMARKET_COMPLETE_MOCKS so predict specs are covered. - Default GET matcher in defaults/polymarket-apis.ts so non-predict specs that pass through Explore don't leak when team-aware markets render. Empty array is safe — TeamsCache short-circuits on non-array responses. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ef93a06 commit 8309b37

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

tests/api-mocking/mock-responses/defaults/polymarket-apis.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export const POLYMARKET_API_MOCKS = {
4444
responseCode: 200,
4545
response: [],
4646
},
47+
// gamma-api: sports league team metadata (TeamsCache)
48+
{
49+
urlEndpoint: /^https:\/\/gamma-api\.polymarket\.com\/teams(\?.*)?$/,
50+
responseCode: 200,
51+
response: [],
52+
},
4753
// polymarket.com: homepage carousel
4854
{
4955
urlEndpoint: 'https://polymarket.com/api/homepage/carousel',

tests/api-mocking/mock-responses/polymarket/polymarket-mocks.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,25 @@ export const POLYMARKET_PRICES_HISTORY_MOCKS = async (mockServer: Mockttp) => {
675675
});
676676
};
677677

678+
/**
679+
* Mock for Polymarket gamma-api /teams API
680+
* Returns an empty teams array — sufficient for predict specs that render
681+
* sports markets with team metadata. Consumer (TeamsCache) handles a
682+
* non-array response by short-circuiting, so [] is safe.
683+
*/
684+
export const POLYMARKET_TEAMS_MOCKS = async (mockServer: Mockttp) => {
685+
await mockServer
686+
.forGet('/proxy')
687+
.matching((request) => {
688+
const url = new URL(request.url).searchParams.get('url');
689+
return Boolean(url?.includes('gamma-api.polymarket.com/teams'));
690+
})
691+
.asPriority(PRIORITY.BASE)
692+
.thenReply(200, JSON.stringify([]), {
693+
'content-type': 'application/json',
694+
});
695+
};
696+
678697
/**
679698
* Mock for Polymarket CLOB order book API
680699
* Returns order book data for specific token IDs with correct market mapping
@@ -2234,6 +2253,7 @@ export const POLYMARKET_COMPLETE_MOCKS = async (mockServer: Mockttp) => {
22342253
await POLYMARKET_ORDER_BOOK_MOCKS(mockServer);
22352254
await POLYMARKET_PRICES_MOCKS(mockServer); // Mock for CLOB prices API
22362255
await POLYMARKET_PRICES_HISTORY_MOCKS(mockServer); // Mock for CLOB prices-history API (chart series)
2256+
await POLYMARKET_TEAMS_MOCKS(mockServer); // Mock for gamma-api /teams (sports league team metadata)
22372257
await POLYMARKET_FEE_RATE_MOCKS(mockServer);
22382258
await POLYMARKET_MARKET_FEEDS_MOCKS(mockServer);
22392259
await POLYMARKET_CLOB_AUTH_MOCKS(mockServer);

0 commit comments

Comments
 (0)