Skip to content
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

Merged
merged 5 commits into from
Apr 11, 2024

Conversation

@Ruchika4 Ruchika4 added needs-verification PR requires E2E testing by a reviewer high priority Why is this a high priority? Blocker? Critical? Dependency? labels Apr 9, 2024
Copy link
Contributor

aem-code-sync bot commented Apr 9, 2024

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

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link
Contributor

aem-code-sync bot commented Apr 9, 2024

Page Scores Audits Google
/drafts/ruchika/branch-io/branch-io-page11?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Copy link

codecov bot commented Apr 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.38%. Comparing base (be31bf0) to head (1941abb).
Report is 23 commits behind head on stage.

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.
📢 Have feedback on the report? Share it here.

@Ruchika4 Ruchika4 requested a review from TsayAdobe April 9, 2024 23:28
Copy link
Contributor

@mokimo mokimo left a 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!

test/blocks/mobile-app-banner/mobile-app-banner.test.js Outdated Show resolved Hide resolved
Comment on lines +32 to +35
const scriptSrcs = [];
scriptTags.forEach((scriptTag) => {
scriptSrcs.push(scriptTag.getAttribute('src'));
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const scriptSrcs = [];
scriptTags.forEach((scriptTag) => {
scriptSrcs.push(scriptTag.getAttribute('src'));
});
const scriptSrcs = scriptTags.map(script => script.getAttribute('src'));

Comment on lines +47 to +50
const scriptSrcs = [];
scriptTags.forEach((scriptTag) => {
if (scriptTag.getAttribute('src') !== null) scriptSrcs.push(scriptTag.getAttribute('src'));
});
Copy link
Contributor

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

Suggested change
const scriptSrcs = [];
scriptTags.forEach((scriptTag) => {
if (scriptTag.getAttribute('src') !== null) scriptSrcs.push(scriptTag.getAttribute('src'));
});
const scriptSrcs = scriptTags.map(script => script.getAttribute('src'))

test/blocks/mobile-app-banner/mobile-app-banner.test.js Outdated Show resolved Hide resolved
test/blocks/mobile-app-banner/mobile-app-banner.test.js Outdated Show resolved Hide resolved
test/blocks/mobile-app-banner/mobile-app-banner.test.js Outdated Show resolved Hide resolved
await delay(100);
const scriptTags = document.querySelectorAll('head > script');
const scriptSrcs = [];
scriptTags.forEach((scriptTag) => {
Copy link
Contributor

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');

Comment on lines +65 to +66
const classListArray = Array.from(el.classList);
const product = classListArray.find((token) => token.startsWith('product-')).split('-')[1];
Copy link
Contributor

@mokimo mokimo Apr 10, 2024

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

Copy link
Contributor

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.

Copy link
Contributor

@overmyheadandbody overmyheadandbody left a 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.

Comment on lines +65 to +66
const classListArray = Array.from(el.classList);
const product = classListArray.find((token) => token.startsWith('product-')).split('-')[1];
Copy link
Contributor

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.

test/blocks/mobile-app-banner/mobile-app-banner.test.js Outdated Show resolved Hide resolved
@Ruchika4
Copy link
Contributor Author

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.
This is a new block so there will be no impact on any production page.

@spadmasa spadmasa added verified PR has been E2E tested by a reviewer and removed needs-verification PR requires E2E testing by a reviewer labels Apr 11, 2024
@Blainegunn Blainegunn merged commit 6453307 into stage Apr 11, 2024
17 checks passed
@Blainegunn Blainegunn deleted the branch-latest branch April 11, 2024 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority Why is this a high priority? Blocker? Critical? Dependency? Ready for Stage verified PR has been E2E tested by a reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants