-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MWPW-161289 Catalog CTA IMS country used in commerce calls #3136
Conversation
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## stage #3136 +/- ##
==========================================
+ Coverage 96.37% 96.38% +0.01%
==========================================
Files 245 245
Lines 56686 56688 +2
==========================================
+ Hits 54630 54638 +8
+ Misses 2056 2050 -6 ☔ View full report in Codecov by Sentry. |
@@ -51,7 +51,6 @@ export class CheckoutLink extends HTMLAnchorElement { | |||
'data-checkout-workflow', | |||
'data-checkout-workflow-step', | |||
'data-extra-options', | |||
'data-ims-country', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should stay, it will cause a re-render which is expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, if re-render is expected, I returned it back.
On re-render the line overrides.imsCountry = null
will override the country from IMS, and the page country will be used and since offers for the page country are already loaded on the first render, we will not have another WCS call.
mockIms('CH'); | ||
const service = await initMasCommerceService(); | ||
const checkoutLink = mockCheckoutLink('abm'); | ||
await service.imsCountryPromise; | ||
await delay(1); | ||
await checkoutLink.onceSettled(); | ||
expect(checkoutLink.href).to.equal( | ||
'https://commerce.adobe.com/store/email?items%5B0%5D%5Bid%5D=632B3ADD940A7FBB7864AA5AD19B8D28&cli=adobe_com&ctx=fp&co=CH&lang=en', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CH is expected here, what is NOT expect is an extra WCS call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are fully reverted. So what I did is :
On initial render we use page country and there are no problems.
When IMS country is set in data-ims-country
we have re-render and then before WCS offers are loaded I need to override IMS country with page country overrides.imsCountry = null
After WCS offers are loaded (no new WCS call is triggered since the WCS url is identical as in the first render)
and before checkout link is generated I need to set the country back to IMS country
options.country = this.dataset.imsCountry || options.country
Is it ok now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but have a question.
@@ -121,6 +121,7 @@ export class CheckoutLink extends HTMLAnchorElement { | |||
if (countryCode) this.dataset.imsCountry = countryCode; | |||
}, ignore); | |||
} | |||
overrides.imsCountry = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yesil Yes, this will annul the IMS country in options and then the "page country" will be used, the same country that was used in the first render. And since we already have offers loaded for that country, no new WCS call will be triggered.
@yesil @3ch023 @npeltier @bozojovicic |
@bozojovicic mas.js build is missing in your PR, can you rebuild and commit it please? |
@afmicka thanks, @bozojovicic PR was missing mas.js build, asked him to rebuild it. |
@yesil new mas.js build pushed |
Checked on |
@bozojovicic @afmicka sorry, my message regarding the |
@bozojovicic @yesil @3ch023 |
will log a separate jira for the issue mentioned above. Approving this one. |
IMS country should not be used in https://www.adobe.com/web_commerce_artifact calls
When
data-ims-country
is updated, the/web_commerce_artifact
call is triggered again with IMS country in query parameters. By removing that data attribute fromobservedAttributes
I prevented that.On catalog pages I found one hidden CTA where
/web_commerce_artifact
is called with IMS country even after this change so I had to addoverrides.imsCountry = null
to fix that case as well.Test URL :
https://main--cc--adobecom.hlx.page/products/catalog?milolibs=mwpw161289ctaims--milo--bozojovicic
Resolves: MWPW-161289
Test URLs: