[CDX-277] Add missing Data-Attributes / Create central DDB object#199
Merged
evanyan13 merged 1 commit intocdx-277-plp-ui-bugfix-missing-data-attributesfrom Dec 1, 2025
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors data attribute management by centralizing all Constructor.io data attribute strings into a single exported object (cnstrcDataAttrs). This improves maintainability by providing a single source of truth for data attribute names and eliminates hardcoded string literals throughout the codebase.
Key Changes:
- Created
cnstrcDataAttrsobject with organized categories (common, search, browse) - Updated all functions to use the centralized object instead of string literals
- Updated all test files to reference the new centralized data attributes
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/dataAttributeHelpers.ts | Defines the central cnstrcDataAttrs object and updates helper functions to use it |
| src/types.ts | Expands CnstrcDataAttrs type to accept any string key alongside template literals |
| src/components/ProductSwatch/ProductSwatch.tsx | Refactors to use centralized data attributes instead of hardcoded strings |
| spec/utils/dataAttributeHelpers.test.tsx | Updates test assertions to use the centralized data attribute object |
| spec/components/ProductSwatch/ProductSwatch.test.js | Updates test selectors and assertions to use centralized data attributes |
| spec/components/ProductCard/productCard.test.js | Updates test assertions to use centralized data attributes |
| spec/components/CioPlpGrid/CioPlpGrid.test.jsx | Updates test selectors and assertions to use centralized data attributes |
| spec/components/CioPlpGrid/CioPlpGrid.server.test.jsx | Updates server-side rendering tests to use centralized data attributes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Alexey-Pavlov
approved these changes
Dec 1, 2025
Contributor
Alexey-Pavlov
left a comment
There was a problem hiding this comment.
We've already discussed these changes in the parent pull request, so they all make perfect sense to me. I really appreciate your effort on this! Looks great to me!
1f7f693
into
cdx-277-plp-ui-bugfix-missing-data-attributes
7 of 9 checks passed
Alexey-Pavlov
added a commit
that referenced
this pull request
Dec 22, 2025
* [CDX-277] Add missing Data-Attributes * [CDX-277] refactoring tests & utils * [CDX-277] Refactoring tests & getProductCardCnstrcDataAttributes types * [CDX-277] Improve consistency in data attributes handling * Update naming convention for search term attribute * [CDX-277-1] Add Cnstrc Attribute Object (#199) Co-authored-by: Evan Yan <[email protected]> * [CDX-277] Add test for conditional rendering of price and variation ID attributes --------- Co-authored-by: Evan Yan <[email protected]> Co-authored-by: Evan Yan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Changes
utils/dataAttributeHelpers.tsand use it everywhere in the repo