-
Notifications
You must be signed in to change notification settings - Fork 177
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-143904-Unit test and small authoring update for mobile-app-banner #2126
Conversation
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## stage #2126 +/- ##
==========================================
+ Coverage 96.36% 96.38% +0.02%
==========================================
Files 165 166 +1
Lines 43523 43630 +107
==========================================
+ Hits 41941 42054 +113
+ Misses 1582 1576 -6 ☔ View full report in Codecov by Sentry. |
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.
Some smaller code sanity and efficiency comments. Otherwise looks good, thanks for following up on those unit tests!
const scriptSrcs = []; | ||
scriptTags.forEach((scriptTag) => { | ||
scriptSrcs.push(scriptTag.getAttribute('src')); | ||
}); |
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.
const scriptSrcs = []; | |
scriptTags.forEach((scriptTag) => { | |
scriptSrcs.push(scriptTag.getAttribute('src')); | |
}); | |
const scriptSrcs = scriptTags.map(script => script.getAttribute('src')); |
const scriptSrcs = []; | ||
scriptTags.forEach((scriptTag) => { | ||
if (scriptTag.getAttribute('src') !== null) scriptSrcs.push(scriptTag.getAttribute('src')); | ||
}); |
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.
Since you check the whole content of the array - you don't need to check if the src is null
const scriptSrcs = []; | |
scriptTags.forEach((scriptTag) => { | |
if (scriptTag.getAttribute('src') !== null) scriptSrcs.push(scriptTag.getAttribute('src')); | |
}); | |
const scriptSrcs = scriptTags.map(script => script.getAttribute('src')) |
await delay(100); | ||
const scriptTags = document.querySelectorAll('head > script'); | ||
const scriptSrcs = []; | ||
scriptTags.forEach((scriptTag) => { |
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 suggestion as above to simplify. In fact since you re-use this three times you could also
const getScripts = () => [...document.querySelectorAll('head > script')].map(el => el.getAttribute('src'));
And then you can simplify your expect
expect(getScripts()).to.include('https://cdn.branch.io/branch-latest.min.js');
const classListArray = Array.from(el.classList); | ||
const product = classListArray.find((token) => token.startsWith('product-')).split('-')[1]; |
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'm personally not a huge fan of mixing code changes with unit tests - since it requires regression testing - rather than saying "Those are only unit tests, it's zero-impact and doesn't need any testing since at worst we have broken tests (and not a CSO)"
It's completely fine to do, but that's my general rationale behind it
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.
Agree. The process might be adapted to streamline delivery of zero-impact PRs to prod, adding code to something that would otherwise be zero-impact will slow down the PR in the future. Of course, it can be that unit tests uncover some issues that need to be addressed, then it's totally fine to group them together.
For this particular PR, it shouldn't be an issue though.
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 overall, but @mokimo has some good points that should be considered.
const classListArray = Array.from(el.classList); | ||
const product = classListArray.find((token) => token.startsWith('product-')).split('-')[1]; |
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.
Agree. The process might be adapted to streamline delivery of zero-impact PRs to prod, adding code to something that would otherwise be zero-impact will slow down the PR in the future. Of course, it can be that unit tests uncover some issues that need to be addressed, then it's totally fine to group them together.
For this particular PR, it shouldn't be an issue though.
Hi @spadmasa , could you please verify if the authoring update done in this PR is working as expected and block is rendering. Other issues that we are facing with android device will most likely be handled in branch dashboard or I'll be raising a separate PR to get it merged in milo. |
Verified the changes in the below feature branch urls in mobile (iphone and android) and Ipad the banner is seen loading https://main--cc--adobecom.hlx.page/drafts/ruchika/mobile-app-banner1?milolibs=branch-latest&martech=off https://branch-latest--milo--adobecom.hlx.page/kr/drafts/ruchika/branch-io/branch-io-page12 |
Resolves: MWPW-143904
Test URLs:
CC
Authoring documentation:
https://main--milo--adobecom.hlx.page/docs/authoring/blocks/mobile-app-banner