Double Click not working in testcafe tests

I am having trouble getting the ObjectDoubleClicked diagram listener to fire in tests, it works fine in regular usage. I’m using GoJs 2.1.40, Node 14.16, Chrome 90.

Normally what happens when double-clicking is that a ObjectSingleClicked is fired first, followed by ObjectDoubleClicked on the second click.
When running the tests, two ObjectSingleClicked events are fired consecutively, never getting to the ObjectDoubleClicked. If I remove the single-click functionality it behaves the same, so there shouldn’t be anything interrupting the double-click.

Some other details I’ve observed are that the single-click events are consistently less than 500ms apart when logging the timestamp, so they should qualify as a double click. Adding a DOM event listener for double-click also works as expected, which makes me think this is an issue with Go. However, I tried the same example using Cypress for the testing suite and it worked fine. The same behavior also occurs for different Go elements, Links, Nodes, etc.

Is there something about the way that Go handles clicks that would cause this? Are there any other ways that I could go about debugging this issue?

So everything works interactively as expected, but not when testing using some environments but not others? What are you using when testing when it fails?

Correct. I’m required to use Testcafe, which is where it is failing.

Hmmm, I’m not at all familiar with Testcafe. I don’t know how I can help you.

I’ve found that using diagram.addEventListener('dblclick', console.log) does get called when double-clicking in testcafe. I also noticed that there is some custom click-handling in the Go source code that wasn’t based off of the native click handlers, but since it’s minified I wasn’t able to extract much. Could you provide some clarification about how Go receives DOM events for clicking and how it uses that to determine what type of click it is?

First, I should point out that GoJS does not establish any “dblclick” listener. It does establish “mousedown”, “mousemove”, and “mouseup” listeners, as well as ones for pointer events and for touch events. There is also special handling for various particular browsers, especially Internet Explorer, which I hope you don’t have to worry about.

The code gets the e.detail in order to determine the InputEvent.clickCount.

The code then calls doMouseDown, doMouseMove, or doMouseUp on the Diagram.currentTool. Some tools convert sequences of events into “click” events.

For example, the ClickSelectingTool.doMouseUp method calls Tool.standardMouseClick which, assuming it’s on a GraphObject and if InputEvent.left is true and InputEvent.clickCount == 2, raises the “ObjectDoubleClicked” DiagramEvent and finds and calls any GraphObject.doubleClick event handlers.