Skip to content

Commit

Permalink
Merge pull request #703 from thejackshelton/portal-popover
Browse files Browse the repository at this point in the history
Improved Modal Test Suite
  • Loading branch information
thejackshelton authored Apr 17, 2024
2 parents fd614cc + 81f5c43 commit dc91bcd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default component$(() => {
const isOpen = useSignal(false);

return (
<div style={{ height: '200vh' }}>
<div>
<button class="modal-trigger" onClick$={() => (isOpen.value = true)}>
Open Modal
</button>
Expand Down
28 changes: 4 additions & 24 deletions packages/kit-headless/src/components/modal/modal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,11 @@ test.describe('Scroll locking', () => {
THEN the body should have overflow hidden`, async ({ page }) => {
const { driver: d } = await setup(page, 'scroll-lock');

expect(
await page.evaluate(() => {
const { overflow } = getComputedStyle(document.body);
return overflow === 'hidden';
}),
).toBe(false);
await expect(page.locator('body')).toHaveCSS('overflow', 'visible');

await d.openModal();

expect(
await page.evaluate(() => {
const { overflow } = getComputedStyle(document.body);
return overflow === 'hidden';
}),
).toBe(true);
await expect(page.locator('body')).toHaveCSS('overflow', 'hidden');
});

test(`GIVEN an open modal that has overflow hidden on the body
Expand All @@ -100,22 +90,12 @@ test.describe('Scroll locking', () => {

await d.openModal();

expect(
await page.evaluate(() => {
const { overflow } = getComputedStyle(document.body);
return overflow === 'hidden';
}),
).toBe(true);
await expect(page.locator('body')).toHaveCSS('overflow', 'hidden');

await d.getTrigger().press('Escape');
await expect(d.getModal()).toBeHidden();

expect(
await page.evaluate(() => {
const { overflow } = getComputedStyle(document.body);
return overflow === 'hidden';
}),
).toBe(false);
await expect(page.locator('body')).toHaveCSS('overflow', 'visible');
});

test(`GIVEN two open modals, one nested inside the other
Expand Down
Loading

0 comments on commit dc91bcd

Please sign in to comment.