Skip to content

Commit

Permalink
use ObjectQuery instead of lodash.get
Browse files Browse the repository at this point in the history
  • Loading branch information
GnsP committed Dec 11, 2024
1 parent 5876c88 commit 85aa287
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/cdap/testids/TestidsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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

0 comments on commit 85aa287

Please sign in to comment.