Merge pull request #29659 from overleaf/revert-29656-revert-29521-ar-models-es-conversion

Revert "Revert "[web] Convert models and self-referential test files to ESM ""

GitOrigin-RevId: f64000ae31d298b075a8722dfc51f294c71bc021
This commit is contained in:
Andrew Rumble
2025-11-18 09:04:56 +00:00
committed by Copybot
parent f3d0c6920f
commit 394c60f2cf
203 changed files with 893 additions and 902 deletions
@@ -0,0 +1,58 @@
import { expect } from 'vitest'
import mongodb from 'mongodb-legacy'
import CooldownManager from '../../../../app/src/Features/Cooldown/CooldownManager.mjs'
import { cleanupTestRedis } from '../../../../app/src/infrastructure/RedisWrapper.js'
const { ObjectId } = mongodb
describe('CooldownManager', function () {
beforeEach(cleanupTestRedis)
beforeEach(function (ctx) {
ctx.project1Id = new ObjectId().toString()
ctx.project2Id = new ObjectId().toString()
})
describe('_buildKey', function () {
it('should build a properly formatted redis key', function () {
expect(CooldownManager._buildKey('ABC')).to.equal('Cooldown:{ABC}')
})
})
describe('isProjectOnCooldown', function () {
describe('when no project is on cooldown', function () {
it('returns false for project 1', async function (ctx) {
const result = await CooldownManager.promises.isProjectOnCooldown(
ctx.project1Id
)
expect(result).to.be.false
})
it('returns false for project 2', async function (ctx) {
const result = await CooldownManager.promises.isProjectOnCooldown(
ctx.project2Id
)
expect(result).to.be.false
})
})
describe('when project 1 is on cooldown', function () {
beforeEach(async function (ctx) {
await CooldownManager.promises.putProjectOnCooldown(ctx.project1Id)
})
it('returns true for project 1', async function (ctx) {
const result = await CooldownManager.promises.isProjectOnCooldown(
ctx.project1Id
)
expect(result).to.be.true
})
it('returns false for project 2', async function (ctx) {
const result = await CooldownManager.promises.isProjectOnCooldown(
ctx.project2Id
)
expect(result).to.be.false
})
})
})
})