Skip to content

Commit

Permalink
test: ✅ Add temp interface to fix services/addresses prop
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoval committed Dec 27, 2024
1 parent 4f40b3d commit 13a862c
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 27 deletions.
4 changes: 2 additions & 2 deletions __tests__/MetricLatency.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/MetricRequest.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/MetricTcpConnection.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/MetricTraffic.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/Process.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/ProcessDetails.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}` });

Expand Down
3 changes: 2 additions & 1 deletion __tests__/ProcessPairsList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions __tests__/Response.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/Services.services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
5 changes: 3 additions & 2 deletions __tests__/Site.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}` });

Expand Down
5 changes: 3 additions & 2 deletions __tests__/TopologyDetails.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
5 changes: 3 additions & 2 deletions __tests__/TopologyProcesses.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand Down
8 changes: 6 additions & 2 deletions mocks/server.API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SiteResponse>('SITES');
const components = loadData<ComponentResponse>('COMPONENTS');
const componentPairs = loadData<PairsResponse>('COMPONENT_PAIRS');
const processes = loadData<ProcessResponse>('PROCESSES');
const processes = loadData<extendedProcessResponse>('PROCESSES');
const sitePairs = loadData<PairsResponse>('SITE_PAIRS');
const processPairs = loadData<ProcessPairsResponse>('PROCESS_PAIRS');
const services = loadData<ServiceResponse>('SERVICES');
Expand Down Expand Up @@ -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];

Expand Down
1 change: 1 addition & 0 deletions src/types/REST.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export interface ConnectorResponse extends BaseResponse {
siteId: string;
processes?: ConnectorResponse[];
}

export interface ServiceResponse extends BaseResponse {
name: string;
protocol: Protocols;
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}

0 comments on commit 13a862c

Please sign in to comment.