Skip to content

Commit

Permalink
Fix e2e tests on Mac (#9401)
Browse files Browse the repository at this point in the history
Some e2e tests (about leaving nodes) were always failing on my machine because of the race condition in the tests. The issue was caused by edges positions lagging behind for a few frames when switching Enso functions, which caused incorrect handling of clicks in the test code.

Now we wait for edges being initialized *and* node sizes being updated.

Thanks to @farmaazon for helping with debugging.
  • Loading branch information
vitvakatu authored Mar 14, 2024
1 parent 720a72c commit 2ad6cdd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/gui2/e2e/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export async function goToGraph(page: Page) {
}

export async function expectNodePositionsInitialized(page: Page, yPos: number) {
// Wait until edges are initialized and displayed correctly.
await expect(page.getByTestId('broken-edge')).toHaveCount(0)
// Wait until node sizes are initialized.
await expect(locate.graphNode(page).first().locator('.bgFill')).toBeVisible()
// TODO: The yPos should not need to be a variable. Instead, first automatically positioned nodes
// should always have constant known position. This is a bug caused by incorrect layout after
// entering a function. To be fixed with #9255
Expand Down
10 changes: 10 additions & 0 deletions app/gui2/src/components/GraphEditor/GraphEdge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ const sourceRect = computed<Rect | undefined>(() => {
}
})
/** Edges which do not have `sourceRect` and `targetPos` initialized are marked by a special
* `broken-edge` data-testid, for debugging and e2e test purposes. */
const edgeIsBroken = computed(
() =>
sourceRect.value == null ||
targetPos.value == null ||
(sourceRect.value.pos.equals(targetPos.value) && sourceRect.value.size.equals(Vec2.Zero)),
)
type NodeMask = {
id: string
rect: Rect
Expand Down Expand Up @@ -508,6 +517,7 @@ const connected = computed(() => isConnected(props.edge))
class="edge io"
:data-source-node-id="sourceNode"
:data-target-node-id="targetNode"
:data-testid="edgeIsBroken ? 'broken-edge' : null"
@pointerdown.stop="click"
@pointerenter="hovered = true"
@pointerleave="hovered = false"
Expand Down

0 comments on commit 2ad6cdd

Please sign in to comment.