Repository navigation
[test] Click exposed canvas points in Nightly cases #637
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
Closed
wangtiance
wants to merge
1
commit into
ThinkFlowLab:main
from
wangtiance:codex/hit-test-nightly-canvas-blanks
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,25 @@ | ||
| import assert from "node:assert/strict"; | ||
|
|
||
| /** Create a node through the same tool and type picker used on the canvas. */ | ||
| export async function addCanvasNode(page, label) { | ||
| const toolbar = page.getByRole("toolbar", { name: /^(Canvas creation tools|画布创作工具)$/ }); | ||
| await toolbar.getByRole("button", { name: /^(Add node|添加节点)$/ }).click(); | ||
| const menu = page.getByRole("menu", { name: /^(New node|新建节点)$/ }); | ||
| await menu.getByRole("menuitem", { name: label, exact: true }).click(); | ||
| } | ||
| export async function clickBlankCanvas(page) { | ||
| const pane = page.locator(".react-flow__pane"); | ||
| const point = await pane.evaluate((element) => { | ||
| const bounds = element.getBoundingClientRect(); | ||
| for (const row of [0.7, 0.5, 0.3, 0.85, 0.15]) { | ||
| for (const column of [0.75, 0.5, 0.25, 0.9, 0.1]) { | ||
| const x = bounds.left + bounds.width * column; | ||
| const y = bounds.top + bounds.height * row; | ||
| if (document.elementFromPoint(x, y) === element) return { x, y }; | ||
| } | ||
| } | ||
| return null; | ||
| }); | ||
| assert.ok(point, "A blank point must be visible on the canvas"); | ||
| await page.mouse.click(point.x, point.y); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里刚拿到 pane 就只取一次点;分栏或覆盖层还在收尾时,25 个点可能暂时都点不到,测试会立即断言失败。建议在有界超时内重算可点击点,并在实际点击前再确认一次命中的是 pane,而不是改成固定等待。