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

GitOrigin-RevId: 72874ba6c06c2a602b01cc029bc9c71ce3ce8892
This commit is contained in:
Jakob Ackermann
2026-04-14 14:20:43 +02:00
committed by Copybot
parent e9b50b08bf
commit 917d2700c8
30 changed files with 41 additions and 172 deletions
@@ -31,10 +31,6 @@ describe('ProjectDownloadsController', function () {
default: (ctx.ProjectGetter = {}),
}))
vi.doMock('@overleaf/metrics', () => ({
default: (ctx.metrics = {}),
}))
vi.doMock(
'../../../../app/src/Features/DocumentUpdater/DocumentUpdaterHandler.mjs',
() => ({
@@ -75,7 +71,7 @@ describe('ProjectDownloadsController', function () {
ctx.DocumentUpdaterHandler.flushProjectToMongo = sinon
.stub()
.callsArgWith(1)
ctx.metrics.inc = sinon.stub()
ctx.Metrics.inc = sinon.stub()
return ctx.ProjectDownloadsController.downloadProject(
ctx.req,
ctx.res,
@@ -119,7 +115,7 @@ describe('ProjectDownloadsController', function () {
})
it('should record the action via Metrics', function (ctx) {
return ctx.metrics.inc.calledWith('zip-downloads').should.equal(true)
return ctx.Metrics.inc.calledWith('zip-downloads').should.equal(true)
})
it('should add an audit log entry', function (ctx) {
@@ -152,7 +148,7 @@ describe('ProjectDownloadsController', function () {
ctx.DocumentUpdaterHandler.flushMultipleProjectsToMongo = sinon
.stub()
.callsArgWith(1)
ctx.metrics.inc = sinon.stub()
ctx.Metrics.inc = sinon.stub()
return ctx.ProjectDownloadsController.downloadMultipleProjects(
ctx.req,
ctx.res,
@@ -191,7 +187,7 @@ describe('ProjectDownloadsController', function () {
})
it('should record the action via Metrics', function (ctx) {
return ctx.metrics.inc
return ctx.Metrics.inc
.calledWith('zip-downloads-multiple')
.should.equal(true)
})