Files
overleaf-cep/services/web/test/acceptance/src/ActiveUsersMetricTests.mjs
Andrew Rumble 2838c6d38c Merge pull request #22765 from overleaf/ar-convert-final-acceptance-tests-to-es-modules
[web] convert final acceptance tests to es modules

GitOrigin-RevId: d0d0cd3dfedbe494ce51dd6f8c180dff02429ad8
2025-01-13 09:04:50 +00:00

37 lines
1.0 KiB
JavaScript

import { promisify } from 'node:util'
import { expect } from 'chai'
import Features from '../../../app/src/infrastructure/Features.js'
import MetricsHelper from './helpers/metrics.mjs'
import UserHelper from './helpers/User.mjs'
const sleep = promisify(setTimeout)
const User = UserHelper.promises
const getMetric = MetricsHelper.promises.getMetric
async function getActiveUsersMetric() {
return getMetric(line => line.startsWith('num_active_users'))
}
describe('ActiveUsersMetricTests', function () {
before(async function () {
if (Features.hasFeature('saas')) {
this.skip()
}
})
it('updates "num_active_users" metric after a new user opens a project', async function () {
expect(await getActiveUsersMetric()).to.equal(0)
this.user = new User()
await this.user.login()
const projectId = await this.user.createProject('test project')
await this.user.openProject(projectId)
// settings.activeUserMetricInterval is configured to 100ms
await sleep(110)
expect(await getActiveUsersMetric()).to.equal(1)
})
})