Skip to content

Commit

Permalink
Merge pull request #18154 from timvandermeij/integration-test-rect
Browse files Browse the repository at this point in the history
Introduce a `getRect` utility function for the integration tests
  • Loading branch information
timvandermeij authored May 23, 2024
2 parents 0c562f0 + 145d660 commit 08bf968
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 467 deletions.
13 changes: 5 additions & 8 deletions test/integration/caret_browsing_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import { closePages, loadAndWait } from "./test_utils.mjs";
import { closePages, getRect, loadAndWait } from "./test_utils.mjs";

const waitForSelectionChange = (page, selection) =>
page.waitForFunction(
Expand All @@ -38,13 +38,10 @@ describe("Caret browsing", () => {
it("must move the caret down and check the selection", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const spanRect = await page.evaluate(() => {
const span = document.querySelector(
`.page[data-page-number="1"] > .textLayer > span`
);
const { x, y, width, height } = span.getBoundingClientRect();
return { x, y, width, height };
});
const spanRect = await getRect(
page,
`.page[data-page-number="1"] > .textLayer > span`
);
await page.mouse.click(
spanRect.x + 1,
spanRect.y + spanRect.height / 2,
Expand Down
Loading

0 comments on commit 08bf968

Please sign in to comment.