Skip to content

Improve DOM function tests

Administrator requested to merge better-dom-function-tests into master

Created by: felixfbecker

Experimented with tests that rely on snapshots, either saving SimmerJS selectors or annotated fixtures (the latter is commented out rn).

I removed getElement() to not replicate the implementation in test. Instead, we use the code element from getCodeElementFromLineNumber() (which itself is tested with snapshot tests).

I changed the tests to rely on code-view.html fixtures instead of page.html fixtures, and added a lot of those.

I'm also using a DocumentFragment to force implementations to only rely on the passed code view and not on global document.

Personally I'm positively surprised by the selectors. The benefit of the annotated fixtures is that it allows to take a look at the content of the code element to know which one was selected, but they are very verbose. The solution I like the most is saving both the selector and the content of the line. @lguychard wdyt?

Test plan:

Merge request reports

Loading