[web] use a global shared mock for the metrics module (#32799)

GitOrigin-RevId: 72874ba6c06c2a602b01cc029bc9c71ce3ce8892
This commit is contained in:
Jakob Ackermann
2026-04-15 08:05:38 +00:00
committed by Copybot
parent e9b50b08bf
commit 917d2700c8
30 changed files with 41 additions and 172 deletions
@@ -83,10 +83,6 @@ describe('EditorController', function () {
})
)
vi.doMock('@overleaf/metrics', () => ({
default: (ctx.Metrics = { inc: sinon.stub() }),
}))
ctx.EditorController = (await import(modulePath)).default
})
@@ -137,7 +137,6 @@ describe('EditorHttpController', function () {
ctx.ProjectEditorHandler = {
buildProjectModelView: sinon.stub().returns(ctx.projectView),
}
ctx.Metrics = { inc: sinon.stub() }
ctx.TokenAccessHandler = {
getRequestToken: sinon.stub().returns(ctx.token),
}
@@ -195,9 +194,6 @@ describe('EditorHttpController', function () {
default: ctx.EditorController,
})
)
vi.doMock('@overleaf/metrics', () => ({
default: ctx.Metrics,
}))
vi.doMock(
'../../../../app/src/Features/Collaborators/CollaboratorsGetter.mjs',
() => ({
@@ -9,7 +9,6 @@ const modulePath = path.join(
describe('EditorRealTimeController', function () {
beforeEach(async function (ctx) {
ctx.rclient = { publish: sinon.stub() }
ctx.Metrics = { summary: sinon.stub() }
vi.doMock('../../../../app/src/infrastructure/RedisWrapper', () => ({
default: {
@@ -27,10 +26,6 @@ describe('EditorRealTimeController', function () {
default: { redis: {} },
}))
vi.doMock('@overleaf/metrics', () => ({
default: ctx.Metrics,
}))
vi.doMock('node:crypto', () => ({
default: (ctx.crypto = {
randomBytes: sinon