Skip to content

test: added more detailed debugging with assertions in send mouse hel… #5531

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions test/testing-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { sendMouse } from './plugins/browser.js';
export async function sendMouseTo(
elementOrRect: HTMLElement | DOMRect,
type: 'click' | 'move' | 'down' | 'up' | 'wheel' = 'move',
button?: 'left' | 'right' | 'middle'
button?: 'left' | 'right' | 'middle',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Delete ,

Suggested change
button?: 'left' | 'right' | 'middle',
button?: 'left' | 'right' | 'middle'

): Promise<unknown> {
const rect =
elementOrRect instanceof HTMLElement
Expand All @@ -42,7 +42,7 @@ export async function sendMouseTo(
const y = rect.top + rect.height / 2;
const options = button ? { button: button } : {};

return await sendMouse({
await sendMouse({
steps: [
{
options: options,
Expand All @@ -51,6 +51,11 @@ export async function sendMouseTo(
},
],
});

return expect(
document.elementFromPoint(x, y),
'mouse is on element'
).to.equal(elementOrRect as HTMLElement);
}

/**
Expand All @@ -69,7 +74,7 @@ export async function sendMouseFrom(
const y = rect.top + rect.height * 2;
const options = button ? { button: button } : {};

return await sendMouse({
await sendMouse({
steps: [
{
options: options,
Expand All @@ -78,6 +83,11 @@ export async function sendMouseFrom(
},
],
});

return expect(
document.elementFromPoint(x, y),
'mouse is not on element'
).to.not.equal(elementOrRect as HTMLElement);
}

export async function testForLitDevWarnings(
Expand Down
Loading