Skip to content

Commit

Permalink
Merge pull request #168 from quid/chore/QUID-27499-add-id-for-auto-test
Browse files Browse the repository at this point in the history
chore: add id for dropdown item value for automation testing
  • Loading branch information
yuhsuanchuang authored Jan 30, 2023
2 parents f496b7c + 80042ba commit 572a57d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/react-dropdown/src/HighlightValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const HighlightValue = styled(
if (highlight && valueToHighlight.length && value.length) {
const splittedText = splitStringByValue(value, valueToHighlight, 1);
return (
<Value className={className}>
<Value id={`highlight-value-${value}`} className={className}>
{splittedText.map((chunk, index) => {
return chunk.highlight ? (
<Text key={index} as="span" type="bold">
Expand All @@ -43,7 +43,11 @@ const HighlightValue = styled(
);
}

return <Value className={className}>{value}</Value>;
return (
<Value id={`highlight-value-${value}`} className={className}>
{value}
</Value>
);
}
)`
${props => textStyles(props.disabled ? 'disabled' : '')};
Expand Down
28 changes: 28 additions & 0 deletions packages/react-dropdown/src/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@ exports[`renders an open dropdown 1`] = `
>
<Value
className="emotion-3 emotion-0"
id="highlight-value-One"
>
<span
className="emotion-0 emotion-1 emotion-2"
id="highlight-value-One"
>
One
</span>
Expand Down Expand Up @@ -270,9 +272,11 @@ exports[`renders an open dropdown 1`] = `
>
<Value
className="emotion-3 emotion-0"
id="highlight-value-Two"
>
<span
className="emotion-0 emotion-1 emotion-2"
id="highlight-value-Two"
>
Two
</span>
Expand Down Expand Up @@ -641,9 +645,11 @@ exports[`renders an open dropdown with categories 1`] = `
>
<Value
className="emotion-7 emotion-4"
id="highlight-value-One"
>
<span
className="emotion-4 emotion-5 emotion-6"
id="highlight-value-One"
>
One
</span>
Expand Down Expand Up @@ -683,9 +689,11 @@ exports[`renders an open dropdown with categories 1`] = `
>
<Value
className="emotion-7 emotion-4"
id="highlight-value-Two"
>
<span
className="emotion-4 emotion-5 emotion-6"
id="highlight-value-Two"
>
Two
</span>
Expand Down Expand Up @@ -794,9 +802,11 @@ exports[`renders an open dropdown with categories 1`] = `
>
<Value
className="emotion-7 emotion-4"
id="highlight-value-Three"
>
<span
className="emotion-4 emotion-5 emotion-6"
id="highlight-value-Three"
>
Three
</span>
Expand Down Expand Up @@ -836,9 +846,11 @@ exports[`renders an open dropdown with categories 1`] = `
>
<Value
className="emotion-7 emotion-4"
id="highlight-value-Four"
>
<span
className="emotion-4 emotion-5 emotion-6"
id="highlight-value-Four"
>
Four
</span>
Expand Down Expand Up @@ -1222,9 +1234,11 @@ exports[`renders an open dropdown with categories and twoColumn 1`] = `
>
<Value
className="emotion-7 emotion-4"
id="highlight-value-One"
>
<span
className="emotion-4 emotion-5 emotion-6"
id="highlight-value-One"
>
One
</span>
Expand Down Expand Up @@ -1264,9 +1278,11 @@ exports[`renders an open dropdown with categories and twoColumn 1`] = `
>
<Value
className="emotion-7 emotion-4"
id="highlight-value-Two"
>
<span
className="emotion-4 emotion-5 emotion-6"
id="highlight-value-Two"
>
Two
</span>
Expand Down Expand Up @@ -1375,9 +1391,11 @@ exports[`renders an open dropdown with categories and twoColumn 1`] = `
>
<Value
className="emotion-7 emotion-4"
id="highlight-value-Three"
>
<span
className="emotion-4 emotion-5 emotion-6"
id="highlight-value-Three"
>
Three
</span>
Expand Down Expand Up @@ -1417,9 +1435,11 @@ exports[`renders an open dropdown with categories and twoColumn 1`] = `
>
<Value
className="emotion-7 emotion-4"
id="highlight-value-Four"
>
<span
className="emotion-4 emotion-5 emotion-6"
id="highlight-value-Four"
>
Four
</span>
Expand Down Expand Up @@ -1617,9 +1637,11 @@ exports[`using arrow down should hover on element 1`] = `
>
<Value
className="emotion-3 emotion-0"
id="highlight-value-One"
>
<span
className="emotion-0 emotion-1 emotion-2"
id="highlight-value-One"
>
One
</span>
Expand Down Expand Up @@ -1659,9 +1681,11 @@ exports[`using arrow down should hover on element 1`] = `
>
<Value
className="emotion-3 emotion-0"
id="highlight-value-Two"
>
<span
className="emotion-0 emotion-1 emotion-2"
id="highlight-value-Two"
>
Two
</span>
Expand Down Expand Up @@ -1982,9 +2006,11 @@ exports[`using useFilter should only return items that match the input value 1`]
>
<Value
className="emotion-5 emotion-2"
id="highlight-value-Four"
>
<span
className="emotion-2 emotion-3 emotion-4"
id="highlight-value-Four"
>
<Text
as="span"
Expand Down Expand Up @@ -2034,9 +2060,11 @@ exports[`using useFilter should only return items that match the input value 1`]
>
<Value
className="emotion-5 emotion-2"
id="highlight-value-Five"
>
<span
className="emotion-2 emotion-3 emotion-4"
id="highlight-value-Five"
>
<Text
as="span"
Expand Down

0 comments on commit 572a57d

Please sign in to comment.