freelawproject / recap

This repository is for filing issues on any RECAP-related effort.
https://free.law/recap/
12 stars 4 forks source link

Test related to the attachment menu fails to clear the document object after a 'describe' block #311

Closed ERosendo closed 1 year ago

ERosendo commented 1 year ago

It seems that there's a race condition in the tests related to the attachment menu page. These workflow runs, Workflow Run-3433329209 and Workflow Run-3433337969, were fired after I submitted changes that solved a merge conflict ( those changes didn't include files related to tests) and the first workflow finished without errors but the other one finished with 1 failing test.

After running the tests a couple of times in my local env, I've found that the test fails when HTML elements created by a describe block remain in the object called document when a new describe block begins, so it creates an object that contains previous HTML tags and the new ones, leading to unexpected behavior. For example, the failing test in Workflow Run-3433337969 expects a document object without any button but one of the previous describe block used two buttons that match one of the validations, so when the elements combine in the document object the functions returns true instead of false.

Possible Solution

keeping with the current approach in PacerSpec.js, We could insert this line above line 10:

document.body.innerHTML=''

This will make sure that the body of the document object is clear before creating the main container of HTML tags for every describe block.