From 5876c885a8efc6eb5d4990c04c0b65a37215f809 Mon Sep 17 00:00:00 2001 From: GnsP Date: Wed, 11 Dec 2024 13:11:24 +0530 Subject: [PATCH 1/2] add testid for pipeline run index --- .../PipelineDetails/RunLevelInfo/CurrentRunIndex.tsx | 3 +++ app/cdap/testids/TestidsProvider.tsx | 2 +- app/cdap/testids/testids.yaml | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/cdap/components/PipelineDetails/RunLevelInfo/CurrentRunIndex.tsx b/app/cdap/components/PipelineDetails/RunLevelInfo/CurrentRunIndex.tsx index e1847eb5219..97b9adc69ed 100644 --- a/app/cdap/components/PipelineDetails/RunLevelInfo/CurrentRunIndex.tsx +++ b/app/cdap/components/PipelineDetails/RunLevelInfo/CurrentRunIndex.tsx @@ -31,8 +31,10 @@ import { getCurrentNamespace } from 'services/NamespaceStore'; import { getHydratorUrl } from 'services/UiUtils/UrlGenerator'; import Popover from 'components/shared/Popover'; import { GLOBALS } from 'services/global-constants'; +import { getDataTestid } from '@cdap-ui/testids/TestidsProvider'; const PREFIX = 'features.PipelineDetails.RunLevel'; +const TESTID_PREFIX = 'features.pipelineDetails.runLevel'; const StyledNoRunsHeader = styled.div` display: flex; @@ -203,6 +205,7 @@ const CurrentRunIndex = ({ }).toString() : '' } + data-testid={getDataTestid(`${TESTID_PREFIX}.currentRunIndex`)} > {T.translate(`${PREFIX}.currentRunIndex`, { currentRunIndex: runIndexInTotalRunsCount + 1, diff --git a/app/cdap/testids/TestidsProvider.tsx b/app/cdap/testids/TestidsProvider.tsx index 9d91c42a65a..3401d8d58f4 100644 --- a/app/cdap/testids/TestidsProvider.tsx +++ b/app/cdap/testids/TestidsProvider.tsx @@ -15,7 +15,7 @@ */ import React, { useContext } from 'react'; -import _get from 'lodash/get'; +import _get from 'lodash-es/get'; import testids from './testids.yaml'; import { DataTestIdGetter, TestidContext } from './TestidContext'; diff --git a/app/cdap/testids/testids.yaml b/app/cdap/testids/testids.yaml index cb4094ff6c8..29ef6e64920 100644 --- a/app/cdap/testids/testids.yaml +++ b/app/cdap/testids/testids.yaml @@ -333,3 +333,6 @@ features: home: wrangler: pageLink: ~ + pipelineDetails: + runLevel: + currentRunIndex: ~ From 85aa2875cb523e04b3897c5f6b01d01ce98b9616 Mon Sep 17 00:00:00 2001 From: GnsP Date: Wed, 11 Dec 2024 14:21:58 +0530 Subject: [PATCH 2/2] use ObjectQuery instead of lodash.get --- app/cdap/testids/TestidsProvider.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/cdap/testids/TestidsProvider.tsx b/app/cdap/testids/TestidsProvider.tsx index 3401d8d58f4..3de961c2e46 100644 --- a/app/cdap/testids/TestidsProvider.tsx +++ b/app/cdap/testids/TestidsProvider.tsx @@ -15,9 +15,10 @@ */ import React, { useContext } from 'react'; -import _get from 'lodash-es/get'; +import _get from 'lodash/get'; import testids from './testids.yaml'; import { DataTestIdGetter, TestidContext } from './TestidContext'; +import { objectQuery } from 'services/helpers'; interface ITestidProviderProps { children: React.ReactNode; @@ -30,7 +31,7 @@ function getDataTestidInternal(prefixPath: string, siblingKey?: string | number) // previously hardcoded testid values), for all newly added data-testids the value at the leaf node // should be null. - const actualTestidPrefix = _get(testids, prefixPath); + const actualTestidPrefix = objectQuery(testids, ...prefixPath.split('.')); // actualTestidPrefix is the value at the node of the prefix tree pointed by the prefixPath provided. // We need to ensure that the prefix path provided points to a leaf node. This can be ensured by checking