Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mock hiro ft requests #5811

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/mocks/mock-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { json } from '@tests/utils';

import { mockMainnetTestAccountStacksBnsNameRequest } from './mock-stacks-bns';
import { mockStacksFeeRequests } from './mock-stacks-fees';
import { mockMainnetTestAccountStacksFTsRequest } from './mock-stacks-fts';
import { mockMainnetTestAccountStacksNFTsRequest } from './mock-stacks-nfts';
import { mockMainnetTestAccountStacksTxsRequests } from './mock-stacks-txs';
import { mockMainnetTestAccountBitcoinRequests } from './mock-utxos';
Expand All @@ -18,5 +19,6 @@ export async function setupMockApis(page: Page) {
mockMainnetTestAccountStacksBnsNameRequest(page),
mockMainnetTestAccountStacksTxsRequests(page),
mockMainnetTestAccountStacksNFTsRequest(page),
mockMainnetTestAccountStacksFTsRequest(page),
]);
}
46 changes: 46 additions & 0 deletions tests/mocks/mock-stacks-fts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { Page } from '@playwright/test';

const mockedLongFtMetadata = {
name: 'LONGcoin',
symbol: 'LONG',
decimals: 6,
total_supply: '888888888888888888',
token_uri: 'https://storage.googleapis.com/longcoin/LONGcoin-metadata.json',
description:
"$LONG will bring prosperity and BDE, Big Dragon Energy, to the Stacks blockchain. It's the first and most auspicious memecoin of the year of the dragon!",
image_uri:
'https://assets.hiro.so/api/mainnet/token-metadata-api/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin/1.png',
image_thumbnail_uri:
'https://assets.hiro.so/api/mainnet/token-metadata-api/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin/1-thumb.png',
image_canonical_uri: 'https://storage.googleapis.com/longcoin/LONGcoin-image.png',
tx_id: '0x170498fd9b2762242b833a92c87adb12dea471bb0dfa4584462af7e05ac85ce2',
sender_address: 'SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3',
metadata: {
sip: 16,
name: 'LONGcoin',
description:
"$LONG will bring prosperity and BDE, Big Dragon Energy, to the Stacks blockchain. It's the first and most auspicious memecoin of the year of the dragon!",
image: 'https://storage.googleapis.com/longcoin/LONGcoin-image.png',
cached_image:
'https://assets.hiro.so/api/mainnet/token-metadata-api/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin/1.png',
cached_thumbnail_image:
'https://assets.hiro.so/api/mainnet/token-metadata-api/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin/1-thumb.png',
},
};

export async function mockMainnetTestAccountStacksFTsRequest(page: Page) {
await page.route(`**/api.hiro.so/metadata/v1/ft/**`, route =>
route.fulfill({
json: {},
})
);

// Mock one supported FT token metadata request
await page.route(
'https://api.hiro.so/metadata/v1/ft/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin',
route =>
route.fulfill({
json: mockedLongFtMetadata,
})
);
}
Loading