Skip to content

Commit

Permalink
Merge pull request #1272 from GnsP/add-testid-for-runid
Browse files Browse the repository at this point in the history
add testid for pipeline run index
  • Loading branch information
GnsP authored Dec 11, 2024
2 parents 1bde3fd + 85aa287 commit 9c6d3ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -203,6 +205,7 @@ const CurrentRunIndex = ({
}).toString()
: ''
}
data-testid={getDataTestid(`${TESTID_PREFIX}.currentRunIndex`)}
>
{T.translate(`${PREFIX}.currentRunIndex`, {
currentRunIndex: runIndexInTotalRunsCount + 1,
Expand Down
3 changes: 2 additions & 1 deletion app/cdap/testids/TestidsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import React, { useContext } from 'react';
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;
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/cdap/testids/testids.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,6 @@ features:
home:
wrangler:
pageLink: ~
pipelineDetails:
runLevel:
currentRunIndex: ~

0 comments on commit 9c6d3ec

Please sign in to comment.