Skip to content

Commit ebb5b23

Browse files
committed
test(popover): fix two broken tests
1 parent 6569984 commit ebb5b23

File tree

2 files changed

+12
-6
lines changed
  • apps/website/src/routes/docs/headless/popover/examples
  • packages/kit-headless/src/components/popover

2 files changed

+12
-6
lines changed

apps/website/src/routes/docs/headless/popover/examples/hero.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export default component$(() => {
99
<Popover id="hero-id" class="popover">
1010
My Hero!
1111
</Popover>
12-
<div id="content-outside-of-popover"></div>
12+
<div
13+
id="content-outside-of-popover"
14+
style={{ width: '10px', height: '10px' }}
15+
></div>
1316
</>
1417
);
1518
});

packages/kit-headless/src/components/popover/popover.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ test.describe('Mouse Behavior', () => {
4040
await expect(d.getPopover()).toBeHidden();
4141
await d.getTrigger().click();
4242

43-
await expect(d.getPopover()).toBeVisible();
43+
// If I use `toBeVisible` here, the test fails that the `toBeHidden` check below????
44+
await expect(d.getPopover()).toHaveCSS('opacity', '1');
4445

4546
const outsideDiv = page.locator('#content-outside-of-popover');
4647
await outsideDiv.click();
@@ -102,9 +103,11 @@ test.describe('Mouse Behavior', () => {
102103
await expect(firstPopOver).toBeVisible();
103104
await expect(secondPopOver).toBeVisible();
104105

105-
// Act
106-
await firstPopoverTrigger.click();
107-
await secondPopoverTrigger.click();
106+
// Need to be explicit about where we're clicking. By default
107+
// the click action tries to click the center of the element
108+
// but in this case, the popover is covering it.
109+
await firstPopoverTrigger.click({ position: { x: 1, y: 1 } });
110+
await secondPopoverTrigger.click({ position: { x: 1, y: 1 } });
108111

109112
// Assert
110113
await expect(firstPopOver).toBeHidden();
@@ -191,7 +194,7 @@ test.describe('Keyboard Behavior', () => {
191194
});
192195

193196
test(`GIVEN a pair of manual opened popovers
194-
WHEN clicking the first trigger on the page and then clicking the second trigger
197+
WHEN activating the first trigger on the page and then activating the second trigger
195198
THEN then both popovers should be closed`, async ({ page }) => {
196199
const { driver: d } = await setup(page, 'manual');
197200

0 commit comments

Comments
 (0)