fix: env ssl to subscription (#2440)
* fix: rename ssl environment check to subscription * fix: format
This commit is contained in:
parent
28fe7458ca
commit
2217925285
@ -40,11 +40,13 @@ const getBlockDisplayValue = (
|
|||||||
return '-';
|
return '-';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSslDisplayValue = (ssl?: NodeData['ssl']) => {
|
const getSubscriptionDisplayValue = (
|
||||||
if (ssl?.value) {
|
subscription?: NodeData['subscription']
|
||||||
|
) => {
|
||||||
|
if (subscription?.value) {
|
||||||
return t('Yes');
|
return t('Yes');
|
||||||
}
|
}
|
||||||
if (ssl?.hasError) {
|
if (subscription?.hasError) {
|
||||||
return t('No');
|
return t('No');
|
||||||
}
|
}
|
||||||
return '-';
|
return '-';
|
||||||
@ -81,12 +83,12 @@ const NodeStatsContent = ({
|
|||||||
{getBlockDisplayValue(data.block, setBlock)}
|
{getBlockDisplayValue(data.block, setBlock)}
|
||||||
</LayoutCell>
|
</LayoutCell>
|
||||||
<LayoutCell
|
<LayoutCell
|
||||||
label={t('SSL')}
|
label={t('Subscription')}
|
||||||
isLoading={data.ssl?.isLoading}
|
isLoading={data.subscription?.isLoading}
|
||||||
hasError={data.ssl?.hasError}
|
hasError={data.subscription?.hasError}
|
||||||
dataTestId="ssl-cell"
|
dataTestId="subscription-cell"
|
||||||
>
|
>
|
||||||
{getSslDisplayValue(data.ssl)}
|
{getSubscriptionDisplayValue(data.subscription)}
|
||||||
</LayoutCell>
|
</LayoutCell>
|
||||||
</LayoutRow>
|
</LayoutRow>
|
||||||
);
|
);
|
||||||
|
@ -10,7 +10,7 @@ import { getErrorByType } from '../../utils/validate-node';
|
|||||||
import type { Configuration, NodeData } from '../../types';
|
import type { Configuration, NodeData } from '../../types';
|
||||||
import { Networks, ErrorType, CUSTOM_NODE_KEY } 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-environment');
|
||||||
jest.mock('../../hooks/use-nodes');
|
jest.mock('../../hooks/use-nodes');
|
||||||
@ -99,7 +99,7 @@ const getValidNodeState = (env: Networks, url: string) => ({
|
|||||||
hasError: false,
|
hasError: false,
|
||||||
value: 123,
|
value: 123,
|
||||||
},
|
},
|
||||||
ssl: {
|
subscription: {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasError: false,
|
hasError: false,
|
||||||
value: true,
|
value: true,
|
||||||
@ -203,8 +203,8 @@ describe('Node switcher', () => {
|
|||||||
${'block'} | ${STATES.HAS_ERROR}
|
${'block'} | ${STATES.HAS_ERROR}
|
||||||
${'chain'} | ${STATES.LOADING}
|
${'chain'} | ${STATES.LOADING}
|
||||||
${'chain'} | ${STATES.HAS_ERROR}
|
${'chain'} | ${STATES.HAS_ERROR}
|
||||||
${'ssl'} | ${STATES.LOADING}
|
${'subscription'} | ${STATES.LOADING}
|
||||||
${'ssl'} | ${STATES.HAS_ERROR}
|
${'subscription'} | ${STATES.HAS_ERROR}
|
||||||
`(
|
`(
|
||||||
'disables selecting a node when the $dataProp $state',
|
'disables selecting a node when the $dataProp $state',
|
||||||
({ dataProp, state }: { dataProp: NodeDataProp; state: STATES }) => {
|
({ dataProp, state }: { dataProp: NodeDataProp; state: STATES }) => {
|
||||||
@ -409,8 +409,8 @@ describe('Node switcher', () => {
|
|||||||
${'block'} | ${STATES.HAS_ERROR}
|
${'block'} | ${STATES.HAS_ERROR}
|
||||||
${'chain'} | ${STATES.LOADING}
|
${'chain'} | ${STATES.LOADING}
|
||||||
${'chain'} | ${STATES.HAS_ERROR}
|
${'chain'} | ${STATES.HAS_ERROR}
|
||||||
${'ssl'} | ${STATES.LOADING}
|
${'subscription'} | ${STATES.LOADING}
|
||||||
${'ssl'} | ${STATES.HAS_ERROR}
|
${'subscription'} | ${STATES.HAS_ERROR}
|
||||||
`(
|
`(
|
||||||
'disables selecting a custom node when the $dataProp $state',
|
'disables selecting a custom node when the $dataProp $state',
|
||||||
({ dataProp, state }: { dataProp: NodeDataProp; state: STATES }) => {
|
({ dataProp, state }: { dataProp: NodeDataProp; state: STATES }) => {
|
||||||
@ -494,7 +494,9 @@ describe('Node switcher', () => {
|
|||||||
|
|
||||||
if (state === STATES.HAS_ERROR) {
|
if (state === STATES.HAS_ERROR) {
|
||||||
const expectedErrorType =
|
const expectedErrorType =
|
||||||
dataProp === 'ssl' ? ErrorType.SSL_ERROR : ErrorType.CONNECTION_ERROR;
|
dataProp === 'subscription'
|
||||||
|
? ErrorType.SUBSCRIPTION_ERROR
|
||||||
|
: ErrorType.CONNECTION_ERROR;
|
||||||
const error = getErrorByType(
|
const error = getErrorByType(
|
||||||
expectedErrorType,
|
expectedErrorType,
|
||||||
Networks.TESTNET,
|
Networks.TESTNET,
|
||||||
@ -547,7 +549,7 @@ describe('Node switcher', () => {
|
|||||||
it.each`
|
it.each`
|
||||||
description | errorType
|
description | errorType
|
||||||
${'the node has an invalid url'} | ${ErrorType.INVALID_URL}
|
${'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}
|
${'the node cannot be reached'} | ${ErrorType.CONNECTION_ERROR}
|
||||||
${'none of the config nodes can be connected to'} | ${ErrorType.CONNECTION_ERROR_ALL}
|
${'none of the config nodes can be connected to'} | ${ErrorType.CONNECTION_ERROR_ALL}
|
||||||
${'the config cannot be loaded'} | ${ErrorType.CONFIG_LOAD_ERROR}
|
${'the config cannot be loaded'} | ${ErrorType.CONFIG_LOAD_ERROR}
|
||||||
|
@ -97,7 +97,7 @@ export const NodeSwitcher = ({
|
|||||||
<div />
|
<div />
|
||||||
<span className="text-right">{t('Response time')}</span>
|
<span className="text-right">{t('Response time')}</span>
|
||||||
<span className="text-right">{t('Block')}</span>
|
<span className="text-right">{t('Block')}</span>
|
||||||
<span className="text-right">{t('SSL')}</span>
|
<span className="text-right">{t('Subscription')}</span>
|
||||||
</LayoutRow>
|
</LayoutRow>
|
||||||
</div>
|
</div>
|
||||||
<RadioGroup
|
<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 () => {
|
act(async () => {
|
||||||
// @ts-ignore allow adding a mock return value to mocked module
|
// @ts-ignore allow adding a mock return value to mocked module
|
||||||
createClient.mockImplementation(() => {
|
createClient.mockImplementation(() => {
|
||||||
@ -517,7 +517,7 @@ describe('node selection', () => {
|
|||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(result.current).toEqual({
|
expect(result.current).toEqual({
|
||||||
...mockEnvironmentState,
|
...mockEnvironmentState,
|
||||||
networkError: ErrorType.SSL_ERROR,
|
networkError: ErrorType.SUBSCRIPTION_ERROR,
|
||||||
setNodeSwitcherOpen: result.current.setNodeSwitcherOpen,
|
setNodeSwitcherOpen: result.current.setNodeSwitcherOpen,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -24,7 +24,7 @@ const initialState = {
|
|||||||
hasError: false,
|
hasError: false,
|
||||||
value: undefined,
|
value: undefined,
|
||||||
},
|
},
|
||||||
ssl: {
|
subscription: {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasError: false,
|
hasError: false,
|
||||||
value: undefined,
|
value: undefined,
|
||||||
@ -84,8 +84,8 @@ describe('useNodes hook', () => {
|
|||||||
...initialState.chain,
|
...initialState.chain,
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
},
|
},
|
||||||
ssl: {
|
subscription: {
|
||||||
...initialState.ssl,
|
...initialState.subscription,
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -122,7 +122,7 @@ describe('useNodes hook', () => {
|
|||||||
const { result } = renderHook(() => useNodes({ hosts: [node] }));
|
const { result } = renderHook(() => useNodes({ hosts: [node] }));
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(result.current.state[node].ssl).toEqual({
|
expect(result.current.state[node].subscription).toEqual({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasError: false,
|
hasError: false,
|
||||||
value: true,
|
value: true,
|
||||||
@ -182,7 +182,7 @@ describe('useNodes hook', () => {
|
|||||||
const { result } = renderHook(() => useNodes({ hosts: [node] }));
|
const { result } = renderHook(() => useNodes({ hosts: [node] }));
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(result.current.state[node].ssl).toEqual({
|
expect(result.current.state[node].subscription).toEqual({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasError: true,
|
hasError: true,
|
||||||
value: undefined,
|
value: undefined,
|
||||||
@ -273,7 +273,7 @@ describe('useNodes hook', () => {
|
|||||||
expect(result.current.state[node].block.hasError).toBe(true);
|
expect(result.current.state[node].block.hasError).toBe(true);
|
||||||
expect(result.current.state[node].chain.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].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(() => {
|
await waitFor(() => {
|
||||||
expect(result.current.state[node].ssl).toEqual({
|
expect(result.current.state[node].subscription).toEqual({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasError: true,
|
hasError: true,
|
||||||
value: undefined,
|
value: undefined,
|
||||||
|
@ -61,7 +61,7 @@ const getNodeData = (url?: string): NodeData => ({
|
|||||||
initialized: false,
|
initialized: false,
|
||||||
responseTime: withData(),
|
responseTime: withData(),
|
||||||
block: withData(),
|
block: withData(),
|
||||||
ssl: withData(),
|
subscription: withData(),
|
||||||
chain: 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] = getNodeData(action.payload?.url);
|
||||||
}
|
}
|
||||||
state[action.node].url = 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;
|
state[action.node].initialized = true;
|
||||||
});
|
});
|
||||||
case ACTIONS.CHECK_SUBSCRIPTION_SUCCESS:
|
case ACTIONS.CHECK_SUBSCRIPTION_SUCCESS:
|
||||||
return produce(state, (state) => {
|
return produce(state, (state) => {
|
||||||
if (!state[action.node]) return;
|
if (!state[action.node]) return;
|
||||||
state[action.node].ssl = withData(true);
|
state[action.node].subscription = withData(true);
|
||||||
});
|
});
|
||||||
case ACTIONS.CHECK_SUBSCRIPTION_FAILURE:
|
case ACTIONS.CHECK_SUBSCRIPTION_FAILURE:
|
||||||
return produce(state, (state) => {
|
return produce(state, (state) => {
|
||||||
if (!state[action.node]) return;
|
if (!state[action.node]) return;
|
||||||
state[action.node].ssl = withError();
|
state[action.node].subscription = withError();
|
||||||
});
|
});
|
||||||
case ACTIONS.ADD_NODE:
|
case ACTIONS.ADD_NODE:
|
||||||
return produce(state, (state) => {
|
return produce(state, (state) => {
|
||||||
|
@ -10,7 +10,7 @@ export const CUSTOM_NODE_KEY = 'custom';
|
|||||||
|
|
||||||
export enum ErrorType {
|
export enum ErrorType {
|
||||||
INVALID_URL,
|
INVALID_URL,
|
||||||
SSL_ERROR,
|
SUBSCRIPTION_ERROR,
|
||||||
CONNECTION_ERROR,
|
CONNECTION_ERROR,
|
||||||
CONNECTION_ERROR_ALL,
|
CONNECTION_ERROR_ALL,
|
||||||
CONFIG_LOAD_ERROR,
|
CONFIG_LOAD_ERROR,
|
||||||
@ -37,7 +37,7 @@ type NodeCheck<T> = {
|
|||||||
export type NodeData = {
|
export type NodeData = {
|
||||||
url: string;
|
url: string;
|
||||||
initialized: boolean;
|
initialized: boolean;
|
||||||
ssl: NodeCheck<boolean>;
|
subscription: NodeCheck<boolean>;
|
||||||
block: NodeCheck<number>;
|
block: NodeCheck<number>;
|
||||||
responseTime: NodeCheck<number>;
|
responseTime: NodeCheck<number>;
|
||||||
chain: NodeCheck<string>;
|
chain: NodeCheck<string>;
|
||||||
|
@ -8,7 +8,7 @@ export const getIsNodeLoading = (node?: NodeData): boolean => {
|
|||||||
node.chain.isLoading ||
|
node.chain.isLoading ||
|
||||||
node.responseTime.isLoading ||
|
node.responseTime.isLoading ||
|
||||||
node.block.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.chain.hasError ||
|
||||||
data.responseTime.hasError ||
|
data.responseTime.hasError ||
|
||||||
data.block.hasError ||
|
data.block.hasError ||
|
||||||
data.ssl.hasError)
|
data.subscription.hasError)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,12 +57,12 @@ export const getErrorByType = (
|
|||||||
headline: t('Error: invalid url'),
|
headline: t('Error: invalid url'),
|
||||||
message: t(url ? `${url} is not a valid url.` : ''),
|
message: t(url ? `${url} is not a valid url.` : ''),
|
||||||
};
|
};
|
||||||
case ErrorType.SSL_ERROR:
|
case ErrorType.SUBSCRIPTION_ERROR:
|
||||||
return {
|
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(
|
message: t(
|
||||||
url
|
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;
|
return ErrorType.CONNECTION_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.ssl.hasError) {
|
if (data.subscription.hasError) {
|
||||||
return ErrorType.SSL_ERROR;
|
return ErrorType.SUBSCRIPTION_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user