Skip to content

Commit

Permalink
fix(test): add 200 status code to expected
Browse files Browse the repository at this point in the history
  • Loading branch information
solidovic committed Aug 5, 2024
1 parent 48e4c81 commit 65964b8
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 1 deletion.
110 changes: 110 additions & 0 deletions test/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export interface PostRequest {
schema: object;
}

const FLOAT_REGEX = /^\d+(\.\d+)?$/;

const LIDO_STATS_SCHEMA = {
type: 'object',
properties: {
Expand Down Expand Up @@ -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,
Expand All @@ -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&currency=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[] = [
Expand Down
2 changes: 1 addition & 1 deletion test/smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 65964b8

Please sign in to comment.