Convert top level acceptance tests to ES module

GitOrigin-RevId: ab45010ec557d62576c470d2e024549e67261c66
This commit is contained in:
Andrew Rumble 2024-10-14 11:41:11 +01:00 committed by Copybot
parent 4f0b860cf6
commit e0dba75b81
75 changed files with 430 additions and 380 deletions

View file

@ -2,9 +2,9 @@ import '../../../../../test/acceptance/src/helpers/InitApp.mjs'
import MockDocstoreApi from '../../../../../test/acceptance/src/mocks/MockDocstoreApi.js' import MockDocstoreApi from '../../../../../test/acceptance/src/mocks/MockDocstoreApi.js'
import MockDocUpdaterApi from '../../../../../test/acceptance/src/mocks/MockDocUpdaterApi.js' import MockDocUpdaterApi from '../../../../../test/acceptance/src/mocks/MockDocUpdaterApi.js'
import MockFilestoreApi from '../../../../../test/acceptance/src/mocks/MockFilestoreApi.js' import MockFilestoreApi from '../../../../../test/acceptance/src/mocks/MockFilestoreApi.js'
import MockNotificationsApi from '../../../../../test/acceptance/src/mocks/MockNotificationsApi.js' import MockNotificationsApi from '../../../../../test/acceptance/src/mocks/MockNotificationsApi.mjs'
import MockProjectHistoryApi from '../../../../../test/acceptance/src/mocks/MockProjectHistoryApi.js' import MockProjectHistoryApi from '../../../../../test/acceptance/src/mocks/MockProjectHistoryApi.js'
import MockSpellingApi from '../../../../../test/acceptance/src/mocks/MockSpellingApi.js' import MockSpellingApi from '../../../../../test/acceptance/src/mocks/MockSpellingApi.mjs'
import MockV1Api from '../../../../../test/acceptance/src/mocks/MockV1Api.js' import MockV1Api from '../../../../../test/acceptance/src/mocks/MockV1Api.js'
import MockV1HistoryApi from '../../../../../test/acceptance/src/mocks/MockV1HistoryApi.js' import MockV1HistoryApi from '../../../../../test/acceptance/src/mocks/MockV1HistoryApi.js'

View file

@ -1,12 +1,14 @@
const { promisify } = require('util') import { promisify } from 'util'
const { expect } = require('chai') import { expect } from 'chai'
const Features = require('../../../app/src/infrastructure/Features') import Features from '../../../app/src/infrastructure/Features.js'
const { import MetricsHelper from './helpers/metrics.js'
promises: { getMetric }, import UserHelper from './helpers/User.js'
} = require('./helpers/metrics')
const User = require('./helpers/User').promises
const sleep = promisify(setTimeout) const sleep = promisify(setTimeout)
const User = UserHelper.promises
const getMetric = MetricsHelper.promises.getMetric
async function getActiveUsersMetric() { async function getActiveUsersMetric() {
return getMetric(line => line.startsWith('num_active_users')) return getMetric(line => line.startsWith('num_active_users'))
} }

View file

@ -1,9 +1,11 @@
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const logger = require('@overleaf/logger') import logger from '@overleaf/logger'
const sinon = require('sinon') import sinon from 'sinon'
const { db } = require('../../../app/src/infrastructure/mongodb') import { db } from '../../../app/src/infrastructure/mongodb.js'
const Features = require('../../../app/src/infrastructure/Features') import Features from '../../../app/src/infrastructure/Features.js'
const User = UserHelper.promises
describe('Add secondary email address confirmation code email', function () { describe('Add secondary email address confirmation code email', function () {
let spy let spy

View file

@ -1,7 +1,7 @@
const OError = require('@overleaf/o-error') import OError from '@overleaf/o-error'
const { expect } = require('chai') import { expect } from 'chai'
const async = require('async') import async from 'async'
const User = require('./helpers/User') import User from './helpers/User.js'
describe('AdminEmails', function () { describe('AdminEmails', function () {
beforeEach(function (done) { beforeEach(function (done) {

View file

@ -1,6 +1,8 @@
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const User = UserHelper.promises
describe('AdminOnlyLogin', function () { describe('AdminOnlyLogin', function () {
let adminUser, regularUser let adminUser, regularUser

View file

@ -1,9 +1,9 @@
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const { import { getSafeAdminDomainRedirect } from '../../../app/src/Features/Helpers/UrlHelper.js'
getSafeAdminDomainRedirect,
} = require('../../../app/src/Features/Helpers/UrlHelper') const User = UserHelper.promises
describe('AdminPrivilegeAvailable', function () { describe('AdminPrivilegeAvailable', function () {
let adminUser, otherUser let adminUser, otherUser

View file

@ -1,7 +1,11 @@
const { expect } = require('chai') import { expect } from 'chai'
const { ObjectId } = require('mongodb-legacy') import mongodb from 'mongodb-legacy'
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const ObjectId = mongodb.ObjectId
const User = UserHelper.promises
describe('Authentication', function () { describe('Authentication', function () {
let user let user

View file

@ -1,11 +1,10 @@
const { expect } = require('chai') import { expect } from 'chai'
const async = require('async') import async from 'async'
const User = require('./helpers/User') import User from './helpers/User.js'
const request = require('./helpers/request') import request from './helpers/request.js'
const settings = require('@overleaf/settings') import settings from '@overleaf/settings'
const Features = require('../../../app/src/infrastructure/Features') import Features from '../../../app/src/infrastructure/Features.js'
import expectErrorResponse from './helpers/expectErrorResponse.js'
const expectErrorResponse = require('./helpers/expectErrorResponse')
function tryReadAccess(user, projectId, test, callback) { function tryReadAccess(user, projectId, test, callback) {
async.series( async.series(

View file

@ -1,9 +1,11 @@
const { exec } = require('child_process') import { exec } from 'child_process'
const { promisify } = require('util') import { promisify } from 'util'
const { expect } = require('chai') import { expect } from 'chai'
const logger = require('@overleaf/logger') import logger from '@overleaf/logger'
const { db, ObjectId } = require('../../../app/src/infrastructure/mongodb') import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const User = UserHelper.promises
async function getDeletedFiles(projectId) { async function getDeletedFiles(projectId) {
return (await db.projects.findOne({ _id: projectId })).deletedFiles return (await db.projects.findOne({ _id: projectId })).deletedFiles

View file

@ -1,9 +1,11 @@
const { exec } = require('child_process') import { exec } from 'child_process'
const { promisify } = require('util') import { promisify } from 'util'
const { expect } = require('chai') import { expect } from 'chai'
const logger = require('@overleaf/logger') import logger from '@overleaf/logger'
const { db, ObjectId } = require('../../../app/src/infrastructure/mongodb') import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const User = UserHelper.promises
async function getDeletedDocs(projectId) { async function getDeletedDocs(projectId) {
return (await db.projects.findOne({ _id: projectId })).deletedDocs return (await db.projects.findOne({ _id: projectId })).deletedDocs

View file

@ -1,8 +1,8 @@
const { db, ObjectId } = require('../../../app/src/infrastructure/mongodb') import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js'
const { promisify } = require('util') import { promisify } from 'util'
const { exec } = require('child_process') import { exec } from 'child_process'
const logger = require('@overleaf/logger/logging-manager') import logger from '@overleaf/logger'
const { expect } = require('chai') import { expect } from 'chai'
describe('BackFillDocRevTests', function () { describe('BackFillDocRevTests', function () {
const docId1 = new ObjectId() const docId1 = new ObjectId()

View file

@ -1,9 +1,9 @@
const { exec } = require('child_process') import { exec } from 'child_process'
const { promisify } = require('util') import { promisify } from 'util'
const { expect } = require('chai') import { expect } from 'chai'
const logger = require('@overleaf/logger') import logger from '@overleaf/logger'
const { filterOutput } = require('./helpers/settings') import { filterOutput } from './helpers/settings.mjs'
const { db, ObjectId } = require('../../../app/src/infrastructure/mongodb') import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js'
const DUMMY_NAME = 'unknown.tex' const DUMMY_NAME = 'unknown.tex'
const DUMMY_TIME = new Date('2021-04-12T00:00:00.000Z') const DUMMY_TIME = new Date('2021-04-12T00:00:00.000Z')

View file

@ -1,6 +1,6 @@
const { spawnSync } = require('child_process') import { spawnSync } from 'child_process'
const { expect } = require('chai') import { expect } from 'chai'
const { db, ObjectId } = require('../../../app/src/infrastructure/mongodb') import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js'
describe('BatchedUpdateTests', function () { describe('BatchedUpdateTests', function () {
it('can handle non linear insert order', async function () { it('can handle non linear insert order', async function () {

View file

@ -1,5 +1,5 @@
const { expect } = require('chai') import { expect } from 'chai'
const UserHelper = require('../src/helpers/UserHelper') import UserHelper from '../src/helpers/UserHelper.js'
describe('BetaProgram', function () { describe('BetaProgram', function () {
let email, userHelper let email, userHelper

View file

@ -1,5 +1,5 @@
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const request = require('./helpers/request') import request from './helpers/request.js'
// create a string that is longer than the max allowed (as defined in Server.js) // create a string that is longer than the max allowed (as defined in Server.js)
const wayTooLongString = 'a'.repeat(Settings.max_json_request_size + 1) const wayTooLongString = 'a'.repeat(Settings.max_json_request_size + 1)

View file

@ -1,8 +1,10 @@
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const { import MetricsHelper from './helpers/metrics.js'
promises: { getMetric },
} = require('./helpers/metrics') const User = UserHelper.promises
const getMetric = MetricsHelper.promises.getMetric
describe('CDNMigration', function () { describe('CDNMigration', function () {
let anon, user let anon, user

View file

@ -1,8 +1,10 @@
const { db } = require('../../../app/src/infrastructure/mongodb') import { db } from '../../../app/src/infrastructure/mongodb.js'
const { expect } = require('chai') import { expect } from 'chai'
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const MockHaveIBeenPwnedApiClass = require('./mocks/MockHaveIBeenPwnedApi') import MockHaveIBeenPwnedApiClass from './mocks/MockHaveIBeenPwnedApi.mjs'
const User = UserHelper.promises
let MockHaveIBeenPwnedApi let MockHaveIBeenPwnedApi
before(function () { before(function () {

View file

@ -10,8 +10,9 @@
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const request = require('./helpers/request')
import request from './helpers/request.js'
describe('siteIsOpen', function () { describe('siteIsOpen', function () {
describe('when siteIsOpen is default (true)', function () { describe('when siteIsOpen is default (true)', function () {

View file

@ -1,16 +1,13 @@
const sinon = require('sinon') import sinon from 'sinon'
const chai = require('chai') import chai, { expect } from 'chai'
const { expect } = require('chai') import chaiAsPromised from 'chai-as-promised'
import sinonChai from 'sinon-chai'
import { main } from '../../../scripts/recurly/collect_paypal_past_due_invoice.js'
import RecurlyWrapper from '../../../app/src/Features/Subscription/RecurlyWrapper.js'
import OError from '@overleaf/o-error'
chai.use(require('chai-as-promised')) chai.use(chaiAsPromised)
chai.use(require('sinon-chai')) chai.use(sinonChai)
const {
main,
} = require('../../../scripts/recurly/collect_paypal_past_due_invoice')
const RecurlyWrapper = require('../../../app/src/Features/Subscription/RecurlyWrapper')
const OError = require('@overleaf/o-error')
// from https://recurly.com/developers/api-v2/v2.21/#operation/listInvoices // from https://recurly.com/developers/api-v2/v2.21/#operation/listInvoices
const invoicesXml = invoiceIds => ` const invoicesXml = invoiceIds => `

View file

@ -1,8 +1,11 @@
const { expect } = require('chai') import { expect } from 'chai'
const { exec } = require('child_process') import { exec } from 'child_process'
const { ObjectId } = require('mongodb-legacy') import mongodb from 'mongodb-legacy'
import UserHelper from './helpers/User.js'
const User = require('./helpers/User').promises const User = UserHelper.promises
const ObjectId = mongodb.ObjectId
describe('ConvertArchivedState', function () { describe('ConvertArchivedState', function () {
let userOne, userTwo, userThree, userFour let userOne, userTwo, userThree, userFour

View file

@ -1,11 +1,14 @@
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const { import MetricsHelper from './helpers/metrics.js'
promises: { getMetric }, import cookieSignature from 'cookie-signature'
resetMetrics,
} = require('./helpers/metrics') const User = UserHelper.promises
const cookieSignature = require('cookie-signature')
const getMetric = MetricsHelper.promises.getMetric
const resetMetrics = MetricsHelper.resetMetrics
async function getSessionCookieMetric(status) { async function getSessionCookieMetric(status) {
return getMetric( return getMetric(

View file

@ -1,9 +1,9 @@
const { exec } = require('child_process') import { exec } from 'child_process'
const { promisify } = require('util') import { promisify } from 'util'
const { expect } = require('chai') import { expect } from 'chai'
const logger = require('@overleaf/logger') import logger from '@overleaf/logger'
const { filterOutput } = require('./helpers/settings') import { filterOutput } from './helpers/settings.mjs'
const { db, ObjectId } = require('../../../app/src/infrastructure/mongodb') import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js'
const ONE_DAY_IN_S = 60 * 60 * 24 const ONE_DAY_IN_S = 60 * 60 * 24
const BATCH_SIZE = 3 const BATCH_SIZE = 3

View file

@ -1,15 +1,15 @@
const User = require('./helpers/User') import User from './helpers/User.js'
const Subscription = require('./helpers/Subscription') import Subscription from './helpers/Subscription.js'
const request = require('./helpers/request') import request from './helpers/request.js'
const async = require('async') import async from 'async'
const { expect } = require('chai') import { expect } from 'chai'
const settings = require('@overleaf/settings') import settings from '@overleaf/settings'
const { db, ObjectId } = require('../../../app/src/infrastructure/mongodb') import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js'
const Features = require('../../../app/src/infrastructure/Features') import Features from '../../../app/src/infrastructure/Features.js'
const MockDocstoreApiClass = require('./mocks/MockDocstoreApi') import MockDocstoreApiClass from './mocks/MockDocstoreApi.js'
const MockFilestoreApiClass = require('./mocks/MockFilestoreApi') import MockFilestoreApiClass from './mocks/MockFilestoreApi.js'
const MockChatApiClass = require('./mocks/MockChatApi') import MockChatApiClass from './mocks/MockChatApi.mjs'
const MockGitBridgeApiClass = require('./mocks/MockGitBridgeApi') import MockGitBridgeApiClass from './mocks/MockGitBridgeApi.mjs'
let MockDocstoreApi, MockFilestoreApi, MockChatApi, MockGitBridgeApi let MockDocstoreApi, MockFilestoreApi, MockChatApi, MockGitBridgeApi

View file

@ -1,8 +1,10 @@
const User = require('./helpers/User') import User from './helpers/User.js'
const request = require('./helpers/request') import request from './helpers/request.js'
const { expect } = require('chai') import { expect } from 'chai'
const settings = require('@overleaf/settings') import settings from '@overleaf/settings'
const { ObjectId } = require('mongodb-legacy') import mongodb from 'mongodb-legacy'
const ObjectId = mongodb.ObjectId
describe('DocUpdate', function () { describe('DocUpdate', function () {
beforeEach(function (done) { beforeEach(function (done) {

View file

@ -1,5 +1,5 @@
const User = require('./helpers/User') import User from './helpers/User.js'
const { expect } = require('chai') import { expect } from 'chai'
describe('EditorHttpController', function () { describe('EditorHttpController', function () {
beforeEach('login', function (done) { beforeEach('login', function (done) {

View file

@ -1,9 +1,13 @@
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const MockHaveIBeenPwnedApiClass = require('./mocks/MockHaveIBeenPwnedApi') import MockHaveIBeenPwnedApiClass from './mocks/MockHaveIBeenPwnedApi.mjs'
const { db } = require('../../../app/src/infrastructure/mongodb') import { db } from '../../../app/src/infrastructure/mongodb.js'
const { getMetric } = require('./helpers/metrics').promises import MetricsHelper from './helpers/metrics.js'
const User = UserHelper.promises
const getMetric = MetricsHelper.promises.getMetric
let MockHaveIBeenPwnedApi let MockHaveIBeenPwnedApi
before(function () { before(function () {
@ -11,19 +15,19 @@ before(function () {
}) })
async function getMetricReUsed() { async function getMetricReUsed() {
return getMetric( return await getMetric(
line => line.includes('password_re_use') && line.includes('re-used') line => line.includes('password_re_use') && line.includes('re-used')
) )
} }
async function getMetricUnique() { async function getMetricUnique() {
return getMetric( return await getMetric(
line => line.includes('password_re_use') && line.includes('unique') line => line.includes('password_re_use') && line.includes('unique')
) )
} }
async function getMetricFailure() { async function getMetricFailure() {
return getMetric( return await getMetric(
line => line.includes('password_re_use') && line.includes('failure') line => line.includes('password_re_use') && line.includes('failure')
) )
} }

View file

@ -1,6 +1,8 @@
const { expect } = require('chai') import { expect } from 'chai'
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const User = UserHelper.promises
describe('HealthCheckController', function () { describe('HealthCheckController', function () {
describe('SmokeTests', function () { describe('SmokeTests', function () {

View file

@ -1,6 +1,6 @@
const { expect } = require('chai') import { expect } from 'chai'
const fetch = require('node-fetch') import fetch from 'node-fetch'
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const BASE_URL = `http://${process.env.HTTP_TEST_HOST || '127.0.0.1'}:23000` const BASE_URL = `http://${process.env.HTTP_TEST_HOST || '127.0.0.1'}:23000`

View file

@ -1,20 +1,20 @@
import './helpers/InitApp.mjs' import './helpers/InitApp.mjs'
import Features from '../../../app/src/infrastructure/Features.js' import Features from '../../../app/src/infrastructure/Features.js'
import MockAnalyticsApi from './mocks/MockAnalyticsApi.js' import MockAnalyticsApi from './mocks/MockAnalyticsApi.mjs'
import MockChatApi from './mocks/MockChatApi.js' import MockChatApi from './mocks/MockChatApi.mjs'
import MockClsiApi from './mocks/MockClsiApi.js' import MockClsiApi from './mocks/MockClsiApi.mjs'
import MockDocstoreApi from './mocks/MockDocstoreApi.js' import MockDocstoreApi from './mocks/MockDocstoreApi.js'
import MockDocUpdaterApi from './mocks/MockDocUpdaterApi.js' import MockDocUpdaterApi from './mocks/MockDocUpdaterApi.js'
import MockFilestoreApi from './mocks/MockFilestoreApi.js' import MockFilestoreApi from './mocks/MockFilestoreApi.js'
import MockGitBridgeApi from './mocks/MockGitBridgeApi.js' import MockGitBridgeApi from './mocks/MockGitBridgeApi.mjs'
import MockNotificationsApi from './mocks/MockNotificationsApi.js' import MockNotificationsApi from './mocks/MockNotificationsApi.mjs'
import MockProjectHistoryApi from './mocks/MockProjectHistoryApi.js' import MockProjectHistoryApi from './mocks/MockProjectHistoryApi.js'
import MockSpellingApi from './mocks/MockSpellingApi.js' import MockSpellingApi from './mocks/MockSpellingApi.mjs'
import MockV1Api from './mocks/MockV1Api.js' import MockV1Api from './mocks/MockV1Api.js'
import MockV1HistoryApi from './mocks/MockV1HistoryApi.js' import MockV1HistoryApi from './mocks/MockV1HistoryApi.js'
import MockHaveIBeenPwnedApi from './mocks/MockHaveIBeenPwnedApi.js' import MockHaveIBeenPwnedApi from './mocks/MockHaveIBeenPwnedApi.mjs'
import MockThirdPartyDataStoreApi from './mocks/MockThirdPartyDataStoreApi.js' import MockThirdPartyDataStoreApi from './mocks/MockThirdPartyDataStoreApi.mjs'
const mockOpts = { const mockOpts = {
debug: ['1', 'true', 'TRUE'].includes(process.env.DEBUG_MOCKS), debug: ['1', 'true', 'TRUE'].includes(process.env.DEBUG_MOCKS),

View file

@ -1,6 +1,8 @@
const { expect } = require('chai') import { expect } from 'chai'
const cheerio = require('cheerio') import cheerio from 'cheerio'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const User = UserHelper.promises
describe('Spelling', function () { describe('Spelling', function () {
let user, projectId let user, projectId

View file

@ -1,15 +1,14 @@
const { expect } = require('chai') import { expect } from 'chai'
const _ = require('lodash') import _ from 'lodash'
const fs = require('fs') import fs from 'fs'
const timekeeper = require('timekeeper') import timekeeper from 'timekeeper'
import Settings from '@overleaf/settings'
import UserHelper from './helpers/User.js'
import express from 'express'
import { plainTextResponse } from '../../../app/src/infrastructure/Response.js'
const Settings = require('@overleaf/settings') const User = UserHelper.promises
const User = require('./helpers/User').promises
const express = require('express')
const {
plainTextResponse,
} = require('../../../app/src/infrastructure/Response')
const LinkedUrlProxy = express() const LinkedUrlProxy = express()
LinkedUrlProxy.get('/', (req, res, next) => { LinkedUrlProxy.get('/', (req, res, next) => {
if (req.query.url === 'http://example.com/foo') { if (req.query.url === 'http://example.com/foo') {

View file

@ -1,7 +1,6 @@
const { expect } = require('chai') import { expect } from 'chai'
import { User } from '../../../app/src/models/User.js'
const { User } = require('../../../app/src/models/User') import { Subscription } from '../../../app/src/models/Subscription.js'
const { Subscription } = require('../../../app/src/models/Subscription')
describe('mongoose', function () { describe('mongoose', function () {
describe('User', function () { describe('User', function () {

View file

@ -1,16 +1,19 @@
const { expect } = require('chai') import { expect } from 'chai'
import mongodb from 'mongodb-legacy'
const { ObjectId: NativeObjectId } = require('mongodb-legacy') import mongoose from 'mongoose'
const { ObjectId: MongooseObjectId } = require('mongoose').mongo import { User as UserModel } from '../../../app/src/models/User.js'
import { db } from '../../../app/src/infrastructure/mongodb.js'
const { User: UserModel } = require('../../../app/src/models/User') import {
const { db } = require('../../../app/src/infrastructure/mongodb')
const {
normalizeQuery, normalizeQuery,
normalizeMultiQuery, normalizeMultiQuery,
} = require('../../../app/src/Features/Helpers/Mongo') } from '../../../app/src/Features/Helpers/Mongo.js'
import UserHelper from './helpers/User.js'
const User = require('./helpers/User').promises const User = UserHelper.promises
const NativeObjectId = mongodb.ObjectId
const MongooseObjectId = mongoose.Types.ObjectId
describe('MongoTests', function () { describe('MongoTests', function () {
let userIdAsString, userEmail, userIds let userIdAsString, userEmail, userIds

View file

@ -1,6 +1,6 @@
const { expect } = require('chai') import { expect } from 'chai'
const UserHelper = require('./helpers/UserHelper') import UserHelper from './helpers/UserHelper.js'
const { db } = require('../../../app/src/infrastructure/mongodb') import { db } from '../../../app/src/infrastructure/mongodb.js'
describe('PasswordReset', function () { describe('PasswordReset', function () {
let email, response, user, userHelper, token, emailQuery let email, response, user, userHelper, token, emailQuery

View file

@ -1,6 +1,6 @@
const { expect } = require('chai') import { expect } from 'chai'
const PasswordResetRouter = require('../../../app/src/Features/PasswordReset/PasswordResetRouter') import PasswordResetRouter from '../../../app/src/Features/PasswordReset/PasswordResetRouter.js'
const UserHelper = require('./helpers/UserHelper') import UserHelper from './helpers/UserHelper.js'
describe('PasswordUpdate', function () { describe('PasswordUpdate', function () {
let email, password, response, user, userHelper let email, password, response, user, userHelper

View file

@ -1,9 +1,11 @@
const UserHelper = require('./helpers/UserHelper') import UserHelper from './helpers/UserHelper.js'
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const { expect } = require('chai') import { expect } from 'chai'
const Features = require('../../../app/src/infrastructure/Features') import Features from '../../../app/src/infrastructure/Features.js'
const MockV1ApiClass = require('./mocks/MockV1Api') import MockV1ApiClass from './mocks/MockV1Api.js'
const Subscription = require('./helpers/Subscription').promises import SubscriptionHelper from './helpers/Subscription.js'
const Subscription = SubscriptionHelper.promises
describe('PrimaryEmailCheck', function () { describe('PrimaryEmailCheck', function () {
let userHelper let userHelper

View file

@ -1,10 +1,14 @@
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const { Project } = require('../../../app/src/models/Project') import { Project } from '../../../app/src/models/Project.js'
const { ObjectId } = require('mongodb-legacy') import mongodb from 'mongodb-legacy'
const cheerio = require('cheerio') import cheerio from 'cheerio'
const { Subscription } = require('../../../app/src/models/Subscription') import { Subscription } from '../../../app/src/models/Subscription.js'
const Features = require('../../../app/src/infrastructure/Features') import Features from '../../../app/src/infrastructure/Features.js'
const ObjectId = mongodb.ObjectId
const User = UserHelper.promises
describe('Project CRUD', function () { describe('Project CRUD', function () {
beforeEach(async function () { beforeEach(async function () {

View file

@ -1,16 +1,18 @@
const { expect } = require('chai') import { expect } from 'chai'
const sinon = require('sinon') import sinon from 'sinon'
const Path = require('path') import Path from 'node:path'
const fs = require('fs') import fs from 'node:fs'
const _ = require('lodash') import _ from 'lodash'
const User = require('./helpers/User') import User from './helpers/User.js'
const UserHelper = require('./helpers/UserHelper') import UserHelper from './helpers/UserHelper.js'
import MockDocstoreApiClass from './mocks/MockDocstoreApi.js'
const MockDocstoreApiClass = require('./mocks/MockDocstoreApi') import MockFilestoreApiClass from './mocks/MockFilestoreApi.js'
const MockFilestoreApiClass = require('./mocks/MockFilestoreApi') import { fileURLToPath } from 'node:url'
let MockDocstoreApi, MockFilestoreApi let MockDocstoreApi, MockFilestoreApi
const __dirname = fileURLToPath(new URL('.', import.meta.url))
before(function () { before(function () {
MockDocstoreApi = MockDocstoreApiClass.instance() MockDocstoreApi = MockDocstoreApiClass.instance()
MockFilestoreApi = MockFilestoreApiClass.instance() MockFilestoreApi = MockFilestoreApiClass.instance()

View file

@ -10,11 +10,12 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const { expect } = require('chai') import { expect } from 'chai'
const async = require('async')
const User = require('./helpers/User') import async from 'async'
const request = require('./helpers/request') import User from './helpers/User.js'
const settings = require('@overleaf/settings') import request from './helpers/request.js'
import settings from '@overleaf/settings'
const joinProject = (userId, projectId, callback) => const joinProject = (userId, projectId, callback) =>
request.post( request.post(

View file

@ -1,12 +1,12 @@
const { expect } = require('chai') import { expect } from 'chai'
const Async = require('async') import Async from 'async'
const User = require('./helpers/User') import User from './helpers/User.js'
const settings = require('@overleaf/settings') import settings from '@overleaf/settings'
const CollaboratorsEmailHandler = require('../../../app/src/Features/Collaborators/CollaboratorsEmailHandler') import CollaboratorsEmailHandler from '../../../app/src/Features/Collaborators/CollaboratorsEmailHandler.js'
const CollaboratorsInviteHelper = require('../../../app/src/Features/Collaborators/CollaboratorsInviteHelper') import CollaboratorsInviteHelper from '../../../app/src/Features/Collaborators/CollaboratorsInviteHelper.js'
const Features = require('../../../app/src/infrastructure/Features') import Features from '../../../app/src/infrastructure/Features.js'
const cheerio = require('cheerio') import cheerio from 'cheerio'
const sinon = require('sinon') import sinon from 'sinon'
let generateTokenSpy let generateTokenSpy

View file

@ -1,5 +1,7 @@
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const User = UserHelper.promises
describe('Project ownership transfer', function () { describe('Project ownership transfer', function () {
beforeEach(async function () { beforeEach(async function () {

View file

@ -12,14 +12,14 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const LockManager = require('../../../app/src/infrastructure/LockManager') import LockManager from '../../../app/src/infrastructure/LockManager.js'
const ProjectCreationHandler = require('../../../app/src/Features/Project/ProjectCreationHandler')
const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter')
const ProjectEntityMongoUpdateHandler = require('../../../app/src/Features/Project/ProjectEntityMongoUpdateHandler')
const UserCreator = require('../../../app/src/Features/User/UserCreator')
const { expect } = require('chai') import ProjectCreationHandler from '../../../app/src/Features/Project/ProjectCreationHandler.js'
const _ = require('lodash') import ProjectGetter from '../../../app/src/Features/Project/ProjectGetter.js'
import ProjectEntityMongoUpdateHandler from '../../../app/src/Features/Project/ProjectEntityMongoUpdateHandler.js'
import UserCreator from '../../../app/src/Features/User/UserCreator.js'
import { expect } from 'chai'
import _ from 'lodash'
// These tests are neither acceptance tests nor unit tests. It's difficult to // These tests are neither acceptance tests nor unit tests. It's difficult to
// test/verify that our locking is doing what we hope. // test/verify that our locking is doing what we hope.

View file

@ -1,14 +1,19 @@
const { expect } = require('chai') import { expect } from 'chai'
const { ObjectId } = require('mongodb-legacy') import mongodb from 'mongodb-legacy'
const Path = require('path') import Path from 'node:path'
const fs = require('fs') import fs from 'node:fs'
import { Project } from '../../../app/src/models/Project.js'
import ProjectGetter from '../../../app/src/Features/Project/ProjectGetter.js'
import UserHelper from './helpers/User.js'
import MockDocStoreApiClass from './mocks/MockDocstoreApi.js'
import MockDocUpdaterApiClass from './mocks/MockDocUpdaterApi.js'
import { fileURLToPath } from 'node:url'
const { Project } = require('../../../app/src/models/Project') const User = UserHelper.promises
const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter')
const User = require('./helpers/User').promises const ObjectId = mongodb.ObjectId
const MockDocStoreApiClass = require('./mocks/MockDocstoreApi')
const MockDocUpdaterApiClass = require('./mocks/MockDocUpdaterApi') const __dirname = fileURLToPath(new URL('.', import.meta.url))
let MockDocStoreApi, MockDocUpdaterApi let MockDocStoreApi, MockDocUpdaterApi

View file

@ -9,9 +9,8 @@
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const { assert, expect } = require('chai') import { expect } from 'chai'
const async = require('async') import request from './helpers/request.js'
const request = require('./helpers/request')
const assertRedirect = (method, path, expectedStatusCode, destination, cb) => const assertRedirect = (method, path, expectedStatusCode, destination, cb) =>
request[method](path, (error, response) => { request[method](path, (error, response) => {

View file

@ -1,9 +1,9 @@
const { exec } = require('child_process') import { exec } from 'child_process'
const { promisify } = require('util') import { promisify } from 'util'
const { expect } = require('chai') import { expect } from 'chai'
const logger = require('@overleaf/logger') import logger from '@overleaf/logger'
const { filterOutput } = require('./helpers/settings') import { filterOutput } from './helpers/settings.mjs'
const { db } = require('../../../app/src/infrastructure/mongodb') import { db } from '../../../app/src/infrastructure/mongodb.js'
const BATCH_SIZE = 100 const BATCH_SIZE = 100
let n = 0 let n = 0

View file

@ -1,10 +1,11 @@
const { expect } = require('chai') import { expect } from 'chai'
const async = require('async') import async from 'async'
const metrics = require('./helpers/metrics') import metrics from './helpers/metrics.js'
const User = require('./helpers/User') import User from './helpers/User.js'
const UserPromises = require('./helpers/User').promises import redis from './helpers/redis.mjs'
const redis = require('./helpers/redis') import Features from '../../../app/src/infrastructure/Features.js'
const Features = require('../../../app/src/infrastructure/Features')
const UserPromises = User.promises
// Expectations // Expectations
const expectProjectAccess = function (user, projectId, callback) { const expectProjectAccess = function (user, projectId, callback) {

View file

@ -1,8 +1,8 @@
const { db, ObjectId } = require('../../../app/src/infrastructure/mongodb') import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js'
const { promisify } = require('util') import { promisify } from 'util'
const { exec } = require('child_process') import { exec } from 'child_process'
const logger = require('@overleaf/logger/logging-manager') import logger from '@overleaf/logger'
const { expect } = require('chai') import { expect } from 'chai'
describe('RemoveDeletedUsersFromTokenAccessRefsTests', function () { describe('RemoveDeletedUsersFromTokenAccessRefsTests', function () {
const userId1 = new ObjectId() const userId1 = new ObjectId()

View file

@ -11,11 +11,12 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const { assert } = require('chai') import { assert } from 'chai'
const async = require('async')
const User = require('./helpers/User') import async from 'async'
const request = require('./helpers/request') import User from './helpers/User.js'
const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter') import request from './helpers/request.js'
import ProjectGetter from '../../../app/src/Features/Project/ProjectGetter.js'
const assertHasCommonHeaders = function (response) { const assertHasCommonHeaders = function (response) {
const { headers } = response const { headers } = response

View file

@ -1,10 +1,14 @@
const { expect } = require('chai') import { expect } from 'chai'
const fs = require('fs') import fs from 'fs'
const Path = require('path') import Path from 'path'
const fetch = require('node-fetch') import fetch from 'node-fetch'
const UserHelper = require('./helpers/UserHelper') import UserHelper from './helpers/UserHelper.js'
import glob from 'glob'
import { fileURLToPath } from 'url'
const BASE_URL = UserHelper.baseUrl() const BASE_URL = UserHelper.baseUrl()
const glob = require('glob')
const __dirname = fileURLToPath(new URL('.', import.meta.url))
// Test all files in the crash_test_urls directory // Test all files in the crash_test_urls directory
const CRASH_TEST_FILES = glob.sync( const CRASH_TEST_FILES = glob.sync(

View file

@ -1,15 +1,15 @@
const { expect } = require('chai') import { expect } from 'chai'
const async = require('async') import async from 'async'
const User = require('./helpers/User') import UserHelper from './helpers/User.js'
const redis = require('./helpers/redis') import redis from './helpers/redis.mjs'
const UserSessionsRedis = require('../../../app/src/Features/User/UserSessionsRedis') import UserSessionsRedis from '../../../app/src/Features/User/UserSessionsRedis.js'
const rclient = UserSessionsRedis.client() const rclient = UserSessionsRedis.client()
describe('Sessions', function () { describe('Sessions', function () {
beforeEach(function (done) { beforeEach(function (done) {
this.timeout(20000) this.timeout(20000)
this.user1 = new User() this.user1 = new UserHelper()
this.site_admin = new User({ email: 'admin@example.com' }) this.site_admin = new UserHelper({ email: 'admin@example.com' })
async.series( async.series(
[cb => this.user1.login(cb), cb => this.user1.logout(cb)], [cb => this.user1.login(cb), cb => this.user1.logout(cb)],
done done
@ -73,7 +73,7 @@ describe('Sessions', function () {
describe('two sessions', function () { describe('two sessions', function () {
beforeEach(function () { beforeEach(function () {
// set up second session for this user // set up second session for this user
this.user2 = new User() this.user2 = new UserHelper()
this.user2.email = this.user1.email this.user2.email = this.user1.email
this.user2.emails = this.user1.emails this.user2.emails = this.user1.emails
this.user2.password = this.user1.password this.user2.password = this.user1.password
@ -198,11 +198,11 @@ describe('Sessions', function () {
describe('three sessions, password reset', function () { describe('three sessions, password reset', function () {
beforeEach(function () { beforeEach(function () {
// set up second session for this user // set up second session for this user
this.user2 = new User() this.user2 = new UserHelper()
this.user2.email = this.user1.email this.user2.email = this.user1.email
this.user2.emails = this.user1.emails this.user2.emails = this.user1.emails
this.user2.password = this.user1.password this.user2.password = this.user1.password
this.user3 = new User() this.user3 = new UserHelper()
this.user3.email = this.user1.email this.user3.email = this.user1.email
this.user3.emails = this.user1.emails this.user3.emails = this.user1.emails
this.user3.password = this.user1.password this.user3.password = this.user1.password
@ -324,11 +324,11 @@ describe('Sessions', function () {
describe('three sessions, sessions page', function () { describe('three sessions, sessions page', function () {
beforeEach(function (done) { beforeEach(function (done) {
// set up second session for this user // set up second session for this user
this.user2 = new User() this.user2 = new UserHelper()
this.user2.email = this.user1.email this.user2.email = this.user1.email
this.user2.emails = this.user1.emails this.user2.emails = this.user1.emails
this.user2.password = this.user1.password this.user2.password = this.user1.password
this.user3 = new User() this.user3 = new UserHelper()
this.user3.email = this.user1.email this.user3.email = this.user1.email
this.user3.emails = this.user1.emails this.user3.emails = this.user1.emails
this.user3.password = this.user1.password this.user3.password = this.user1.password
@ -485,7 +485,7 @@ describe('Sessions', function () {
}) })
describe('validationToken', function () { describe('validationToken', function () {
const User = require('./helpers/User').promises const User = UserHelper.promises
async function tryWithValidationToken(validationToken) { async function tryWithValidationToken(validationToken) {
const user = new User() const user = new User()

View file

@ -8,10 +8,11 @@
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const { expect } = require('chai') import { expect } from 'chai'
const async = require('async')
const User = require('./helpers/User') import async from 'async'
const Features = require('../../../app/src/infrastructure/Features') import User from './helpers/User.js'
import Features from '../../../app/src/infrastructure/Features.js'
describe('SettingsPage', function () { describe('SettingsPage', function () {
beforeEach(function (done) { beforeEach(function (done) {

View file

@ -1,5 +1,7 @@
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User').promises import UserHelper from './helpers/User.js'
const User = UserHelper.promises
describe('Sharing', function () { describe('Sharing', function () {
beforeEach(async function () { beforeEach(async function () {

View file

@ -1,10 +1,9 @@
const User = require('./helpers/User') import User from './helpers/User.js'
const async = require('async') import async from 'async'
const { expect } = require('chai') import { expect } from 'chai'
const _ = require('lodash') import _ from 'lodash'
const request = require('./helpers/request') import request from './helpers/request.js'
import expectErrorResponse from './helpers/expectErrorResponse.js'
const expectErrorResponse = require('./helpers/expectErrorResponse')
const _initUser = (user, callback) => { const _initUser = (user, callback) => {
async.series([cb => user.login(cb), cb => user.getCsrfToken(cb)], callback) async.series([cb => user.login(cb), cb => user.getCsrfToken(cb)], callback)

View file

@ -1,12 +1,12 @@
const { expect } = require('chai') import { expect } from 'chai'
const async = require('async') import async from 'async'
const User = require('./helpers/User') import User from './helpers/User.js'
const request = require('./helpers/request') import request from './helpers/request.js'
const settings = require('@overleaf/settings') import settings from '@overleaf/settings'
const { db } = require('../../../app/src/infrastructure/mongodb') import { db } from '../../../app/src/infrastructure/mongodb.js'
const expectErrorResponse = require('./helpers/expectErrorResponse') import expectErrorResponse from './helpers/expectErrorResponse.js'
const SplitTestHandler = require('../../../app/src/Features/SplitTests/SplitTestHandler') import SplitTestHandler from '../../../app/src/Features/SplitTests/SplitTestHandler.js'
const sinon = require('sinon') import sinon from 'sinon'
const tryEditorAccess = (user, projectId, test, callback) => const tryEditorAccess = (user, projectId, test, callback) =>
async.series( async.series(

View file

@ -1,7 +1,7 @@
const { expect } = require('chai') import { expect } from 'chai'
const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter') import ProjectGetter from '../../../app/src/Features/Project/ProjectGetter.js'
const request = require('./helpers/request') import request from './helpers/request.js'
const User = require('./helpers/User') import User from './helpers/User.js'
describe('TpdsUpdateTests', function () { describe('TpdsUpdateTests', function () {
beforeEach(function (done) { beforeEach(function (done) {

View file

@ -1,5 +1,5 @@
const { expect } = require('chai') import { expect } from 'chai'
const User = require('./helpers/User') import User from './helpers/User.js'
const botUserAgents = new Map([ const botUserAgents = new Map([
[ [

View file

@ -1,7 +1,7 @@
const AuthenticationManager = require('../../../app/src/Features/Authentication/AuthenticationManager') import AuthenticationManager from '../../../app/src/Features/Authentication/AuthenticationManager.js'
const UserHelper = require('./helpers/UserHelper') import UserHelper from './helpers/UserHelper.js'
const Features = require('../../../app/src/infrastructure/Features') import Features from '../../../app/src/infrastructure/Features.js'
const { expect } = require('chai') import { expect } from 'chai'
describe('UserHelper', function () { describe('UserHelper', function () {
// Disable all tests unless the registration feature is enabled // Disable all tests unless the registration feature is enabled

View file

@ -1,9 +1,9 @@
const { expect } = require('chai') import { expect } from 'chai'
const async = require('async') import async from 'async'
const User = require('./helpers/User') import User from './helpers/User.js'
const Institution = require('./helpers/Institution') import Institution from './helpers/Institution.js'
const Subscription = require('./helpers/Subscription') import Subscription from './helpers/Subscription.js'
const Publisher = require('./helpers/Publisher') import Publisher from './helpers/Publisher.js'
describe('UserMembershipAuthorization', function () { describe('UserMembershipAuthorization', function () {
beforeEach(function (done) { beforeEach(function (done) {

View file

@ -11,9 +11,10 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const { expect } = require('chai') import { expect } from 'chai'
const async = require('async')
const User = require('./helpers/User') import async from 'async'
import User from './helpers/User.js'
describe('User Must Reconfirm', function () { describe('User Must Reconfirm', function () {
beforeEach(function (done) { beforeEach(function (done) {

View file

@ -1,10 +1,8 @@
const { expect } = require('chai') import { expect } from 'chai'
const MockSubscription = require('./Subscription') import MockSubscription from './Subscription.js'
const SubscriptionUpdater = require('../../../../app/src/Features/Subscription/SubscriptionUpdater') import SubscriptionUpdater from '../../../../app/src/Features/Subscription/SubscriptionUpdater.js'
const SubscriptionModel = import { Subscription as SubscriptionModel } from '../../../../app/src/models/Subscription.js'
require('../../../../app/src/models/Subscription').Subscription import { DeletedSubscription as DeletedSubscriptionModel } from '../../../../app/src/models/DeletedSubscription.js'
const DeletedSubscriptionModel =
require('../../../../app/src/models/DeletedSubscription').DeletedSubscription
class DeletedSubscription { class DeletedSubscription {
constructor(options = {}) { constructor(options = {}) {
@ -43,4 +41,4 @@ class DeletedSubscription {
} }
} }
module.exports = DeletedSubscription export default DeletedSubscription

View file

@ -1,13 +1,13 @@
import App from '../../../../app.mjs' import App from '../../../../app.mjs'
import QueueWorkers from '../../../../app/src/infrastructure/QueueWorkers.js' import QueueWorkers from '../../../../app/src/infrastructure/QueueWorkers.js'
import MongoHelper from './MongoHelper.js' import MongoHelper from './MongoHelper.mjs'
import RedisHelper from './RedisHelper.js' import RedisHelper from './RedisHelper.mjs'
import logger from '@overleaf/logger' import logger from '@overleaf/logger'
import Settings from '@overleaf/settings' import Settings from '@overleaf/settings'
import MockReCAPTCHAApi from '../mocks/MockReCaptchaApi.js' import MockReCAPTCHAApi from '../mocks/MockReCaptchaApi.mjs'
import { gracefulShutdown } from '../../../../app/src/infrastructure/GracefulShutdown.js' import { gracefulShutdown } from '../../../../app/src/infrastructure/GracefulShutdown.js'
import Server from '../../../../app/src/infrastructure/Server.mjs' import Server from '../../../../app/src/infrastructure/Server.mjs'
import { injectRouteAfter } from './injectRoute.js' import { injectRouteAfter } from './injectRoute.mjs'
import SplitTestHandler from '../../../../app/src/Features/SplitTests/SplitTestHandler.js' import SplitTestHandler from '../../../../app/src/Features/SplitTests/SplitTestHandler.js'
import SplitTestSessionHandler from '../../../../app/src/Features/SplitTests/SplitTestSessionHandler.js' import SplitTestSessionHandler from '../../../../app/src/Features/SplitTests/SplitTestSessionHandler.js'
import Modules from '../../../../app/src/infrastructure/Modules.js' import Modules from '../../../../app/src/infrastructure/Modules.js'

View file

@ -1,14 +1,14 @@
const { execFile } = require('child_process') import { execFile } from 'child_process'
const { import {
waitForDb, waitForDb,
db, db,
dropTestDatabase, dropTestDatabase,
} = require('../../../../app/src/infrastructure/mongodb') } from '../../../../app/src/infrastructure/mongodb.js'
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const DEFAULT_ENV = 'saas' const DEFAULT_ENV = 'saas'
module.exports = { export default {
initialize() { initialize() {
before('wait for db', waitForDb) before('wait for db', waitForDb)
if (process.env.CLEANUP_MONGO === 'true') { if (process.env.CLEANUP_MONGO === 'true') {

View file

@ -1,7 +1,7 @@
const RedisWrapper = require('../../../../app/src/infrastructure/RedisWrapper') import RedisWrapper from '../../../../app/src/infrastructure/RedisWrapper.js'
const client = RedisWrapper.client('ratelimiter') const client = RedisWrapper.client('ratelimiter')
module.exports = { export default {
initialize() { initialize() {
beforeEach('clear redis', function (done) { beforeEach('clear redis', function (done) {
client.flushdb(done) client.flushdb(done)

View file

@ -6,7 +6,7 @@
* @param searchFilter - a filter function to locate a route to position the new route immediatley after. * @param searchFilter - a filter function to locate a route to position the new route immediatley after.
* @param addRouteCallback - a callback that takes a router and creates the new route. * @param addRouteCallback - a callback that takes a router and creates the new route.
*/ */
function injectRouteAfter(app, searchFilter, addRouteCallback) { export function injectRouteAfter(app, searchFilter, addRouteCallback) {
const stack = app._router.stack const stack = app._router.stack
stack.forEach(layer => { stack.forEach(layer => {
@ -36,4 +36,4 @@ function injectRouteAfter(app, searchFilter, addRouteCallback) {
}) })
} }
module.exports = { injectRouteAfter } export default { injectRouteAfter }

View file

@ -11,16 +11,16 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const Settings = require('@overleaf/settings') import Settings from '@overleaf/settings'
const logger = require('@overleaf/logger')
const Async = require('async')
const UserSessionsRedis = require('../../../../app/src/Features/User/UserSessionsRedis') import logger from '@overleaf/logger'
import Async from 'async'
import UserSessionsRedis from '../../../../app/src/Features/User/UserSessionsRedis.js'
// rclient = redis.createClient(Settings.redis.web) // rclient = redis.createClient(Settings.redis.web)
const rclient = UserSessionsRedis.client() const rclient = UserSessionsRedis.client()
module.exports = { export default {
getUserSessions(user, callback) { getUserSessions(user, callback) {
if (callback == null) { if (callback == null) {
callback = function () {} callback = function () {}

View file

@ -1,4 +1,4 @@
function filterOutput(line) { export function filterOutput(line) {
return ( return (
!line.startsWith('Using settings from ') && !line.startsWith('Using settings from ') &&
!line.startsWith('Using default settings from ') && !line.startsWith('Using default settings from ') &&
@ -7,4 +7,4 @@ function filterOutput(line) {
) )
} }
module.exports = { filterOutput } export default { filterOutput }

View file

@ -1,4 +1,4 @@
const AbstractMockApi = require('./AbstractMockApi') import AbstractMockApi from './AbstractMockApi.js'
class MockAnalyticsApi extends AbstractMockApi { class MockAnalyticsApi extends AbstractMockApi {
reset() { reset() {
@ -30,7 +30,7 @@ class MockAnalyticsApi extends AbstractMockApi {
} }
} }
module.exports = MockAnalyticsApi export default MockAnalyticsApi
// type hint for the inherited `instance` method // type hint for the inherited `instance` method
/** /**

View file

@ -1,4 +1,4 @@
const AbstractMockApi = require('./AbstractMockApi') import AbstractMockApi from './AbstractMockApi.js'
class MockChatApi extends AbstractMockApi { class MockChatApi extends AbstractMockApi {
reset() { reset() {
@ -41,7 +41,7 @@ class MockChatApi extends AbstractMockApi {
} }
} }
module.exports = MockChatApi export default MockChatApi
// type hint for the inherited `instance` method // type hint for the inherited `instance` method
/** /**

View file

@ -1,7 +1,5 @@
const AbstractMockApi = require('./AbstractMockApi') import AbstractMockApi from './AbstractMockApi.js'
const { import { plainTextResponse } from '../../../../app/src/infrastructure/Response.js'
plainTextResponse,
} = require('../../../../app/src/infrastructure/Response')
class MockClsiApi extends AbstractMockApi { class MockClsiApi extends AbstractMockApi {
static compile(req, res) { static compile(req, res) {
@ -61,7 +59,7 @@ class MockClsiApi extends AbstractMockApi {
} }
} }
module.exports = MockClsiApi export default MockClsiApi
// type hint for the inherited `instance` method // type hint for the inherited `instance` method
/** /**

View file

@ -1,4 +1,4 @@
const AbstractMockApi = require('./AbstractMockApi') import AbstractMockApi from './AbstractMockApi.js'
class MockGitBridgeApi extends AbstractMockApi { class MockGitBridgeApi extends AbstractMockApi {
reset() { reset() {
@ -18,4 +18,4 @@ class MockGitBridgeApi extends AbstractMockApi {
} }
} }
module.exports = MockGitBridgeApi export default MockGitBridgeApi

View file

@ -1,7 +1,5 @@
const AbstractMockApi = require('./AbstractMockApi') import AbstractMockApi from './AbstractMockApi.js'
const { import { plainTextResponse } from '../../../../app/src/infrastructure/Response.js'
plainTextResponse,
} = require('../../../../app/src/infrastructure/Response')
class MockHaveIBeenPwnedApi extends AbstractMockApi { class MockHaveIBeenPwnedApi extends AbstractMockApi {
reset() { reset() {
@ -42,7 +40,7 @@ class MockHaveIBeenPwnedApi extends AbstractMockApi {
} }
} }
module.exports = MockHaveIBeenPwnedApi export default MockHaveIBeenPwnedApi
// type hint for the inherited `instance` method // type hint for the inherited `instance` method
/** /**

View file

@ -1,4 +1,4 @@
const AbstractMockApi = require('./AbstractMockApi') import AbstractMockApi from './AbstractMockApi.js'
// Currently there is nothing implemented here as we have no acceptance tests // Currently there is nothing implemented here as we have no acceptance tests
// for the notifications API. This does however stop errors appearing in the // for the notifications API. This does however stop errors appearing in the
@ -11,7 +11,7 @@ class MockNotificationsApi extends AbstractMockApi {
} }
} }
module.exports = MockNotificationsApi export default MockNotificationsApi
// type hint for the inherited `instance` method // type hint for the inherited `instance` method
/** /**

View file

@ -1,4 +1,4 @@
const AbstractMockApi = require('./AbstractMockApi') import AbstractMockApi from './AbstractMockApi.js'
class MockReCaptchaApi extends AbstractMockApi { class MockReCaptchaApi extends AbstractMockApi {
applyRoutes() { applyRoutes() {
@ -10,7 +10,7 @@ class MockReCaptchaApi extends AbstractMockApi {
} }
} }
module.exports = MockReCaptchaApi export default MockReCaptchaApi
// type hint for the inherited `instance` method // type hint for the inherited `instance` method
/** /**

View file

@ -1,4 +1,4 @@
const AbstractMockApi = require('./AbstractMockApi') import AbstractMockApi from './AbstractMockApi.js'
class MockSpellingApi extends AbstractMockApi { class MockSpellingApi extends AbstractMockApi {
reset() { reset() {
@ -44,7 +44,7 @@ class MockSpellingApi extends AbstractMockApi {
} }
} }
module.exports = MockSpellingApi export default MockSpellingApi
// type hint for the inherited `instance` method // type hint for the inherited `instance` method
/** /**

View file

@ -1,4 +1,4 @@
const AbstractMockApi = require('./AbstractMockApi') import AbstractMockApi from './AbstractMockApi.js'
class MockThirdPartyDataStoreApi extends AbstractMockApi { class MockThirdPartyDataStoreApi extends AbstractMockApi {
reset() {} reset() {}
@ -19,7 +19,7 @@ class MockThirdPartyDataStoreApi extends AbstractMockApi {
} }
} }
module.exports = MockThirdPartyDataStoreApi export default MockThirdPartyDataStoreApi
// type hint for the inherited `instance` method // type hint for the inherited `instance` method
/** /**