Skip to content

Spot it. Save it. Free, local-first Chrome extension for images, videos and prompts. Explore 2,000+ curated cases and connect your library to AI Agents via MCP. 提示词导演

使跨平台拖动验收等待真实可见的目标行

MigenAI997f39889f25
diff --git a/test/project_tree_e2e.py b/test/project_tree_e2e.py
index 67b3106..31a2062 100644
--- a/test/project_tree_e2e.py
+++ b/test/project_tree_e2e.py
@@ -26,15 +26,26 @@ def state(page):
def drag_to(page, source, target, position='inside'):
- source_box = row(page, source).locator('.project-filter').bounding_box()
+ source_box = project_box(page, source, '.project-filter')
page.mouse.move(source_box['x'] + source_box['width'] / 2, source_box['y'] + source_box['height'] / 2)
page.mouse.down()
page.mouse.move(source_box['x'] + source_box['width'] / 2, source_box['y'] + source_box['height'] / 2 + 8)
- target_box = row(page, target).bounding_box()
+ target_box = project_box(page, target)
y = target_box['y'] + (3 if position == 'before' else target_box['height'] - 3 if position == 'after' else target_box['height'] / 2)
page.mouse.move(target_box['x'] + target_box['width'] / 2, y, steps=6)
+def project_box(page, project_id, child=''):
+ # Resolve and measure in one browser turn. A saved element handle may be
+ # detached by the storage refresh between Playwright's two protocol calls.
+ return page.wait_for_function("""({id, child}) => {
+ const row=document.querySelector(`.project-row[data-collection-id="${CSS.escape(id)}"]`);
+ const element=child ? row?.querySelector(child) : row;
+ const rect=element?.getBoundingClientRect();
+ return rect?.width && rect?.height ? {x:rect.x,y:rect.y,width:rect.width,height:rect.height} : false;
+ }""", arg={'id':project_id,'child':child}).json_value()
+
+
def main():
# Synthetic long library exercises distances; never touches the installed profile.
projects = [dict(id=f'p{i}', name=f'项目 {i:03}', parentId=None, order=i, entryIds=[]) for i in range(100)]