Skip to content
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

fix: reset cursor correctly for body with negative coords #752

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/worker/runner/test-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ module.exports = class TestRunner {
}

await body.scrollIntoView();
await body.moveTo({ xOffset: 0, yOffset: 0 });

const { x, y } = await body.getLocation();
await body.moveTo({ xOffset: -x, yOffset: -y });

Choose a reason for hiding this comment

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

После этого изменения стала возникать ошибка

  (Session info: chrome=90.0.4430.72)
stack: move target out of bounds: move target out of bounds

Copy link
Member

Choose a reason for hiding this comment

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

У меня проблему воспроизвести не получается. Нужен minimal reproducible example.

}
};

Expand Down
9 changes: 9 additions & 0 deletions test/src/worker/runner/test-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe("worker/runner/test-runner", () => {

const mkElement_ = proto => {
return _.defaults(proto, {
getLocation: sandbox.stub().named("getLocation").resolves({ x: 0, y: 0 }),
scrollIntoView: sandbox.stub().named("scrollIntoView").resolves(),
moveTo: sandbox.stub().named("moveTo").resolves(),
});
Expand Down Expand Up @@ -302,6 +303,14 @@ describe("worker/runner/test-runner", () => {
assert.calledOnceWith(body.moveTo, { xOffset: 0, yOffset: 0 });
});

it("should move cursor correctly if body element has negative coords", async () => {
body.getLocation.resolves({ x: -100, y: -500 });

await run_();

assert.calledOnceWith(body.moveTo, { xOffset: 100, yOffset: 500 });
});

it("should scroll before moving cursor", async () => {
await run_();

Expand Down