MWPW-192308: Add ability to create a grouped variation of a collection#812
MWPW-192308: Add ability to create a grouped variation of a collection#812Andrei4226 wants to merge 5 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #812 +/- ##
==========================================
+ Coverage 87.45% 87.47% +0.01%
==========================================
Files 214 214
Lines 63670 63702 +32
==========================================
+ Hits 55682 55722 +40
+ Misses 7988 7980 -8
... and 6 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
|
||
| function pznTagIdsForMatching(variation) { | ||
| const fromField = variation.fields?.pznTags; | ||
| if (fromField != null && fromField !== '') { |
There was a problem hiding this comment.
No unit tests for pznTagIdsForMatching — the fromField !== '' guard, empty-array path, and string-vs-object tag fallback are all worth covering.
| const REFERENCE_FIELDS = [...CF_REFERENCE_FIELDS, 'tags']; | ||
| const COLLECTION_MODEL_PATH = '/conf/mas/settings/dam/cfm/models/collection'; | ||
|
|
||
| function collectPathToIdMap(references, map = {}) { |
There was a problem hiding this comment.
COLLECTION_MODEL_PATH is already exported from studio/src/constants.js. Keeping two copies in sync means a path change needs two edits.
There was a problem hiding this comment.
I duplicated the constant because io/www cannot import studio/src/constants.js, when running tests, that relative import is resolved incorrectly by the dev server, causing test failures.
| const fields = transformFields(ref.fields, pathToIdMap); | ||
| const isCollection = ref.model?.path === COLLECTION_MODEL_PATH; | ||
| const value = { | ||
| name: ref.name, |
There was a problem hiding this comment.
The isCollection tag-spreading branch in transformReferences has no unit tests.
| if (isCollection) { | ||
| const mergedTags = [...(parentFragment.tags || []), ...(pznTags || [])]; | ||
| if (mergedTags.length) { | ||
| await this.aem.sites.cf.fragments.copyFragmentTags(newFragment, mergedTags); |
There was a problem hiding this comment.
parentFragment.tags entries are objects ({ id, path, ... }) while pznTags are plain strings — copyFragmentTags receives a heterogeneous array. Worth verifying it handles this mix, or normalizing to one type before merging.
| return tags.join(','); | ||
| const fromField = pznTagsField?.values || []; | ||
| if (fromField.length) return fromField.join(','); | ||
| const seen = new Set(); |
There was a problem hiding this comment.
The same mas:locale//mas:pzn/ metadata fallback pattern is duplicated in mas-fragment-editor.js:displayGroupedVariationInfo. A shared helper would prevent drift.
3ch023
left a comment
There was a problem hiding this comment.
creation works well:
https://mwpw-192308--mas--adobecom.aem.live/studio.html#fragmentId=08d15928-9c84-4fac-84fe-a238a4e6462b&page=fragment-editor&path=sandbox
but i believe we need to set pznTags field similar to how we do it for cards.
see this card example:
https://mwpw-192308--mas--adobecom.aem.live/studio.html#fragmentId=9df02a22-3340-41f8-8694-877550b86cc8&page=fragment-editor&path=sandbox
after this i think variation will start rendering correctly:
https://main--cc--adobecom.aem.page/eg_en/drafts/mariia/coll
https://main--cc--adobecom.aem.live/eg_en/drafts/mariia/coll
| return matchedTokens * 100 + (regionMatch ? 20 : 0) + (countryMatch ? 10 : 0); | ||
| } | ||
|
|
||
| function pznTagIdsForMatching(variation) { |
There was a problem hiding this comment.
not sure about it, is it needed?
There was a problem hiding this comment.
The pznTagIdsForMatching function is meant to extract tags from a variation
For cards, fields.pznTags is populated, so the new variation.tags fallback is unused
However, for collections, fields.pznTags doesn’t exist, so the function falls back to variation.tags
Should we need to have pznTags for grouped variations in collections (just like we do for cards), or should we want to using variation.tags?
3ch023
left a comment
There was a problem hiding this comment.
pznTagIdsForMatching likely doesn't do any impact
Resolves https://jira.corp.adobe.com/browse/MWPW-192308
QA Checklist: https://wiki.corp.adobe.com/display/adobedotcom/M@S+Engineering+QA+Use+Cases
Adds support for grouped variations on collections in MAS Studio.
The collection CF model has no
pznTagsfield in its schema (and no OSI).For collections only, tags are now stored on
metadata.tagsinstead of fields. A synthetic PAC (merch-card-collection/COLLECTION_GROUPED_VARIATION_PAC) is used to construct the target folder path (en_US/merch-card-collection/pzn/...) since collections have no offer selector.Explicit
COLLECTION_MODEL_PATHguards were added to handle collections separately from cards:pznTagsin fields, stores tags onmetadata.tags(collections only)fragment.tagswhenfields.pznTagsis empty (collections only)metadata.tagsfor collections, so grouped variations are correctly selected.URL differs from cards only in the tags param:
mas:studio/content-type/merch-card-collectionvs
mas:studio/content-type/merch-cardGrouped variations of a collection: https://mwpw-192308--mas--adobecom.aem.live/studio.html#fragmentId=4bea6742-f4d5-4953-ac28-92ac1c42dc83&page=fragment-editor&path=sandbox&tags=mas%3Astudio%2Fcontent-type%2Fmerch-card-collection
Please do the steps below before submitting your PR for a code review or QA
🧪 Nala E2E Tests
Nala tests run automatically when you open this PR.
To run Nala tests again:
run nalalabel to this PR (in the right sidebar)To stop automatic Nala tests:
run nalalabelTest URLs:
Milo Page
https://main--cc--adobecom.aem.page/eg_en/drafts/mariia/coll?maslibs=MWPW-192308
https://main--cc--adobecom.aem.live/eg_en/drafts/mariia/coll?mas-io-url=https://14257-merchatscale-qa.adobeioruntime.net/api/v1/web/MerchAtScale