/* * Copyright 2020 EPAM Systems * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import React, { useMemo } from "react"; import { Icons, Legend, Stub, Table, useTableActionsState, Cells, Tooltip, LinkButton, } from "@drill4j/ui-kit"; import { Link } from "react-router-dom"; import { capitalize } from "@drill4j/common-utils"; import { FilterList } from "@drill4j/types-admin"; import "twin.macro"; import { getModalPath, DATA_VISUALIZATION_COLORS } from "common"; import { TestsStatus } from "components"; import { TestCoverageInfo } from "types/test-coverage-info"; import { BuildSummary } from "types/build-summary"; import { TestsInfo } from "types/tests-info"; import { ParentBuild } from "types/parent-build"; import { transformTests } from "utils"; import { useFilteredData, useAgentRouteParams, useTestToCodeRouteParams, useActiveBuild, useTestToCodeData, } from "hooks"; import { TestsToRunSummary } from "types/tests-to-run-summary"; import { TestsToRunHeader } from "./tests-to-run-header"; import { BarChart } from "./bar-chart"; interface Props { agentType?: string; } export const TestsToRun = ({ agentType = "Agent" }: Props) => { const { search } = useTableActionsState(); const { items: testsToRun = [], } = useFilteredData>("/build/tests-to-run", { filters: search, output: "LIST" }) || {}; const { agentId } = useAgentRouteParams(); const { buildVersion } = useTestToCodeRouteParams(); const { buildVersion: activeBuildVersion = "" } = useActiveBuild(agentId) || {}; const { version: previousBuildVersion = "" } = useTestToCodeData("/data/parent") || {}; const summaryTestsToRun = useFilteredData("/build/summary/tests-to-run") || {}; const { tests: previousBuildTests = [], testDuration: totalDuration = 1 } = useFilteredData( "/build/summary", { buildVersion: previousBuildVersion }, ) || {}; const { AUTO } = previousBuildTests .reduce((test, testType) => ({ ...test, [testType.type]: testType }), {}) as TestsInfo; const previousBuildAutoTestsCount = AUTO?.summary?.testCount || 0; const tableStub = useMemo(() => (testsToRun.length > 0 ? ( } title="No results found" message="Try adjusting your search or filter to find what you are looking for." /> ) : ( } title="No suggested tests" message="There is no information about the suggested to run tests in this build." /> )), [testsToRun.length]); // It need because test that don`t run can have the same (0) percentage & duration & covered methods count with done tests // And tests that weren`t run should be in the start of table when we sorting DESC const tableData = useMemo(() => transformTests(testsToRun).map((test) => { if (test.toRun) { return { ...test, coverage: { percentage: -1, methodCount: { covered: -1 } }, overview: { ...test.overview, duration: -1 }, }; } return test; }), [testsToRun]); return ( <>
saved time history
{previousBuildAutoTestsCount ? ( ) : ( } title="No data about saved time" message="There is no information about Auto Tests duration in the parent build." /> )}
( <> {capitalize(value)} ), textAlign: "left", width: "120px", }, { Header: "Status", accessor: "overview.result", Cell: ({ value, row: { original: { toRun } } }: any) => ( {toRun ? To run : } ), textAlign: "left", width: "101px", }, { Header: "Coverage, %", accessor: "coverage.percentage", Cell: ({ value, row: { original: { toRun } } }: any) => ( toRun ? ( Will be available after the test run )} > – ) : ), sortType: "number", width: "115px", }, { Header: "Duration", accessor: "overview.duration", Cell: ({ value, row: { original: { toRun } } }: any) => (toRun ? ( Will be available after the test run )} > – ) : ), sortType: "number", width: "104px", }, { Header: "Methods covered", accessor: "coverage.methodCount.covered", Cell: ({ value, row: { original: { id = "", toRun = false, coverage: { methodCount: { covered = 0 } = {} } = {} } = {} }, }: any) => ( toRun ? ( Will be available after the test run )} > – ) : ( {value ? ( {value} ) : value} ) ), width: "150px", }]} renderHeader={({ currentCount }: { currentCount: number }) => (
{`All suggested tests (${currentCount})`}
)} /> ); };