ls1intum / Apollon

UML Modeling Editor written in React
https://apollon-library.readthedocs.io
MIT License
65 stars 22 forks source link

Enable Artemis to hook into the React render timeline for more reliable tests #296

Closed pal03377 closed 11 months ago

pal03377 commented 1 year ago

Checklist

Motivation and Context

To fix flaky client tests related to Apollon in #6955, I need to be able to wait for the next render cycle in React. To my knowledge, this is not possible without some "help" from the React code itself (or with a React testing library, which we don't use). Therefore, we need this PR.

Description

Added a new promise to the ApollonEditor called nextRender, which resolves when the next scheduled React render of the editor component happens. It also ensures that ApollonEditor.store will be properly initialized before it resolves.

Steps for Testing

Test Coverage

File Line
apollon-editor.ts 82%
application.tsx 100%
pal03377 commented 12 months ago

We tested this through https://github.com/ls1intum/Artemis/pull/6955 in a testing session.