mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-20 02:03:48 +00:00
[misc] back-fill stubbing of mongodb package in sandboxed-module imports (#3209)
* [misc] back-fill stubbing of mongodb package in sandboxed-module imports Unit tests are about 10 percent faster: 9m16s vs 10m8s. * [misc] stubs: app code should have access to the ObjectId only GitOrigin-RevId: 9a52186e190863c9463b3aeb98c3db68011926e4
This commit is contained in:
parent
6f6a9e714d
commit
b3197b5f12
15 changed files with 17 additions and 1 deletions
|
@ -19,6 +19,7 @@ const modulePath =
|
|||
'../../../../app/src/Features/Authorization/AuthorizationManager.js'
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const Errors = require('../../../../app/src/Features/Errors/Errors.js')
|
||||
const { ObjectId } = require('mongodb')
|
||||
|
||||
describe('AuthorizationManager', function() {
|
||||
beforeEach(function() {
|
||||
|
@ -27,6 +28,7 @@ describe('AuthorizationManager', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'../Collaborators/CollaboratorsGetter': (this.CollaboratorsGetter = {}),
|
||||
'../Collaborators/CollaboratorsHandler': (this.CollaboratorsHandler = {}),
|
||||
'../Project/ProjectGetter': (this.ProjectGetter = {}),
|
||||
|
|
|
@ -61,6 +61,7 @@ describe('CollaboratorsController', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'./CollaboratorsHandler': this.CollaboratorsHandler,
|
||||
'./CollaboratorsGetter': this.CollaboratorsGetter,
|
||||
'./OwnershipTransferHandler': this.OwnershipTransferHandler,
|
||||
|
|
|
@ -51,6 +51,7 @@ describe('CollaboratorsGetter', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'../User/UserGetter': this.UserGetter,
|
||||
'../../models/Project': { Project },
|
||||
'../Project/ProjectGetter': this.ProjectGetter,
|
||||
|
|
|
@ -38,6 +38,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'../../models/Project': { Project: this.ProjectModel }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ describe('ProjectController', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'settings-sharelatex': this.settings,
|
||||
'logger-sharelatex': {
|
||||
log() {},
|
||||
|
|
|
@ -4,6 +4,7 @@ const modulePath =
|
|||
'../../../../app/src/Features/Project/ProjectCreationHandler.js'
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const Path = require('path')
|
||||
const { ObjectId } = require('mongodb')
|
||||
|
||||
describe('ProjectCreationHandler', function() {
|
||||
const ownerId = '4eecb1c1bffa66588e0000a1'
|
||||
|
@ -64,6 +65,7 @@ describe('ProjectCreationHandler', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'../../models/User': {
|
||||
User: this.User
|
||||
},
|
||||
|
|
|
@ -186,6 +186,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'logger-sharelatex': this.logger,
|
||||
'settings-sharelatex': this.Settings,
|
||||
'../Cooldown/CooldownManager': this.CooldownManager,
|
||||
|
|
|
@ -36,6 +36,7 @@ describe('ProjectHelper', function() {
|
|||
|
||||
this.ProjectHelper = SandboxedModule.require(MODULE_PATH, {
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'settings-sharelatex': this.Settings
|
||||
}
|
||||
})
|
||||
|
|
|
@ -98,6 +98,7 @@ describe('SubscriptionUpdater', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'../../models/Subscription': {
|
||||
Subscription: this.SubscriptionModel
|
||||
},
|
||||
|
|
|
@ -87,6 +87,7 @@ describe('TeamInvitesHandler', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'logger-sharelatex': { log() {} },
|
||||
crypto: this.crypto,
|
||||
'settings-sharelatex': { siteUrl: 'http://example.com' },
|
||||
|
|
|
@ -64,6 +64,7 @@ describe('TpdsUpdateSender', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'settings-sharelatex': this.settings,
|
||||
'logger-sharelatex': { log() {} },
|
||||
'request-promise-native': this.request,
|
||||
|
|
|
@ -39,6 +39,7 @@ describe('TokenAccessHandler', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'../../models/Project': { Project: (this.Project = {}) },
|
||||
'settings-sharelatex': (this.settings = {}),
|
||||
'../Collaborators/CollaboratorsGetter': (this.CollaboratorsGetter = {}),
|
||||
|
|
|
@ -39,6 +39,7 @@ describe('UserInfoController', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'./UserGetter': this.UserGetter,
|
||||
'./UserUpdater': this.UserUpdater,
|
||||
'./UserDeleter': this.UserDeleter,
|
||||
|
|
|
@ -72,6 +72,7 @@ describe('UserMembershipHandler', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: { ObjectId },
|
||||
'./UserMembershipViewModel': this.UserMembershipViewModel,
|
||||
'../User/UserGetter': this.UserGetter,
|
||||
'../Errors/Errors': Errors,
|
||||
|
|
|
@ -29,7 +29,7 @@ describe('UserMembershipViewModel', function() {
|
|||
console: console
|
||||
},
|
||||
requires: {
|
||||
mongodb: require('mongodb'),
|
||||
mongodb: { ObjectId },
|
||||
'../User/UserGetter': this.UserGetter
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue