From 9f331df037433495ef33e5977dd512ebd4678956 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Wed, 25 Dec 2024 01:59:23 +0100 Subject: [PATCH] test: stub requests to coingecko in e2e to avoid rate limit errors --- tests/e2e/support/coingecko-stubs.js | 203 +++++++++++++++++++++++++++ tests/e2e/support/index.js | 1 + 2 files changed, 204 insertions(+) create mode 100644 tests/e2e/support/coingecko-stubs.js diff --git a/tests/e2e/support/coingecko-stubs.js b/tests/e2e/support/coingecko-stubs.js new file mode 100644 index 000000000..59870620f --- /dev/null +++ b/tests/e2e/support/coingecko-stubs.js @@ -0,0 +1,203 @@ +beforeEach(() => { + cy.intercept({ + method: 'GET', + url: 'https://api.coingecko.com/api/v3/coins/markets*', + }, [ + { + id: 'bitcoin', + symbol: 'btc', + name: 'Bitcoin', + image: 'https://coin-images.coingecko.com/coins/images/1/large/bitcoin.png?1696501400', + current_price: 98739, + market_cap: 1950216630313, + market_cap_rank: 1, + fully_diluted_valuation: 2068338872360, + total_volume: 48429694783, + high_24h: 99304, + low_24h: 93580, + price_change_24h: 4524.26, + price_change_percentage_24h: 4.80209, + market_cap_change_24h: 81720260459, + market_cap_change_percentage_24h: 4.37358, + circulating_supply: 19800696.0, + total_supply: 21000000.0, + max_supply: 21000000.0, + ath: 108135, + ath_change_percentage: -8.89464, + ath_date: '2024-12-17T15:02:41.429Z', + atl: 67.81, + atl_change_percentage: 145185.31094, + atl_date: '2013-07-06T00:00:00.000Z', + roi: null, + last_updated: '2024-12-25T00:48:27.798Z', + }, + { + id: 'ethereum', + symbol: 'eth', + name: 'Ethereum', + image: 'https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628', + current_price: 3491.98, + market_cap: 419691068693, + market_cap_rank: 2, + fully_diluted_valuation: 419691068693, + total_volume: 23764422728, + high_24h: 3524.86, + low_24h: 3359.57, + price_change_24h: 86.49, + price_change_percentage_24h: 2.53983, + market_cap_change_24h: 9103680941, + market_cap_change_percentage_24h: 2.21723, + circulating_supply: 120458692.0293685, + total_supply: 120458692.0293685, + max_supply: null, + ath: 4878.26, + ath_change_percentage: -28.54126, + ath_date: '2021-11-10T14:24:19.604Z', + atl: 0.432979, + atl_change_percentage: 805007.08887, + atl_date: '2015-10-20T00:00:00.000Z', + roi: { + times: 46.299457997123795, + currency: 'btc', + percentage: 4629.945799712379, + }, + last_updated: '2024-12-25T00:48:22.476Z', + }, + { + id: 'aeternity', + symbol: 'ae', + name: 'Aeternity', + image: 'https://coin-images.coingecko.com/coins/images/1091/large/aeternity.png?1696502190', + current_price: 0.03813756, + market_cap: 16410033, + market_cap_rank: 1461, + fully_diluted_valuation: 20455726, + total_volume: 408531, + high_24h: 0.03816407, + low_24h: 0.03735612, + price_change_24h: 0.00063088, + price_change_percentage_24h: 1.68206, + market_cap_change_24h: 229133, + market_cap_change_percentage_24h: 1.41607, + circulating_supply: 430237039.49932, + total_supply: 536306702.0, + max_supply: null, + ath: 5.69, + ath_change_percentage: -99.33072, + ath_date: '2018-04-29T03:50:39.593Z', + atl: 0.01637085, + atl_change_percentage: 132.67895, + atl_date: '2024-01-23T20:59:54.123Z', + roi: { + times: -0.863794413942024, + currency: 'usd', + percentage: -86.3794413942024, + }, + last_updated: '2024-12-25T00:48:23.684Z', + }, + ]); +}); + +beforeEach(() => { + cy.intercept({ + method: 'GET', + url: 'https://api.coingecko.com/api/v3/simple/price*', + }, { + aeternity: { + usd: 0.03813334, + eur: 0.036648, + aud: 0.061083, + brl: 0.235553, + cad: 0.054767, + chf: 0.03431554, + cny: 0.278206, + czk: 0.921048, + dkk: 0.273436, + gbp: 0.03041419, + hkd: 0.296175, + huf: 15.09, + idr: 620.29, + ils: 0.139088, + inr: 3.26, + jpy: 5.99, + krw: 55.62, + mxn: 0.768671, + myr: 0.171104, + nok: 0.432844, + nzd: 0.067607, + php: 2.24, + pln: 0.156182, + rub: 3.81, + sek: 0.42602, + sgd: 0.051905, + thb: 1.3, + try: 1.34, + zar: 0.710984, + xau: 1.457e-05, + }, + bitcoin: { + usd: 98755, + eur: 94890, + aud: 158302, + brl: 610022, + cad: 141828, + chf: 88856, + cny: 720480, + czk: 2384855, + dkk: 707874, + gbp: 78739, + hkd: 767019, + huf: 39082115, + idr: 1604890389, + ils: 360202, + inr: 8439136, + jpy: 15517243, + krw: 144035662, + mxn: 1991828, + myr: 443116, + nok: 1123987, + nzd: 175022, + php: 5806819, + pln: 404480, + rub: 9867856, + sek: 1103717, + sgd: 134203, + thb: 3378127, + try: 3467920, + zar: 1849645, + xau: 37.74, + }, + ethereum: { + usd: 3492.38, + eur: 3355.68, + aud: 5598.18, + brl: 21573, + cad: 5015.58, + chf: 3142.28, + cny: 25479, + czk: 84338, + dkk: 25033, + gbp: 2784.52, + hkd: 27125, + huf: 1382096, + idr: 56755180, + ils: 12738.13, + inr: 298441, + jpy: 548750, + krw: 5093662, + mxn: 70439, + myr: 15670.3, + nok: 39749, + nzd: 6189.45, + php: 205352, + pln: 14303.99, + rub: 348966, + sek: 39032, + sgd: 4745.93, + thb: 119464, + try: 122639, + zar: 65411, + xau: 1.33, + }, + }); +}); diff --git a/tests/e2e/support/index.js b/tests/e2e/support/index.js index 1221b17e0..195dd7377 100644 --- a/tests/e2e/support/index.js +++ b/tests/e2e/support/index.js @@ -1 +1,2 @@ import './commands'; +import './coingecko-stubs';