-
Notifications
You must be signed in to change notification settings - Fork 175
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-161625: fix mas:pending event on requestUpdate #3388
base: stage
Are you sure you want to change the base?
Conversation
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
|
|
libs/deps/mas/commerce.js
Outdated
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.
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
libs/deps/mas/mas.js
Outdated
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.
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
libs/features/mas/dist/mas.js
Outdated
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.
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## stage #3388 +/- ##
=======================================
Coverage 96.45% 96.46%
=======================================
Files 255 255
Lines 59420 59402 -18
=======================================
- Hits 57314 57301 -13
+ Misses 2106 2101 -5 ☔ View full report in Codecov by Sentry. |
nala/features/mas/docs/docs.test.js
Outdated
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 is nice 👍
name: '@MAS-DOCS-checkout-link', | ||
path: '/libs/features/mas/docs/checkout-link.html', | ||
browserParams: '?theme=dark', | ||
tags: '@mas-docs @checkout-link @commerce @smoke @regression @milo', |
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 mas-
prefix for the tags?
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.
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.
yes, those tags are global, and docs would be ambiguous
libs/features/mas/src/mas-element.js
Outdated
@@ -153,6 +153,8 @@ export class MasElement { | |||
this.state = STATE_FAILED; | |||
this.update(); | |||
this.log?.error('Failed:', { element: this.wrapperElement, error }); | |||
// Allow calling code to perform sync updates of this element | |||
// before notifying observers about state change |
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.
actually, setImmediate
is deprecated, should we try it with setTimeout(callback, 0)
by this occasion?
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.
i refactored it to just call notify function where we need to call it.. imo this thread breaks are making comprehension harder
@@ -166,7 +168,8 @@ export class MasElement { | |||
if (options) this.options = options; |
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.
I wonder if you can listen the very first mas:pending
event.
If you try to register an even listener for a <span is="price" data-wcs-osi="xyz">/span>
, it is possible that, the pending
event will be dispatched before you register.
To check. I would really remove pending all together, and consider the default state as pending.
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.
removed it, agree it's an unnessary event
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.
i would somewhere here though add some debug log to mention that element is pending resolution
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.
added, thx
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.
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
libs/deps/mas/merch-sidenav.js
Outdated
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.
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
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.
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
libs/features/mas/src/constants.js
Outdated
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.
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR. |
selectOffers(await promise, options), | ||
options, | ||
version, | ||
); | ||
this.masElement.notify(); |
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 logic is handled at mas-element level(*), the custom elements (we may have more in the future) should not know how / when to notify.
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.
got it, i moved it back into mas-element
@@ -162,13 +162,15 @@ export class CheckoutLink extends HTMLAnchorElement { | |||
{ ...extraOptions, ...options }, | |||
this, | |||
); | |||
return this.renderOffers( | |||
const result = this.renderOffers( |
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.
same comment as for inline-price
libs/features/mas/src/mas-element.js
Outdated
@@ -166,7 +168,8 @@ export class MasElement { | |||
if (options) this.options = options; | |||
this.state = STATE_PENDING; | |||
this.update(); | |||
setImmediate(() => this.notify()); | |||
// immediately notify observers about state change | |||
this.notify(); |
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.
couldn't we even remove notification for pending state?
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.
did that, thx
@@ -166,7 +168,8 @@ export class MasElement { | |||
if (options) this.options = options; |
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.
i would somewhere here though add some debug log to mention that element is pending resolution
name: '@MAS-DOCS-checkout-link', | ||
path: '/libs/features/mas/docs/checkout-link.html', | ||
browserParams: '?theme=dark', | ||
tags: '@mas-docs @checkout-link @commerce @smoke @regression @milo', |
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.
yes, those tags are global, and docs would be ambiguous
@@ -148,6 +148,7 @@ export class MasElement { | |||
if (options) this.options = options; | |||
this.state = STATE_PENDING; | |||
this.update(); | |||
this.log?.debug('Pending:', { element: this.wrapperElement }); |
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.
I wonder if this has any performance impact, this it needs to kind of serialize the wrapperElement.
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.
nala tests failing?
Reminder to set the |
Verified, Regressions covered |
Skipped 3388: "MWPW-161625: fix mas:pending event on requestUpdate" due to file "libs/deps/mas/commerce.js" overlap. Merging will be attempted in the next batch |
Skipped 3388: "MWPW-161625: fix mas:pending event on requestUpdate" due to file "libs/deps/mas/mas.js" overlap. Merging will be attempted in the next batch |
@3ch023 Plz resolve conflicts in this PR to merge, thanks |
# Conflicts: # libs/deps/mas/commerce.js # libs/deps/mas/mas.js # libs/deps/mas/merch-card-collection.js # libs/deps/mas/merch-sidenav.js # libs/deps/mas/merch-subscription-panel.js # libs/features/mas/dist/mas.js
Skipped 3388: "MWPW-161625: fix mas:pending event on requestUpdate" due to file "libs/deps/mas/commerce.js" overlap. Merging will be attempted in the next batch |
# Conflicts: # libs/deps/mas/commerce.js # libs/deps/mas/mas.js # libs/features/mas/dist/mas.js
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.
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.
when requestUpdate on MAS inline-price or checkout-link is called the 'mas:resolved' event is dispatched twice.
this PR is fixing first event to be 'mas:pending' and it is followed by a single 'mas:resolved' or 'mas:failed'
added nala tests to cover this too.
Test URLs: