diff --git a/__tests__/MetricLatency.spec.tsx b/__tests__/MetricLatency.spec.tsx index ff0be754..c8cec11a 100644 --- a/__tests__/MetricLatency.spec.tsx +++ b/__tests__/MetricLatency.spec.tsx @@ -12,9 +12,9 @@ import LoadingPage from '../src/core/components/SkLoading'; import { Providers } from '../src/providers'; import Latency from '../src/pages/shared/Metrics/components/Latency'; import { Labels } from '../src/config/labels'; -import { ProcessResponse } from '../src/types/REST.interfaces'; +import { extendedProcessResponse } from '../mocks/server.API'; -const processResult = processesData.results[0] as ProcessResponse; +const processResult = processesData.results[0] as extendedProcessResponse; describe('Latency component', () => { let server: Server; diff --git a/__tests__/MetricRequest.spec.tsx b/__tests__/MetricRequest.spec.tsx index d47a8011..5e6e2950 100644 --- a/__tests__/MetricRequest.spec.tsx +++ b/__tests__/MetricRequest.spec.tsx @@ -12,9 +12,9 @@ import LoadingPage from '../src/core/components/SkLoading'; import { Providers } from '../src/providers'; import Request from '../src/pages/shared/Metrics/components/Request'; import { Labels } from '../src/config/labels'; -import { ProcessResponse } from '../src/types/REST.interfaces'; +import { extendedProcessResponse } from '../mocks/server.API'; -const processResult = processesData.results[0] as ProcessResponse; +const processResult = processesData.results[0] as extendedProcessResponse; describe('Request component', () => { let server: Server; diff --git a/__tests__/MetricTcpConnection.spec.tsx b/__tests__/MetricTcpConnection.spec.tsx index 6d1cc25f..2c694c95 100644 --- a/__tests__/MetricTcpConnection.spec.tsx +++ b/__tests__/MetricTcpConnection.spec.tsx @@ -12,9 +12,9 @@ import LoadingPage from '../src/core/components/SkLoading'; import { Providers } from '../src/providers'; import TcpConnection from '../src/pages/shared/Metrics/components/TcpConnection'; import { Labels } from '../src/config/labels'; -import { ProcessResponse } from '../src/types/REST.interfaces'; +import { extendedProcessResponse } from '../mocks/server.API'; -const processResult = processesData.results[0] as ProcessResponse; +const processResult = processesData.results[0] as extendedProcessResponse; describe('Tcp component', () => { let server: Server; diff --git a/__tests__/MetricTraffic.spec.tsx b/__tests__/MetricTraffic.spec.tsx index 4feee792..1c6b0f05 100644 --- a/__tests__/MetricTraffic.spec.tsx +++ b/__tests__/MetricTraffic.spec.tsx @@ -12,9 +12,9 @@ import { Providers } from '../src/providers'; import Traffic from '../src/pages/shared/Metrics/components/Traffic'; import { Labels } from '../src/config/labels'; import * as MetricsModule from '../src/pages/shared/Metrics/services/index'; -import { ProcessResponse } from '../src/types/REST.interfaces'; +import { extendedProcessResponse } from '../mocks/server.API'; -const processResult = processesData.results[0] as ProcessResponse; +const processResult = processesData.results[0] as extendedProcessResponse; describe('Traffic component', () => { let server: Server; diff --git a/__tests__/Process.spec.tsx b/__tests__/Process.spec.tsx index e4268fd6..06eaa180 100644 --- a/__tests__/Process.spec.tsx +++ b/__tests__/Process.spec.tsx @@ -11,10 +11,10 @@ import { getTestsIds } from '../src/config/testIds'; import LoadingPage from '../src/core/components/SkLoading'; import { Providers } from '../src/providers'; import Process from '../src/pages/Processes/views/Process'; -import { ProcessResponse } from '../src/types/REST.interfaces'; import { Labels } from '../src/config/labels'; +import { extendedProcessResponse } from '../mocks/server.API'; -const processResult = processesData.results[0] as ProcessResponse; +const processResult = processesData.results[0] as extendedProcessResponse; describe('Process component', () => { let server: Server; diff --git a/__tests__/ProcessDetails.spec.tsx b/__tests__/ProcessDetails.spec.tsx index fde0fae0..6a16b7c4 100644 --- a/__tests__/ProcessDetails.spec.tsx +++ b/__tests__/ProcessDetails.spec.tsx @@ -8,10 +8,10 @@ import { loadMockServer } from '../mocks/server'; import LoadingPage from '../src/core/components/SkLoading'; import { Providers } from '../src/providers'; import Details from '../src/pages/Processes/components/Details'; -import { ProcessResponse } from '../src/types/REST.interfaces'; import { setMockUseParams } from '../jest.mock.router'; +import { extendedProcessResponse } from '../mocks/server.API'; -const processResult = processesData.results[0] as ProcessResponse; +const processResult = processesData.results[0] as extendedProcessResponse; setMockUseParams({ id: `${processResult.name}@${processResult.identity}` }); diff --git a/__tests__/ProcessPairsList.spec.tsx b/__tests__/ProcessPairsList.spec.tsx index 04526bc8..f4eec4c8 100644 --- a/__tests__/ProcessPairsList.spec.tsx +++ b/__tests__/ProcessPairsList.spec.tsx @@ -15,8 +15,9 @@ import PairsList from '../src/pages/Processes/components/PairsList'; import { ProcessesRoutesPaths } from '../src/pages/Processes/Processes.enum'; import { ProcessResponse, PairsResponse } from '../src/types/REST.interfaces'; import { Labels } from '../src/config/labels'; +import { extendedProcessResponse } from '../mocks/server.API'; -const data = processesData.results[0] as ProcessResponse; +const data = processesData.results[0] as extendedProcessResponse; const dataNoPairs = { endTime: 0, identity: 'no-pairs', diff --git a/__tests__/Response.spec.tsx b/__tests__/Response.spec.tsx index 5b212191..d8e2345a 100644 --- a/__tests__/Response.spec.tsx +++ b/__tests__/Response.spec.tsx @@ -12,9 +12,9 @@ import LoadingPage from '../src/core/components/SkLoading'; import { Providers } from '../src/providers'; import Response from '../src/pages/shared/Metrics/components/Response'; import { Labels } from '../src/config/labels'; -import { ProcessResponse } from '../src/types/REST.interfaces'; +import { extendedProcessResponse } from '../mocks/server.API'; -const processResult = processesData.results[0] as ProcessResponse; +const processResult = processesData.results[0] as extendedProcessResponse; describe('Response component', () => { let server: Server; diff --git a/__tests__/Services.services.spec.ts b/__tests__/Services.services.spec.ts index d490be7a..1ab1ef24 100644 --- a/__tests__/Services.services.spec.ts +++ b/__tests__/Services.services.spec.ts @@ -6,8 +6,8 @@ import { DEFAULT_SANKEY_CHART_FLOW_VALUE } from '../src/core/components/SKSancke import connectorsData from '../mocks/data/CONNECTORS.json'; import listenersData from '../mocks/data/LISTENERS.json'; -const connectorResults = connectorsData.results as ConnectorResponse[]; -const listenerResults = listenersData.results as ListenerResponse[]; +const connectorResults = connectorsData.results as any[]; +const listenerResults = listenersData.results as any[]; describe('ServicesController', () => { describe('convertPairsToSankeyChartData', () => { diff --git a/__tests__/Site.spec.tsx b/__tests__/Site.spec.tsx index 1f06cbeb..3ec9ad23 100644 --- a/__tests__/Site.spec.tsx +++ b/__tests__/Site.spec.tsx @@ -12,12 +12,13 @@ import LoadingPage from '../src/core/components/SkLoading'; import { Providers } from '../src/providers'; import { ProcessesRoutesPaths } from '../src/pages/Processes/Processes.enum'; import Site from '../src/pages/Sites/views/Site'; -import { ProcessResponse, SiteResponse } from '../src/types/REST.interfaces'; +import { SiteResponse } from '../src/types/REST.interfaces'; import { setMockUseParams } from '../jest.mock.router'; import { Labels } from '../src/config/labels'; +import { extendedProcessResponse } from '../mocks/server.API'; const siteResults = sitesData.results as SiteResponse[]; -const processResults = processesData.results as ProcessResponse[]; +const processResults = processesData.results as extendedProcessResponse[]; setMockUseParams({ id: `${siteResults[0].name}@${siteResults[0].identity}` }); diff --git a/__tests__/TopologyDetails.spec.tsx b/__tests__/TopologyDetails.spec.tsx index 282b82fe..06b33ef0 100644 --- a/__tests__/TopologyDetails.spec.tsx +++ b/__tests__/TopologyDetails.spec.tsx @@ -6,11 +6,12 @@ import processesData from '../mocks/data/PROCESSES.json'; import { loadMockServer } from '../mocks/server'; import { Providers } from '../src/providers'; import TopologyDetails from '../src/pages/Topology/components/TopologyDetails'; -import { ProcessPairsResponse, ProcessResponse } from '../src/types/REST.interfaces'; +import { ProcessPairsResponse } from '../src/types/REST.interfaces'; import { DEFAULT_COMPLEX_STRING_SEPARATOR } from '../src/config/app'; import { mapResponseProperties } from '../src/API/REST.utils'; +import { extendedProcessResponse } from '../mocks/server.API'; -const processesResults = mapResponseProperties(processesData.results, 'toFrontend') as ProcessResponse[]; +const processesResults = mapResponseProperties(processesData.results, 'toFrontend') as extendedProcessResponse[]; const processPairsResults = processesPairsData.results as ProcessPairsResponse[]; describe('Topology details', () => { diff --git a/__tests__/TopologyProcesses.spec.tsx b/__tests__/TopologyProcesses.spec.tsx index bd18da71..22b70c95 100644 --- a/__tests__/TopologyProcesses.spec.tsx +++ b/__tests__/TopologyProcesses.spec.tsx @@ -20,10 +20,11 @@ import * as useTopologyState from '../src/pages/Topology/hooks/useTopologyState' import { TopologyController } from '../src/pages/Topology/services'; import { convertProcessToNode } from '../src/pages/Topology/services/topologyProcessController'; import { SkGraphProps } from '../src/types/Graph.interfaces'; -import { ProcessPairsResponse, ProcessResponse, ServiceResponse } from '../src/types/REST.interfaces'; +import { ProcessPairsResponse, ServiceResponse } from '../src/types/REST.interfaces'; import { Labels } from '../src/config/labels'; +import { extendedProcessResponse } from '../mocks/server.API'; -const processesResults = processesData.results as ProcessResponse[]; +const processesResults = processesData.results as extendedProcessResponse[]; const processesPairsResults = processesPairsData.results as ProcessPairsResponse[]; const serviceResults = servicesData.results as ServiceResponse[]; diff --git a/mocks/server.API.ts b/mocks/server.API.ts index d7da2cc0..d9247e22 100644 --- a/mocks/server.API.ts +++ b/mocks/server.API.ts @@ -22,13 +22,17 @@ interface ApiProps { url?: string; } +export interface extendedProcessResponse extends ProcessResponse { + addresses: string[]; // TODO: we are changing naming convention from addresses to services. This type is a temporal bridge +} + const ITEM_COUNT = Number(process.env.MOCK_ITEM_COUNT) || 0; // Mock data setup const sites = loadData('SITES'); const components = loadData('COMPONENTS'); const componentPairs = loadData('COMPONENT_PAIRS'); -const processes = loadData('PROCESSES'); +const processes = loadData('PROCESSES'); const sitePairs = loadData('SITE_PAIRS'); const processPairs = loadData('PROCESS_PAIRS'); const services = loadData('SERVICES'); @@ -347,7 +351,7 @@ for (let i = 0; i < ITEM_COUNT; i++) { }); } -const mockProcessesForPerf: ProcessResponse[] = []; +const mockProcessesForPerf: extendedProcessResponse[] = []; for (let i = 0; i < ITEM_COUNT; i++) { const process = processes.results[i % processes.results.length]; diff --git a/src/types/REST.interfaces.ts b/src/types/REST.interfaces.ts index 32d8ea4c..00847b38 100644 --- a/src/types/REST.interfaces.ts +++ b/src/types/REST.interfaces.ts @@ -144,6 +144,7 @@ export interface ConnectorResponse extends BaseResponse { siteId: string; processes?: ConnectorResponse[]; } + export interface ServiceResponse extends BaseResponse { name: string; protocol: Protocols; diff --git a/tsconfig.json b/tsconfig.json index 155b2ada..d408c97d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -71,9 +71,9 @@ }, // Include the following directories for type-checking and compiling - "include": ["src", "jest.config.ts"], + "include": ["src", "__tests__", "jest.config.ts"], // Exclude unnecessary directories like build and node_modules from type-checking // Cypress config is excluded due to a known issue: https://github.com/cypress-io/cypress/issues/22059 - "exclude": ["node_modules", "build", "cypress.config.ts", "__tests__", "mocks"] + "exclude": ["node_modules", "build", "cypress.config.ts"] }