Skip to content

Commit de5252f

Browse files
committed
chore: fix unit test
1 parent 1489394 commit de5252f

File tree

6 files changed

+7
-5
lines changed

6 files changed

+7
-5
lines changed

packages/web-integration/src/extractor/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export interface ExtractedRect {
129129
zoom: number;
130130
}
131131

132-
function getRect(el: HTMLElement | Node, baseZoom = 1): ExtractedRect {
132+
export function getRect(el: HTMLElement | Node, baseZoom = 1): ExtractedRect {
133133
let originalRect: DOMRect;
134134
let newZoom = 1;
135135
if (!(el instanceof HTMLElement)) {
@@ -229,8 +229,8 @@ export function visibleRect(
229229
}
230230

231231
// check if the element is covered by another element
232-
// zoom can cause the element to be covered by another element
233-
if (baseZoom !== 1 && isElementCovered(el, rect)) {
232+
// if the element is zoomed, the coverage check should be done with the original zoom
233+
if (baseZoom === 1 && isElementCovered(el, rect)) {
234234
return false;
235235
}
236236

packages/web-integration/src/extractor/web-extractor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
getDocument,
1717
getNodeAttributes,
1818
getPseudoElementContent,
19+
getRect,
1920
logger,
2021
midsceneGenerateHash,
2122
setDataForNode,
@@ -252,9 +253,10 @@ export function extractTextWithPosition(
252253
return elementInfo;
253254
}
254255

256+
const rect = getRect(node, baseZoom);
255257
for (let i = 0; i < node.childNodes.length; i++) {
256258
logger('will dfs', node.childNodes[i]);
257-
dfs(node.childNodes[i], `${nodePath}-${i}`, elementInfo?.zoom);
259+
dfs(node.childNodes[i], `${nodePath}-${i}`, rect.zoom);
258260
}
259261

260262
if (!elementInfo) {

packages/web-integration/tests/ai/web/puppeteer/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export async function launchPage(
1010
},
1111
) {
1212
const browser = await puppeteer.launch({
13-
headless: typeof opt?.headless === 'boolean' ? opt.headless : true,
13+
headless: typeof opt?.headless === 'boolean' ? opt.headless : false,
1414
});
1515
const originPage = (await browser.pages())[0];
1616
const viewportConfig = {
Loading
Loading
Loading

0 commit comments

Comments
 (0)