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 162709 tooltip unit tests #3612

Merged

Conversation

skholkhojaev
Copy link
Contributor

Discription

This PR enhances the unit tests for the tooltip component

Changes

  • added UnitTests in icons.test.js

Resolves: MWPW-162709

Test URLs:

Copy link
Contributor

aem-code-sync bot commented Feb 3, 2025

Page Scores Audits Google
📱 /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.39%. Comparing base (cf4c08b) to head (9b4e85b).

Additional details and impacted files
@@            Coverage Diff             @@
##            stage    #3612      +/-   ##
==========================================
+ Coverage   96.53%   98.39%   +1.86%     
==========================================
  Files         274       79     -195     
  Lines       61849    10149   -51700     
==========================================
- Hits        59705     9986   -49719     
+ Misses       2144      163    -1981     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mokimo
Copy link
Contributor

mokimo commented Feb 3, 2025

Oh lucky you, seems like you get to also investigate a flaky test 😁

❌ media > medium compact > has a cdt
AssertionError: expected { entries: [Function: entries],
keys: [Function: keys],
values: [Function: values],
forEach: [Function: forEach],
length: 0,
item: [Function: item] } to have a length of 1 but got 0
+ expected - actual
-0
+1
at n. (test/blocks/media/media.test.js:142:66)

Copy link
Contributor

github-actions bot commented Feb 4, 2025

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.

@skholkhojaev skholkhojaev requested a review from mokimo February 6, 2025 08:24
@skholkhojaev skholkhojaev force-pushed the MWPW-162709-tooltip-UnitTests branch from b64b25c to ad3f9d4 Compare February 10, 2025 08:33
@skholkhojaev skholkhojaev requested a review from mokimo February 10, 2025 12:45
icons = document.querySelectorAll('span.icon');
await loadIcons(icons, config);
await loadIcons(icons, config); // Test duplicate icon not created if run twice
});

it('Fetches successfully with cache control enabled', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the test name appropiate? How does cache control play in here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i dont think so but i wasnt sure about that becasue i wasnt sure what the dev that originally wrote that test meant with that, but i will change it

Comment on lines 44 to 47
it('Replaces span.icon', () => {
const selector = icons[0].querySelector(':scope svg');
expect(selector).to.exist;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rename this to Renders an SVG after loading the icons

expect(tooltip.getAttribute('role')).to.equal('button');
expect(tooltip.className).to.contain('top');
tooltip.focus();
expect(document.activeElement).to.equal(tooltip);
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we had this on Slack, but is there no ward to check if the if the tooltip is visible or at least something more like this? https://stackoverflow.com/questions/29084253/how-to-unit-test-pseudo-elements

Verifying the existance of the pseudo class is likely a bit better, since the element would still be active even if someone removed the CSS class and the tooltip would not show anymore.

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.

Cool!

Copy link
Contributor

@robert-bogos robert-bogos left a comment

Choose a reason for hiding this comment

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

👍

@SilviuLCF SilviuLCF self-requested a review February 14, 2025 08:01
Copy link

@SilviuLCF SilviuLCF left a comment

Choose a reason for hiding this comment

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

Zero impact, NO QA needed

Co-authored-by: Robert Bogos <146744221+robert-bogos@users.noreply.github.com>
@milo-pr-merge milo-pr-merge bot merged commit f5b6be1 into adobecom:stage Feb 18, 2025
12 checks passed
@milo-pr-merge milo-pr-merge bot mentioned this pull request Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants