/* * 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 from "react"; import { Modal, useCloseModal, useQueryParams, VirtualizedTable, Cells, Icons, Skeleton, Stub, Tooltip, CopyButton, removeQueryParamsFromPath, } from "@drill4j/ui-kit"; import { Link, useHistory } from "react-router-dom"; import tw, { styled } from "twin.macro"; import { MethodsCoveredByTestSummary } from "types/methods-covered-by-test-summary"; import { useFilteredData, useNavigation, useTestToCodeRouteParams } from "hooks"; import { MethodsDetails } from "types"; import { concatTestName } from "utils/transform-tests"; export const CoveredMethodsModal = () => { const { push } = useHistory(); const { scopeId } = useTestToCodeRouteParams(); const { getPagePath } = useNavigation(); const { buildVersion } = useTestToCodeRouteParams(); const params = useQueryParams<{testId?: string; coveredMethods?: number}>(); const topicCoveredMethodsByTest = scopeId ? `/build/scopes/${scopeId}/tests` : "/build/tests"; const testSummary = useFilteredData( `${topicCoveredMethodsByTest}/${params?.testId}/methods/summary`, ) || {}; const showSkeleton = !Object.keys(testSummary).length; const closeModal = useCloseModal(["testId", "coveredMethods"]); const clearVirtualTableState = () => { push(removeQueryParamsFromPath(["virtualTableState"])); }; const coveredMethods = useFilteredData( `${topicCoveredMethodsByTest}/${testSummary.id}/methods/all`, ) || []; const testName = concatTestName(testSummary?.details?.testName, testSummary?.details?.params?.methodParams); const testPath = concatTestName(testSummary?.details?.path, testSummary?.details?.params?.classParams); return ( { clearVirtualTableState(); closeModal(); }}>
Covered Methods {params.coveredMethods}
Test Name Path Test Type {testName} {testPath || "-"} {testSummary?.testType}
(
methods
{`Displaying ${currentCount} of ${Number(params.coveredMethods)} rows`}
)} gridTemplateColumns="1fr 120px 184px" data={coveredMethods} initialRowsCount={Number(params.coveredMethods)} stub={( } title="No results found" message="Try adjusting your search or filter to find what you are looking for." /> )} columns={ [ { Header: "Name", accessor: "name", textAlign: "left", filterable: true, isCustomCell: true, width: "100%", Cell: ({ value = "", row: { original: { ownerClass = "", desc = "" } = {} } = {}, state }: any) => (value ? ( } link={( { const queryParams = { methodName: value, methodOwnerClass: ownerClass, methodDesc: desc, activeTab: "methods", tableState: JSON.stringify({ filters: [{ id: "name", value: ownerClass.slice(0, ownerClass.lastIndexOf("/")), }], }), }; return scopeId ? getPagePath({ name: "scope", params: { scopeId, buildVersion }, queryParams }) : getPagePath({ name: "overview", params: { buildVersion }, queryParams }); }} tw="max-w-280px text-monochrome-black text-14 text-ellipsis link" title={value} target="_blank" > Navigate to method in Application package )} > )} >
filter.value)} />
) : ), }, { Header: "Type", Cell: ({ value = "" }) => (value ? ( {value} ) : ), accessor: "type", textAlign: "left", width: "100%", }, { Header: "Coverage, %", Cell: ({ value = 0 }) => (value ? ( ) : ), accessor: "coverage", textAlign: "right", width: "100%", }, ] } />
); }; const MethodInfoLabel = styled.div(tw`min-w-32px text-left text-14 leading-32 font-bold text-monochrome-black`); const MethodInfoValue = styled.div(({ skeleton }: { skeleton?: boolean }) => [ tw`text-monochrome-default text-14 leading-20 break-all text-ellipsis`, skeleton && tw`h-4 animate-pulse w-full bg-monochrome-medium-tint rounded`, ]);