Merge remote-tracking branch 'origin/develop' into feat/2297-pre-js-loading-state

This commit is contained in:
maciek
2022-12-27 14:55:00 +01:00
10 changed files with 149 additions and 68 deletions
+30 -19
View File
@@ -351,7 +351,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "129999.45",
"total_removed": "0",
"locked_amount": "81307.540315053463525065",
"locked_amount": "81248.44266700247332743",
"deposits": [
{
"amount": "129999.45",
@@ -417,7 +417,7 @@
"tranche_end": "2023-09-03T00:00:00.000Z",
"total_added": "52600",
"total_removed": "0",
"locked_amount": "35990.50587265347206",
"locked_amount": "35954.60523845763496",
"deposits": [
{
"amount": "2600",
@@ -590,7 +590,7 @@
"tranche_end": "2023-09-17T00:00:00.000Z",
"total_added": "5000",
"total_removed": "0",
"locked_amount": "3612.931570268899",
"locked_amount": "3609.518962455606",
"deposits": [
{
"amount": "5000",
@@ -801,7 +801,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "97499.58",
"total_removed": "0",
"locked_amount": "22977.3245319974778494292",
"locked_amount": "22919.355244454384926296",
"deposits": [
{
"amount": "97499.58",
@@ -834,7 +834,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "135173.4239508",
"total_removed": "98230.390980249184455396",
"locked_amount": "31406.03576564866087005483132",
"locked_amount": "31326.801757557241202249339196",
"deposits": [
{
"amount": "135173.4239508",
@@ -880,7 +880,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "32499.86",
"total_removed": "0",
"locked_amount": "9666.16363344070691823",
"locked_amount": "9641.77695524737925814",
"deposits": [
{
"amount": "32499.86",
@@ -913,7 +913,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "10833.29",
"total_removed": "0",
"locked_amount": "3146.242464453294772696",
"locked_amount": "3138.304837344090628721",
"deposits": [
{
"amount": "10833.29",
@@ -946,7 +946,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "22749.93",
"total_removed": "0",
"locked_amount": "11761.357032689791441887",
"locked_amount": "11731.684409718586439931",
"deposits": [
{
"amount": "6500",
@@ -1085,7 +1085,7 @@
"tranche_end": "2023-05-01T00:00:00.000Z",
"total_added": "22500",
"total_removed": "2310.007577475",
"locked_amount": "15506.85140423572725",
"locked_amount": "15475.883402394108",
"deposits": [
{
"amount": "7500",
@@ -1195,7 +1195,7 @@
"tranche_end": "2023-06-02T00:00:00.000Z",
"total_added": "1939928.38",
"total_removed": "928642.9598472029154",
"locked_amount": "833074.364317451785811321",
"locked_amount": "831750.321368088516416672",
"deposits": [
{
"amount": "1852091.69",
@@ -1547,7 +1547,7 @@
"tranche_end": "2023-02-01T00:00:00.000Z",
"total_added": "42500",
"total_removed": "22452.0135114",
"locked_amount": "8256.088025865538725",
"locked_amount": "8198.5466359702077",
"deposits": [
{
"amount": "12500",
@@ -31990,7 +31990,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "3732368.4671",
"total_removed": "428705.3729302523069",
"locked_amount": "1304646.5769976062751817308",
"locked_amount": "1302611.983967228485957345394",
"deposits": [
{
"amount": "1998.95815",
@@ -33216,7 +33216,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "15870102.715470999700000001",
"total_removed": "511218.93522350218767952",
"locked_amount": "9925880.5813578269289248200293407539226817",
"locked_amount": "9918666.0451054660999487872683874447066774",
"deposits": [
{
"amount": "16249.93",
@@ -37985,7 +37985,7 @@
"tranche_end": "2023-05-05T00:00:00.000Z",
"total_added": "14597706.0446472999",
"total_removed": "3489401.90950082536320653",
"locked_amount": "3442064.349073341394799607916857306",
"locked_amount": "3435403.935270409773977622448850085",
"deposits": [
{
"amount": "129284.449",
@@ -44278,7 +44278,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "5778205.3912159303",
"total_removed": "2479228.813551817124120168",
"locked_amount": "1043077.038210560557981748676738499",
"locked_amount": "1040445.46843517541177374554941811",
"deposits": [
{
"amount": "552496.6455",
@@ -46074,7 +46074,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "472355.6199999996",
"total_removed": "27238.3679206278963",
"locked_amount": "206728.70780304521507469111821412",
"locked_amount": "206406.314907152309626154543277504",
"deposits": [
{
"amount": "3000",
@@ -74117,7 +74117,7 @@
"tranche_start": "2021-12-05T00:00:00.000Z",
"tranche_end": "2022-06-05T00:00:00.000Z",
"total_added": "171288.42",
"total_removed": "60531.9043909997989",
"total_removed": "60641.2093106172989",
"locked_amount": "0",
"deposits": [
{
@@ -78367,6 +78367,11 @@
"user": "0xe611723f968ED5735B3742ae721b4A2A6edB6758",
"tx": "0x940ac7457a2b8a9072a31ad871c5e4c0a343f302e0d9f76de99df369abe297fc"
},
{
"amount": "109.3049196175",
"user": "0x667B436A05523B8D80483b030f559f034753DD74",
"tx": "0x48d6761a237f75fa95ff67082e4f0b5538586a58a7a677943f1c4260f3abb860"
},
{
"amount": "250",
"user": "0x3E1CECDc3d15Cb03e91a60470C4453f4fBFc75F9",
@@ -87079,6 +87084,12 @@
}
],
"withdrawals": [
{
"amount": "109.3049196175",
"user": "0x667B436A05523B8D80483b030f559f034753DD74",
"tranche_id": 6,
"tx": "0x48d6761a237f75fa95ff67082e4f0b5538586a58a7a677943f1c4260f3abb860"
},
{
"amount": "140.6950803825",
"user": "0x667B436A05523B8D80483b030f559f034753DD74",
@@ -87087,8 +87098,8 @@
}
],
"total_tokens": "250",
"withdrawn_tokens": "140.6950803825",
"remaining_tokens": "109.3049196175"
"withdrawn_tokens": "250",
"remaining_tokens": "0"
},
{
"address": "0x036946f917076119Dc6a221F8ad587938CBf14d3",
@@ -96,7 +96,7 @@ describe('orders list', { tags: '@smoke' }, () => {
});
it('orders are sorted by most recent order', () => {
//7003-MORD-002
// 7003-MORD-002
const expectedOrderList = ['BTCUSD.MF21', 'BTCUSD.MF21'];
cy.getByTestId('tab-orders')
@@ -133,9 +133,9 @@ describe('subscribe orders', { tags: '@smoke' }, () => {
});
});
const orderId = '1234567890';
//7002-SORD-053
//7002-SORD-040
//7003-MORD-001
// 7002-SORD-053
// 7002-SORD-040
// 7003-MORD-001
it('must see an active order', () => {
// 7002-SORD-041
updateOrder({
@@ -224,6 +224,70 @@ describe('subscribe orders', { tags: '@smoke' }, () => {
cy.getByTestId(`order-status-${orderId}`).should('have.text', 'Parked');
});
it('must see the size of the order and direction/side -', () => {
// 7003-MORD-003
// 7003-MORD-004
updateOrder({
id: orderId,
size: '15',
side: Schema.Side.SIDE_SELL,
status: Schema.OrderStatus.STATUS_ACTIVE,
});
cy.get(`[row-id=${orderId}]`)
.find('[col-id="size"]')
.should('have.text', '-15');
});
it('must see the size of the order and direction/side +', () => {
// 7003-MORD-003
// 7003-MORD-004
updateOrder({
id: orderId,
size: '5',
side: Schema.Side.SIDE_BUY,
status: Schema.OrderStatus.STATUS_ACTIVE,
});
cy.get(`[row-id=${orderId}]`)
.find('[col-id="size"]')
.should('have.text', '+5');
});
it('for limit typy must see the Limit price that was set on the order', () => {
// 7003-MORD-005
updateOrder({
id: orderId,
status: Schema.OrderStatus.STATUS_ACTIVE,
});
cy.get(`[row-id=${orderId}]`)
.find('[col-id="price"]')
.should('have.text', '200.00');
});
it('for market typy must not see a price for active or parked orders', () => {
// 7003-MORD-005
updateOrder({
id: orderId,
type: Schema.OrderType.TYPE_MARKET,
status: Schema.OrderStatus.STATUS_PARKED,
});
cy.get(`[row-id=${orderId}]`)
.find('[col-id="price"]')
.should('have.text', '200.00');
});
it('must see the time in force applied to the order', () => {
// 7003-MORD-006
updateOrder({
id: orderId,
type: Schema.OrderType.TYPE_MARKET,
status: Schema.OrderStatus.STATUS_ACTIVE,
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
});
cy.get(`[row-id=${orderId}]`)
.find(`[col-id='${orderTimeInForce}']`)
.should('have.text', "Good 'til Cancelled (GTC)");
});
it('for Active order when is part of a liquidity or peg shape, must not see an option to amend the individual order ', () => {
// 7003-MORD-008
updateOrder({
@@ -288,9 +352,10 @@ describe('amend and cancel order', { tags: '@smoke' }, () => {
const orderId = '1234567890';
it('must be able to amend the price of an order', () => {
//7003-MORD-012
//7003-MORD-014
//7003-MORD-015
// 7003-MORD-007
// 7003-MORD-012
// 7003-MORD-014
// 7003-MORD-015
updateOrder({
id: orderId,
status: Schema.OrderStatus.STATUS_ACTIVE,
@@ -316,9 +381,10 @@ describe('amend and cancel order', { tags: '@smoke' }, () => {
});
});
it('must be able to cancel an individual order', () => {
//7003-MORD-009
//7003-MORD-010
//7003-MORD-011
// 7003-MORD-007
// 7003-MORD-009
// 7003-MORD-010
// 7003-MORD-011
updateOrder({
id: orderId,
status: Schema.OrderStatus.STATUS_ACTIVE,
@@ -40,11 +40,13 @@ const getBlockDisplayValue = (
return '-';
};
const getSslDisplayValue = (ssl?: NodeData['ssl']) => {
if (ssl?.value) {
const getSubscriptionDisplayValue = (
subscription?: NodeData['subscription']
) => {
if (subscription?.value) {
return t('Yes');
}
if (ssl?.hasError) {
if (subscription?.hasError) {
return t('No');
}
return '-';
@@ -81,12 +83,12 @@ const NodeStatsContent = ({
{getBlockDisplayValue(data.block, setBlock)}
</LayoutCell>
<LayoutCell
label={t('SSL')}
isLoading={data.ssl?.isLoading}
hasError={data.ssl?.hasError}
dataTestId="ssl-cell"
label={t('Subscription')}
isLoading={data.subscription?.isLoading}
hasError={data.subscription?.hasError}
dataTestId="subscription-cell"
>
{getSslDisplayValue(data.ssl)}
{getSubscriptionDisplayValue(data.subscription)}
</LayoutCell>
</LayoutRow>
);
@@ -10,7 +10,7 @@ import { getErrorByType } from '../../utils/validate-node';
import type { Configuration, NodeData } from '../../types';
import { Networks, ErrorType, CUSTOM_NODE_KEY } from '../../types';
type NodeDataProp = 'responseTime' | 'block' | 'chain' | 'ssl';
type NodeDataProp = 'responseTime' | 'block' | 'chain' | 'subscription';
jest.mock('../../hooks/use-environment');
jest.mock('../../hooks/use-nodes');
@@ -99,7 +99,7 @@ const getValidNodeState = (env: Networks, url: string) => ({
hasError: false,
value: 123,
},
ssl: {
subscription: {
isLoading: false,
hasError: false,
value: true,
@@ -203,8 +203,8 @@ describe('Node switcher', () => {
${'block'} | ${STATES.HAS_ERROR}
${'chain'} | ${STATES.LOADING}
${'chain'} | ${STATES.HAS_ERROR}
${'ssl'} | ${STATES.LOADING}
${'ssl'} | ${STATES.HAS_ERROR}
${'subscription'} | ${STATES.LOADING}
${'subscription'} | ${STATES.HAS_ERROR}
`(
'disables selecting a node when the $dataProp $state',
({ dataProp, state }: { dataProp: NodeDataProp; state: STATES }) => {
@@ -409,8 +409,8 @@ describe('Node switcher', () => {
${'block'} | ${STATES.HAS_ERROR}
${'chain'} | ${STATES.LOADING}
${'chain'} | ${STATES.HAS_ERROR}
${'ssl'} | ${STATES.LOADING}
${'ssl'} | ${STATES.HAS_ERROR}
${'subscription'} | ${STATES.LOADING}
${'subscription'} | ${STATES.HAS_ERROR}
`(
'disables selecting a custom node when the $dataProp $state',
({ dataProp, state }: { dataProp: NodeDataProp; state: STATES }) => {
@@ -494,7 +494,9 @@ describe('Node switcher', () => {
if (state === STATES.HAS_ERROR) {
const expectedErrorType =
dataProp === 'ssl' ? ErrorType.SSL_ERROR : ErrorType.CONNECTION_ERROR;
dataProp === 'subscription'
? ErrorType.SUBSCRIPTION_ERROR
: ErrorType.CONNECTION_ERROR;
const error = getErrorByType(
expectedErrorType,
Networks.TESTNET,
@@ -547,7 +549,7 @@ describe('Node switcher', () => {
it.each`
description | errorType
${'the node has an invalid url'} | ${ErrorType.INVALID_URL}
${'the node has an ssl issue'} | ${ErrorType.SSL_ERROR}
${'the node has a subscription issue'} | ${ErrorType.SUBSCRIPTION_ERROR}
${'the node cannot be reached'} | ${ErrorType.CONNECTION_ERROR}
${'none of the config nodes can be connected to'} | ${ErrorType.CONNECTION_ERROR_ALL}
${'the config cannot be loaded'} | ${ErrorType.CONFIG_LOAD_ERROR}
@@ -97,7 +97,7 @@ export const NodeSwitcher = ({
<div />
<span className="text-right">{t('Response time')}</span>
<span className="text-right">{t('Block')}</span>
<span className="text-right">{t('SSL')}</span>
<span className="text-right">{t('Subscription')}</span>
</LayoutRow>
</div>
<RadioGroup
@@ -503,7 +503,7 @@ describe('node selection', () => {
});
});
it('has a network error when the selected node has not ssl available', async () => {
it('has a network error when the selected node has not subscription available', async () => {
act(async () => {
// @ts-ignore allow adding a mock return value to mocked module
createClient.mockImplementation(() => {
@@ -517,7 +517,7 @@ describe('node selection', () => {
await waitFor(() => {
expect(result.current).toEqual({
...mockEnvironmentState,
networkError: ErrorType.SSL_ERROR,
networkError: ErrorType.SUBSCRIPTION_ERROR,
setNodeSwitcherOpen: result.current.setNodeSwitcherOpen,
});
});
@@ -24,7 +24,7 @@ const initialState = {
hasError: false,
value: undefined,
},
ssl: {
subscription: {
isLoading: false,
hasError: false,
value: undefined,
@@ -84,8 +84,8 @@ describe('useNodes hook', () => {
...initialState.chain,
isLoading: true,
},
ssl: {
...initialState.ssl,
subscription: {
...initialState.subscription,
isLoading: true,
},
});
@@ -122,7 +122,7 @@ describe('useNodes hook', () => {
const { result } = renderHook(() => useNodes({ hosts: [node] }));
await waitFor(() => {
expect(result.current.state[node].ssl).toEqual({
expect(result.current.state[node].subscription).toEqual({
isLoading: false,
hasError: false,
value: true,
@@ -182,7 +182,7 @@ describe('useNodes hook', () => {
const { result } = renderHook(() => useNodes({ hosts: [node] }));
await waitFor(() => {
expect(result.current.state[node].ssl).toEqual({
expect(result.current.state[node].subscription).toEqual({
isLoading: false,
hasError: true,
value: undefined,
@@ -273,7 +273,7 @@ describe('useNodes hook', () => {
expect(result.current.state[node].block.hasError).toBe(true);
expect(result.current.state[node].chain.hasError).toBe(true);
expect(result.current.state[node].responseTime.hasError).toBe(true);
expect(result.current.state[node].ssl.hasError).toBe(true);
expect(result.current.state[node].subscription.hasError).toBe(true);
});
});
@@ -331,7 +331,7 @@ describe('useNodes hook', () => {
});
await waitFor(() => {
expect(result.current.state[node].ssl).toEqual({
expect(result.current.state[node].subscription).toEqual({
isLoading: false,
hasError: true,
value: undefined,
+4 -4
View File
@@ -61,7 +61,7 @@ const getNodeData = (url?: string): NodeData => ({
initialized: false,
responseTime: withData(),
block: withData(),
ssl: withData(),
subscription: withData(),
chain: withData(),
});
@@ -141,18 +141,18 @@ const reducer = (state: Record<string, NodeData>, action: Action) => {
state[action.node] = getNodeData(action.payload?.url);
}
state[action.node].url = action.payload?.url ?? '';
state[action.node].ssl.isLoading = true;
state[action.node].subscription.isLoading = true;
state[action.node].initialized = true;
});
case ACTIONS.CHECK_SUBSCRIPTION_SUCCESS:
return produce(state, (state) => {
if (!state[action.node]) return;
state[action.node].ssl = withData(true);
state[action.node].subscription = withData(true);
});
case ACTIONS.CHECK_SUBSCRIPTION_FAILURE:
return produce(state, (state) => {
if (!state[action.node]) return;
state[action.node].ssl = withError();
state[action.node].subscription = withError();
});
case ACTIONS.ADD_NODE:
return produce(state, (state) => {
+2 -2
View File
@@ -10,7 +10,7 @@ export const CUSTOM_NODE_KEY = 'custom';
export enum ErrorType {
INVALID_URL,
SSL_ERROR,
SUBSCRIPTION_ERROR,
CONNECTION_ERROR,
CONNECTION_ERROR_ALL,
CONFIG_LOAD_ERROR,
@@ -37,7 +37,7 @@ type NodeCheck<T> = {
export type NodeData = {
url: string;
initialized: boolean;
ssl: NodeCheck<boolean>;
subscription: NodeCheck<boolean>;
block: NodeCheck<number>;
responseTime: NodeCheck<number>;
chain: NodeCheck<string>;
+7 -7
View File
@@ -8,7 +8,7 @@ export const getIsNodeLoading = (node?: NodeData): boolean => {
node.chain.isLoading ||
node.responseTime.isLoading ||
node.block.isLoading ||
node.ssl.isLoading
node.subscription.isLoading
);
};
@@ -29,7 +29,7 @@ export const getIsNodeDisabled = (env: Networks, data?: NodeData) => {
data.chain.hasError ||
data.responseTime.hasError ||
data.block.hasError ||
data.ssl.hasError)
data.subscription.hasError)
);
};
@@ -57,12 +57,12 @@ export const getErrorByType = (
headline: t('Error: invalid url'),
message: t(url ? `${url} is not a valid url.` : ''),
};
case ErrorType.SSL_ERROR:
case ErrorType.SUBSCRIPTION_ERROR:
return {
headline: t(`Error: the node you are reading from does not have SSL`),
headline: t(`Error: the node you are reading from does not emit data`),
message: t(
url
? `${url} does not have SSL. SSL is required to subscribe to data.`
? `${url} is required to have subscriptions working to enable data updates on the page.`
: ''
),
};
@@ -112,8 +112,8 @@ export const getErrorType = (env: Networks, data?: NodeData) => {
return ErrorType.CONNECTION_ERROR;
}
if (data.ssl.hasError) {
return ErrorType.SSL_ERROR;
if (data.subscription.hasError) {
return ErrorType.SUBSCRIPTION_ERROR;
}
}