-
Notifications
You must be signed in to change notification settings - Fork 152
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
Tooltip/TooltipPrimitive: add visual tests #4508
Conversation
Storybook staging is available at https://kiwicom-orbit-sarka-tooltip-visual-tests.surge.sh |
Size Change: 0 B Total Size: 459 kB
ℹ️ View Unchanged
|
Deploying orbit with Cloudflare Pages
|
f3093c5
to
130f516
Compare
Hi guys, I would like to discuss some minor things - Tooltip visual tests. I’ve done some tests (tooltip/tooltip primitive), but the number of screenshots is pretty huge. I haven’t covered all of the cases (eg. all of the possible tooltip placements,..). Currently, I’m thinking about ways how to decrease the final number of screenshots.
Do you have any ideas/suggestions on how to reduce the amount of images? |
2b40edf
to
be815cb
Compare
716ec19
to
a8f301e
Compare
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 can’t include multiple tooltips in one screenshot, as the behavior is dependent on hover/click events
You can 😉 no need to use actions. You can open via props.
Exclude different placements at all and have only one placement (eg. bottom)
I think it's important to test all placements. Ideally we can have multiple placements in one screenshots (no need to have them all in one, but grouped somehow).
Exclude some of the viewports (eg. have only one mobile device and only two desktop viewports?)
That seems reasonable to me.
Exclude some variants - eg. block tooltip, with/without image
We don't need these. I'd say for TooltipPrimitive it's important to test: placement
, size
, error
, help
and removeUnderlinedText
props. Same for Tooltip.
I'd also advise not to use an icon as the trigger, so we can actually test removeUnderlinedText
.
test(`screenshot for default - ${placement}`, async ({ mount }) => { | ||
const component = await mount(<DefaultTooltipPrimitive placement={placement as Placement} />); | ||
|
||
await component.getByRole("button").hover(); |
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.
We can avoid having the hover action. This behavior should be tested in unit tests, not visual tests
placement={placement} | ||
error={error} | ||
help={help} | ||
block={block} |
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.
If we add tooltipShown
here, we don't need the hover
return ( | ||
<div | ||
className={cx([ | ||
"flex min-h-[128px]", |
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.
We can add some padding here, so the tooltip can "breathe" better. We probably need a bigger min-height as well.
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 set bigger height before, I wanted to avoid "big blank spaces", but side-padding will be good (especially for small mobile viewport).
); | ||
} | ||
|
||
export function TooltipPrimitiveWithImage({ size = "medium" }: { size?: Size }) { |
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 feel we don't need this test with image at all
a8f301e
to
0e7aad2
Compare
352e39c
to
c83d59b
Compare
export const resizeViewportHeight = async page => { | ||
const viewportSize = page.viewportSize(); | ||
|
||
if (viewportSize) { |
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.
Thank you for the feedback, currently I covered these variants:
(basic) Tooltip component test covers only default tooltip. This tooltip is a wrapper of primitiveTooltip (without some props - tooltipShown, error, help,..), and that's the reason why no all of the variants mentioned above are not covered in these test file. The main difference is how the tooltip is shown on mobile devices. |
LGTM, but I think we don't need to test all the placements for all the variations. So, for small size, error, help and noUnderline I'd say we only need one tooltip. This way we can have much smaller snapshots (bigger snapshots are more likely to give false results) |
Yeah, I agree with the statement that we don't need test all plasements for variations (noUderline, error, etc..). I'll exclude them, and the size of the snapshots will be smaller. |
c83d59b
to
521b0ed
Compare
63d729d
to
d21bd67
Compare
8588df7
to
e670af9
Compare
This Pull Request meets the following criteria:
For new components:
d.ts
files and are exported inindex.d.ts