Skip to content

[CDX-277] Add missing Data-Attributes / Create central DDB object#199

Merged
evanyan13 merged 1 commit intocdx-277-plp-ui-bugfix-missing-data-attributesfrom
cdx-277-plp-ui-bugfix-missing-data-attributes-add-central-object
Dec 1, 2025
Merged

[CDX-277] Add missing Data-Attributes / Create central DDB object#199
evanyan13 merged 1 commit intocdx-277-plp-ui-bugfix-missing-data-attributesfrom
cdx-277-plp-ui-bugfix-missing-data-attributes-add-central-object

Conversation

@evanyan13
Copy link
Contributor

PR Type

  • Refactoring (no functional changes, no API changes)

Changes

  • Created a central object to house all data attributes
  • Export the object from utils/dataAttributeHelpers.ts and use it everywhere in the repo
  • Updated reference in other files

@evanyan13 evanyan13 self-assigned this Nov 27, 2025
Copilot AI review requested due to automatic review settings November 27, 2025 01:30
@evanyan13 evanyan13 changed the title Create central data attribute object [CDX-277Create central data attribute object Nov 27, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 cnstrcDataAttrs object 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.

@evanyan13 evanyan13 changed the title [CDX-277Create central data attribute object [CDX-277] Add missing Data-Attributes - Create central DDB object Nov 27, 2025
@evanyan13 evanyan13 changed the title [CDX-277] Add missing Data-Attributes - Create central DDB object [CDX-277] Add missing Data-Attributes / Create central DDB object Nov 27, 2025
Copy link
Contributor

@Alexey-Pavlov Alexey-Pavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! 

@evanyan13 evanyan13 merged commit 1f7f693 into cdx-277-plp-ui-bugfix-missing-data-attributes Dec 1, 2025
7 of 9 checks passed
@evanyan13 evanyan13 deleted the cdx-277-plp-ui-bugfix-missing-data-attributes-add-central-object branch December 1, 2025 18:03
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants