Waiting for diagram to be updated during testing


We are using Cypress to do some integration testing in our application, however we are finding that we occasionally run into race conditions where the diagram may not have updated yet or we do our check mid way through it doing something functionally.

Is there any functionality to wait for the diagram to settle after running some functionality so that we are able to have more reliable tests? We are using the robot and we also have access to the diagrams reference if needed

We have currently implemented the tests using delays in Cypress however these are not the most stable way of doing it as it depends on many other factors such as the users/cicd pipelines machine specs and how JavaScript is feeling at the time :)

Might that be due layout animation? You could when testing greatly decrease the value of AnimationManager.duration. Or can you only proceed with a test in an “AnimationFinished” DiagramEvent listener?

Or even just set AnimationManager.isEnabled to false.

Most things can be checked in a “LayoutCompleted” DiagramEvent listener.

I am assuming the AnimationFinished event only fires if an animation has been called?
and I am also assuming that the LayoutCompleted event only fires once the layout have completed re-rendering and not for if the viewport has changed/a new part has been selected ect.

We have a combination of animations adding to the issue (I believe we already wait for the animation duration time / have already turned animations off) however we also have to wait for the data to propagate into the diagram from sources external to the diagram so I was looking to see if there was a way we could wait for this change as we would be expecting data to have passed into the diagram.

This may be more of an issue in our code but I wanted to see if there was a final event of sorts for settled changes. It does seem however i could use a combination of the AnimationFinished, LayoutCompleted, and various other events (assuming I know what is meant to be changed) to at least know once that has finished in the diagram.

Yes to your two questions.

In general I would think you’d be able to use the “LayoutCompleted” DiagramEvent for testing the state of various objects after each transaction.

Awesome, Thanks for the help!

Ill have a look into how reliable it would be to use this event during our tests. I know we don’t make heavy use of transactions right now so depending on whats happening we may need to implement those a bit more in our code.

If you use any command or tool, either programmatically or via Robot or via true input events, transactions are automatically conducted when needed. Unless you have custom commands or tools that don’t perform a transaction when they actually are needed…

We do have a few custom commands, and they probably do not use transactions, I’ll raise that up here to get transactions added for those that need them… We are not making use of the Undo Manager yet so we have not had a need for the transactions yet.