Skip to content

Commit

Permalink
Merge pull request #752 from gemini-testing/rashid.fix.HERMIONE-147
Browse files Browse the repository at this point in the history
fix: reset cursor correctly for body with negative coords
  • Loading branch information
xrsd committed Apr 6, 2023
2 parents e6bc3f2 + a0b8cd6 commit fb36132
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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 });
}
};

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

0 comments on commit fb36132

Please sign in to comment.