From 65964b8a07df21141f485f0a99670fda4eea1578 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Mon, 5 Aug 2024 19:33:04 +0300 Subject: [PATCH] fix(test): add 200 status code to expected --- test/consts.ts | 110 +++++++++++++++++++++++++++++++++++++++++++++ test/smoke.spec.ts | 2 +- 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/test/consts.ts b/test/consts.ts index 3b8f03ef7..295fc7eaa 100644 --- a/test/consts.ts +++ b/test/consts.ts @@ -13,6 +13,8 @@ export interface PostRequest { schema: object; } +const FLOAT_REGEX = /^\d+(\.\d+)?$/; + const LIDO_STATS_SCHEMA = { type: 'object', properties: { @@ -162,6 +164,46 @@ const LIDO_STATS_SCHEMA = { }; export const GET_REQUESTS: GetRequest[] = [ + { + uri: '/api/oneinch-rate', + schema: { + type: 'object', + properties: { + rate: { type: 'number', min: 0 }, + toReceive: { type: 'string' }, + }, + required: ['rate', 'toReceive'], + additionalProperties: false, + }, + }, + { + uri: `/api/short-lido-stats?chainId=${CONFIG.STAND_CONFIG.chainId}`, + schema: { + type: 'object', + properties: { + uniqueAnytimeHolders: { type: 'string' }, + uniqueHolders: { type: 'string' }, + totalStaked: { type: 'string' }, + marketCap: { type: 'number' }, + }, + required: [ + 'totalStaked', + 'marketCap', + 'uniqueAnytimeHolders', + 'uniqueHolders', + ], + additionalProperties: false, + }, + }, + { + uri: '/api/eth-apr', + isDeprecated: true, + schema: { type: 'string', pattern: FLOAT_REGEX }, + }, + { + uri: '/api/totalsupply', + schema: { type: 'string', pattern: FLOAT_REGEX }, + }, { uri: '/api/lidostats', isDeprecated: true, @@ -172,6 +214,74 @@ export const GET_REQUESTS: GetRequest[] = [ isDeprecated: true, schema: LIDO_STATS_SCHEMA, }, + { + uri: '/api/eth-price', + schema: { + type: 'object', + properties: { + price: { + type: 'number', + min: 0, + }, + }, + required: ['price'], + additionalProperties: false, + }, + }, + { + uri: '/api/rewards?address=0x87c0e047F4e4D3e289A56a36570D4CB957A37Ef1¤cy=usd&onlyRewards=false&archiveRate=true&skip=0&limit=10', + skipTestnet: true, // api/rewards don't work on testnet + schema: { + type: 'object', + properties: { + averageApr: { type: 'string' }, + ethToStEthRatio: { type: 'number' }, + events: { + type: 'array', + items: [ + { + type: 'object', + additionalProperties: true, + }, + ], + }, + stETHCurrencyPrice: { + type: 'object', + properties: { + eth: { type: 'number' }, + usd: { type: 'number' }, + }, + required: ['eth', 'usd'], + additionalProperties: false, + }, + totalItems: { type: 'number' }, + totals: { + type: 'object', + properties: { + currencyRewards: { type: 'string' }, + ethRewards: { type: 'string' }, + }, + }, + required: [ + 'averageApr', + 'ethToStEthRatio', + 'events', + 'stETHCurrencyPrice', + 'totalItems', + 'totals', + ], + additionalProperties: false, + }, + }, + }, + { + uri: '/api/sma-steth-apr', + isDeprecated: true, + schema: { + type: 'string', + pattern: FLOAT_REGEX, + }, + }, ]; export const POST_REQUESTS: PostRequest[] = [ diff --git a/test/smoke.spec.ts b/test/smoke.spec.ts index 3f2d2a83c..9a65dff84 100644 --- a/test/smoke.spec.ts +++ b/test/smoke.spec.ts @@ -19,7 +19,7 @@ test.describe('Smoke GET', () => { const resp = await request.get(element.uri); if (element.isDeprecated) { - expect([299, 410]).toContain(resp.status()); + expect([200, 299, 410]).toContain(resp.status()); if (resp.status() === 299) { expect(resp.headers()).toHaveProperty('warning'); expect(resp.headers()).toHaveProperty('deprecation');