allow admins to manipulate time on test servers

This commit is contained in:
Phillip Thelen
2024-02-15 13:09:46 +01:00
committed by Sabe Jones
parent 1b12e9d8b7
commit 593524905e
6 changed files with 109 additions and 37 deletions

View File

@@ -1,5 +1,4 @@
import Vue from 'vue';
import sinon from 'sinon';
import BootstrapVue from 'bootstrap-vue';
import Fragment from 'vue-fragment';
import AppComponent from './app';
@@ -14,7 +13,6 @@ import './filters/registerGlobals';
import i18n from './libs/i18n';
import 'smartbanner.js/dist/smartbanner';
let jumped = false;
const IS_PRODUCTION = process.env.NODE_ENV === 'production'; // eslint-disable-line no-process-env
// Configure Vue global options, see https://vuejs.org/v2/api/#Global-Config
@@ -37,20 +35,21 @@ setUpLogging();
setupAnalytics(); // just create queues for analytics, no scripts loaded at this time
const store = getStore();
const time = new Date(2024, 2, 18);
const clock = sinon.useFakeTimers({
now: time,
shouldAdvanceTime: true,
});
if (process.env.ENABLE_TIME_TRAVEL) {
(async () => {
const sinon = await import('sinon');
const axios = await import('axios');
const response = await axios.get('/api/v4/debug/time-travel-time');
console.log(response.data.data.time);
const time = new Date(response.data.data.time);
Vue.config.clock = sinon.useFakeTimers({
now: time,
shouldAdvanceTime: true,
});
setInterval(() => {
if (jumped) {
jumped = false;
return;
}
jumped = true;
clock.jump(36000);
}, 1000);
console.log('Time travel mode activated. It is now', new Date());
})();
}
const vueInstance = new Vue({
el: '#app',