Commit 304f28cb authored by Lukas Eipert's avatar Lukas Eipert

Remove timeago methods exposed on window object

We currently expose `window.timeago` and `window.gl.utils.localTimeAgo`.
As far as I can tell, they are not used like that anymore and any part
of the code base that still uses it like that should move to direct
imports.

This was actually the _last_ instance of a JavaScript file setting up a
`window.gl` side-effect. Unfortunately this breaks a lot of tests.
Therefore we add the `window.gl` sideeffect to our jest set up. And in
order to be 100% sure that we do not break production, we add the
sideeffect to main.js as well.
parent d73de719
......@@ -134,10 +134,3 @@ export const timeFor = (time, expiredLabel) => {
}
return timeago.format(time, `${timeagoLanguageCode}-remaining`).trim();
};
window.timeago = getTimeago();
window.gl = window.gl || {};
window.gl.utils = {
...(window.gl.utils || {}),
localTimeAgo,
};
......@@ -46,6 +46,9 @@ applyGitLabUIConfig();
window.jQuery = jQuery;
window.$ = jQuery;
// ensure that window.gl is set up
window.gl = window.gl || {};
// inject test utilities if necessary
if (process.env.NODE_ENV !== 'production' && gon?.test_env) {
import(/* webpackMode: "eager" */ './test_utils/');
......
......@@ -43,6 +43,9 @@ class CustomEnvironment extends JSDOMEnvironment {
};
this.global.IS_EE = IS_EE;
// Set up global `gl` object
this.global.gl = {};
this.rejectedPromises = [];
this.global.promiseRejectionHandler = (error) => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment