The test is flaky (can sometimes pass, sometimes fail) for several reasons:
- It tries to assert the position of the focused item in a collection of items, but it fails to detect it. This is because the DOM hierarchy does not match the "logical" hierarchy: the
<a>
link for projects is nested in a <div>
which is itself nested in a <nav>
, containing all links. The assertion assumes the <a>
is directly child of the <nav>
, and thus fails.
- It does not wait for asynchronous requests. The user history takes time to load, and when the test tries to jump from the project list to the recent items, the latter are not loaded yet, which fails the test.
We should fix the "position-detection" assertion and wait for the history to be loaded and displayed to fix the flakiness.