Utilize jest-environment-jsdom-sixteen for tests
What does this MR do?
Utilize jest-environment-jsdom-sixteen for tests
This allows us to utilize the newest version of jsdom (16) in jest. Our current version of jest relies on version 11. The newer version of jsdom brings a lot of features, e.g. Custom Elements which we need for gl_emoji tests.
Other necessary changes in this MR
Update jest snapshots
Apparently a few of our snapshots change because of the implementation changes in jsdom
Fix emitting of events in jest
Some of the internal changes of jsdom seem to have an effect on events. Especially with click events on links. These refactors those events to be triggered by Vue.
In other cases we were manually dispatching events, when it is easier to just trigger an event directly.
Fix focus tests with new jsdom version
If elements are not attached to the DOM, jsdom doesn't update
document.activeElement
or add :focus
pseudo classes.
This fixes tests that are testing focus states.
Add a helper to spy on window.location
The window.location interface is read only in newer versions of jsdom. This breaks our manual mocks / spys on that interface.
With a helper which replaces window.location
with a mocked interface
we are able to circumvent that problem.
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team