Skip to content

GAUD-10597 - Add drag test command - #1069

Open
svanherk wants to merge 1 commit into
mainfrom
GAUD-10597-Add-drag-helper
Open

GAUD-10597 - Add drag test command#1069
svanherk wants to merge 1 commit into
mainfrom
GAUD-10597-Add-drag-helper

Conversation

@svanherk

Copy link
Copy Markdown
Contributor

Not really tied to how this works at all, so figured I'd get it up and get feedback rather than trying to keep tweaking it.

@svanherk
svanherk requested a review from a team as a code owner August 26, 2026 22:29
Comment thread src/browser/commands.js
}

export async function dragElemBy(elem, offsetX = 0, offsetY = 0) {
const pixels = 10; // Mimic dragging by moving in 10px increments to the target position

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I want to simulate a user actually dragging something, which fires events every few pixels. Just moving from one place to another programmatically doesn't fire any intermediate values.

I'm firing every 10px, but this could also just break up the values passed into 5 steps of x pixels. That's likely better for large numbers, whereas this is better for small number (eg not bothering to divide a move of 2 pixels).

Comment thread src/browser/commands.js
await sendMouse({ type: 'up' });
}

export async function dragElemBy(elem, offsetX = 0, offsetY = 0) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Name is a little odd. I'm trying to follow the pattern of the other helpers in this file, taking x and y offsets as parameters. They work a little differently though, and use "at" terminology, which doesn't make sense here.

But dragElemTo isn't correct, unless I take an x and y location rather than an offset. This is nicer for the helper, worse for the consumer - it's much easier if I can say "Drag it back 5 pixels" instead of "Drag it to spot x = 250".

});

beforeEach(() => {
pointerEvents.length = 0;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also not sure I love this - was trying to follow the pattern of the file and define this stuff at the top level. But it might be better to just set it and remove it in the tests below, rather than having to clear this value every test, then clear it again after calling the fixture so I don't get any mouse moves as things reset.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is what that looks like instead: #1070

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant