test(storybook): tooltip hover 시험이 hover가 유지되는지를 직접 본다
tooltip hover 시험의 마지막 단언은 opacity가 1인지 poll로 본다. 숨김은 100ms 동안 흐려지므로, hover를 잃은 직후에 읽으면 결함이 있어도 1이 나와 통과할 수 있다(확인 리뷰). 고른 방법: 포인터를 틈과 tooltip 위로 옮길 때마다 tooltip을 감싼 요소가 :hover인지 본다. 보이는 것은 이 hover가 정한다. opacity 단언은 그대로 둔다. 검증: tooltip의 틈 다리(::before)를 지운 변이에서 새 단언이 실패하고 원래 코드에서 통과한다(desktop, PR 본문). Refs: 1112/05-06
This commit is contained in:
@@ -32,8 +32,15 @@ test("keeps a tooltip shown while the pointer moves onto it", async ({ page }) =
|
||||
const box = await tooltip.boundingBox();
|
||||
if (!box) throw new Error("expected the tooltip box");
|
||||
|
||||
// The hover that shows it holds in the gap and over the tooltip itself:
|
||||
// read where it is decided, not only the opacity, which fades over 100 ms
|
||||
// and still reads 1 the moment the hover is lost.
|
||||
const stillHovered = () =>
|
||||
tooltip.evaluate((element) => element.closest(".ui-tooltip")?.matches(":hover") ?? false);
|
||||
await page.mouse.move(box.x + box.width / 2, box.y + box.height + 2, { steps: 4 });
|
||||
expect(await stillHovered()).toBe(true);
|
||||
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 4 });
|
||||
expect(await stillHovered()).toBe(true);
|
||||
|
||||
await expect.poll(() => tooltip.evaluate((element) => getComputedStyle(element).opacity)).toBe("1");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user