Skip to content

MWPW-202563: Validate promo variation geo tags on save in Card Editor - #1182

Open
Axelcureno wants to merge 15 commits into
mainfrom
MWPW-202563
Open

MWPW-202563: Validate promo variation geo tags on save in Card Editor#1182
Axelcureno wants to merge 15 commits into
mainfrom
MWPW-202563

Conversation

@Axelcureno

Copy link
Copy Markdown
Member

Adds save-time validation for a promo variation's geo tags in the Card Editor: blocks the save with an error toast if the tags conflict with a sibling variation, violate the single no-geo-variation rule, or fall outside the promotion project's configured geos.

Also fixes getPromotionTagFromFragment/fragmentIsPromoVariation, which preferred a fragment's tags field over its metadata tags array even when the field held unrelated tags (offer_type, plan_type) — this silently broke promotion-project matching for real Promotion/Card fragments, which would have made the project-containment check dead code in production.

Resolves https://jira.corp.adobe.com/browse/MWPW-202563
QA Checklist: https://wiki.corp.adobe.com/display/adobedotcom/M@S+Engineering+QA+Use+Cases

Please do the steps below before submitting your PR for a code review or QA

  • C1. Cover code with Unit Tests
  • C2. Add a Nala test (double check with #fishbags if nala test is needed)
  • C3. Verify all Checks are green (unit tests, nala tests)
  • C4. PR description contains working Test Page link where the feature can be tested
  • C5: you are ready to do a demo from Test Page in PR (bonus: write a working demo script that you'll use on Thursday, you can eventually put in your PR)
  • C.6 read your Jira one more time to validate that you've addressed all AC's and nothing is missing

NALA E2E coverage (C2) is deferred: it requires minting a new mas:promotion/<name> taxonomy tag in Odin, which isn't available through any current Odin MCP tool (only applying existing tags is). Will follow up once that's created via Studio UI.

Test URLs:

Extends editable geo tags on promo variations with save-time validation
against sibling conflicts, the single no-geo-variation rule, and the
promotion project's configured geos, blocking the save with a toast on
conflict.

Also fixes getPromotionTagFromFragment/fragmentIsPromoVariation, which
preferred a fragment's tags field over its metadata tags array even when
the field held unrelated tags (offer_type, plan_type) - this silently
broke promotion-project matching for real Promotion/Card fragments.
Reuse getPromotionTagFromFragment in fragmentIsPromoVariation instead of
re-inlining the same fallback expression, and extract getAttachedFragmentPaths
to mirror the existing getProjectGeos accessor pattern.
@aem-code-sync

aem-code-sync Bot commented Aug 26, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

@github-actions

Copy link
Copy Markdown

SNOW Change Request Transaction ID [STUDIO]: 0000019c1ef37582-1fc7dd34

@github-actions

Copy link
Copy Markdown

SNOW Change Request Transaction ID [IO]: 0000019c1ef37582-1fc7dd8b

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.80%. Comparing base (65dafed) to head (afb7bb5).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1182      +/-   ##
==========================================
+ Coverage   90.74%   90.80%   +0.06%     
==========================================
  Files         319      319              
  Lines      101832   101922      +90     
==========================================
+ Hits        92410    92555     +145     
+ Misses       9422     9367      -55     
Files with missing lines Coverage Δ
studio/src/mas-repository.js 82.78% <100.00%> (+1.73%) ⬆️
studio/src/promotions/promotion-model.js 100.00% <100.00%> (ø)
studio/src/promotions/promotion-variations.js 100.00% <100.00%> (ø)
studio/src/promotions/promotions-repository.js 100.00% <100.00%> (ø)

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65dafed...afb7bb5. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Andrei4226 Andrei4226 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I noticed that when I open a promo variation, it no longer opens in Fragments > Editor, but in Promotions > Edit promotion project > Edit promotion variation (which already allows editing geos from the Geos tags field).
Based on the requirements, I think we want to keep the existing route when opening a promo variation (meaning Fragments > Editor) and create a connection between the geos from the promo project and the Geos tags field from the card editor, so we can discuss about it.
One more thing: now, if I open a promo variation and press the back button once, nothing happens. If I press it one more time, I get redirected to the home page: https://mwpw-202563--mas--adobecom.aem.live/

@Axelcureno

Axelcureno commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

@Andrei4226 Good catch, but that routing/breadcrumb behavior is pre-existing (not something this PR touches), and it's more of a product decision than a bug, so I think that's one for Lucy/Frauke to weigh in on rather than something to fix here.

This ticket's scope was specifically to stop saves that create conflicting geo tags across promo variations, that's built and tested. Happy to file a follow-up ticket for the routing/back-button behavior if you want to track it separately.

@Axelcureno
Axelcureno requested a review from Andrei4226 August 28, 2026 17:15

@seanchoi0 seanchoi0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work. The getPromotionTagFromFragment fix is the right call — preferring the tags metadata array over the field value was silently breaking promotion-project matching for real Card fragments. Good catch, and the extracted assertPromoVariationGeoTagsValid is a clean shape for reuse.

Two small things, neither blocking:

  • Dead arg: resolveDefaultFragmentForPromoVariation is called with 4 args but only accepts 3 — attachedFragmentPaths is silently ignored. Either drop the arg or wire it through to avoid the misleading pre-fetch.
  • Validation reads pre-prepareVariationForSave pznTags (fragment.getFieldValues) while AEM receives fragmentToSave — semantically these should match. In practice it won't misfire since promo variation pznTags are always explicitly set, but fragmentToSave.getFieldValues('pznTags') would be more correct.

Worth adding tests for the !promoTagId and !defaultFragment early-exit branches in assertPromoVariationGeoTagsValid too — the happy paths are well covered but those guards are untested.

Approving.

@Andrei4226 Andrei4226 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@yesil yesil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One thing worth checking (not a blocker): the saveFragment hook validates geos on every promo-variation save, not just when pznTags changed. With pre-existing conflicting sibling data (legacy geo-less/overlapping geos — cf. MWPW-205737), editing an unrelated field like price would block the save. Intended, or gate on pznTags actually changing?

Non-blocking: the !promoTagId and !defaultFragment early-returns are untested, and the "no promotion tag" test trips the path guard, not the tag guard.

@afmicka

afmicka commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@Axelcureno can we connect about these changes? I am not able to add geo tag on my promo variation, the menu is empty. Also the existing variation has only one geo tag out of 2 that project has. I should be able to add at least the second one if not any.

https://mwpw-202563--mas--adobecom.aem.live/studio.html#fragmentId=86f1e468-109e-438e-a536-6f918f298d68&page=fragment-editor&path=sandbox
Screenshot 2026-09-07 at 14 09 52

project: https://main--mas--adobecom.aem.live/studio.html#page=promotions-editor&path=sandbox&promotionId=855a482d-1ebb-49b4-bd20-de19e98ff089

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants