Skip to content

Commit

Permalink
test(tooltip): add proper visual test
Browse files Browse the repository at this point in the history
  • Loading branch information
nowseemee committed Nov 8, 2021
1 parent e39a1b1 commit 9cae171
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/components/src/components/tooltip/tooltip.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
/*tooltip hide*/
--max-width: 20rem;
--transition-delay-hide: 0s;
--transition-duration-hide: 0.125s;
--transition-duration-hide: var(--scl-motion-duration-immediate);
--transition-timing-function-hide: ease;
/*tooltip show*/
--transition-duration-show: 0.125s;
--transition-duration-show: var(--scl-motion-duration-immediate);
--transition-timing-function-show: ease;
--z-index: var(--scl-z-index-70);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export default class Popover {
show() {
this.isVisible = true;
this.popover.hidden = false;
// tslint:disable-next-line
this.popover.clientWidth; // force reflow
requestAnimationFrame(() =>
this.popover.classList.add(this.options.visibleClass)
);
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 19 additions & 2 deletions packages/visual-tests/src/tooltip.visual.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
describe('Tooltip', () => {
test.each([['opendefault']])('%p', async (variant) => {
describe.only('Tooltip', () => {
test.each([['standard']])('%p', async (variant) => {
await global.page.goto(
`http://host.docker.internal:3123/iframe.html?id=beta-components-tooltip--${variant}&viewMode=story`
);
await page.waitForSelector('html.hydrated');
const previewHtml = await page.$('body');
await page.evaluate(() => {
const transitions = [
'--scl-motion-duration-immediate',
'--scl-motion-duration-fast',
'--scl-motion-duration-slower',
'--scl-motion-duration-deliberate',
];

transitions.forEach((transitionSpeed) => {
document.body.style.setProperty(transitionSpeed, '0s');
});
});

const button = await page.evaluateHandle(
'document.querySelector("#root > div > scale-tooltip > scale-button")'
);
await button.hover();
expect(await previewHtml.screenshot()).toMatchImageSnapshot();
});
});

0 comments on commit 9cae171

Please sign in to comment.