Skip to content

Node.js based forum software built for the modern web

test: dont clear local when testing

Barış Soner Uşaklı669755d1e9f7
diff --git a/src/analytics.js b/src/analytics.js
index 45e8f698d9..b70aec7e5c 100644
--- a/src/analytics.js
+++ b/src/analytics.js
@@ -28,8 +28,11 @@ const total = _.cloneDeep(local);
const runJobs = nconf.get('runJobs');
+Analytics.pause = false;
+
Analytics.init = async function () {
new cronJob('*/10 * * * * *', (async () => {
+ if (Analytics.pause) return;
publishLocalAnalytics();
if (runJobs) {
await sleep(2000);
diff --git a/test/activitypub/analytics.js b/test/activitypub/analytics.js
index af836be14f..eda578b675 100644
--- a/test/activitypub/analytics.js
+++ b/test/activitypub/analytics.js
@@ -126,9 +126,9 @@ describe('Analytics', () => {
it('should increment various metrics', async () => {
let counters;
+ analytics.pause = true;
({ counters } = analytics.peek());
const before = { ...counters };
- const { setTimeout } = require('timers/promises');
const id = `https://example.org/activity/${utils.generateUUID()}`;
await controllers.activitypub.postInbox({
body: {
@@ -141,7 +141,7 @@ describe('Analytics', () => {
},
},
}, { sendStatus: () => {} });
- await setTimeout(2000);
+
({ counters } = analytics.peek());
const after = { ...counters };
@@ -150,5 +150,6 @@ describe('Analytics', () => {
assert(before[metric] && after[metric], JSON.stringify({ before, after }, null, 2));
assert(before[metric] < after[metric]);
});
+ analytics.pause = false;
});
});