From 9ddaa8c9f652a61386133ffc21fbbe23aafe5211 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween Date: Wed, 31 Mar 2021 08:20:55 -0400 Subject: [PATCH] Merge pull request #3830 from overleaf/em-upgrade-node-12 Upgrade to Node 12 GitOrigin-RevId: 19870922884b7c98e7e5f2c94df21829672d2db5 --- services/web/Dockerfile | 2 +- services/web/Dockerfile.frontend | 2 +- services/web/docker-compose.yml | 2 +- .../aceEditor/auto-complete/CommandManager.js | 2 +- .../js/ide/file-tree/FileTreeManager.js | 4 +- .../js/ide/review-panel/RangesTracker.js | 8 +- .../test/unit/src/LaunchpadControllerTests.js | 10 - .../unit/src/UserActivateControllerTests.js | 3 - services/web/package-lock.json | 507 +++++++++++++----- services/web/package.json | 6 +- services/web/test/acceptance/bootstrap.js | 2 + .../web/test/acceptance/src/CloseSiteTests.js | 1 - .../web/test/acceptance/src/ModelTests.js | 5 +- services/web/test/acceptance/src/ProxyUrls.js | 5 +- .../test/acceptance/src/RedirectUrlsTests.js | 7 +- .../test/acceptance/src/RegistrationTests.js | 3 +- .../web/test/acceptance/src/SettingsTests.js | 6 +- .../test/acceptance/src/UserHelperTests.js | 7 +- .../test/acceptance/src/UserReconfirmTests.js | 1 - .../src/UserThirdPartyIdentityTests.js | 4 +- services/web/test/unit/bootstrap.js | 137 +++-- .../src/Analytics/AnalyticsControllerTests.js | 6 - .../src/Analytics/AnalyticsManagerTests.js | 6 - .../AuthenticationControllerTests.js | 12 +- .../AuthenticationManagerTests.js | 7 +- .../AuthorizationManagerTests.js | 7 +- .../AuthorizationMiddlewareTests.js | 4 - .../BetaProgram/BetaProgramControllerTests.js | 10 - .../BetaProgram/BetaProgramHandlerTests.js | 7 +- .../BrandVariationsHandlerTests.js | 12 +- .../test/unit/src/Chat/ChatApiHandlerTests.js | 9 - .../test/unit/src/Chat/ChatControllerTests.js | 10 +- .../CollaboratorsControllerTests.js | 11 +- .../Collaborators/CollaboratorsGetterTests.js | 3 - .../CollaboratorsHandlerTests.js | 9 - .../CollaboratorsInviteControllerTests.js | 13 +- .../CollaboratorsInviteHandlerTests.js | 13 +- .../OwnershipTransferHandlerTests.js | 10 +- .../src/Compile/ClsiCookieManagerTests.js | 16 +- .../src/Compile/ClsiFormatCheckerTests.js | 14 +- .../test/unit/src/Compile/ClsiManagerTests.js | 13 +- .../unit/src/Compile/ClsiStateManagerTests.js | 14 +- .../src/Compile/CompileControllerTests.js | 12 +- .../unit/src/Compile/CompileManagerTests.js | 12 +- .../src/Contact/ContactControllerTests.js | 12 +- .../unit/src/Contact/ContactManagerTests.js | 5 - .../unit/src/Cooldown/CooldownManagerTests.js | 7 +- .../src/Cooldown/CooldownMiddlewareTests.js | 7 +- .../unit/src/Docstore/DocstoreManagerTests.js | 11 - .../DocumentUpdaterHandlerTests.js | 4 - .../src/Documents/DocumentControllerTests.js | 12 +- .../unit/src/Documents/DocumentHelperTests.js | 4 +- .../ProjectDownloadsControllerTests.js | 8 +- .../Downloads/ProjectZipStreamManagerTests.js | 11 +- .../unit/src/Editor/EditorControllerTests.js | 10 +- .../src/Editor/EditorHttpControllerTests.js | 8 - .../Editor/EditorRealTimeControllerTests.js | 4 - .../test/unit/src/Email/EmailBuilderTests.js | 8 +- .../test/unit/src/Email/EmailHandlerTests.js | 8 +- .../unit/src/Email/EmailMessageHelperTests.js | 6 +- .../test/unit/src/Email/EmailSenderTests.js | 8 - .../unit/src/Errors/HttpErrorHandlerTests.js | 11 +- .../src/Exports/ExportsControllerTests.js | 10 +- .../unit/src/Exports/ExportsHandlerTests.js | 12 +- .../src/FileStore/FileStoreControllerTests.js | 7 - .../src/FileStore/FileStoreHandlerTests.js | 12 +- .../HelperFiles/AuthorizationHelperTests.js | 6 +- .../unit/src/HelperFiles/UrlHelperTests.js | 3 +- .../src/History/HistoryControllerTests.js | 10 - .../unit/src/History/HistoryManagerTests.js | 3 - .../unit/src/History/RestoreManagerTests.js | 10 +- .../InactiveProjectManagerTests.js | 14 - .../src/Institutions/InstitutionsAPITests.js | 38 +- .../InstitutionsControllerTests.js | 8 +- .../Institutions/InstitutionsFeaturesTests.js | 8 - .../Institutions/InstitutionsGetterTests.js | 10 +- .../Institutions/InstitutionsManagerTests.js | 18 +- .../unit/src/Metadata/MetaControllerTests.js | 12 +- .../unit/src/Metadata/MetaHandlerTests.js | 7 +- .../src/Newsletter/NewsletterManagerTests.js | 4 +- .../NotificationsBuilderTests.js | 10 +- .../NotificationsControllerTests.js | 8 - .../NotificationsHandlerTests.js | 10 +- .../PasswordResetControllerTests.js | 9 - .../PasswordResetHandlerTests.js | 13 +- .../src/Project/DocLinesComparitorTests.js | 11 +- .../src/Project/ProjectApiControllerTests.js | 10 +- .../Project/ProjectCollabratecDetailsTest.js | 7 +- .../src/Project/ProjectControllerTests.js | 10 - .../Project/ProjectCreationHandlerTests.js | 4 - .../unit/src/Project/ProjectDeleterTests.js | 15 +- .../src/Project/ProjectDetailsHandlerTests.js | 8 - .../src/Project/ProjectDuplicatorTests.js | 10 +- .../src/Project/ProjectEditorHandlerTests.js | 36 +- .../src/Project/ProjectEntityHandlerTests.js | 13 +- .../ProjectEntityMongoUpdateHandlerTests.js | 10 - .../ProjectEntityUpdateHandlerTests.js | 14 +- .../unit/src/Project/ProjectGetterTests.js | 10 +- .../unit/src/Project/ProjectHelperTests.js | 3 +- .../src/Project/ProjectHistoryHandlerTests.js | 13 +- .../unit/src/Project/ProjectLocatorTests.js | 10 +- .../src/Project/ProjectOptionsHandlerTests.js | 11 +- .../src/Project/ProjectRootDocManagerTests.js | 7 +- .../src/Project/ProjectUpdateHandlerTests.js | 7 +- .../test/unit/src/Project/SafePathTests.js | 5 +- .../src/Publishers/PublishersGetterTests.js | 10 +- .../unit/src/Referal/ReferalAllocatorTests.js | 10 +- .../unit/src/Referal/ReferalConnectTests.js | 13 +- .../src/Referal/ReferalControllerTests.js | 13 +- .../unit/src/Referal/ReferalFeaturesTests.js | 10 +- .../unit/src/Referal/ReferalHandlerTests.js | 17 +- .../References/ReferencesControllerTests.js | 8 - .../src/References/ReferencesHandlerTests.js | 12 +- .../unit/src/SamlLog/SamlLogHandlerTests.js | 19 +- .../src/Security/LoginRateLimiterTests.js | 4 - .../src/Security/OneTimeTokenHandlerTests.js | 7 - .../Security/RateLimiterMiddlewareTests.js | 5 - .../SessionAutostartMiddlewareTests.js | 6 +- .../src/Security/SessionStoreManagerTests.js | 14 +- .../src/Spelling/SpellingControllerTests.js | 6 - .../unit/src/Spelling/SpellingHandlerTests.js | 5 - .../src/Subscription/FeaturesUpdaterTests.js | 7 - .../Subscription/LimitationsManagerTests.js | 9 +- .../src/Subscription/RecurlyWrapperTests.js | 14 +- .../SubscriptionControllerTests.js | 9 - .../SubscriptionGroupControllerTests.js | 7 - .../SubscriptionGroupHandlerTests.js | 18 +- .../Subscription/SubscriptionHandlerTests.js | 6 - .../Subscription/SubscriptionLocatorTests.js | 7 - .../Subscription/SubscriptionUpdaterTests.js | 10 - .../Subscription/TeamInvitesHandlerTests.js | 4 - .../Subscription/UserFeaturesUpdaterTests.js | 7 - .../V1SusbcriptionManagerTests.js | 9 - .../SystemMessageManagerTests.js | 4 - .../test/unit/src/Tags/TagsControllerTests.js | 8 - .../test/unit/src/Tags/TagsHandlerTests.js | 1 - .../src/Templates/TemplatesControllerTests.js | 14 +- .../src/Templates/TemplatesManagerTests.js | 10 - .../TpdsControllerTests.js | 10 - .../TpdsProjectFlusherTests.js | 1 - .../TpdsUpdateHandlerTests.js | 6 +- .../TpdsUpdateSenderTests.js | 7 - .../ThirdPartyDataStore/UpdateMergerTests.js | 7 - .../TokenAccess/TokenAccessHandlerTests.js | 5 - .../unit/src/Uploads/ArchiveManagerTests.js | 12 - .../Uploads/FileSystemImportManagerTests.js | 10 +- .../unit/src/Uploads/FileTypeManagerTests.js | 7 +- .../Uploads/ProjectUploadControllerTests.js | 12 +- .../src/Uploads/ProjectUploadManagerTests.js | 4 - .../unit/src/User/SAMLIdentityManagerTests.js | 14 +- .../User/ThirdPartyIdentityManagerTests.js | 9 +- .../unit/src/User/UserAuditLogHandlerTests.js | 3 - .../test/unit/src/User/UserControllerTests.js | 12 +- .../test/unit/src/User/UserCreatorTests.js | 13 +- .../test/unit/src/User/UserDeleterTests.js | 14 +- .../UserEmailsConfirmationHandlerTests.js | 5 - .../src/User/UserEmailsControllerTests.js | 13 +- .../web/test/unit/src/User/UserGetterTests.js | 11 +- .../test/unit/src/User/UserHandlerTests.js | 3 - .../unit/src/User/UserInfoControllerTests.js | 11 +- .../unit/src/User/UserPagesControllerTests.js | 15 - .../src/User/UserRegistrationHandlerTests.js | 5 - .../unit/src/User/UserSessionsManagerTests.js | 14 +- .../test/unit/src/User/UserUpdaterTests.js | 62 +-- .../UserMembershipControllerTests.js | 14 +- .../UserMembershipHandlerTests.js | 13 +- .../UserMembershipViewModelTests.js | 13 +- .../UserMembershipsHandlerTests.js | 3 - .../test/unit/src/infrastructure/CsrfTests.js | 8 +- .../unit/src/infrastructure/FeaturesTests.js | 6 +- .../src/infrastructure/GeoIpLookupTests.js | 10 +- .../LockManager/ReleasingTheLock.js | 3 - .../LockManager/getLockTests.js | 8 - .../LockManager/tryLockTests.js | 8 - .../src/infrastructure/ProxyManagerTests.js | 10 +- .../src/infrastructure/RateLimterTests.js | 12 +- 176 files changed, 695 insertions(+), 1555 deletions(-) diff --git a/services/web/Dockerfile b/services/web/Dockerfile index 5db3a53d1f..0a2e5d6983 100644 --- a/services/web/Dockerfile +++ b/services/web/Dockerfile @@ -1,5 +1,5 @@ # the base image is suitable for running web with /app bind mounted -FROM node:10.23.1 as base +FROM node:12.21.0 as base WORKDIR /app diff --git a/services/web/Dockerfile.frontend b/services/web/Dockerfile.frontend index bc7f89664a..3c5a06cdb8 100644 --- a/services/web/Dockerfile.frontend +++ b/services/web/Dockerfile.frontend @@ -1,4 +1,4 @@ -FROM node:10.23.1 +FROM node:12.21.0 # Install Google Chrome RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - diff --git a/services/web/docker-compose.yml b/services/web/docker-compose.yml index a221d16ad1..60ed6f3d05 100644 --- a/services/web/docker-compose.yml +++ b/services/web/docker-compose.yml @@ -19,7 +19,7 @@ services: user: node test_acceptance: - image: node:10.23.1 + image: node:12.21.0 volumes: - .:/app working_dir: /app diff --git a/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/CommandManager.js b/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/CommandManager.js index 796b75b099..c41f87eba7 100644 --- a/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/CommandManager.js +++ b/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/CommandManager.js @@ -87,7 +87,7 @@ class Parser { // check incidentals, see if we should pluck out a match if (incidentalCommands.length > 1) { const bestMatch = incidentalCommands.sort( - (a, b) => a[1] + a[2] < b[1] + b[2] + (a, b) => b[1] + b[2] - (a[1] + a[2]) )[0] realCommands.push(bestMatch) } diff --git a/services/web/frontend/js/ide/file-tree/FileTreeManager.js b/services/web/frontend/js/ide/file-tree/FileTreeManager.js index b56cc4aa97..99fe3830cf 100644 --- a/services/web/frontend/js/ide/file-tree/FileTreeManager.js +++ b/services/web/frontend/js/ide/file-tree/FileTreeManager.js @@ -477,8 +477,10 @@ export default FileTreeManager = class FileTreeManager { return -(aDepth - bDepth) // Deeper path == folder first } else if (a.path < b.path) { return -1 - } else { + } else if (a.path > b.path) { return 1 + } else { + return 0 } }) } diff --git a/services/web/frontend/js/ide/review-panel/RangesTracker.js b/services/web/frontend/js/ide/review-panel/RangesTracker.js index 4ca3863a48..077a635033 100644 --- a/services/web/frontend/js/ide/review-panel/RangesTracker.js +++ b/services/web/frontend/js/ide/review-panel/RangesTracker.js @@ -705,8 +705,10 @@ export default RangesTracker = class RangesTracker { return result } else if (c1.op.i != null && c2.op.d != null) { return 1 - } else { + } else if (c1.op.d != null && c2.op.i != null) { return -1 + } else { + return 0 } }) @@ -727,8 +729,10 @@ export default RangesTracker = class RangesTracker { return result } else if (a.i != null && b.d != null) { return 1 - } else { + } else if (a.d != null && b.i != null) { return -1 + } else { + return 0 } }) diff --git a/services/web/modules/launchpad/test/unit/src/LaunchpadControllerTests.js b/services/web/modules/launchpad/test/unit/src/LaunchpadControllerTests.js index f1e61d9853..7ca3559f30 100644 --- a/services/web/modules/launchpad/test/unit/src/LaunchpadControllerTests.js +++ b/services/web/modules/launchpad/test/unit/src/LaunchpadControllerTests.js @@ -12,7 +12,6 @@ */ const SandboxedModule = require('sandboxed-module') const assert = require('assert') -require('chai').should() const { expect } = require('chai') const sinon = require('sinon') const modulePath = require('path').join( @@ -31,17 +30,8 @@ describe('LaunchpadController', function() { this.User = {} this.LaunchpadController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': (this.Settings = {}), - 'logger-sharelatex': (this.Logger = { - log() {}, - warn() {}, - err() {}, - error() {} - }), '@overleaf/metrics': (this.Metrics = {}), '../../../../app/src/Features/User/UserRegistrationHandler': (this.UserRegistrationHandler = {}), '../../../../app/src/Features/Email/EmailHandler': (this.EmailHandler = {}), diff --git a/services/web/modules/user-activate/test/unit/src/UserActivateControllerTests.js b/services/web/modules/user-activate/test/unit/src/UserActivateControllerTests.js index 65d328bf1c..59ed17ea9a 100644 --- a/services/web/modules/user-activate/test/unit/src/UserActivateControllerTests.js +++ b/services/web/modules/user-activate/test/unit/src/UserActivateControllerTests.js @@ -19,9 +19,6 @@ describe('UserActivateController', function() { this.UserGetter = { getUser: sinon.stub() } this.ErrorController = { notFound: sinon.stub() } this.UserActivateController = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { '../../../../app/src/Features/User/UserGetter': this.UserGetter, '../../../../app/src/Features/Errors/ErrorController': this diff --git a/services/web/package-lock.json b/services/web/package-lock.json index 6f1a9484a3..18d4e76466 100644 --- a/services/web/package-lock.json +++ b/services/web/package-lock.json @@ -3401,9 +3401,9 @@ }, "dependencies": { "core-js": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.8.3.tgz", - "integrity": "sha512-KPYXeVZYemC2TkNEkX/01I+7yd+nX3KddKwZ1Ww7SKWdI2wQprSgLmrTddT8nw92AjEklTsPBoSdQBhbI1bQ6Q==" + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.9.1.tgz", + "integrity": "sha512-gSjRvzkxQc1zjM/5paAmL4idJBFzuJoo+jDjF1tStYFMV2ERfD02HhahhCGXUyHxQRG4yFKVSdO6g62eoRMcDg==" } } }, @@ -6000,6 +6000,12 @@ "cuid": "^2.1.1" } }, + "@ungap/promise-all-settled": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", + "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", + "dev": true + }, "@webassemblyjs/ast": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz", @@ -14928,21 +14934,10 @@ } }, "flat": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", - "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", - "dev": true, - "requires": { - "is-buffer": "~2.0.3" - }, - "dependencies": { - "is-buffer": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", - "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", - "dev": true - } - } + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true }, "flat-cache": { "version": "3.0.4", @@ -15440,7 +15435,7 @@ "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", "dev": true }, "functions-have-names": { @@ -20718,128 +20713,369 @@ } }, "mocha": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.2.tgz", - "integrity": "sha512-FgDS9Re79yU1xz5d+C4rv1G7QagNGHZ+iXF81hO8zY35YZZcLEsJVfFolfsqKFWunATEvNzMK0r/CwWd/szO9A==", + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.3.2.tgz", + "integrity": "sha512-UdmISwr/5w+uXLPKspgoV7/RXZwKRTiTjJ2/AC5ZiEztIoOYdfKb19+9jNmEInzx5pBsCyJQzarAxqIGBNYJhg==", "dev": true, "requires": { - "ansi-colors": "3.2.3", + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "debug": "3.2.6", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "find-up": "3.0.0", - "glob": "7.1.3", + "chokidar": "3.5.1", + "debug": "4.3.1", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.6", "growl": "1.10.5", "he": "1.2.0", - "js-yaml": "3.13.1", - "log-symbols": "2.2.0", + "js-yaml": "4.0.0", + "log-symbols": "4.0.0", "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "ms": "2.1.1", - "node-environment-flags": "1.0.5", - "object.assign": "4.1.0", - "strip-json-comments": "2.0.1", - "supports-color": "6.0.0", - "which": "1.3.1", + "ms": "2.1.3", + "nanoid": "3.1.20", + "serialize-javascript": "5.0.1", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", "wide-align": "1.1.3", - "yargs": "13.3.0", - "yargs-parser": "13.1.1", - "yargs-unparser": "1.6.0" + "workerpool": "6.1.0", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" }, "dependencies": { "ansi-colors": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", - "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", "dev": true }, - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", "dev": true, "requires": { - "ms": "^2.1.1" + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "chokidar": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", + "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "dev": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.3.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.5.0" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" } }, "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "requires": { - "locate-path": "^3.0.0" + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" } }, - "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "is-glob": "^4.0.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "js-yaml": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", + "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", + "dev": true, + "requires": { + "argparse": "^2.0.1" } }, "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" + "p-locate": "^5.0.0" } }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha512-miQKw5Hv4NS1Psg2517mV4e4dYNaO3++hjAvLOAzKqZ61rH8NS1SK+vbfBWZ5PY/Me/bEWhUwqMghEW5Fb9T7Q==" + "log-symbols": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", + "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", + "dev": true, + "requires": { + "chalk": "^4.0.0" + } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "p-locate": { + "normalize-path": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "requires": { - "p-limit": "^2.0.0" + "yocto-queue": "^0.1.0" } }, - "supports-color": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", - "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "p-limit": "^3.0.2" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "readdirp": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", + "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "serialize-javascript": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-5.0.1.tgz", + "integrity": "sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz", + "integrity": "sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==", + "dev": true + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" } }, "yargs-parser": { - "version": "13.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", - "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true } } }, @@ -21147,6 +21383,12 @@ "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" }, + "nanoid": { + "version": "3.1.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", + "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==", + "dev": true + }, "nanomatch": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", @@ -21185,7 +21427,7 @@ "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "ncp": { @@ -21334,24 +21576,6 @@ "resolved": "https://registry.npmjs.org/node-ensure/-/node-ensure-0.0.0.tgz", "integrity": "sha512-DRI60hzo2oKN1ma0ckc6nQWlHU69RH6xN0sjQTjMpChPfTYvKZdcQFfdYK2RWbJcKyUizSIy/l8OTGxMAM1QDw==" }, - "node-environment-flags": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", - "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", - "dev": true, - "requires": { - "object.getownpropertydescriptors": "^2.0.3", - "semver": "^5.7.0" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } - } - }, "node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", @@ -27008,7 +27232,7 @@ "require-like": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/require-like/-/require-like-0.1.2.tgz", - "integrity": "sha512-oyrU88skkMtDdauHDuKVrgR+zuItqr6/c//FXzvmxRGMexSDc6hNvJInGW3LL46n+8b50RykrvwSUIIQH2LQ5A==", + "integrity": "sha1-rW8wwTvs15cBDEaK+ndcDAprR/o=", "dev": true }, "require-main-filename": { @@ -27410,19 +27634,19 @@ } }, "sandboxed-module": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/sandboxed-module/-/sandboxed-module-0.3.0.tgz", - "integrity": "sha1-8fvvvYCaT2kHO9B8rm/H2y6vX2o=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/sandboxed-module/-/sandboxed-module-2.0.4.tgz", + "integrity": "sha512-AwEPOdO8mg/wJjr876yCHP2DHqVN0MaggEXhp6IIf3bcI5cYoQl9QrrCHSrvToHjvdEiS5x4TVZRgjD2bEmNTA==", "dev": true, "requires": { "require-like": "0.1.2", - "stack-trace": "0.0.6" + "stack-trace": "0.0.9" }, "dependencies": { "stack-trace": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.6.tgz", - "integrity": "sha1-HnGb1qJin/CcGJ4Xqe+QKpT8XbA=", + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.9.tgz", + "integrity": "sha1-qPbq7KkGdMMz58Q5U/J1tFFRBpU=", "dev": true } } @@ -32922,6 +33146,12 @@ "microevent.ts": "~0.1.1" } }, + "workerpool": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz", + "integrity": "sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg==", + "dev": true + }, "wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", @@ -33274,14 +33504,35 @@ } }, "yargs-unparser": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz", - "integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", "dev": true, "requires": { - "flat": "^4.1.0", - "lodash": "^4.17.15", - "yargs": "^13.3.0" + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "dependencies": { + "camelcase": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", + "dev": true + }, + "decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true + }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true + } } }, "yauzl": { diff --git a/services/web/package.json b/services/web/package.json index 5c71d6d3a2..2e8734afc4 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -14,7 +14,7 @@ "scripts": { "test:acceptance:run_dir": "mocha --recursive --timeout 25000 --exit --grep=$MOCHA_GREP --require test/acceptance/bootstrap.js", "test:acceptance:app": "npm run test:acceptance:run_dir -- test/acceptance/src", - "test:unit:run_dir": "mocha --recursive --timeout 25000 --exit --grep=$MOCHA_GREP --file test/unit/bootstrap.js", + "test:unit:run_dir": "mocha --recursive --timeout 25000 --exit --grep=$MOCHA_GREP --require test/unit/bootstrap.js", "test:unit:all": "npm run test:unit:run_dir -- test/unit/src modules/*/test/unit/src", "test:unit:all:silent": "npm run test:unit:all -- --reporter dot", "test:unit:app": "npm run test:unit:run_dir -- test/unit/src", @@ -223,7 +223,7 @@ "mathjax": "^2.7.9", "mini-css-extract-plugin": "^0.8.0", "mkdirp": "0.5.1", - "mocha": "^6.2.2", + "mocha": "^8.3.2", "mock-fs": "^4.11.0", "node-fetch": "^2.6.1", "nodemon": "^2.0.6", @@ -233,7 +233,7 @@ "prettier": "^1.19.1", "requirejs": "^2.3.6", "samlp": "^3.4.1", - "sandboxed-module": "0.3.0", + "sandboxed-module": "^2.0.4", "sinon": "^7.5.0", "sinon-chai": "^3.5.0", "sinon-mongoose": "^2.3.0", diff --git a/services/web/test/acceptance/bootstrap.js b/services/web/test/acceptance/bootstrap.js index 76909ef833..7372c5cf70 100644 --- a/services/web/test/acceptance/bootstrap.js +++ b/services/web/test/acceptance/bootstrap.js @@ -1,6 +1,8 @@ const chai = require('chai') +chai.should() chai.use(require('chai-as-promised')) chai.use(require('chaid')) +chai.use(require('sinon-chai')) // Do not truncate assertion errors chai.config.truncateThreshold = 0 diff --git a/services/web/test/acceptance/src/CloseSiteTests.js b/services/web/test/acceptance/src/CloseSiteTests.js index 0eddd279e5..78268b6dd4 100644 --- a/services/web/test/acceptance/src/CloseSiteTests.js +++ b/services/web/test/acceptance/src/CloseSiteTests.js @@ -11,7 +11,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const Settings = require('settings-sharelatex') -const chai = require('chai') const request = require('./helpers/request') describe('siteIsOpen', function() { diff --git a/services/web/test/acceptance/src/ModelTests.js b/services/web/test/acceptance/src/ModelTests.js index 25ca8a4790..643ae52d49 100644 --- a/services/web/test/acceptance/src/ModelTests.js +++ b/services/web/test/acceptance/src/ModelTests.js @@ -1,7 +1,4 @@ -const chai = require('chai') -const expect = chai.expect -const chaiAsPromised = require('chai-as-promised') -chai.use(chaiAsPromised) +const { expect } = require('chai') const { User } = require('../../../app/src/models/User') const { Subscription } = require('../../../app/src/models/Subscription') diff --git a/services/web/test/acceptance/src/ProxyUrls.js b/services/web/test/acceptance/src/ProxyUrls.js index 7bf7d7d15e..cb7b666202 100644 --- a/services/web/test/acceptance/src/ProxyUrls.js +++ b/services/web/test/acceptance/src/ProxyUrls.js @@ -9,14 +9,13 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() -const { assert } = require('chai') +const { assert, expect } = require('chai') const async = require('async') const request = require('./helpers/request') const assertResponse = (path, expectedStatusCode, expectedBody, cb) => request.get(path, (error, response) => { - should.not.exist(error) + expect(error).not.to.exist response.statusCode.should.equal(expectedStatusCode) if (expectedBody) { assert.deepEqual(JSON.parse(response.body), expectedBody) diff --git a/services/web/test/acceptance/src/RedirectUrlsTests.js b/services/web/test/acceptance/src/RedirectUrlsTests.js index 35b6127a6e..64cbe596bc 100644 --- a/services/web/test/acceptance/src/RedirectUrlsTests.js +++ b/services/web/test/acceptance/src/RedirectUrlsTests.js @@ -9,14 +9,13 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() -const { assert } = require('chai') +const { assert, expect } = require('chai') const async = require('async') const request = require('./helpers/request') const assertRedirect = (method, path, expectedStatusCode, destination, cb) => request[method](path, (error, response) => { - should.not.exist(error) + expect(error).not.to.exist response.statusCode.should.equal(expectedStatusCode) response.headers.location.should.equal(destination) return cb() @@ -85,7 +84,7 @@ describe('RedirectUrls', function() { return request.get( { url: '/redirect/one', headers: { 'x-skip-redirects': 'true' } }, (error, response) => { - should.not.exist(error) + expect(error).not.to.exist response.statusCode.should.equal(404) return done() } diff --git a/services/web/test/acceptance/src/RegistrationTests.js b/services/web/test/acceptance/src/RegistrationTests.js index 9d60f1c798..4ddc11c238 100644 --- a/services/web/test/acceptance/src/RegistrationTests.js +++ b/services/web/test/acceptance/src/RegistrationTests.js @@ -2,8 +2,7 @@ handle-callback-err */ -const { expect } = require('chai') -const { assert } = require('chai') +const { assert, expect } = require('chai') const async = require('async') const User = require('./helpers/User') const redis = require('./helpers/redis') diff --git a/services/web/test/acceptance/src/SettingsTests.js b/services/web/test/acceptance/src/SettingsTests.js index d8304c3a62..60552a65c3 100644 --- a/services/web/test/acceptance/src/SettingsTests.js +++ b/services/web/test/acceptance/src/SettingsTests.js @@ -8,7 +8,7 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() +const { expect } = require('chai') const async = require('async') const User = require('./helpers/User') const MockV1ApiClass = require('./mocks/MockV1Api') @@ -56,7 +56,7 @@ describe('SettingsPage', function() { it('update main email address', function(done) { const newEmail = 'foo@bar.com' return this.user.updateSettings({ email: newEmail }, error => { - should.not.exist(error) + expect(error).not.to.exist return this.user.get((error, user) => { user.email.should.equal(newEmail) user.emails.length.should.equal(1) @@ -77,7 +77,7 @@ describe('SettingsPage', function() { it('should be able to update settings', function(done) { const newName = 'third-party-references' this.user.updateSettings({ first_name: newName }, error => { - should.not.exist(error) + expect(error).not.to.exist this.user.get((error, user) => { user.first_name.should.equal(newName) done() diff --git a/services/web/test/acceptance/src/UserHelperTests.js b/services/web/test/acceptance/src/UserHelperTests.js index ab5563186c..b0a4b5c666 100644 --- a/services/web/test/acceptance/src/UserHelperTests.js +++ b/services/web/test/acceptance/src/UserHelperTests.js @@ -1,12 +1,7 @@ const AuthenticationManager = require('../../../app/src/Features/Authentication/AuthenticationManager') const UserHelper = require('./helpers/UserHelper') -const chai = require('chai') -const chaiAsPromised = require('chai-as-promised') const Features = require('../../../app/src/infrastructure/Features') - -const expect = chai.expect -chai.should() -chai.use(chaiAsPromised) +const { expect } = require('chai') describe('UserHelper', function() { // Disable all tests unless the public-registration feature is enabled diff --git a/services/web/test/acceptance/src/UserReconfirmTests.js b/services/web/test/acceptance/src/UserReconfirmTests.js index 21de561f82..fe7bfbb04b 100644 --- a/services/web/test/acceptance/src/UserReconfirmTests.js +++ b/services/web/test/acceptance/src/UserReconfirmTests.js @@ -12,7 +12,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const { expect } = require('chai') -const should = require('chai').should() const async = require('async') const User = require('./helpers/User') diff --git a/services/web/test/acceptance/src/UserThirdPartyIdentityTests.js b/services/web/test/acceptance/src/UserThirdPartyIdentityTests.js index 40628b5c2d..b3d91007a0 100644 --- a/services/web/test/acceptance/src/UserThirdPartyIdentityTests.js +++ b/services/web/test/acceptance/src/UserThirdPartyIdentityTests.js @@ -14,9 +14,7 @@ const Errors = require('../../../app/src/Features/Errors/Errors') const Settings = require('settings-sharelatex') const User = require('./helpers/User') const ThirdPartyIdentityManager = require('../../../app/src/Features/User/ThirdPartyIdentityManager') -const chai = require('chai') - -const { expect } = chai +const { expect } = require('chai') describe('ThirdPartyIdentityManager', function() { beforeEach(function(done) { diff --git a/services/web/test/unit/bootstrap.js b/services/web/test/unit/bootstrap.js index 2bdf4744a4..eae144d620 100644 --- a/services/web/test/unit/bootstrap.js +++ b/services/web/test/unit/bootstrap.js @@ -1,6 +1,11 @@ +const Path = require('path') const chai = require('chai') const sinon = require('sinon') +/* + * Chai configuration + */ + // add chai.should() chai.should() @@ -17,52 +22,108 @@ chai.config.truncateThreshold = 0 // add support for mongoose in sinon require('sinon-mongoose') -afterEach(function() { - sinon.restore() -}) +/* + * Global stubs + */ +const globalStubsSandbox = sinon.createSandbox() +const globalStubs = { + logger: { + debug: globalStubsSandbox.stub(), + info: globalStubsSandbox.stub(), + log: globalStubsSandbox.stub(), + warn: globalStubsSandbox.stub(), + err: globalStubsSandbox.stub(), + error: globalStubsSandbox.stub(), + fatal: globalStubsSandbox.stub() + } +} + +/* + * Sandboxed module configuration + */ const SandboxedModule = require('sandboxed-module') -const PromisesUtils = require('../../app/src/util/promises') -const Errors = require('../../app/src/Features/Errors/Errors') -const GLOBAL_REQUIRE_CACHE_FOR_SANDBOXED_MODULES = { - // cache p-limit for all expressify/promisifyAll users - '../../util/promises': PromisesUtils, - '../../../../app/src/util/promises': PromisesUtils, - - // Errors are widely used and instance checks need the exact same prototypes - '../Errors/Errors': Errors, - '../../../../app/src/Features/Errors/Errors': Errors, - '../../../../../app/src/Features/Errors/Errors': Errors -} -const LIBRARIES = [ - '@overleaf/o-error', - 'async', - 'lodash', - 'moment', - 'underscore', - 'xml2js', - 'json2csv', - 'sanitize-html', - 'marked' -] -LIBRARIES.forEach(lib => { - GLOBAL_REQUIRE_CACHE_FOR_SANDBOXED_MODULES[lib] = require(lib) -}) - SandboxedModule.configure({ - requires: GLOBAL_REQUIRE_CACHE_FOR_SANDBOXED_MODULES + requires: getSandboxedModuleRequires(), + globals: { Buffer, Promise, console, process }, + sourceTransformers: { + coffee(source) { + if (this.filename.endsWith('.coffee')) { + // Coffeescript mucks with Error.prepareStackTrace, which, in turn, + // conflicts with OError. This is a hacky way to prevent Coffeescript + // from interfering. + // + // See https://github.com/jashkenas/coffeescript/blob/07f644c39223e016aceedd2cd71b5941579b5659/src/coffeescript.coffee#L368 + const originalPrepareStackTrace = Error.prepareStackTrace + const compiled = require('coffeescript').compile(source) + Error.prepareStackTrace = originalPrepareStackTrace + return compiled + } + return source + } + } }) +function getSandboxedModuleRequires() { + const requires = { + 'logger-sharelatex': globalStubs.logger + } + + const internalModules = [ + '../../app/src/util/promises', + '../../app/src/Features/Errors/Errors', + '../../app/src/Features/Helpers/Mongo' + ] + const externalLibs = [ + 'async', + 'json2csv', + 'lodash', + 'marked', + 'moment', + '@overleaf/o-error', + 'sanitize-html', + 'sshpk', + 'underscore', + 'xml2js' + ] + for (const modulePath of internalModules) { + requires[Path.resolve(__dirname, modulePath)] = require(modulePath) + } + for (const lib of externalLibs) { + requires[lib] = require(lib) + } + return requires +} + +/* + * Mocha hooks + */ + // sandboxed-module somehow registers every fake module it creates in this // module's children array, which uses quite a big amount of memory. We'll take // a copy of the module children array and restore it after each test so that // the garbage collector has a chance to reclaim the fake modules. let initialModuleChildren -before('record initial module children', function() { - initialModuleChildren = module.children.slice() -}) -afterEach('restore module children', function() { - // Delete leaking sandboxed modules - module.children = initialModuleChildren.slice() -}) +exports.mochaHooks = { + beforeAll() { + // Record initial module children + initialModuleChildren = module.children.slice() + }, + + beforeEach() { + // Install logger stub + this.logger = globalStubs.logger + }, + + afterEach() { + // Delete leaking sandboxed modules + module.children = initialModuleChildren.slice() + + // Reset global stubs + globalStubsSandbox.reset() + + // Restore other stubs + sinon.restore() + } +} diff --git a/services/web/test/unit/src/Analytics/AnalyticsControllerTests.js b/services/web/test/unit/src/Analytics/AnalyticsControllerTests.js index d1121951c8..80a35f75d2 100644 --- a/services/web/test/unit/src/Analytics/AnalyticsControllerTests.js +++ b/services/web/test/unit/src/Analytics/AnalyticsControllerTests.js @@ -24,18 +24,12 @@ describe('AnalyticsController', function() { } this.controller = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './AnalyticsManager': this.AnalyticsManager, '../Authentication/AuthenticationController': this .AuthenticationController, '../Institutions/InstitutionsAPI': this.InstitutionsAPI, '../../infrastructure/Features': this.Features, - 'logger-sharelatex': { - log() {} - }, '../../infrastructure/GeoIpLookup': (this.GeoIpLookup = { getDetails: sinon.stub() }) diff --git a/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js b/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js index 7f74afc680..ac3eea81bc 100644 --- a/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js +++ b/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js @@ -40,14 +40,8 @@ describe('AnalyticsManager', function() { this.backgroundRequest = sinon.stub().yields() this.request = sinon.stub().yields() this.AnalyticsManager = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.Settings, - 'logger-sharelatex': { - warn() {} - }, '../../infrastructure/Queues': this.Queues } }) diff --git a/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js b/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js index 221bc8f762..98c3bc6c71 100644 --- a/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js +++ b/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js @@ -1,6 +1,5 @@ const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Authentication/AuthenticationController.js' const SandboxedModule = require('sandboxed-module') @@ -19,9 +18,6 @@ describe('AuthenticationController', function() { .slice(2) } this.AuthenticationController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../User/UserAuditLogHandler': (this.UserAuditLogHandler = { addEntry: sinon.stub().yields(null) @@ -49,12 +45,6 @@ describe('AuthenticationController', function() { identifyUser: sinon.stub() }), '../../infrastructure/SessionStoreManager': (this.SessionStoreManager = {}), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - warn: sinon.stub(), - error: sinon.stub(), - err: sinon.stub() - }), 'settings-sharelatex': (this.Settings = { siteUrl: 'http://www.foo.bar', httpAuthUsers: this.httpAuthUsers diff --git a/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js b/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js index fcf66205d9..2df236ca5a 100644 --- a/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js +++ b/services/web/test/unit/src/Authentication/AuthenticationManagerTests.js @@ -1,11 +1,9 @@ const sinon = require('sinon') -const chai = require('chai') +const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const { ObjectId } = require('mongodb') const AuthenticationErrors = require('../../../../app/src/Features/Authentication/AuthenticationErrors') -chai.should() -const { expect } = chai const modulePath = '../../../../app/src/Features/Authentication/AuthenticationManager.js' @@ -13,9 +11,6 @@ describe('AuthenticationManager', function() { beforeEach(function() { this.settings = { security: { bcryptRounds: 4 } } this.AuthenticationManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/User': { User: (this.User = {}) diff --git a/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js b/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js index 9043215e13..79ae4a13d3 100644 --- a/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js +++ b/services/web/test/unit/src/Authorization/AuthorizationManagerTests.js @@ -12,9 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Authorization/AuthorizationManager.js' const SandboxedModule = require('sandboxed-module') @@ -24,9 +22,6 @@ const { ObjectId } = require('mongodb') describe('AuthorizationManager', function() { beforeEach(function() { this.AuthorizationManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, '../Collaborators/CollaboratorsGetter': (this.CollaboratorsGetter = {}), diff --git a/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js b/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js index fdd5461c91..ebee3a8834 100644 --- a/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js +++ b/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js @@ -30,12 +30,8 @@ describe('AuthorizationMiddleware', function() { } this.AuthorizationManager = {} this.AuthorizationMiddleware = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { './AuthorizationManager': this.AuthorizationManager, - 'logger-sharelatex': { log() {} }, mongodb: { ObjectId: this.ObjectId }, diff --git a/services/web/test/unit/src/BetaProgram/BetaProgramControllerTests.js b/services/web/test/unit/src/BetaProgram/BetaProgramControllerTests.js index d6ad6a0a8e..484d1f0682 100644 --- a/services/web/test/unit/src/BetaProgram/BetaProgramControllerTests.js +++ b/services/web/test/unit/src/BetaProgram/BetaProgramControllerTests.js @@ -1,4 +1,3 @@ -require('chai').should() const SandboxedModule = require('sandboxed-module') const path = require('path') const sinon = require('sinon') @@ -23,9 +22,6 @@ describe('BetaProgramController', function() { } } this.BetaProgramController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './BetaProgramHandler': (this.BetaProgramHandler = { optIn: sinon.stub(), @@ -37,12 +33,6 @@ describe('BetaProgramController', function() { 'settings-sharelatex': (this.settings = { languages: {} }), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - warn: sinon.stub(), - err: sinon.stub(), - error: sinon.stub() - }), '../Authentication/AuthenticationController': (this.AuthenticationController = { getLoggedInUserId: sinon.stub().returns(this.user._id) }) diff --git a/services/web/test/unit/src/BetaProgram/BetaProgramHandlerTests.js b/services/web/test/unit/src/BetaProgram/BetaProgramHandlerTests.js index b8be30c6db..649b56782e 100644 --- a/services/web/test/unit/src/BetaProgram/BetaProgramHandlerTests.js +++ b/services/web/test/unit/src/BetaProgram/BetaProgramHandlerTests.js @@ -18,13 +18,10 @@ describe('BetaProgramHandler', function() { save: sinon.stub().callsArgWith(0, null) } this.handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - '@overleaf/metrics': (this.logger = { + '@overleaf/metrics': { inc: sinon.stub() - }), + }, '../User/UserUpdater': (this.UserUpdater = { promises: { updateUser: sinon.stub().resolves() diff --git a/services/web/test/unit/src/BrandVariations/BrandVariationsHandlerTests.js b/services/web/test/unit/src/BrandVariations/BrandVariationsHandlerTests.js index 31ef7133f6..80f948620c 100644 --- a/services/web/test/unit/src/BrandVariations/BrandVariationsHandlerTests.js +++ b/services/web/test/unit/src/BrandVariations/BrandVariationsHandlerTests.js @@ -11,12 +11,11 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -let { expect } = require('chai') +const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') const sinon = require('sinon') -;({ expect } = require('chai')) const modulePath = path.join( __dirname, '../../../../app/src/Features/BrandVariations/BrandVariationsHandler' @@ -31,19 +30,10 @@ describe('BrandVariationsHandler', function() { } } } - this.logger = { - warn() {}, - err() {}, - log() {} - } this.V1Api = { request: sinon.stub() } this.BrandVariationsHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, - 'logger-sharelatex': this.logger, '../V1/V1Api': this.V1Api } }) diff --git a/services/web/test/unit/src/Chat/ChatApiHandlerTests.js b/services/web/test/unit/src/Chat/ChatApiHandlerTests.js index 9ca93fd18a..2a75bd5e62 100644 --- a/services/web/test/unit/src/Chat/ChatApiHandlerTests.js +++ b/services/web/test/unit/src/Chat/ChatApiHandlerTests.js @@ -10,7 +10,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -32,16 +31,8 @@ describe('ChatApiHandler', function() { } this.request = sinon.stub() this.ChatApiHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log: sinon.stub(), - warn: sinon.stub(), - error: sinon.stub() - }, request: this.request } }) diff --git a/services/web/test/unit/src/Chat/ChatControllerTests.js b/services/web/test/unit/src/Chat/ChatControllerTests.js index fea1ff0ec9..0122336e77 100644 --- a/services/web/test/unit/src/Chat/ChatControllerTests.js +++ b/services/web/test/unit/src/Chat/ChatControllerTests.js @@ -12,7 +12,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -33,21 +32,14 @@ describe('ChatController', function() { getLoggedInUserId: sinon.stub().returns(this.user_id) } this.ChatController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log() {} - }, './ChatApiHandler': this.ChatApiHandler, '../Editor/EditorRealTimeController': this.EditorRealTimeController, '../Authentication/AuthenticationController': this .AuthenticationController, '../User/UserInfoManager': (this.UserInfoManager = {}), - '../User/UserInfoController': (this.UserInfoController = {}), - '../Comments/CommentsController': (this.CommentsController = {}) + '../User/UserInfoController': (this.UserInfoController = {}) } }) this.req = { diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js index 3e93c10a83..346aae5786 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsControllerTests.js @@ -50,16 +50,8 @@ describe('CollaboratorsController', function() { transferOwnership: sinon.stub().resolves() } } - this.logger = { - err: sinon.stub(), - warn: sinon.stub(), - log: sinon.stub() - } this.CollaboratorsController = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, './CollaboratorsHandler': this.CollaboratorsHandler, @@ -69,8 +61,7 @@ describe('CollaboratorsController', function() { '../../Features/Errors/HttpErrorHandler': this.HttpErrorHandler, '../Tags/TagsHandler': this.TagsHandler, '../Authentication/AuthenticationController': this - .AuthenticationController, - 'logger-sharelatex': this.logger + .AuthenticationController } }) }) diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js index 1a18c8fa96..3626f3b384 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsGetterTests.js @@ -47,9 +47,6 @@ describe('CollaboratorsGetter', function() { buildOwnerAndMembersViews: sinon.stub() } this.CollaboratorsGetter = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, '../User/UserGetter': this.UserGetter, diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js index f2650a7ab4..27f0b15ee6 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsHandlerTests.js @@ -16,11 +16,6 @@ const sleep = promisify(setTimeout) describe('CollaboratorsHandler', function() { beforeEach(function() { - this.logger = { - log: sinon.stub(), - warn: sinon.stub(), - err: sinon.stub() - } this.userId = ObjectId() this.addingUserId = ObjectId() this.project = { @@ -66,11 +61,7 @@ describe('CollaboratorsHandler', function() { } } this.CollaboratorsHandler = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': this.logger, '../User/UserGetter': this.UserGetter, '../Contacts/ContactManager': this.ContactManager, '../../models/Project': { Project }, diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js index 92462ddd2a..c81bd3693d 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsInviteControllerTests.js @@ -12,9 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Collaborators/CollaboratorsInviteController.js' const SandboxedModule = require('sandboxed-module') @@ -44,21 +42,12 @@ describe('CollaboratorsInviteController', function() { } this.CollaboratorsInviteController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Project/ProjectGetter': (this.ProjectGetter = {}), '../Subscription/LimitationsManager': this.LimitationsManager, '../User/UserGetter': this.UserGetter, './CollaboratorsGetter': (this.CollaboratorsGetter = {}), './CollaboratorsInviteHandler': (this.CollaboratorsInviteHandler = {}), - 'logger-sharelatex': (this.logger = { - err: sinon.stub(), - error: sinon.stub(), - warn: sinon.stub(), - log: sinon.stub() - }), '../Editor/EditorRealTimeController': (this.EditorRealTimeController = { emitToRoom: sinon.stub() }), diff --git a/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js b/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js index 030df066b6..1c658ca93b 100644 --- a/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js +++ b/services/web/test/unit/src/Collaborators/CollaboratorsInviteHandlerTests.js @@ -15,9 +15,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Collaborators/CollaboratorsInviteHandler.js' const SandboxedModule = require('sandboxed-module') @@ -55,18 +53,9 @@ describe('CollaboratorsInviteHandler', function() { })() this.Crypto = Crypto this.CollaboratorsInviteHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': (this.settings = {}), '../../models/ProjectInvite': { ProjectInvite: this.ProjectInvite }, - 'logger-sharelatex': (this.logger = { - err: sinon.stub(), - error: sinon.stub(), - warn: sinon.stub(), - log: sinon.stub() - }), './CollaboratorsEmailHandler': (this.CollaboratorsEmailHandler = {}), './CollaboratorsHandler': (this.CollaboratorsHandler = { addUserIdToProject: sinon.stub() diff --git a/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js b/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js index 3842ce89a8..67ef08ec98 100644 --- a/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js +++ b/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js @@ -60,9 +60,6 @@ describe('OwnershipTransferHandler', function() { } } this.handler = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { '../Project/ProjectGetter': this.ProjectGetter, '../../models/Project': { @@ -72,12 +69,7 @@ describe('OwnershipTransferHandler', function() { '../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher, '../Project/ProjectAuditLogHandler': this.ProjectAuditLogHandler, '../Email/EmailHandler': this.EmailHandler, - './CollaboratorsHandler': this.CollaboratorsHandler, - 'logger-sharelatex': { - log() {}, - warn() {}, - err() {} - } + './CollaboratorsHandler': this.CollaboratorsHandler } }) }) diff --git a/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js b/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js index d4e9b2b92a..87b734da7f 100644 --- a/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js +++ b/services/web/test/unit/src/Compile/ClsiCookieManagerTests.js @@ -12,10 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const { assert } = chai -const should = chai.should() -const { expect } = chai +const { assert, expect } = require('chai') const modulePath = '../../../../app/src/Features/Compile/ClsiCookieManager.js' const SandboxedModule = require('sandboxed-module') const realRequst = require('request') @@ -56,18 +53,9 @@ describe('ClsiCookieManager', function() { client: () => this.redis }), 'settings-sharelatex': this.settings, - request: this.request, - - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - error: sinon.stub(), - warn: sinon.stub() - }) + request: this.request } return (this.ClsiCookieManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: this.requires })()) }) diff --git a/services/web/test/unit/src/Compile/ClsiFormatCheckerTests.js b/services/web/test/unit/src/Compile/ClsiFormatCheckerTests.js index a2b5ee3527..ce6e06480e 100644 --- a/services/web/test/unit/src/Compile/ClsiFormatCheckerTests.js +++ b/services/web/test/unit/src/Compile/ClsiFormatCheckerTests.js @@ -12,25 +12,15 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Compile/ClsiFormatChecker.js' const SandboxedModule = require('sandboxed-module') describe('ClsiFormatChecker', function() { beforeEach(function() { this.ClsiFormatChecker = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'settings-sharelatex': (this.settings = { compileBodySizeLimitMb: 5 }), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - error: sinon.stub(), - warn: sinon.stub() - }) + 'settings-sharelatex': (this.settings = { compileBodySizeLimitMb: 5 }) } }) return (this.project_id = 'project-id') diff --git a/services/web/test/unit/src/Compile/ClsiManagerTests.js b/services/web/test/unit/src/Compile/ClsiManagerTests.js index 3a1b0c22db..39bdf35ca1 100644 --- a/services/web/test/unit/src/Compile/ClsiManagerTests.js +++ b/services/web/test/unit/src/Compile/ClsiManagerTests.js @@ -1,6 +1,5 @@ const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Compile/ClsiManager.js' const SandboxedModule = require('sandboxed-module') @@ -25,12 +24,6 @@ describe('ClsiManager', function() { this.DocumentUpdaterHandler = { getProjectDocsIfMatch: sinon.stub().callsArgWith(2, null, null) } - this.logger = { - log: sinon.stub(), - error: sinon.stub(), - err: sinon.stub(), - warn: sinon.stub() - } this.request = sinon.stub() this.Metrics = { Timer: class Metrics { @@ -41,9 +34,6 @@ describe('ClsiManager', function() { inc: sinon.stub() } this.ClsiManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': (this.settings = { apis: { @@ -68,7 +58,6 @@ describe('ClsiManager', function() { .DocumentUpdaterHandler, './ClsiCookieManager': () => this.ClsiCookieManager, './ClsiStateManager': this.ClsiStateManager, - 'logger-sharelatex': this.logger, request: this.request, './ClsiFormatChecker': this.ClsiFormatChecker, '@overleaf/metrics': this.Metrics diff --git a/services/web/test/unit/src/Compile/ClsiStateManagerTests.js b/services/web/test/unit/src/Compile/ClsiStateManagerTests.js index 312dfc3172..b69247fa2d 100644 --- a/services/web/test/unit/src/Compile/ClsiStateManagerTests.js +++ b/services/web/test/unit/src/Compile/ClsiStateManagerTests.js @@ -13,26 +13,16 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Compile/ClsiStateManager.js' const SandboxedModule = require('sandboxed-module') describe('ClsiStateManager', function() { beforeEach(function() { this.ClsiStateManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': (this.settings = {}), - '../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - error: sinon.stub(), - warn: sinon.stub() - }) + '../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}) } }) this.project = 'project' diff --git a/services/web/test/unit/src/Compile/CompileControllerTests.js b/services/web/test/unit/src/Compile/CompileControllerTests.js index afdd694626..042a7160a9 100644 --- a/services/web/test/unit/src/Compile/CompileControllerTests.js +++ b/services/web/test/unit/src/Compile/CompileControllerTests.js @@ -12,10 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { assert } = require('chai') -const { expect } = chai +const { assert, expect } = require('chai') const modulePath = '../../../../app/src/Features/Compile/CompileController.js' const SandboxedModule = require('sandboxed-module') const MockRequest = require('../helpers/MockRequest') @@ -61,17 +58,10 @@ describe('CompileController', function() { isUserLoggedIn: sinon.stub().returns(true) } this.CompileController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, request: (this.request = sinon.stub()), '../Project/ProjectGetter': (this.ProjectGetter = {}), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - error: sinon.stub() - }), '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }), './CompileManager': this.CompileManager, '../User/UserGetter': this.UserGetter, diff --git a/services/web/test/unit/src/Compile/CompileManagerTests.js b/services/web/test/unit/src/Compile/CompileManagerTests.js index 832dfed6dc..284c2dd7c7 100644 --- a/services/web/test/unit/src/Compile/CompileManagerTests.js +++ b/services/web/test/unit/src/Compile/CompileManagerTests.js @@ -13,11 +13,8 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { assert, expect } = require('chai') const modulePath = '../../../../app/src/Features/Compile/CompileManager.js' -const { assert } = require('chai') const SandboxedModule = require('sandboxed-module') describe('CompileManager', function() { @@ -27,9 +24,6 @@ describe('CompileManager', function() { const { rateLimitGetStub } = this this.ratelimiter = { addCount: sinon.stub() } this.CompileManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': (this.settings = { redis: { web: { host: 'localhost', port: 42 } }, @@ -56,10 +50,6 @@ describe('CompileManager', function() { return Timer })()), inc: sinon.stub() - }), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - warn: sinon.stub() }) } }) diff --git a/services/web/test/unit/src/Contact/ContactControllerTests.js b/services/web/test/unit/src/Contact/ContactControllerTests.js index a80595933d..1837b15711 100644 --- a/services/web/test/unit/src/Contact/ContactControllerTests.js +++ b/services/web/test/unit/src/Contact/ContactControllerTests.js @@ -12,10 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { assert } = chai -const { expect } = chai +const { assert, expect } = require('chai') const modulePath = '../../../../app/src/Features/Contacts/ContactController.js' const SandboxedModule = require('sandboxed-module') @@ -23,14 +20,7 @@ describe('ContactController', function() { beforeEach(function() { this.AuthenticationController = { getLoggedInUserId: sinon.stub() } this.ContactController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - error: sinon.stub() - }), '../User/UserGetter': (this.UserGetter = {}), './ContactManager': (this.ContactManager = {}), '../Authentication/AuthenticationController': (this.AuthenticationController = {}), diff --git a/services/web/test/unit/src/Contact/ContactManagerTests.js b/services/web/test/unit/src/Contact/ContactManagerTests.js index 93c653e095..f3b9a51dea 100644 --- a/services/web/test/unit/src/Contact/ContactManagerTests.js +++ b/services/web/test/unit/src/Contact/ContactManagerTests.js @@ -9,8 +9,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -chai.should() const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Contacts/ContactManager' const SandboxedModule = require('sandboxed-module') @@ -18,9 +16,6 @@ const SandboxedModule = require('sandboxed-module') describe('ContactManager', function() { beforeEach(function() { this.ContactManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { request: (this.request = sinon.stub()), 'settings-sharelatex': (this.settings = { diff --git a/services/web/test/unit/src/Cooldown/CooldownManagerTests.js b/services/web/test/unit/src/Cooldown/CooldownManagerTests.js index 4fda89750d..eeba93e4db 100644 --- a/services/web/test/unit/src/Cooldown/CooldownManagerTests.js +++ b/services/web/test/unit/src/Cooldown/CooldownManagerTests.js @@ -12,7 +12,6 @@ */ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -require('chai').should() const { expect } = require('chai') const modulePath = require('path').join( __dirname, @@ -25,12 +24,8 @@ describe('CooldownManager', function() { this.rclient = { set: sinon.stub(), get: sinon.stub() } this.RedisWrapper = { client: () => this.rclient } return (this.CooldownManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - '../../infrastructure/RedisWrapper': this.RedisWrapper, - 'logger-sharelatex': { log: sinon.stub() } + '../../infrastructure/RedisWrapper': this.RedisWrapper } })) }) diff --git a/services/web/test/unit/src/Cooldown/CooldownMiddlewareTests.js b/services/web/test/unit/src/Cooldown/CooldownMiddlewareTests.js index d50319db8f..433196fbda 100644 --- a/services/web/test/unit/src/Cooldown/CooldownMiddlewareTests.js +++ b/services/web/test/unit/src/Cooldown/CooldownMiddlewareTests.js @@ -11,7 +11,6 @@ */ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -require('chai').should() const { expect } = require('chai') const modulePath = require('path').join( __dirname, @@ -22,12 +21,8 @@ describe('CooldownMiddleware', function() { beforeEach(function() { this.CooldownManager = { isProjectOnCooldown: sinon.stub() } return (this.CooldownMiddleware = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - './CooldownManager': this.CooldownManager, - 'logger-sharelatex': { log: sinon.stub() } + './CooldownManager': this.CooldownManager } })) }) diff --git a/services/web/test/unit/src/Docstore/DocstoreManagerTests.js b/services/web/test/unit/src/Docstore/DocstoreManagerTests.js index bbda554083..8e59452b02 100644 --- a/services/web/test/unit/src/Docstore/DocstoreManagerTests.js +++ b/services/web/test/unit/src/Docstore/DocstoreManagerTests.js @@ -9,8 +9,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -chai.should() const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Docstore/DocstoreManager' const SandboxedModule = require('sandboxed-module') @@ -20,9 +18,6 @@ describe('DocstoreManager', function() { beforeEach(function() { this.requestDefaults = sinon.stub().returns((this.request = sinon.stub())) this.DocstoreManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { request: { defaults: this.requestDefaults @@ -33,12 +28,6 @@ describe('DocstoreManager', function() { url: 'docstore.sharelatex.com' } } - }), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - warn: sinon.stub(), - error: sinon.stub(), - err() {} }) } }) diff --git a/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js b/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js index 1b5f7cec75..a817dc76d3 100644 --- a/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js +++ b/services/web/test/unit/src/DocumentUpdater/DocumentUpdaterHandlerTests.js @@ -32,9 +32,6 @@ describe('DocumentUpdaterHandler', function() { this.callback = sinon.stub() this.handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { request: { defaults: () => { @@ -42,7 +39,6 @@ describe('DocumentUpdaterHandler', function() { } }, 'settings-sharelatex': this.settings, - 'logger-sharelatex': { log() {}, error() {}, warn() {} }, '../Project/ProjectEntityHandler': this.projectEntityHandler, '../../models/Project': { Project: (this.Project = {}) diff --git a/services/web/test/unit/src/Documents/DocumentControllerTests.js b/services/web/test/unit/src/Documents/DocumentControllerTests.js index 39258d2585..57ce31ee3a 100644 --- a/services/web/test/unit/src/Documents/DocumentControllerTests.js +++ b/services/web/test/unit/src/Documents/DocumentControllerTests.js @@ -11,9 +11,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Documents/DocumentController.js' const SandboxedModule = require('sandboxed-module') @@ -25,15 +23,7 @@ const Errors = require('../../../../app/src/Features/Errors/Errors') describe('DocumentController', function() { beforeEach(function() { this.DocumentController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': { - log() {}, - warn() {}, - err() {} - }, '../Project/ProjectGetter': (this.ProjectGetter = {}), '../Project/ProjectLocator': (this.ProjectLocator = {}), '../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}), diff --git a/services/web/test/unit/src/Documents/DocumentHelperTests.js b/services/web/test/unit/src/Documents/DocumentHelperTests.js index abe07b9951..f2ad88bdf9 100644 --- a/services/web/test/unit/src/Documents/DocumentHelperTests.js +++ b/services/web/test/unit/src/Documents/DocumentHelperTests.js @@ -11,9 +11,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Documents/DocumentHelper.js' const SandboxedModule = require('sandboxed-module') diff --git a/services/web/test/unit/src/Downloads/ProjectDownloadsControllerTests.js b/services/web/test/unit/src/Downloads/ProjectDownloadsControllerTests.js index efc9ee2ab3..d14da27ab1 100644 --- a/services/web/test/unit/src/Downloads/ProjectDownloadsControllerTests.js +++ b/services/web/test/unit/src/Downloads/ProjectDownloadsControllerTests.js @@ -11,9 +11,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Downloads/ProjectDownloadsController.js' const SandboxedModule = require('sandboxed-module') @@ -30,14 +28,10 @@ describe('ProjectDownloadsController', function() { return (this.ProjectDownloadsController = SandboxedModule.require( modulePath, { - globals: { - console: console - }, requires: { './ProjectZipStreamManager': (this.ProjectZipStreamManager = {}), '../Project/ProjectGetter': (this.ProjectGetter = {}), '@overleaf/metrics': (this.metrics = {}), - 'logger-sharelatex': (this.logger = { log: sinon.stub() }), '../DocumentUpdater/DocumentUpdaterHandler': this .DocumentUpdaterHandler } diff --git a/services/web/test/unit/src/Downloads/ProjectZipStreamManagerTests.js b/services/web/test/unit/src/Downloads/ProjectZipStreamManagerTests.js index 36d54bfda0..e99f02b0f2 100644 --- a/services/web/test/unit/src/Downloads/ProjectZipStreamManagerTests.js +++ b/services/web/test/unit/src/Downloads/ProjectZipStreamManagerTests.js @@ -16,9 +16,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Downloads/ProjectZipStreamManager.js' const SandboxedModule = require('sandboxed-module') @@ -33,15 +31,8 @@ describe('ProjectZipStreamManager', function() { append: sinon.stub() } return (this.ProjectZipStreamManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { archiver: (this.archiver = sinon.stub().returns(this.archive)), - 'logger-sharelatex': (this.logger = { - error: sinon.stub(), - log: sinon.stub() - }), '../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}), '../FileStore/FileStoreHandler': (this.FileStoreHandler = {}), '../Project/ProjectGetter': (this.ProjectGetter = {}) diff --git a/services/web/test/unit/src/Editor/EditorControllerTests.js b/services/web/test/unit/src/Editor/EditorControllerTests.js index 361e677453..228f98e4fc 100644 --- a/services/web/test/unit/src/Editor/EditorControllerTests.js +++ b/services/web/test/unit/src/Editor/EditorControllerTests.js @@ -13,7 +13,6 @@ */ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -require('chai').should() const { expect } = require('chai') const modulePath = require('path').join( @@ -47,9 +46,6 @@ describe('EditorController', function() { this.callback = sinon.stub() return (this.EditorController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Project/ProjectEntityUpdateHandler': (this.ProjectEntityUpdateHandler = {}), '../Project/ProjectOptionsHandler': (this.ProjectOptionsHandler = { @@ -70,11 +66,7 @@ describe('EditorController', function() { './EditorRealTimeController': (this.EditorRealTimeController = { emitToRoom: sinon.stub() }), - '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - err: sinon.stub() - }) + '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }) } })) }) diff --git a/services/web/test/unit/src/Editor/EditorHttpControllerTests.js b/services/web/test/unit/src/Editor/EditorHttpControllerTests.js index 70f819ef02..90b7603862 100644 --- a/services/web/test/unit/src/Editor/EditorHttpControllerTests.js +++ b/services/web/test/unit/src/Editor/EditorHttpControllerTests.js @@ -106,10 +106,6 @@ describe('EditorHttpController', function() { this.ProjectEditorHandler = { buildProjectModelView: sinon.stub().returns(this.projectView) } - this.logger = { - log: sinon.stub(), - error: sinon.stub() - } this.Metrics = { inc: sinon.stub() } this.TokenAccessHandler = { getRequestToken: sinon.stub().returns(this.token), @@ -128,15 +124,11 @@ describe('EditorHttpController', function() { unprocessableEntity: sinon.stub() } this.EditorHttpController = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { '../Project/ProjectDeleter': this.ProjectDeleter, '../Project/ProjectGetter': this.ProjectGetter, '../Authorization/AuthorizationManager': this.AuthorizationManager, '../Project/ProjectEditorHandler': this.ProjectEditorHandler, - 'logger-sharelatex': this.logger, './EditorController': this.EditorController, '@overleaf/metrics': this.Metrics, '../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter, diff --git a/services/web/test/unit/src/Editor/EditorRealTimeControllerTests.js b/services/web/test/unit/src/Editor/EditorRealTimeControllerTests.js index 4d31490fe8..551b964b14 100644 --- a/services/web/test/unit/src/Editor/EditorRealTimeControllerTests.js +++ b/services/web/test/unit/src/Editor/EditorRealTimeControllerTests.js @@ -12,7 +12,6 @@ */ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -require('chai').should() const modulePath = require('path').join( __dirname, '../../../../app/src/Features/Editor/EditorRealTimeController' @@ -23,9 +22,6 @@ describe('EditorRealTimeController', function() { this.rclient = { publish: sinon.stub() } this.Metrics = { summary: sinon.stub() } this.EditorRealTimeController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../infrastructure/RedisWrapper': { client: () => this.rclient diff --git a/services/web/test/unit/src/Email/EmailBuilderTests.js b/services/web/test/unit/src/Email/EmailBuilderTests.js index 1722205190..750105ccd7 100644 --- a/services/web/test/unit/src/Email/EmailBuilderTests.js +++ b/services/web/test/unit/src/Email/EmailBuilderTests.js @@ -20,18 +20,12 @@ describe('EmailBuilder', function() { siteUrl: 'https://www.overleaf.com' } this.EmailBuilder = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { './EmailMessageHelper': EmailMessageHelper, './Bodies/cta-email': ctaEmailBody, './Bodies/NoCTAEmailBody': NoCTAEmailBody, './Layouts/BaseWithHeaderEmailLayout': BaseWithHeaderEmailLayout, - 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log() {} - } + 'settings-sharelatex': this.settings } }) }) diff --git a/services/web/test/unit/src/Email/EmailHandlerTests.js b/services/web/test/unit/src/Email/EmailHandlerTests.js index e814246a67..7708727e4c 100644 --- a/services/web/test/unit/src/Email/EmailHandlerTests.js +++ b/services/web/test/unit/src/Email/EmailHandlerTests.js @@ -21,16 +21,10 @@ describe('EmailHandler', function() { } } this.EmailHandler = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { './EmailBuilder': this.EmailBuilder, './EmailSender': this.EmailSender, - 'settings-sharelatex': this.Settings, - 'logger-sharelatex': { - log() {} - } + 'settings-sharelatex': this.Settings } }) }) diff --git a/services/web/test/unit/src/Email/EmailMessageHelperTests.js b/services/web/test/unit/src/Email/EmailMessageHelperTests.js index 1a653b68ce..4200082bd4 100644 --- a/services/web/test/unit/src/Email/EmailMessageHelperTests.js +++ b/services/web/test/unit/src/Email/EmailMessageHelperTests.js @@ -9,11 +9,7 @@ const MODULE_PATH = path.join( describe('EmailMessageHelper', function() { beforeEach(function() { - this.EmailMessageHelper = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - } - }) + this.EmailMessageHelper = SandboxedModule.require(MODULE_PATH, {}) }) describe('cleanHTML', function() { beforeEach(function() { diff --git a/services/web/test/unit/src/Email/EmailSenderTests.js b/services/web/test/unit/src/Email/EmailSenderTests.js index 5e01d1684b..bbc8de50f8 100644 --- a/services/web/test/unit/src/Email/EmailSenderTests.js +++ b/services/web/test/unit/src/Email/EmailSenderTests.js @@ -33,20 +33,12 @@ describe('EmailSender', function() { this.ses = { createTransport: () => this.sesClient } this.EmailSender = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { nodemailer: this.ses, 'nodemailer-ses-transport': sinon.stub(), 'nodemailer-mandrill-transport': {}, 'settings-sharelatex': this.Settings, '../../infrastructure/RateLimiter': this.RateLimiter, - 'logger-sharelatex': { - log() {}, - warn() {}, - err() {} - }, '@overleaf/metrics': { inc() {} } diff --git a/services/web/test/unit/src/Errors/HttpErrorHandlerTests.js b/services/web/test/unit/src/Errors/HttpErrorHandlerTests.js index abddaf53fe..d902e16743 100644 --- a/services/web/test/unit/src/Errors/HttpErrorHandlerTests.js +++ b/services/web/test/unit/src/Errors/HttpErrorHandlerTests.js @@ -1,5 +1,4 @@ const { expect } = require('chai') -const sinon = require('sinon') const MockResponse = require('../helpers/MockResponse') const MockRequest = require('../helpers/MockRequest') const SandboxedModule = require('sandboxed-module') @@ -10,19 +9,12 @@ describe('HttpErrorHandler', function() { this.req = new MockRequest() this.res = new MockResponse() - this.logger = { - warn() {}, - error() {} - } - this.HttpErrorHandler = SandboxedModule.require(modulePath, { - globals: { console }, requires: { 'settings-sharelatex': { appName: 'Overleaf', statusPageUrl: 'https://status.overlaf.com' - }, - 'logger-sharelatex': this.logger + } } }) }) @@ -342,7 +334,6 @@ describe('HttpErrorHandler', function() { it('should send the error to the logger', function() { const error = new Error('message') - this.logger.error = sinon.stub() this.HttpErrorHandler.legacyInternal( this.req, this.res, diff --git a/services/web/test/unit/src/Exports/ExportsControllerTests.js b/services/web/test/unit/src/Exports/ExportsControllerTests.js index d8ff4c77ee..b30b9226cd 100644 --- a/services/web/test/unit/src/Exports/ExportsControllerTests.js +++ b/services/web/test/unit/src/Exports/ExportsControllerTests.js @@ -14,8 +14,7 @@ */ const SandboxedModule = require('sandboxed-module') const assert = require('assert') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -64,15 +63,8 @@ describe('ExportsController', function() { getLoggedInUserId: sinon.stub().returns(this.req.session.user._id) } return (this.controller = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './ExportsHandler': this.handler, - 'logger-sharelatex': { - log() {}, - err() {} - }, '../Authentication/AuthenticationController': this .AuthenticationController } diff --git a/services/web/test/unit/src/Exports/ExportsHandlerTests.js b/services/web/test/unit/src/Exports/ExportsHandlerTests.js index 4503ffe2e4..ebe0d5fb28 100644 --- a/services/web/test/unit/src/Exports/ExportsHandlerTests.js +++ b/services/web/test/unit/src/Exports/ExportsHandlerTests.js @@ -12,9 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Exports/ExportsHandler.js' const SandboxedModule = require('sandboxed-module') @@ -27,15 +25,7 @@ describe('ExportsHandler', function() { } } this.ExportsHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': { - log() {}, - warn() {}, - err() {} - }, '../Project/ProjectGetter': (this.ProjectGetter = {}), '../Project/ProjectHistoryHandler': (this.ProjectHistoryHandler = {}), '../Project/ProjectLocator': (this.ProjectLocator = {}), diff --git a/services/web/test/unit/src/FileStore/FileStoreControllerTests.js b/services/web/test/unit/src/FileStore/FileStoreControllerTests.js index f3447edb2f..4a18557a29 100644 --- a/services/web/test/unit/src/FileStore/FileStoreControllerTests.js +++ b/services/web/test/unit/src/FileStore/FileStoreControllerTests.js @@ -14,15 +14,8 @@ describe('FileStoreController', function() { } this.ProjectLocator = { findElement: sinon.stub() } this.controller = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - err: sinon.stub() - }), '../Project/ProjectLocator': this.ProjectLocator, './FileStoreHandler': this.FileStoreHandler } diff --git a/services/web/test/unit/src/FileStore/FileStoreHandlerTests.js b/services/web/test/unit/src/FileStore/FileStoreHandlerTests.js index 3356834b6d..fe356a3c86 100644 --- a/services/web/test/unit/src/FileStore/FileStoreHandlerTests.js +++ b/services/web/test/unit/src/FileStore/FileStoreHandlerTests.js @@ -1,6 +1,5 @@ -const { assert } = require('chai') +const { assert, expect } = require('chai') const sinon = require('sinon') -const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const Errors = require('../../../../app/src/Features/Errors/Errors') const OError = require('@overleaf/o-error') @@ -54,22 +53,13 @@ describe('FileStoreHandler', function() { } } } - this.logger = { - log: sinon.stub(), - warn: sinon.stub(), - err: sinon.stub() - } this.FileHashManager = { computeHash: sinon.stub().callsArgWith(1, null, this.hashValue) } this.handler = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, request: this.request, - 'logger-sharelatex': this.logger, './FileHashManager': this.FileHashManager, // FIXME: need to stub File object here '../../models/File': { diff --git a/services/web/test/unit/src/HelperFiles/AuthorizationHelperTests.js b/services/web/test/unit/src/HelperFiles/AuthorizationHelperTests.js index 71f920f1c6..d90227f7dc 100644 --- a/services/web/test/unit/src/HelperFiles/AuthorizationHelperTests.js +++ b/services/web/test/unit/src/HelperFiles/AuthorizationHelperTests.js @@ -1,14 +1,10 @@ -const chai = require('chai') const SandboxedModule = require('sandboxed-module') -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Helpers/AuthorizationHelper' describe('AuthorizationHelper', function() { beforeEach(function() { this.AuthorizationHelper = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/User': { UserSchema: { diff --git a/services/web/test/unit/src/HelperFiles/UrlHelperTests.js b/services/web/test/unit/src/HelperFiles/UrlHelperTests.js index 4312436ff1..b0a8d00a1f 100644 --- a/services/web/test/unit/src/HelperFiles/UrlHelperTests.js +++ b/services/web/test/unit/src/HelperFiles/UrlHelperTests.js @@ -1,5 +1,4 @@ -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const modulePath = require('path').join( __dirname, diff --git a/services/web/test/unit/src/History/HistoryControllerTests.js b/services/web/test/unit/src/History/HistoryControllerTests.js index 7b48d29d7d..a5be813c49 100644 --- a/services/web/test/unit/src/History/HistoryControllerTests.js +++ b/services/web/test/unit/src/History/HistoryControllerTests.js @@ -9,8 +9,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -chai.should() const sinon = require('sinon') const Errors = require('../../../../app/src/Features/Errors/Errors') @@ -26,17 +24,9 @@ describe('HistoryController', function() { getLoggedInUserId: sinon.stub().returns(this.user_id) } this.HistoryController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { request: (this.request = sinon.stub()), 'settings-sharelatex': (this.settings = {}), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - warn: sinon.stub(), - error: sinon.stub() - }), '../Authentication/AuthenticationController': this .AuthenticationController, './HistoryManager': (this.HistoryManager = {}), diff --git a/services/web/test/unit/src/History/HistoryManagerTests.js b/services/web/test/unit/src/History/HistoryManagerTests.js index 1f25758ee8..5b88738133 100644 --- a/services/web/test/unit/src/History/HistoryManagerTests.js +++ b/services/web/test/unit/src/History/HistoryManagerTests.js @@ -44,9 +44,6 @@ describe('HistoryManager', function() { } this.HistoryManager = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { 'request-promise-native': this.request, 'settings-sharelatex': this.settings, diff --git a/services/web/test/unit/src/History/RestoreManagerTests.js b/services/web/test/unit/src/History/RestoreManagerTests.js index d1469b71fc..e6037f2f3c 100644 --- a/services/web/test/unit/src/History/RestoreManagerTests.js +++ b/services/web/test/unit/src/History/RestoreManagerTests.js @@ -12,7 +12,6 @@ */ const SandboxedModule = require('sandboxed-module') const assert = require('assert') -require('chai').should() const { expect } = require('chai') const sinon = require('sinon') const modulePath = require('path').join( @@ -27,19 +26,12 @@ describe('RestoreManager', function() { beforeEach(function() { tk.freeze(Date.now()) // freeze the time for these tests this.RestoreManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': {}, '../../infrastructure/FileWriter': (this.FileWriter = {}), '../Uploads/FileSystemImportManager': (this.FileSystemImportManager = {}), '../Project/ProjectEntityHandler': (this.ProjectEntityHandler = {}), - '../Editor/EditorController': (this.EditorController = {}), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - err: sinon.stub() - }) + '../Editor/EditorController': (this.EditorController = {}) } }) this.user_id = 'mock-user-id' diff --git a/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js b/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js index 1f8dec493c..30d89a49db 100644 --- a/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js +++ b/services/web/test/unit/src/InactiveData/InactiveProjectManagerTests.js @@ -11,7 +11,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -35,23 +34,13 @@ describe('InactiveProjectManager', function() { markAsInactive: sinon.stub() } this.ProjectGetter = { getProject: sinon.stub() } - this.TrackChangesManager = { archiveProject: sinon.stub() } this.InactiveProjectManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log() {}, - warn() {}, - err() {} - }, '../Docstore/DocstoreManager': this.DocstoreManager, '../Project/ProjectUpdateHandler': this.ProjectUpdateHandler, '../Project/ProjectGetter': this.ProjectGetter, - '../TrackChanges/TrackChangesManager': this.TrackChangesManager, '../../models/Project': {} } }) @@ -120,7 +109,6 @@ describe('InactiveProjectManager', function() { describe('deactivateProject', function() { it('should call unarchiveProject and markAsInactive', function(done) { this.DocstoreManager.archiveProject.callsArgWith(1) - this.TrackChangesManager.archiveProject.callsArgWith(1) this.ProjectUpdateHandler.markAsInactive.callsArgWith(1) @@ -130,7 +118,6 @@ describe('InactiveProjectManager', function() { this.DocstoreManager.archiveProject .calledWith(this.project_id) .should.equal(true) - // @TrackChangesManager.archiveProject.calledWith(@project_id).should.equal true this.ProjectUpdateHandler.markAsInactive .calledWith(this.project_id) .should.equal(true) @@ -141,7 +128,6 @@ describe('InactiveProjectManager', function() { it('should not call markAsInactive if there was a problem archiving in docstore', function(done) { this.DocstoreManager.archiveProject.callsArgWith(1, 'errorrr') - this.TrackChangesManager.archiveProject.callsArgWith(1) this.ProjectUpdateHandler.markAsInactive.callsArgWith(1) diff --git a/services/web/test/unit/src/Institutions/InstitutionsAPITests.js b/services/web/test/unit/src/Institutions/InstitutionsAPITests.js index 2fb3ce64fa..ef600d491c 100644 --- a/services/web/test/unit/src/Institutions/InstitutionsAPITests.js +++ b/services/web/test/unit/src/Institutions/InstitutionsAPITests.js @@ -10,8 +10,7 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() -let { expect } = require('chai') +const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -20,23 +19,17 @@ const modulePath = path.join( __dirname, '../../../../app/src/Features/Institutions/InstitutionsAPI' ) -;({ expect } = require('chai')) const Errors = require('../../../../app/src/Features/Errors/Errors') describe('InstitutionsAPI', function() { beforeEach(function() { - this.logger = { warn: sinon.stub(), err: sinon.stub(), log() {} } this.settings = { apis: { v1: { url: 'v1.url', user: '', pass: '' } } } this.request = sinon.stub() this.ipMatcherNotification = { read: (this.markAsReadIpMatcher = sinon.stub().callsArgWith(1, null)) } this.InstitutionsAPI = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': this.logger, '@overleaf/metrics': { timeAsyncMethod: sinon.stub() }, @@ -44,9 +37,6 @@ describe('InstitutionsAPI', function() { request: this.request, '../Notifications/NotificationsBuilder': { ipMatcherAffiliation: sinon.stub().returns(this.ipMatcherNotification) - }, - '../../../../../app/src/Features/V1/V1Api': { - request: sinon.stub() } } }) @@ -67,13 +57,13 @@ describe('InstitutionsAPI', function() { return this.InstitutionsAPI.getInstitutionAffiliations( this.institutionId, (err, body) => { - should.not.exist(err) + expect(err).not.to.exist this.request.calledOnce.should.equal(true) const requestOptions = this.request.lastCall.args[0] const expectedUrl = `v1.url/api/v2/institutions/${this.institutionId}/affiliations` requestOptions.url.should.equal(expectedUrl) requestOptions.method.should.equal('GET') - should.not.exist(requestOptions.body) + expect(requestOptions.body).not.to.exist body.should.equal(responseBody) return done() } @@ -86,7 +76,7 @@ describe('InstitutionsAPI', function() { return this.InstitutionsAPI.getInstitutionAffiliations( this.institutionId, (err, body) => { - should.not.exist(err) + expect(err).not.to.exist expect(body).to.be.a('Array') body.length.should.equal(0) return done() @@ -111,7 +101,7 @@ describe('InstitutionsAPI', function() { endDate, 'monthly', (err, body) => { - should.not.exist(err) + expect(err).not.to.exist this.request.calledOnce.should.equal(true) const requestOptions = this.request.lastCall.args[0] const expectedUrl = `v1.url/api/v2/institutions/${this.institutionId}/institution_licences` @@ -134,13 +124,13 @@ describe('InstitutionsAPI', function() { return this.InstitutionsAPI.getUserAffiliations( this.stubbedUser._id, (err, body) => { - should.not.exist(err) + expect(err).not.to.exist this.request.calledOnce.should.equal(true) const requestOptions = this.request.lastCall.args[0] const expectedUrl = `v1.url/api/v2/users/${this.stubbedUser._id}/affiliations` requestOptions.url.should.equal(expectedUrl) requestOptions.method.should.equal('GET') - should.not.exist(requestOptions.body) + expect(requestOptions.body).not.to.exist body.should.equal(responseBody) return done() } @@ -164,7 +154,7 @@ describe('InstitutionsAPI', function() { return this.InstitutionsAPI.getUserAffiliations( this.stubbedUser._id, (err, body) => { - should.not.exist(err) + expect(err).not.to.exist expect(body).to.be.a('Array') body.length.should.equal(0) return done() @@ -191,7 +181,7 @@ describe('InstitutionsAPI', function() { this.newEmail, affiliationOptions, err => { - should.not.exist(err) + expect(err).not.to.exist this.request.calledOnce.should.equal(true) const requestOptions = this.request.lastCall.args[0] const expectedUrl = `v1.url/api/v2/users/${this.stubbedUser._id}/affiliations` @@ -220,7 +210,7 @@ describe('InstitutionsAPI', function() { this.newEmail, {}, err => { - should.exist(err) + expect(err).to.exist err.message.should.have.string(422) err.message.should.have.string(body.errors) return done() @@ -239,7 +229,7 @@ describe('InstitutionsAPI', function() { this.stubbedUser._id, this.newEmail, err => { - should.not.exist(err) + expect(err).not.to.exist this.request.calledOnce.should.equal(true) const requestOptions = this.request.lastCall.args[0] const expectedUrl = `v1.url/api/v2/users/${this.stubbedUser._id}/affiliations/remove` @@ -257,7 +247,7 @@ describe('InstitutionsAPI', function() { this.stubbedUser._id, this.newEmail, err => { - should.exist(err) + expect(err).to.exist err.message.should.exist return done() } @@ -271,7 +261,7 @@ describe('InstitutionsAPI', function() { return this.InstitutionsAPI.deleteAffiliations( this.stubbedUser._id, err => { - should.not.exist(err) + expect(err).not.to.exist this.request.calledOnce.should.equal(true) const requestOptions = this.request.lastCall.args[0] const expectedUrl = `v1.url/api/v2/users/${this.stubbedUser._id}/affiliations` @@ -307,7 +297,7 @@ describe('InstitutionsAPI', function() { 'Student', 'Physics', err => { - should.not.exist(err) + expect(err).not.to.exist this.request.calledOnce.should.equal(true) const requestOptions = this.request.lastCall.args[0] const expectedUrl = `v1.url/api/v2/users/${this.stubbedUser._id}/affiliations/endorse` diff --git a/services/web/test/unit/src/Institutions/InstitutionsControllerTests.js b/services/web/test/unit/src/Institutions/InstitutionsControllerTests.js index 42e29a276f..65dada5e7c 100644 --- a/services/web/test/unit/src/Institutions/InstitutionsControllerTests.js +++ b/services/web/test/unit/src/Institutions/InstitutionsControllerTests.js @@ -10,20 +10,18 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') +const { expect } = require('chai') const path = require('path') const sinon = require('sinon') const modulePath = path.join( __dirname, '../../../../app/src/Features/Institutions/InstitutionsController' ) -const { expect } = require('chai') describe('InstitutionsController', function() { beforeEach(function() { - this.logger = { err: sinon.stub(), warn: sinon.stub(), log() {} } this.host = 'mit.edu' .split('') .reverse() @@ -81,11 +79,7 @@ describe('InstitutionsController', function() { .withArgs(this.stubbedUser2._id) .yields(null, this.stubbedUser2DecoratedEmails) this.InstitutionsController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': this.logger, '../User/UserGetter': { getUsersByHostname: this.getUsersByHostname, getUserFullEmails: this.getUserFullEmails diff --git a/services/web/test/unit/src/Institutions/InstitutionsFeaturesTests.js b/services/web/test/unit/src/Institutions/InstitutionsFeaturesTests.js index 6b9429e76e..e264f7ad6c 100644 --- a/services/web/test/unit/src/Institutions/InstitutionsFeaturesTests.js +++ b/services/web/test/unit/src/Institutions/InstitutionsFeaturesTests.js @@ -12,7 +12,6 @@ */ const SandboxedModule = require('sandboxed-module') const assert = require('assert') -require('chai').should() const { expect } = require('chai') const sinon = require('sinon') const modulePath = require('path').join( @@ -26,18 +25,11 @@ describe('InstitutionsFeatures', function() { this.PlansLocator = { findLocalPlanInSettings: sinon.stub() } this.institutionPlanCode = 'institution_plan_code' this.InstitutionsFeatures = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../User/UserGetter': this.UserGetter, '../Subscription/PlansLocator': this.PlansLocator, 'settings-sharelatex': { institutionPlanCode: this.institutionPlanCode - }, - 'logger-sharelatex': { - log() {}, - err() {} } } }) diff --git a/services/web/test/unit/src/Institutions/InstitutionsGetterTests.js b/services/web/test/unit/src/Institutions/InstitutionsGetterTests.js index e574bc451f..4299ab74ca 100644 --- a/services/web/test/unit/src/Institutions/InstitutionsGetterTests.js +++ b/services/web/test/unit/src/Institutions/InstitutionsGetterTests.js @@ -10,7 +10,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const SandboxedModule = require('sandboxed-module') -require('chai').should() const { expect } = require('chai') const sinon = require('sinon') const modulePath = require('path').join( @@ -22,17 +21,10 @@ describe('InstitutionsGetter', function() { beforeEach(function() { this.UserGetter = { getUserFullEmails: sinon.stub() } this.InstitutionsGetter = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../User/UserGetter': this.UserGetter, '../UserMembership/UserMembershipsHandler': (this.UserMembershipsHandler = {}), - '../UserMembership/UserMembershipEntityConfigs': (this.UserMembershipEntityConfigs = {}), - 'logger-sharelatex': { - log() {}, - err() {} - } + '../UserMembership/UserMembershipEntityConfigs': (this.UserMembershipEntityConfigs = {}) } }) diff --git a/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js b/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js index ec2b995769..cdb7995bfc 100644 --- a/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js +++ b/services/web/test/unit/src/Institutions/InstitutionsManagerTests.js @@ -1,17 +1,15 @@ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const path = require('path') const sinon = require('sinon') +const { expect } = require('chai') const modulePath = path.join( __dirname, '../../../../app/src/Features/Institutions/InstitutionsManager' ) -const { expect } = require('chai') describe('InstitutionsManager', function() { beforeEach(function() { this.institutionId = 123 - this.logger = { log() {} } this.user = {} this.getInstitutionAffiliations = sinon.stub() this.refreshFeatures = sinon.stub().yields() @@ -54,11 +52,7 @@ describe('InstitutionsManager', function() { this.Mongo = { ObjectId: sinon.stub().returnsArg(0) } this.InstitutionsManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': this.logger, './InstitutionsAPI': { getInstitutionAffiliations: this.getInstitutionAffiliations }, @@ -105,7 +99,7 @@ describe('InstitutionsManager', function() { this.institutionId, false, error => { - should.not.exist(error) + expect(error).not.to.exist sinon.assert.calledTwice(this.refreshFeatures) // expect no notifications @@ -125,7 +119,7 @@ describe('InstitutionsManager', function() { this.institutionId, true, error => { - should.not.exist(error) + expect(error).not.to.exist sinon.assert.calledOnce( this.NotificationsBuilder.featuresUpgradedByAffiliation ) @@ -144,7 +138,7 @@ describe('InstitutionsManager', function() { this.institutionId, true, error => { - should.not.exist(error) + expect(error).not.to.exist sinon.assert.calledOnce( this.NotificationsBuilder.redundantPersonalSubscription ) @@ -184,7 +178,7 @@ describe('InstitutionsManager', function() { this.InstitutionsManager.checkInstitutionUsers( this.institutionId, (error, usersSummary) => { - should.not.exist(error) + expect(error).not.to.exist usersSummary.confirmedEmailUsers.total.should.equal(3) usersSummary.confirmedEmailUsers.totalProUsers.should.equal(1) @@ -217,7 +211,7 @@ describe('InstitutionsManager', function() { this.InstitutionsManager.getInstitutionUsersSubscriptions( this.institutionId, (error, subscriptions) => { - should.not.exist(error) + expect(error).not.to.exist sinon.assert.calledOnce(this.subscriptionExec) done() } diff --git a/services/web/test/unit/src/Metadata/MetaControllerTests.js b/services/web/test/unit/src/Metadata/MetaControllerTests.js index 20e1037e7a..a83c2a3359 100644 --- a/services/web/test/unit/src/Metadata/MetaControllerTests.js +++ b/services/web/test/unit/src/Metadata/MetaControllerTests.js @@ -9,9 +9,7 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -chai.should() -const { expect } = chai +const { expect } = require('chai') const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Metadata/MetaController' const SandboxedModule = require('sandboxed-module') @@ -27,15 +25,7 @@ describe('MetaController', function() { getMetaForDoc: sinon.stub() } return (this.MetadataController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': { - log: sinon.stub(), - warn: sinon.stub(), - err: sinon.stub() - }, '../Editor/EditorRealTimeController': this.EditorRealTimeController, './MetaHandler': this.MetaHandler } diff --git a/services/web/test/unit/src/Metadata/MetaHandlerTests.js b/services/web/test/unit/src/Metadata/MetaHandlerTests.js index 75df5be74f..1b4025cf4d 100644 --- a/services/web/test/unit/src/Metadata/MetaHandlerTests.js +++ b/services/web/test/unit/src/Metadata/MetaHandlerTests.js @@ -10,9 +10,7 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -chai.should() -const { expect } = chai +const { expect } = require('chai') const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Metadata/MetaHandler' const SandboxedModule = require('sandboxed-module') @@ -54,9 +52,6 @@ describe('MetaHandler', function() { } return (this.MetaHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Project/ProjectEntityHandler': this.ProjectEntityHandler, '../DocumentUpdater/DocumentUpdaterHandler': this diff --git a/services/web/test/unit/src/Newsletter/NewsletterManagerTests.js b/services/web/test/unit/src/Newsletter/NewsletterManagerTests.js index fafbc1401a..d8d9ae7d4c 100644 --- a/services/web/test/unit/src/Newsletter/NewsletterManagerTests.js +++ b/services/web/test/unit/src/Newsletter/NewsletterManagerTests.js @@ -27,11 +27,9 @@ describe('NewsletterManager', function() { this.NewsletterManager = SandboxedModule.require(MODULE_PATH, { requires: { - 'logger-sharelatex': { info: sinon.stub() }, 'mailchimp-api-v3': this.Mailchimp, 'settings-sharelatex': this.Settings - }, - globals: { console: console } + } }).promises this.user = { diff --git a/services/web/test/unit/src/Notifications/NotificationsBuilderTests.js b/services/web/test/unit/src/Notifications/NotificationsBuilderTests.js index 77724bf6ee..9c21f7f7a0 100644 --- a/services/web/test/unit/src/Notifications/NotificationsBuilderTests.js +++ b/services/web/test/unit/src/Notifications/NotificationsBuilderTests.js @@ -1,5 +1,4 @@ const SandboxedModule = require('sandboxed-module') -require('chai').should() const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -15,17 +14,10 @@ describe('NotificationsBuilder', function() { this.settings = { apis: { v1: { url: 'v1.url', user: '', pass: '' } } } this.request = sinon.stub() this.controller = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './NotificationsHandler': this.handler, 'settings-sharelatex': this.settings, - request: this.request, - 'logger-sharelatex': { - log() {}, - err() {} - } + request: this.request } }) }) diff --git a/services/web/test/unit/src/Notifications/NotificationsControllerTests.js b/services/web/test/unit/src/Notifications/NotificationsControllerTests.js index 8289e64f06..faaa023fac 100644 --- a/services/web/test/unit/src/Notifications/NotificationsControllerTests.js +++ b/services/web/test/unit/src/Notifications/NotificationsControllerTests.js @@ -13,7 +13,6 @@ */ const SandboxedModule = require('sandboxed-module') const assert = require('assert') -require('chai').should() const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -46,15 +45,8 @@ describe('NotificationsController', function() { getLoggedInUserId: sinon.stub().returns(this.req.session.user._id) } return (this.controller = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './NotificationsHandler': this.handler, - 'logger-sharelatex': { - log() {}, - err() {} - }, '../Authentication/AuthenticationController': this .AuthenticationController } diff --git a/services/web/test/unit/src/Notifications/NotificationsHandlerTests.js b/services/web/test/unit/src/Notifications/NotificationsHandlerTests.js index a3d5dd79f8..62e99b65bc 100644 --- a/services/web/test/unit/src/Notifications/NotificationsHandlerTests.js +++ b/services/web/test/unit/src/Notifications/NotificationsHandlerTests.js @@ -14,7 +14,6 @@ */ const SandboxedModule = require('sandboxed-module') const { assert } = require('chai') -require('chai').should() const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -30,18 +29,11 @@ describe('NotificationsHandler', function() { beforeEach(function() { this.request = sinon.stub().callsArgWith(1) return (this.handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': { apis: { notifications: { url: notificationUrl } } }, - request: this.request, - 'logger-sharelatex': { - log() {}, - err() {} - } + request: this.request } })) }) diff --git a/services/web/test/unit/src/PasswordReset/PasswordResetControllerTests.js b/services/web/test/unit/src/PasswordReset/PasswordResetControllerTests.js index aba78fc8a6..62d2ef786d 100644 --- a/services/web/test/unit/src/PasswordReset/PasswordResetControllerTests.js +++ b/services/web/test/unit/src/PasswordReset/PasswordResetControllerTests.js @@ -50,18 +50,9 @@ describe('PasswordResetController', function() { } } this.PasswordResetController = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, './PasswordResetHandler': this.PasswordResetHandler, - 'logger-sharelatex': { - log() {}, - warn() {}, - err: sinon.stub(), - error() {} - }, '../../infrastructure/RateLimiter': this.RateLimiter, '../Authentication/AuthenticationController': (this.AuthenticationController = { getLoggedInUserId: sinon.stub(), diff --git a/services/web/test/unit/src/PasswordReset/PasswordResetHandlerTests.js b/services/web/test/unit/src/PasswordReset/PasswordResetHandlerTests.js index a1b0c7e208..3c4331977e 100644 --- a/services/web/test/unit/src/PasswordReset/PasswordResetHandlerTests.js +++ b/services/web/test/unit/src/PasswordReset/PasswordResetHandlerTests.js @@ -15,15 +15,11 @@ const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') const sinon = require('sinon') -const sinonChai = require('sinon-chai') -const chai = require('chai') +const { expect } = require('chai') const modulePath = path.join( __dirname, '../../../../app/src/Features/PasswordReset/PasswordResetHandler' ) -const should = require('chai').should() -chai.use(sinonChai) -const { expect } = chai describe('PasswordResetHandler', function() { beforeEach(function() { @@ -45,7 +41,6 @@ describe('PasswordResetHandler', function() { } } this.PasswordResetHandler = SandboxedModule.require(modulePath, { - globals: { console: console }, requires: { '../User/UserAuditLogHandler': (this.UserAuditLogHandler = { promises: { @@ -56,11 +51,7 @@ describe('PasswordResetHandler', function() { '../Security/OneTimeTokenHandler': this.OneTimeTokenHandler, '../Email/EmailHandler': this.EmailHandler, '../Authentication/AuthenticationManager': this.AuthenticationManager, - 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log() {}, - err() {} - } + 'settings-sharelatex': this.settings } }) this.token = '12312321i' diff --git a/services/web/test/unit/src/Project/DocLinesComparitorTests.js b/services/web/test/unit/src/Project/DocLinesComparitorTests.js index 054e737741..dc93291007 100644 --- a/services/web/test/unit/src/Project/DocLinesComparitorTests.js +++ b/services/web/test/unit/src/Project/DocLinesComparitorTests.js @@ -12,21 +12,12 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() const modulePath = '../../../../app/src/Features/Project/DocLinesComparitor.js' const SandboxedModule = require('sandboxed-module') describe('doc lines comparitor', function() { beforeEach(function() { - return (this.comparitor = SandboxedModule.require(modulePath, { - globals: { - console: console - }, - requires: { - 'logger-sharelatex': { log() {} } - } - })) + return (this.comparitor = SandboxedModule.require(modulePath, {})) }) it('should return true when the lines are the same', function() { diff --git a/services/web/test/unit/src/Project/ProjectApiControllerTests.js b/services/web/test/unit/src/Project/ProjectApiControllerTests.js index 12d3c15842..073fd6be70 100644 --- a/services/web/test/unit/src/Project/ProjectApiControllerTests.js +++ b/services/web/test/unit/src/Project/ProjectApiControllerTests.js @@ -10,24 +10,16 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const modulePath = '../../../../app/src/Features/Project/ProjectApiController' const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -require('chai').should() describe('Project api controller', function() { beforeEach(function() { this.ProjectDetailsHandler = { getDetails: sinon.stub() } this.controller = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - './ProjectDetailsHandler': this.ProjectDetailsHandler, - 'logger-sharelatex': { - log() {} - } + './ProjectDetailsHandler': this.ProjectDetailsHandler } }) this.project_id = '321l3j1kjkjl' diff --git a/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js b/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js index 62d9e2b104..bfac5b5c5d 100644 --- a/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js +++ b/services/web/test/unit/src/Project/ProjectCollabratecDetailsTest.js @@ -15,11 +15,9 @@ const { ObjectId } = require('mongodb') const Path = require('path') const SandboxedModule = require('sandboxed-module') const assert = require('assert') -const chai = require('chai') +const { expect } = require('chai') const sinon = require('sinon') -const { expect } = chai - const modulePath = Path.join( __dirname, '../../../../app/src/Features/Project/ProjectCollabratecDetailsHandler' @@ -34,9 +32,6 @@ describe('ProjectCollabratecDetailsHandler', function() { this.ProjectCollabratecDetailsHandler = SandboxedModule.require( modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, '../../models/Project': { Project: this.ProjectModel } diff --git a/services/web/test/unit/src/Project/ProjectControllerTests.js b/services/web/test/unit/src/Project/ProjectControllerTests.js index 2fde847650..22cc4cf83b 100644 --- a/services/web/test/unit/src/Project/ProjectControllerTests.js +++ b/services/web/test/unit/src/Project/ProjectControllerTests.js @@ -66,7 +66,6 @@ describe('ProjectController', function() { this.EditorController = { renameProject: sinon.stub() } this.InactiveProjectManager = { reactivateProjectIfRequired: sinon.stub() } this.ProjectUpdateHandler = { markAsOpened: sinon.stub() } - this.ReferencesSearchHandler = { indexProjectReferences: sinon.stub() } this.ProjectGetter = { findAllUsersProjects: sinon.stub(), getProject: sinon.stub() @@ -127,16 +126,9 @@ describe('ProjectController', function() { } this.ProjectController = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log() {}, - err() {} - }, '@overleaf/metrics': this.Metrics, './ProjectDeleter': this.ProjectDeleter, './ProjectDuplicator': this.ProjectDuplicator, @@ -152,8 +144,6 @@ describe('ProjectController', function() { '../Authorization/AuthorizationManager': this.AuthorizationManager, '../InactiveData/InactiveProjectManager': this.InactiveProjectManager, './ProjectUpdateHandler': this.ProjectUpdateHandler, - '../ReferencesSearch/ReferencesSearchHandler': this - .ReferencesSearchHandler, './ProjectGetter': this.ProjectGetter, './ProjectDetailsHandler': this.ProjectDetailsHandler, '../Authentication/AuthenticationController': this diff --git a/services/web/test/unit/src/Project/ProjectCreationHandlerTests.js b/services/web/test/unit/src/Project/ProjectCreationHandlerTests.js index c1e143f05f..8f3f1658e0 100644 --- a/services/web/test/unit/src/Project/ProjectCreationHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectCreationHandlerTests.js @@ -61,9 +61,6 @@ describe('ProjectCreationHandler', function() { this.AnalyticsManager = { recordEvent: sinon.stub() } this.handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, '../../models/User': { @@ -76,7 +73,6 @@ describe('ProjectCreationHandler', function() { './ProjectDetailsHandler': this.ProjectDetailsHandler, 'settings-sharelatex': this.Settings, '../Analytics/AnalyticsManager': this.AnalyticsManager, - 'logger-sharelatex': { log() {} }, '@overleaf/metrics': { inc() {}, timeAsyncMethod() {} diff --git a/services/web/test/unit/src/Project/ProjectDeleterTests.js b/services/web/test/unit/src/Project/ProjectDeleterTests.js index b6e44fe2d1..a45c190ea8 100644 --- a/services/web/test/unit/src/Project/ProjectDeleterTests.js +++ b/services/web/test/unit/src/Project/ProjectDeleterTests.js @@ -1,8 +1,7 @@ const modulePath = '../../../../app/src/Features/Project/ProjectDeleter' const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const tk = require('timekeeper') const moment = require('moment') const { Project } = require('../helpers/models/Project') @@ -93,12 +92,6 @@ describe('ProjectDeleter', function() { } } - this.logger = { - err: sinon.stub(), - log: sinon.stub(), - warn: sinon.stub() - } - this.ProjectDetailsHandler = { promises: { generateUniqueName: sinon.stub().resolves(this.project.name) @@ -150,11 +143,7 @@ describe('ProjectDeleter', function() { '../Docstore/DocstoreManager': this.DocstoreManager, './ProjectDetailsHandler': this.ProjectDetailsHandler, '../../infrastructure/mongodb': { db: this.db, ObjectId }, - '../History/HistoryManager': this.HistoryManager, - 'logger-sharelatex': this.logger - }, - globals: { - console: console + '../History/HistoryManager': this.HistoryManager } }) }) diff --git a/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js b/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js index 47e01dce57..fc4eac0b50 100644 --- a/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js @@ -66,9 +66,6 @@ describe('ProjectDetailsHandler', function() { defaultFeatures: 'default-features' } this.handler = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { './ProjectHelper': ProjectHelper, './ProjectGetter': this.ProjectGetter, @@ -77,11 +74,6 @@ describe('ProjectDetailsHandler', function() { }, '../User/UserGetter': this.UserGetter, '../ThirdPartyDataStore/TpdsUpdateSender': this.TpdsUpdateSender, - 'logger-sharelatex': { - log() {}, - warn() {}, - err() {} - }, '../TokenGenerator/TokenGenerator': this.TokenGenerator, 'settings-sharelatex': this.settings } diff --git a/services/web/test/unit/src/Project/ProjectDuplicatorTests.js b/services/web/test/unit/src/Project/ProjectDuplicatorTests.js index 967f1c4e02..7b6e33185b 100644 --- a/services/web/test/unit/src/Project/ProjectDuplicatorTests.js +++ b/services/web/test/unit/src/Project/ProjectDuplicatorTests.js @@ -200,9 +200,6 @@ describe('ProjectDuplicator', function() { } this.ProjectDuplicator = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { '../../models/Doc': { Doc: this.Doc }, '../../models/File': { File: this.File }, @@ -218,12 +215,7 @@ describe('ProjectDuplicator', function() { './ProjectGetter': this.ProjectGetter, './ProjectLocator': this.ProjectLocator, './ProjectOptionsHandler': this.ProjectOptionsHandler, - '../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher, - 'logger-sharelatex': { - log() {}, - warn() {}, - err() {} - } + '../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher } }) }) diff --git a/services/web/test/unit/src/Project/ProjectEditorHandlerTests.js b/services/web/test/unit/src/Project/ProjectEditorHandlerTests.js index 82108aa728..686a136250 100644 --- a/services/web/test/unit/src/Project/ProjectEditorHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectEditorHandlerTests.js @@ -10,9 +10,7 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -const { expect } = chai -const should = chai.should() +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Project/ProjectEditorHandler' const SandboxedModule = require('sandboxed-module') @@ -122,27 +120,27 @@ describe('ProjectEditorHandler', function() { }) it('should include the id', function() { - should.exist(this.result._id) + expect(this.result._id).to.exist return this.result._id.should.equal('project-id') }) it('should include the name', function() { - should.exist(this.result.name) + expect(this.result.name).to.exist return this.result.name.should.equal('Project Name') }) it('should include the root doc id', function() { - should.exist(this.result.rootDoc_id) + expect(this.result.rootDoc_id).to.exist return this.result.rootDoc_id.should.equal('file-id') }) it('should include the public access level', function() { - should.exist(this.result.publicAccesLevel) + expect(this.result.publicAccesLevel).to.exist return this.result.publicAccesLevel.should.equal('private') }) it('should include the owner', function() { - should.exist(this.result.owner) + expect(this.result.owner).to.exist this.result.owner._id.should.equal('owner-id') this.result.owner.email.should.equal('owner@sharelatex.com') this.result.owner.first_name.should.equal('Owner') @@ -151,7 +149,7 @@ describe('ProjectEditorHandler', function() { }) it('should include the deletedDocs', function() { - should.exist(this.result.deletedDocs) + expect(this.result.deletedDocs).to.exist this.result.deletedDocs.should.deep.equal([ { // omit deletedAt field @@ -162,8 +160,8 @@ describe('ProjectEditorHandler', function() { }) it('invites should not include the token', function() { - should.not.exist(this.result.invites[0].token) - should.not.exist(this.result.invites[1].token) + expect(this.result.invites[0].token).not.to.exist + expect(this.result.invites[1].token).not.to.exist }) it('should gather readOnly_refs and collaberators_refs into a list of members', function() { @@ -178,7 +176,7 @@ describe('ProjectEditorHandler', function() { this.result.members.length.should.equal(2) - should.exist(findMember('read-only-id')) + expect(findMember('read-only-id')).to.exist findMember('read-only-id').privileges.should.equal('readOnly') findMember('read-only-id').first_name.should.equal('Read') findMember('read-only-id').last_name.should.equal('Only') @@ -186,7 +184,7 @@ describe('ProjectEditorHandler', function() { 'read-only@sharelatex.com' ) - should.exist(findMember('read-write-id')) + expect(findMember('read-write-id')).to.exist findMember('read-write-id').privileges.should.equal('readAndWrite') findMember('read-write-id').first_name.should.equal('Read') findMember('read-write-id').last_name.should.equal('Write') @@ -218,9 +216,8 @@ describe('ProjectEditorHandler', function() { this.result.rootFolder[0].folders[0].fileRefs[0].created.should.equal( this.created ) - return should.not.exist( - this.result.rootFolder[0].folders[0].fileRefs[0].size - ) + return expect(this.result.rootFolder[0].folders[0].fileRefs[0].size).not + .to.exist }) it('should include docs in the project but not the lines', function() { @@ -228,13 +225,12 @@ describe('ProjectEditorHandler', function() { this.result.rootFolder[0].folders[0].docs[0].name.should.equal( 'main.tex' ) - return should.not.exist( - this.result.rootFolder[0].folders[0].docs[0].lines - ) + return expect(this.result.rootFolder[0].folders[0].docs[0].lines).not.to + .exist }) it('should include invites', function() { - should.exist(this.result.invites) + expect(this.result.invites).to.exist return this.result.invites.should.deep.equal(this.invites) }) }) diff --git a/services/web/test/unit/src/Project/ProjectEntityHandlerTests.js b/services/web/test/unit/src/Project/ProjectEntityHandlerTests.js index 9fcff4a2e5..d30a8fd0b1 100644 --- a/services/web/test/unit/src/Project/ProjectEntityHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectEntityHandlerTests.js @@ -13,10 +13,7 @@ * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -const { assert } = require('chai') -const should = chai.should() -const { expect } = chai +const { assert, expect } = require('chai') const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Project/ProjectEntityHandler' const SandboxedModule = require('sandboxed-module') @@ -60,15 +57,7 @@ describe('ProjectEntityHandler', function() { this.callback = sinon.stub() return (this.ProjectEntityHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - error: sinon.stub(), - err() {} - }), '../Docstore/DocstoreManager': (this.DocstoreManager = {}), '../../Features/DocumentUpdater/DocumentUpdaterHandler': this .DocumentUpdaterHandler, diff --git a/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js b/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js index 045f3d4ec1..84855326e5 100644 --- a/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectEntityMongoUpdateHandlerTests.js @@ -62,12 +62,6 @@ describe('ProjectEntityMongoUpdateHandler', function() { rootFolder: [this.rootFolder] } - this.logger = { - log: sinon.stub(), - warn: sinon.stub(), - error: sinon.stub(), - err() {} - } this.Settings = { maxEntitiesPerProject: 100 } this.CooldownManager = {} this.LockManager = { @@ -184,12 +178,8 @@ describe('ProjectEntityMongoUpdateHandler', function() { } this.subject = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, - 'logger-sharelatex': this.logger, 'settings-sharelatex': this.Settings, '../Cooldown/CooldownManager': this.CooldownManager, '../../models/Folder': { Folder: this.FolderModel }, diff --git a/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js b/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js index 15c583f854..438ec409ad 100644 --- a/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js @@ -1,5 +1,4 @@ -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const sinon = require('sinon') const Errors = require('../../../../app/src/Features/Errors/Errors') const SandboxedModule = require('sandboxed-module') @@ -82,13 +81,6 @@ describe('ProjectEntityUpdateHandler', function() { resyncProjectHistory: sinon.stub(), deleteDoc: sinon.stub().yields() } - this.logger = { - info: sinon.stub(), - log: sinon.stub(), - warn: sinon.stub(), - error: sinon.stub(), - err() {} - } this.fs = { unlink: sinon.stub().yields() } @@ -152,12 +144,8 @@ describe('ProjectEntityUpdateHandler', function() { emitToRoom: sinon.stub() } this.ProjectEntityUpdateHandler = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { 'settings-sharelatex': { validRootDocExtensions: ['tex'] }, - 'logger-sharelatex': this.logger, fs: this.fs, '../../models/Doc': { Doc: this.DocModel }, '../Docstore/DocstoreManager': this.DocstoreManager, diff --git a/services/web/test/unit/src/Project/ProjectGetterTests.js b/services/web/test/unit/src/Project/ProjectGetterTests.js index 064eedd5b2..d667b33905 100644 --- a/services/web/test/unit/src/Project/ProjectGetterTests.js +++ b/services/web/test/unit/src/Project/ProjectGetterTests.js @@ -1,6 +1,5 @@ const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Project/ProjectGetter.js' const SandboxedModule = require('sandboxed-module') const { ObjectId } = require('mongodb') @@ -43,7 +42,6 @@ describe('ProjectGetter', function() { lockKey: sinon.stub().returnsArg(0) } this.ProjectGetter = SandboxedModule.require(modulePath, { - globals: { console }, requires: { '../../infrastructure/mongodb': { db: this.db, ObjectId }, '@overleaf/metrics': { @@ -58,11 +56,7 @@ describe('ProjectGetter', function() { '../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter, '../../infrastructure/LockManager': this.LockManager, './ProjectEntityMongoUpdateHandler': this - .ProjectEntityMongoUpdateHandler, - 'logger-sharelatex': { - err() {}, - log() {} - } + .ProjectEntityMongoUpdateHandler } }) }) diff --git a/services/web/test/unit/src/Project/ProjectHelperTests.js b/services/web/test/unit/src/Project/ProjectHelperTests.js index ac820585a6..f2bb644ec5 100644 --- a/services/web/test/unit/src/Project/ProjectHelperTests.js +++ b/services/web/test/unit/src/Project/ProjectHelperTests.js @@ -1,5 +1,4 @@ -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const { ObjectId } = require('mongodb') diff --git a/services/web/test/unit/src/Project/ProjectHistoryHandlerTests.js b/services/web/test/unit/src/Project/ProjectHistoryHandlerTests.js index f1d0cbf5b8..f02ccf3c1b 100644 --- a/services/web/test/unit/src/Project/ProjectHistoryHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectHistoryHandlerTests.js @@ -12,10 +12,7 @@ * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -const { assert } = require('chai') -const should = chai.should() -const { expect } = chai +const { assert, expect } = require('chai') const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Project/ProjectHistoryHandler' const SandboxedModule = require('sandboxed-module') @@ -46,15 +43,7 @@ describe('ProjectHistoryHandler', function() { this.callback = sinon.stub() return (this.ProjectHistoryHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - error: sinon.stub(), - err() {} - }), 'settings-sharelatex': (this.Settings = {}), '../../models/Project': { Project: this.ProjectModel diff --git a/services/web/test/unit/src/Project/ProjectLocatorTests.js b/services/web/test/unit/src/Project/ProjectLocatorTests.js index de286905f3..e2695cbf9a 100644 --- a/services/web/test/unit/src/Project/ProjectLocatorTests.js +++ b/services/web/test/unit/src/Project/ProjectLocatorTests.js @@ -52,19 +52,11 @@ describe('ProjectLocator', function() { isArchivedOrTrashed: sinon.stub() } this.locator = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/Project': { Project }, '../../models/User': { User: this.User }, './ProjectGetter': this.ProjectGetter, - './ProjectHelper': this.ProjectHelper, - 'logger-sharelatex': { - log() {}, - err() {}, - warn() {} - } + './ProjectHelper': this.ProjectHelper } }) }) diff --git a/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js b/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js index 2a0dac7272..91d0100d69 100644 --- a/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectOptionsHandlerTests.js @@ -14,9 +14,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai -const should = chai.should() +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Project/ProjectOptionsHandler.js' const SandboxedModule = require('sandboxed-module') @@ -32,9 +30,6 @@ describe('ProjectOptionsHandler', function() { this.projectModel.updateOne = sinon.stub().yields() this.handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/Project': { Project: this.projectModel }, 'settings-sharelatex': { @@ -47,10 +42,6 @@ describe('ProjectOptionsHandler', function() { { imageName: 'texlive-0000.0', imageDesc: 'test image 0' }, { imageName: 'texlive-1234.5', imageDesc: 'test image 1' } ] - }, - 'logger-sharelatex': { - log() {}, - err() {} } } }) diff --git a/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js b/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js index 84c1290226..9203768b85 100644 --- a/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js +++ b/services/web/test/unit/src/Project/ProjectRootDocManagerTests.js @@ -11,9 +11,7 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Project/ProjectRootDocManager.js' @@ -41,9 +39,6 @@ describe('ProjectRootDocManager', function() { stat: sinon.stub().callsArgWith(1, null, { size: 100 }) } return (this.ProjectRootDocManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './ProjectEntityHandler': (this.ProjectEntityHandler = {}), './ProjectEntityUpdateHandler': (this.ProjectEntityUpdateHandler = {}), diff --git a/services/web/test/unit/src/Project/ProjectUpdateHandlerTests.js b/services/web/test/unit/src/Project/ProjectUpdateHandlerTests.js index aec99a39ce..1c5faca4a0 100644 --- a/services/web/test/unit/src/Project/ProjectUpdateHandlerTests.js +++ b/services/web/test/unit/src/Project/ProjectUpdateHandlerTests.js @@ -13,7 +13,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai').should() const modulePath = '../../../../app/src/Features/Project/ProjectUpdateHandler.js' const SandboxedModule = require('sandboxed-module') @@ -29,12 +28,8 @@ describe('ProjectUpdateHandler', function() { this.ProjectModel = Project = class Project {} this.ProjectModel.updateOne = sinon.stub().callsArg(3) return (this.handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - '../../models/Project': { Project: this.ProjectModel }, - 'logger-sharelatex': { log: sinon.stub() } + '../../models/Project': { Project: this.ProjectModel } } })) }) diff --git a/services/web/test/unit/src/Project/SafePathTests.js b/services/web/test/unit/src/Project/SafePathTests.js index 9129dd3b1a..93ca1806fe 100644 --- a/services/web/test/unit/src/Project/SafePathTests.js +++ b/services/web/test/unit/src/Project/SafePathTests.js @@ -10,10 +10,7 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -const { assert } = require('chai') -const should = chai.should() -const { expect } = chai +const { assert, expect } = require('chai') const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Project/SafePath' const SandboxedModule = require('sandboxed-module') diff --git a/services/web/test/unit/src/Publishers/PublishersGetterTests.js b/services/web/test/unit/src/Publishers/PublishersGetterTests.js index d83dd81307..7a769f35d3 100644 --- a/services/web/test/unit/src/Publishers/PublishersGetterTests.js +++ b/services/web/test/unit/src/Publishers/PublishersGetterTests.js @@ -12,7 +12,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const SandboxedModule = require('sandboxed-module') -require('chai').should() const { expect } = require('chai') const sinon = require('sinon') const modulePath = require('path').join( @@ -29,9 +28,6 @@ describe('PublishersGetter', function() { } this.PublishersGetter = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../User/UserGetter': this.UserGetter, '../UserMembership/UserMembershipsHandler': (this.UserMembershipsHandler = { @@ -47,11 +43,7 @@ describe('PublishersGetter', function() { primaryKey: 'slug' } } - }), - 'logger-sharelatex': { - log() {}, - err() {} - } + }) } }) diff --git a/services/web/test/unit/src/Referal/ReferalAllocatorTests.js b/services/web/test/unit/src/Referal/ReferalAllocatorTests.js index 9b9acfe032..a111d54782 100644 --- a/services/web/test/unit/src/Referal/ReferalAllocatorTests.js +++ b/services/web/test/unit/src/Referal/ReferalAllocatorTests.js @@ -1,5 +1,4 @@ const SandboxedModule = require('sandboxed-module') -require('chai').should() const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -9,19 +8,12 @@ const modulePath = require('path').join( describe('ReferalAllocator', function() { beforeEach(function() { this.ReferalAllocator = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/User': { User: (this.User = {}) }, '../Subscription/FeaturesUpdater': (this.FeaturesUpdater = {}), - 'settings-sharelatex': (this.Settings = {}), - 'logger-sharelatex': { - log() {}, - err() {} - } + 'settings-sharelatex': (this.Settings = {}) } }) this.callback = sinon.stub() diff --git a/services/web/test/unit/src/Referal/ReferalConnectTests.js b/services/web/test/unit/src/Referal/ReferalConnectTests.js index c18eaf0bca..394534aeab 100644 --- a/services/web/test/unit/src/Referal/ReferalConnectTests.js +++ b/services/web/test/unit/src/Referal/ReferalConnectTests.js @@ -1,5 +1,4 @@ const SandboxedModule = require('sandboxed-module') -require('chai').should() const modulePath = require('path').join( __dirname, '../../../../app/src/Features/Referal/ReferalConnect.js' @@ -7,17 +6,7 @@ const modulePath = require('path').join( describe('Referal connect middle wear', function() { beforeEach(function() { - this.connect = SandboxedModule.require(modulePath, { - globals: { - console: console - }, - requires: { - 'logger-sharelatex': { - log() {}, - err() {} - } - } - }) + this.connect = SandboxedModule.require(modulePath, {}) }) it('should take a referal query string and put it on the session if it exists', function(done) { diff --git a/services/web/test/unit/src/Referal/ReferalControllerTests.js b/services/web/test/unit/src/Referal/ReferalControllerTests.js index a9082542e2..d11c0e757a 100644 --- a/services/web/test/unit/src/Referal/ReferalControllerTests.js +++ b/services/web/test/unit/src/Referal/ReferalControllerTests.js @@ -1,5 +1,4 @@ const SandboxedModule = require('sandboxed-module') -require('chai').should() const modulePath = require('path').join( __dirname, '../../../../app/src/Features/Referal/ReferalController.js' @@ -7,16 +6,6 @@ const modulePath = require('path').join( describe('Referal controller', function() { beforeEach(function() { - this.controller = SandboxedModule.require(modulePath, { - globals: { - console: console - }, - requires: { - 'logger-sharelatex': { - log() {}, - err() {} - } - } - }) + this.controller = SandboxedModule.require(modulePath, {}) }) }) diff --git a/services/web/test/unit/src/Referal/ReferalFeaturesTests.js b/services/web/test/unit/src/Referal/ReferalFeaturesTests.js index 8f438d4ce5..7797730ddc 100644 --- a/services/web/test/unit/src/Referal/ReferalFeaturesTests.js +++ b/services/web/test/unit/src/Referal/ReferalFeaturesTests.js @@ -1,5 +1,4 @@ const SandboxedModule = require('sandboxed-module') -require('chai').should() const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -9,18 +8,11 @@ const modulePath = require('path').join( describe('ReferalFeatures', function() { beforeEach(function() { this.ReferalFeatures = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/User': { User: (this.User = {}) }, - 'settings-sharelatex': (this.Settings = {}), - 'logger-sharelatex': { - log() {}, - err() {} - } + 'settings-sharelatex': (this.Settings = {}) } }) this.callback = sinon.stub() diff --git a/services/web/test/unit/src/Referal/ReferalHandlerTests.js b/services/web/test/unit/src/Referal/ReferalHandlerTests.js index 019b532da2..1caa616ae6 100644 --- a/services/web/test/unit/src/Referal/ReferalHandlerTests.js +++ b/services/web/test/unit/src/Referal/ReferalHandlerTests.js @@ -1,5 +1,5 @@ const SandboxedModule = require('sandboxed-module') -const should = require('chai').should() +const { expect } = require('chai') const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -10,14 +10,7 @@ describe('Referal handler', function() { beforeEach(function() { this.User = { findById: sinon.stub() } this.handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': { - log() {}, - err() {} - }, '../../models/User': { User: this.User } @@ -37,7 +30,7 @@ describe('Referal handler', function() { this.handler.getReferedUsers( this.user_id, (err, passedReferedUserIds, passedReferedUserCount) => { - should.not.exist(err) + expect(err).not.to.exist passedReferedUserIds.should.deep.equal(user.refered_users) passedReferedUserCount.should.equal(3) done() @@ -52,7 +45,7 @@ describe('Referal handler', function() { this.handler.getReferedUsers( this.user_id, (err, passedReferedUserIds, passedReferedUserCount) => { - should.not.exist(err) + expect(err).not.to.exist passedReferedUserIds.length.should.equal(0) done() } @@ -66,7 +59,7 @@ describe('Referal handler', function() { this.handler.getReferedUsers( this.user_id, (err, passedReferedUserIds, passedReferedUserCount) => { - should.not.exist(err) + expect(err).not.to.exist passedReferedUserCount.should.equal(0) done() } @@ -80,7 +73,7 @@ describe('Referal handler', function() { this.handler.getReferedUsers( this.user_id, (err, passedReferedUserIds, passedReferedUserCount) => { - should.not.exist(err) + expect(err).not.to.exist passedReferedUserCount.should.equal(3) done() } diff --git a/services/web/test/unit/src/References/ReferencesControllerTests.js b/services/web/test/unit/src/References/ReferencesControllerTests.js index ab525ca000..1ba6a730eb 100644 --- a/services/web/test/unit/src/References/ReferencesControllerTests.js +++ b/services/web/test/unit/src/References/ReferencesControllerTests.js @@ -11,7 +11,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const SandboxedModule = require('sandboxed-module') -const should = require('chai').should() const sinon = require('sinon') const { assert } = require('chai') const modulePath = @@ -23,14 +22,7 @@ describe('ReferencesController', function() { beforeEach(function() { this.projectId = '2222' this.controller = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': { - log() {}, - err() {} - }, 'settings-sharelatex': (this.settings = { apis: { web: { url: 'http://some.url' } } }), diff --git a/services/web/test/unit/src/References/ReferencesHandlerTests.js b/services/web/test/unit/src/References/ReferencesHandlerTests.js index e7f99c1e52..6a03977ca7 100644 --- a/services/web/test/unit/src/References/ReferencesHandlerTests.js +++ b/services/web/test/unit/src/References/ReferencesHandlerTests.js @@ -13,10 +13,8 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const SandboxedModule = require('sandboxed-module') -const should = require('chai').should() -const { expect } = require('chai') +const { assert, expect } = require('chai') const sinon = require('sinon') -const { assert } = require('chai') const modulePath = '../../../../app/src/Features/References/ReferencesHandler' describe('ReferencesHandler', function() { @@ -48,15 +46,7 @@ describe('ReferencesHandler', function() { } this.docIds = ['aaa', 'ccc'] this.handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': { - log() {}, - warn() {}, - err() {} - }, 'settings-sharelatex': (this.settings = { apis: { references: { url: 'http://some.url/references' }, diff --git a/services/web/test/unit/src/SamlLog/SamlLogHandlerTests.js b/services/web/test/unit/src/SamlLog/SamlLogHandlerTests.js index f89b3cf42b..9e881a8389 100644 --- a/services/web/test/unit/src/SamlLog/SamlLogHandlerTests.js +++ b/services/web/test/unit/src/SamlLog/SamlLogHandlerTests.js @@ -1,23 +1,16 @@ const APP_ROOT = '../../../../app/src' const SandboxedModule = require('sandboxed-module') -const chai = require('chai') const sinon = require('sinon') -const sinonChai = require('sinon-chai') - -chai.use(sinonChai) -const { expect } = chai +const { expect } = require('chai') const modulePath = `${APP_ROOT}/Features/SamlLog/SamlLogHandler` describe('SamlLogHandler', function() { - let LoggerSharelatex, SamlLog, SamlLogHandler, SamlLogModel + let SamlLog, SamlLogHandler, SamlLogModel let data, providerId, samlLog, sessionId beforeEach(function() { - LoggerSharelatex = { - error: sinon.stub() - } samlLog = { save: sinon.stub() } @@ -26,10 +19,8 @@ describe('SamlLogHandler', function() { } SamlLogModel = { SamlLog } SamlLogHandler = SandboxedModule.require(modulePath, { - globals: { console }, requires: { - '../../models/SamlLog': SamlLogModel, - 'logger-sharelatex': LoggerSharelatex + '../../models/SamlLog': SamlLogModel } }) @@ -66,7 +57,7 @@ describe('SamlLogHandler', function() { expect(samlLog.data).to.be.undefined expect(samlLog.jsonData).to.be.undefined samlLog.save.should.have.been.calledOnce - LoggerSharelatex.error.should.have.been.calledOnce.and.calledWithMatch( + this.logger.error.should.have.been.calledOnce.and.calledWithMatch( { providerId, sessionId: sessionId.substr(0, 8) }, 'SamlLog JSON.stringify Error' ) @@ -81,7 +72,7 @@ describe('SamlLogHandler', function() { }) it('should log error', function() { - LoggerSharelatex.error.should.have.been.calledOnce.and.calledWithMatch( + this.logger.error.should.have.been.calledOnce.and.calledWithMatch( { err: 'error', providerId, sessionId: sessionId.substr(0, 8) }, 'SamlLog Error' ) diff --git a/services/web/test/unit/src/Security/LoginRateLimiterTests.js b/services/web/test/unit/src/Security/LoginRateLimiterTests.js index 10837c453a..b3580601d2 100644 --- a/services/web/test/unit/src/Security/LoginRateLimiterTests.js +++ b/services/web/test/unit/src/Security/LoginRateLimiterTests.js @@ -12,7 +12,6 @@ */ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -require('chai').should() const { expect } = require('chai') const modulePath = require('path').join( __dirname, @@ -28,9 +27,6 @@ describe('LoginRateLimiter', function() { } return (this.LoginRateLimiter = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../infrastructure/RateLimiter': this.RateLimiter } diff --git a/services/web/test/unit/src/Security/OneTimeTokenHandlerTests.js b/services/web/test/unit/src/Security/OneTimeTokenHandlerTests.js index 41f0ed4bd3..a055d2f370 100644 --- a/services/web/test/unit/src/Security/OneTimeTokenHandlerTests.js +++ b/services/web/test/unit/src/Security/OneTimeTokenHandlerTests.js @@ -10,7 +10,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -29,14 +28,8 @@ describe('OneTimeTokenHandler', function() { this.stubbedToken = 'mock-token' this.callback = sinon.stub() return (this.OneTimeTokenHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log() {} - }, crypto: { randomBytes: () => this.stubbedToken }, diff --git a/services/web/test/unit/src/Security/RateLimiterMiddlewareTests.js b/services/web/test/unit/src/Security/RateLimiterMiddlewareTests.js index 81b76b50a7..08a071964d 100644 --- a/services/web/test/unit/src/Security/RateLimiterMiddlewareTests.js +++ b/services/web/test/unit/src/Security/RateLimiterMiddlewareTests.js @@ -13,7 +13,6 @@ */ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -require('chai').should() const modulePath = require('path').join( __dirname, '../../../../app/src/Features/Security/RateLimiterMiddleware' @@ -33,13 +32,9 @@ describe('RateLimiterMiddleware', function() { } } this.RateLimiterMiddleware = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': (this.settings = {}), '../../infrastructure/RateLimiter': (this.RateLimiter = {}), - 'logger-sharelatex': (this.logger = { warn: sinon.stub() }), './LoginRateLimiter': {}, '../Authentication/AuthenticationController': this .AuthenticationController diff --git a/services/web/test/unit/src/Security/SessionAutostartMiddlewareTests.js b/services/web/test/unit/src/Security/SessionAutostartMiddlewareTests.js index d929a2b377..b48fd4d8f5 100644 --- a/services/web/test/unit/src/Security/SessionAutostartMiddlewareTests.js +++ b/services/web/test/unit/src/Security/SessionAutostartMiddlewareTests.js @@ -1,6 +1,5 @@ const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/infrastructure/SessionAutostartMiddleware.js' const SandboxedModule = require('sandboxed-module') @@ -18,9 +17,6 @@ describe('SessionAutostartMiddleware', function() { } SessionAutostartMiddleware = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': Settings } diff --git a/services/web/test/unit/src/Security/SessionStoreManagerTests.js b/services/web/test/unit/src/Security/SessionStoreManagerTests.js index bfb9d31ed8..d739a7eb66 100644 --- a/services/web/test/unit/src/Security/SessionStoreManagerTests.js +++ b/services/web/test/unit/src/Security/SessionStoreManagerTests.js @@ -1,23 +1,13 @@ const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/infrastructure/SessionStoreManager.js' const SandboxedModule = require('sandboxed-module') describe('SessionStoreManager', function() { beforeEach(function() { this.SessionStoreManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - warn: sinon.stub(), - error: sinon.stub(), - err: sinon.stub() - }) + '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }) } }) this.sessionStore = { diff --git a/services/web/test/unit/src/Spelling/SpellingControllerTests.js b/services/web/test/unit/src/Spelling/SpellingControllerTests.js index 7c1d0ba219..2aab39be41 100644 --- a/services/web/test/unit/src/Spelling/SpellingControllerTests.js +++ b/services/web/test/unit/src/Spelling/SpellingControllerTests.js @@ -1,5 +1,4 @@ const SandboxedModule = require('sandboxed-module') -require('chai').should() const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -29,11 +28,6 @@ describe('SpellingController', function() { this.controller = SandboxedModule.require(modulePath, { requires: { request: this.request, - 'logger-sharelatex': { - warn() {}, - error() {}, - info() {} - }, 'settings-sharelatex': { languages: [ { name: 'English', code: 'en' }, diff --git a/services/web/test/unit/src/Spelling/SpellingHandlerTests.js b/services/web/test/unit/src/Spelling/SpellingHandlerTests.js index 96d448e0f3..89391b9dca 100644 --- a/services/web/test/unit/src/Spelling/SpellingHandlerTests.js +++ b/services/web/test/unit/src/Spelling/SpellingHandlerTests.js @@ -30,11 +30,6 @@ describe('SpellingHandler', function() { SpellingHandler = SandboxedModule.require(modulePath, { requires: { request: request, - 'logger-sharelatex': { - warn() {}, - error() {}, - info() {} - }, 'settings-sharelatex': { apis: { spelling: { host: SPELLING_HOST, url: SPELLING_URL } } } diff --git a/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js b/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js index aa5ebae0e9..3737376603 100644 --- a/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js +++ b/services/web/test/unit/src/Subscription/FeaturesUpdaterTests.js @@ -9,17 +9,10 @@ describe('FeaturesUpdater', function() { this.user_id = ObjectId().toString() this.FeaturesUpdater = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './UserFeaturesUpdater': (this.UserFeaturesUpdater = {}), './SubscriptionLocator': (this.SubscriptionLocator = {}), './PlansLocator': (this.PlansLocator = {}), - 'logger-sharelatex': { - log() {}, - warn() {} - }, 'settings-sharelatex': (this.Settings = {}), '../Referal/ReferalFeatures': (this.ReferalFeatures = {}), './V1SubscriptionManager': (this.V1SubscriptionManager = {}), diff --git a/services/web/test/unit/src/Subscription/LimitationsManagerTests.js b/services/web/test/unit/src/Subscription/LimitationsManagerTests.js index 85748bba48..1e4e4f949c 100644 --- a/services/web/test/unit/src/Subscription/LimitationsManagerTests.js +++ b/services/web/test/unit/src/Subscription/LimitationsManagerTests.js @@ -14,7 +14,6 @@ */ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -require('chai').should() const modulePath = require('path').join( __dirname, '../../../../app/src/Features/Subscription/LimitationsManager' @@ -49,9 +48,6 @@ describe('LimitationsManager', function() { } return (this.LimitationsManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Project/ProjectGetter': this.ProjectGetter, '../User/UserGetter': this.UserGetter, @@ -59,10 +55,7 @@ describe('LimitationsManager', function() { 'settings-sharelatex': (this.Settings = {}), '../Collaborators/CollaboratorsGetter': (this.CollaboratorsGetter = {}), '../Collaborators/CollaboratorsInviteHandler': (this.CollaboratorsInviteHandler = {}), - './V1SubscriptionManager': (this.V1SubscriptionManager = {}), - 'logger-sharelatex': { - log() {} - } + './V1SubscriptionManager': (this.V1SubscriptionManager = {}) } })) }) diff --git a/services/web/test/unit/src/Subscription/RecurlyWrapperTests.js b/services/web/test/unit/src/Subscription/RecurlyWrapperTests.js index d41bc2dbf4..49e08006af 100644 --- a/services/web/test/unit/src/Subscription/RecurlyWrapperTests.js +++ b/services/web/test/unit/src/Subscription/RecurlyWrapperTests.js @@ -12,7 +12,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const { expect } = require('chai') const sinon = require('sinon') const crypto = require('crypto') @@ -145,17 +144,8 @@ describe('RecurlyWrapper', function() { return (this.RecurlyWrapper = RecurlyWrapper = SandboxedModule.require( modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - err: sinon.stub(), - error: sinon.stub(), - warn: sinon.stub(), - log: sinon.stub() - }, request: sinon.stub(), './Errors': SubscriptionErrors } @@ -292,7 +282,7 @@ describe('RecurlyWrapper', function() { }) it('should return the updated account', function() { - should.exist(this.recurlyAccount) + expect(this.recurlyAccount).to.exist this.recurlyAccount.account_code.should.equal('104') }) }) @@ -339,7 +329,7 @@ describe('RecurlyWrapper', function() { }) it('should return the updated subscription', function() { - should.exist(this.recurlySubscription) + expect(this.recurlySubscription).to.exist return this.recurlySubscription.plan.plan_code.should.equal('gold') }) }) diff --git a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js index bcf98f1a44..373c1146c5 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js @@ -13,7 +13,6 @@ */ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -const should = require('chai').should() const { expect } = require('chai') const MockRequest = require('../helpers/MockRequest') const MockResponse = require('../helpers/MockResponse') @@ -96,9 +95,6 @@ describe('SubscriptionController', function() { getUser: sinon.stub().callsArgWith(2, null, this.user) } this.SubscriptionController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Authentication/AuthenticationController': this .AuthenticationController, @@ -107,11 +103,6 @@ describe('SubscriptionController', function() { './SubscriptionViewModelBuilder': this.SubscriptionViewModelBuilder, './LimitationsManager': this.LimitationsManager, '../../infrastructure/GeoIpLookup': this.GeoIpLookup, - 'logger-sharelatex': { - log() {}, - warn() {}, - error() {} - }, 'settings-sharelatex': this.settings, '../User/UserGetter': this.UserGetter, './RecurlyWrapper': (this.RecurlyWrapper = { diff --git a/services/web/test/unit/src/Subscription/SubscriptionGroupControllerTests.js b/services/web/test/unit/src/Subscription/SubscriptionGroupControllerTests.js index 72284f023b..b871f67362 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionGroupControllerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionGroupControllerTests.js @@ -11,7 +11,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const SandboxedModule = require('sandboxed-module') -const should = require('chai').should() const sinon = require('sinon') const { assert } = require('chai') const modulePath = @@ -57,14 +56,8 @@ describe('SubscriptionGroupController', function() { } return (this.Controller = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './SubscriptionGroupHandler': this.GroupHandler, - 'logger-sharelatex': { - log() {} - }, './SubscriptionLocator': this.SubscriptionLocator, '../Authentication/AuthenticationController': this .AuthenticationController diff --git a/services/web/test/unit/src/Subscription/SubscriptionGroupHandlerTests.js b/services/web/test/unit/src/Subscription/SubscriptionGroupHandlerTests.js index e3e9b5aaf5..62f4937a30 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionGroupHandlerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionGroupHandlerTests.js @@ -13,9 +13,8 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const SandboxedModule = require('sandboxed-module') -const should = require('chai').should() const sinon = require('sinon') -const { assert } = require('chai') +const { assert, expect } = require('chai') const modulePath = '../../../../app/src/Features/Subscription/SubscriptionGroupHandler' @@ -87,13 +86,7 @@ describe('SubscriptionGroupHandler', function() { } return (this.Handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': { - log() {} - }, '../User/UserCreator': this.UserCreator, './SubscriptionUpdater': this.SubscriptionUpdater, './SubscriptionLocator': this.SubscriptionLocator, @@ -107,12 +100,7 @@ describe('SubscriptionGroupHandler', function() { 'settings-sharelatex': this.settings, '../Notifications/NotificationsBuilder': this.NotificationsBuilder, '../UserMembership/UserMembershipViewModel': this - .UserMembershipViewModel, - 'logger-sharelatex': { - err() {}, - log() {}, - warn() {} - } + .UserMembershipViewModel } })) }) @@ -242,7 +230,7 @@ describe('SubscriptionGroupHandler', function() { return this.Handler.getTotalConfirmedUsersInGroup( 'fake-id', (err, count) => { - should.not.exist(count) + expect(count).not.to.exist return done() } ) diff --git a/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js b/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js index d36dfcc27f..6f43f7a737 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js @@ -1,5 +1,4 @@ const SandboxedModule = require('sandboxed-module') -require('chai').should() const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Subscription/SubscriptionHandler' @@ -75,9 +74,6 @@ describe('SubscriptionHandler', function() { this.AnalyticsManager = { recordEvent: sinon.stub() } this.SubscriptionHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './RecurlyWrapper': this.RecurlyWrapper, 'settings-sharelatex': this.Settings, @@ -85,10 +81,8 @@ describe('SubscriptionHandler', function() { User: this.User }, './SubscriptionUpdater': this.SubscriptionUpdater, - 'logger-sharelatex': { log() {} }, './LimitationsManager': this.LimitationsManager, '../Email/EmailHandler': this.EmailHandler, - '../Dropbox/DropboxHandler': this.DropboxHandler, '../Analytics/AnalyticsManager': this.AnalyticsManager } }) diff --git a/services/web/test/unit/src/Subscription/SubscriptionLocatorTests.js b/services/web/test/unit/src/Subscription/SubscriptionLocatorTests.js index 506d93a148..d8da940b3a 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionLocatorTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionLocatorTests.js @@ -12,7 +12,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const SandboxedModule = require('sandboxed-module') -const should = require('chai').should() const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Subscription/SubscriptionLocator' @@ -31,9 +30,6 @@ describe('Subscription Locator Tests', function() { find: sinon.stub().yields() } return (this.SubscriptionLocator = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './GroupPlansData': {}, '../../models/Subscription': { @@ -41,9 +37,6 @@ describe('Subscription Locator Tests', function() { }, '../../models/DeletedSubscription': { DeletedSubscription: this.DeletedSubscription - }, - 'logger-sharelatex': { - log() {} } } })) diff --git a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js index 769601fe2b..cfef9f34f0 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js @@ -1,13 +1,10 @@ const SandboxedModule = require('sandboxed-module') -const chai = require('chai') const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Subscription/SubscriptionUpdater' const { assert, expect } = require('chai') const { ObjectId } = require('mongodb') -chai.should() - describe('SubscriptionUpdater', function() { beforeEach(function() { this.recurlySubscription = { @@ -90,9 +87,6 @@ describe('SubscriptionUpdater', function() { findOneAndUpdate: sinon.stub().yields() } this.SubscriptionUpdater = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, '../../models/Subscription': { @@ -102,10 +96,6 @@ describe('SubscriptionUpdater', function() { './SubscriptionLocator': this.SubscriptionLocator, '../User/UserGetter': this.UserGetter, './PlansLocator': this.PlansLocator, - 'logger-sharelatex': { - log() {}, - warn() {} - }, 'settings-sharelatex': this.Settings, '../../infrastructure/mongodb': { db: {}, ObjectId }, './FeaturesUpdater': this.FeaturesUpdater, diff --git a/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js b/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js index 90f47a3948..e147886868 100644 --- a/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js +++ b/services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js @@ -83,12 +83,8 @@ describe('TeamInvitesHandler', function() { this.Subscription.findOne.yields(null, this.subscription) this.TeamInvitesHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, - 'logger-sharelatex': { log() {} }, crypto: this.crypto, 'settings-sharelatex': { siteUrl: 'http://example.com' }, '../../models/TeamInvite': { TeamInvite: (this.TeamInvite = {}) }, diff --git a/services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js b/services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js index 8c72c61722..3df246571b 100644 --- a/services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js +++ b/services/web/test/unit/src/Subscription/UserFeaturesUpdaterTests.js @@ -13,7 +13,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const SandboxedModule = require('sandboxed-module') -const should = require('chai').should() const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Subscription/UserFeaturesUpdater' @@ -23,15 +22,9 @@ describe('UserFeaturesUpdater', function() { beforeEach(function() { this.User = { updateOne: sinon.stub().callsArgWith(2) } return (this.UserFeaturesUpdater = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/User': { User: this.User - }, - 'logger-sharelatex': { - log() {} } } })) diff --git a/services/web/test/unit/src/Subscription/V1SusbcriptionManagerTests.js b/services/web/test/unit/src/Subscription/V1SusbcriptionManagerTests.js index 439df8ffa8..74aaa2aeea 100644 --- a/services/web/test/unit/src/Subscription/V1SusbcriptionManagerTests.js +++ b/services/web/test/unit/src/Subscription/V1SusbcriptionManagerTests.js @@ -12,7 +12,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -26,16 +25,8 @@ const { expect } = require('chai') describe('V1SubscriptionManager', function() { beforeEach(function() { this.V1SubscriptionManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../User/UserGetter': (this.UserGetter = {}), - 'logger-sharelatex': { - log: sinon.stub(), - err: sinon.stub(), - warn: sinon.stub() - }, 'settings-sharelatex': (this.Settings = { apis: { v1: { diff --git a/services/web/test/unit/src/SystemMessages/SystemMessageManagerTests.js b/services/web/test/unit/src/SystemMessages/SystemMessageManagerTests.js index e06edc2c87..13ef25618d 100644 --- a/services/web/test/unit/src/SystemMessages/SystemMessageManagerTests.js +++ b/services/web/test/unit/src/SystemMessages/SystemMessageManagerTests.js @@ -12,7 +12,6 @@ */ const SandboxedModule = require('sandboxed-module') const assert = require('assert') -require('chai').should() const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -26,9 +25,6 @@ describe('SystemMessageManager', function() { find: sinon.stub().yields(null, this.messages) } this.SystemMessageManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/SystemMessage': { SystemMessage: this.SystemMessage } } diff --git a/services/web/test/unit/src/Tags/TagsControllerTests.js b/services/web/test/unit/src/Tags/TagsControllerTests.js index 08f37693e1..1831f13b20 100644 --- a/services/web/test/unit/src/Tags/TagsControllerTests.js +++ b/services/web/test/unit/src/Tags/TagsControllerTests.js @@ -13,7 +13,6 @@ */ const SandboxedModule = require('sandboxed-module') const assert = require('assert') -require('chai').should() const sinon = require('sinon') const modulePath = require('path').join( __dirname, @@ -39,15 +38,8 @@ describe('TagsController', function() { } } this.controller = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './TagsHandler': this.handler, - 'logger-sharelatex': { - log() {}, - err() {} - }, '../Authentication/AuthenticationController': this .AuthenticationController } diff --git a/services/web/test/unit/src/Tags/TagsHandlerTests.js b/services/web/test/unit/src/Tags/TagsHandlerTests.js index 2584c8c6b1..d88c7d1d0b 100644 --- a/services/web/test/unit/src/Tags/TagsHandlerTests.js +++ b/services/web/test/unit/src/Tags/TagsHandlerTests.js @@ -1,6 +1,5 @@ const SandboxedModule = require('sandboxed-module') const { expect } = require('chai') -require('chai').should() const sinon = require('sinon') const { Tag } = require('../helpers/models/Tag') const { ObjectId } = require('mongodb') diff --git a/services/web/test/unit/src/Templates/TemplatesControllerTests.js b/services/web/test/unit/src/Templates/TemplatesControllerTests.js index cc4d960f5d..037915d60a 100644 --- a/services/web/test/unit/src/Templates/TemplatesControllerTests.js +++ b/services/web/test/unit/src/Templates/TemplatesControllerTests.js @@ -12,22 +12,16 @@ */ const SandboxedModule = require('sandboxed-module') const assert = require('assert') -const chai = require('chai') +const { expect } = require('chai') const sinon = require('sinon') const ProjectHelper = require('../../../../app/src/Features/Project/ProjectHelper') -chai.should() -const { expect } = chai - const modulePath = '../../../../app/src/Features/Templates/TemplatesController' describe('TemplatesController', function() { beforeEach(function() { this.user_id = 'user-id' this.TemplatesController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Project/ProjectHelper': ProjectHelper, '../Authentication/AuthenticationController': (this.AuthenticationController = { @@ -35,11 +29,7 @@ describe('TemplatesController', function() { }), './TemplatesManager': (this.TemplatesManager = { createProjectFromV1Template: sinon.stub() - }), - 'logger-sharelatex': { - log() {}, - err() {} - } + }) } }) this.next = sinon.stub() diff --git a/services/web/test/unit/src/Templates/TemplatesManagerTests.js b/services/web/test/unit/src/Templates/TemplatesManagerTests.js index 0ef856cb34..6d10fb94bf 100644 --- a/services/web/test/unit/src/Templates/TemplatesManagerTests.js +++ b/services/web/test/unit/src/Templates/TemplatesManagerTests.js @@ -12,11 +12,8 @@ */ const SandboxedModule = require('sandboxed-module') const assert = require('assert') -const chai = require('chai') const sinon = require('sinon') -const should = require('chai').should() - const modulePath = '../../../../app/src/Features/Templates/TemplatesManager' describe('TemplatesManager', function() { @@ -65,9 +62,6 @@ describe('TemplatesManager', function() { this.Project = { updateOne: sinon.stub().callsArgWith(3, null) } this.FileWriter = { ensureDumpFolderExists: sinon.stub().callsArg(0) } this.TemplatesManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'request-promise-native': sinon.stub(), '../Uploads/ProjectUploadManager': this.ProjectUploadManager, @@ -78,10 +72,6 @@ describe('TemplatesManager', function() { getLoggedInUserId: sinon.stub() }), '../../infrastructure/FileWriter': this.FileWriter, - 'logger-sharelatex': { - log() {}, - err() {} - }, 'settings-sharelatex': { path: { dumpFolder: this.dumpFolder diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js index 3597cc4424..0762e5d8bf 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsControllerTests.js @@ -1,6 +1,5 @@ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') -require('chai').should() const Errors = require('../../../../app/src/Features/Errors/Errors') const modulePath = require('path').join( __dirname, @@ -19,9 +18,6 @@ describe('TpdsController', function() { } } this.TpdsController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { './TpdsUpdateHandler': this.TpdsUpdateHandler, './UpdateMerger': (this.UpdateMerger = {}), @@ -31,12 +27,6 @@ describe('TpdsController', function() { '../Authentication/AuthenticationController': this .AuthenticationController, './TpdsQueueManager': this.TpdsQueueManager, - 'logger-sharelatex': { - log() {}, - warn() {}, - info() {}, - err() {} - }, '@overleaf/metrics': { inc() {} } diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js index 8114797b75..c5218574f9 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsProjectFlusherTests.js @@ -50,7 +50,6 @@ describe('TpdsProjectFlusher', function() { this.TpdsProjectFlusher = SandboxedModule.require(MODULE_PATH, { requires: { - 'logger-sharelatex': { debug() {} }, '../DocumentUpdater/DocumentUpdaterHandler': this .DocumentUpdaterHandler, '../Project/ProjectGetter': this.ProjectGetter, diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js index 2e842fab9a..a14d41dae8 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateHandlerTests.js @@ -77,7 +77,6 @@ describe('TpdsUpdateHandler', function() { } this.TpdsUpdateHandler = SandboxedModule.require(MODULE_PATH, { - globals: { console }, requires: { '../Cooldown/CooldownManager': this.CooldownManager, '../Uploads/FileTypeManager': this.FileTypeManager, @@ -88,10 +87,7 @@ describe('TpdsUpdateHandler', function() { '../Project/ProjectGetter': this.ProjectGetter, '../Project/ProjectHelper': this.ProjectHelper, '../Project/ProjectRootDocManager': this.RootDocManager, - './UpdateMerger': this.UpdateMerger, - 'logger-sharelatex': { - debug() {} - } + './UpdateMerger': this.UpdateMerger } }) }) diff --git a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js index 77d5a80356..7e483ed789 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/TpdsUpdateSenderTests.js @@ -1,11 +1,8 @@ const { ObjectId } = require('mongodb') const SandboxedModule = require('sandboxed-module') -const chai = require('chai') const path = require('path') const sinon = require('sinon') -chai.should() - const modulePath = path.join( __dirname, '../../../../app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js' @@ -60,13 +57,9 @@ describe('TpdsUpdateSender', function() { promises: { getUsers } } this.updateSender = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, 'settings-sharelatex': this.settings, - 'logger-sharelatex': { log() {} }, 'request-promise-native': this.request, '../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter, '../User/UserGetter.js': this.UserGetter, diff --git a/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js b/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js index cb1f1a9837..97ba619d7a 100644 --- a/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js +++ b/services/web/test/unit/src/ThirdPartyDataStore/UpdateMergerTests.js @@ -9,15 +9,8 @@ const BufferedStream = require('bufferedstream') describe('UpdateMerger :', function() { beforeEach(function() { this.updateMerger = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { fs: (this.fs = { unlink: sinon.stub().callsArgWith(1) }), - 'logger-sharelatex': { - log() {}, - err() {} - }, '../Editor/EditorController': (this.EditorController = {}), '../Uploads/FileTypeManager': (this.FileTypeManager = {}), '../../infrastructure/FileWriter': (this.FileWriter = {}), diff --git a/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js b/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js index 4153c2e36c..8717bd8a70 100644 --- a/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js +++ b/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js @@ -11,7 +11,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -35,13 +34,9 @@ describe('TokenAccessHandler', function() { this.userId = ObjectId() this.req = {} return (this.TokenAccessHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, '../../models/Project': { Project: (this.Project = {}) }, - 'logger-sharelatex': { err: sinon.stub() }, 'settings-sharelatex': (this.settings = {}), '../User/UserGetter': (this.UserGetter = {}), '../V1/V1Api': (this.V1Api = { diff --git a/services/web/test/unit/src/Uploads/ArchiveManagerTests.js b/services/web/test/unit/src/Uploads/ArchiveManagerTests.js index 3bf268a6ff..2722226861 100644 --- a/services/web/test/unit/src/Uploads/ArchiveManagerTests.js +++ b/services/web/test/unit/src/Uploads/ArchiveManagerTests.js @@ -14,8 +14,6 @@ */ const sinon = require('sinon') const { expect } = require('chai') -const chai = require('chai') -const should = chai.should() const modulePath = '../../../../app/src/Features/Uploads/ArchiveManager.js' const ArchiveErrors = require('../../../../app/src/Features/Uploads/ArchiveErrors') const SandboxedModule = require('sandboxed-module') @@ -24,12 +22,6 @@ const events = require('events') describe('ArchiveManager', function() { beforeEach(function() { let Timer - this.logger = { - error: sinon.stub(), - warn: sinon.stub(), - err() {}, - log: sinon.stub() - } this.metrics = { Timer: (Timer = (function() { Timer = class Timer { @@ -46,15 +38,11 @@ describe('ArchiveManager', function() { this.zipfile.close = sinon.stub() this.ArchiveManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': {}, yauzl: (this.yauzl = { open: sinon.stub().callsArgWith(2, null, this.zipfile) }), - 'logger-sharelatex': this.logger, '@overleaf/metrics': this.metrics, fs: (this.fs = {}), 'fs-extra': (this.fse = {}), diff --git a/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js b/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js index 146e6fd36f..6a93da1dcd 100644 --- a/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js +++ b/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js @@ -23,17 +23,9 @@ describe('FileSystemImportManager', function() { addFolder: sinon.stub().resolves({ _id: this.newFolderId }) } } - this.logger = { - log() {}, - err() {} - } this.FileSystemImportManager = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { - '../Editor/EditorController': this.EditorController, - 'logger-sharelatex': this.logger + '../Editor/EditorController': this.EditorController } }) }) diff --git a/services/web/test/unit/src/Uploads/FileTypeManagerTests.js b/services/web/test/unit/src/Uploads/FileTypeManagerTests.js index 06222f623e..edcede8759 100644 --- a/services/web/test/unit/src/Uploads/FileTypeManagerTests.js +++ b/services/web/test/unit/src/Uploads/FileTypeManagerTests.js @@ -2,6 +2,7 @@ const sinon = require('sinon') const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const isUtf8 = require('utf-8-validate') +const Settings = require('settings-sharelatex') const modulePath = '../../../../app/src/Features/Uploads/FileTypeManager.js' describe('FileTypeManager', function() { @@ -40,12 +41,10 @@ describe('FileTypeManager', function() { this.callback = sinon.stub() this.DocumentHelper = { getEncodingFromTexContent: sinon.stub() } this.FileTypeManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { fs: this.fs, - 'utf-8-validate': this.isUtf8 + 'utf-8-validate': this.isUtf8, + 'settings-sharelatex': Settings } }) }) diff --git a/services/web/test/unit/src/Uploads/ProjectUploadControllerTests.js b/services/web/test/unit/src/Uploads/ProjectUploadControllerTests.js index b6aaf3f4c1..6fe9607ea6 100644 --- a/services/web/test/unit/src/Uploads/ProjectUploadControllerTests.js +++ b/services/web/test/unit/src/Uploads/ProjectUploadControllerTests.js @@ -12,9 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/Uploads/ProjectUploadController.js' const SandboxedModule = require('sandboxed-module') @@ -44,19 +42,11 @@ describe('ProjectUploadController', function() { } return (this.ProjectUploadController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { multer: sinon.stub(), 'settings-sharelatex': { path: {} }, './ProjectUploadManager': (this.ProjectUploadManager = {}), './FileSystemImportManager': (this.FileSystemImportManager = {}), - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - error: sinon.stub(), - err() {} - }), '@overleaf/metrics': this.metrics, '../Authentication/AuthenticationController': this .AuthenticationController, diff --git a/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js b/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js index c53cd32c5a..aa854c0d19 100644 --- a/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js +++ b/services/web/test/unit/src/Uploads/ProjectUploadManagerTests.js @@ -145,11 +145,7 @@ describe('ProjectUploadManager', function() { } this.ProjectUploadManager = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': {}, 'fs-extra': this.fs, './ArchiveManager': this.ArchiveManager, '../../models/Doc': { Doc: this.Doc }, diff --git a/services/web/test/unit/src/User/SAMLIdentityManagerTests.js b/services/web/test/unit/src/User/SAMLIdentityManagerTests.js index 39294b8578..2ba8c677b8 100644 --- a/services/web/test/unit/src/User/SAMLIdentityManagerTests.js +++ b/services/web/test/unit/src/User/SAMLIdentityManagerTests.js @@ -1,7 +1,6 @@ const { ObjectId } = require('mongodb') const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const Errors = require('../../../../app/src/Features/Errors/Errors') const modulePath = '../../../../app/src/Features/User/SAMLIdentityManager.js' @@ -42,19 +41,11 @@ describe('SAMLIdentityManager', function() { removeEntitlement: sinon.stub().resolves() } } - this.logger = { - error: sinon.stub(), - warn: sinon.stub() - } this.SAMLIdentityManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Email/EmailHandler': (this.EmailHandler = { sendEmail: sinon.stub().yields() }), - '../Errors/Errors': this.Errors, '../Notifications/NotificationsBuilder': (this.NotificationsBuilder = { promises: { redundantPersonalSubscription: sinon @@ -101,8 +92,7 @@ describe('SAMLIdentityManager', function() { updateUser: sinon.stub().resolves() } }), - '../Institutions/InstitutionsAPI': this.InstitutionsAPI, - 'logger-sharelatex': this.logger + '../Institutions/InstitutionsAPI': this.InstitutionsAPI } }) }) diff --git a/services/web/test/unit/src/User/ThirdPartyIdentityManagerTests.js b/services/web/test/unit/src/User/ThirdPartyIdentityManagerTests.js index 78053ac696..cdef2b2182 100644 --- a/services/web/test/unit/src/User/ThirdPartyIdentityManagerTests.js +++ b/services/web/test/unit/src/User/ThirdPartyIdentityManagerTests.js @@ -1,6 +1,5 @@ const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const modulePath = '../../../../app/src/Features/User/ThirdPartyIdentityManager.js' @@ -16,9 +15,6 @@ describe('ThirdPartyIdentityManager', function() { this.externalData = {} this.auditLog = { initiatorId: this.userId, ipAddress: '0:0:0:0' } this.ThirdPartyIdentityManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../../../app/src/Features/User/UserAuditLogHandler': (this.UserAuditLogHandler = { addEntry: sinon.stub().yields() @@ -26,9 +22,6 @@ describe('ThirdPartyIdentityManager', function() { '../../../../app/src/Features/Email/EmailHandler': (this.EmailHandler = { sendEmail: sinon.stub().yields() }), - 'logger-sharelatex': (this.logger = { - error: sinon.stub() - }), '../../../../app/src/models/User': { User: (this.User = { findOneAndUpdate: sinon.stub().yields(undefined, this.user), diff --git a/services/web/test/unit/src/User/UserAuditLogHandlerTests.js b/services/web/test/unit/src/User/UserAuditLogHandlerTests.js index 6bc3704e2c..0fb707d650 100644 --- a/services/web/test/unit/src/User/UserAuditLogHandlerTests.js +++ b/services/web/test/unit/src/User/UserAuditLogHandlerTests.js @@ -25,9 +25,6 @@ describe('UserAuditLogHandler', function() { } this.UserMock = sinon.mock(User) this.UserAuditLogHandler = SandboxedModule.require(MODULE_PATH, { - globals: { - console: console - }, requires: { '../../models/User': { User } } diff --git a/services/web/test/unit/src/User/UserControllerTests.js b/services/web/test/unit/src/User/UserControllerTests.js index 925cfd8e5d..9ef829f4db 100644 --- a/services/web/test/unit/src/User/UserControllerTests.js +++ b/services/web/test/unit/src/User/UserControllerTests.js @@ -1,6 +1,5 @@ const sinon = require('sinon') -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/User/UserController.js' const SandboxedModule = require('sandboxed-module') const OError = require('@overleaf/o-error') @@ -91,9 +90,6 @@ describe('UserController', function() { this.UrlHelper.getSafeRedirectPath.returnsArg(0) this.UserController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Helpers/UrlHelper': this.UrlHelper, './UserGetter': this.UserGetter, @@ -119,12 +115,6 @@ describe('UserController', function() { './UserSessionsManager': this.UserSessionsManager, '../Errors/HttpErrorHandler': this.HttpErrorHandler, 'settings-sharelatex': this.settings, - 'logger-sharelatex': (this.logger = { - log() {}, - warn() {}, - err() {}, - error: sinon.stub() - }), '@overleaf/metrics': { inc() {} }, diff --git a/services/web/test/unit/src/User/UserCreatorTests.js b/services/web/test/unit/src/User/UserCreatorTests.js index 9a4adc8254..55a8d6c2dc 100644 --- a/services/web/test/unit/src/User/UserCreatorTests.js +++ b/services/web/test/unit/src/User/UserCreatorTests.js @@ -1,8 +1,7 @@ const SandboxedModule = require('sandboxed-module') -const chai = require('chai') const sinon = require('sinon') +const { assert } = require('chai') -const { assert } = chai const modulePath = '../../../../app/src/Features/User/UserCreator.js' describe('UserCreator', function() { @@ -16,16 +15,10 @@ describe('UserCreator', function() { } } this.UserCreator = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/User': { User: this.UserModel }, - 'logger-sharelatex': (this.Logger = { - error: sinon.stub() - }), '@overleaf/metrics': { timeAsyncMethod() {} }, '../../infrastructure/Features': (this.Features = { hasFeature: sinon.stub().returns(false) @@ -177,7 +170,7 @@ describe('UserCreator', function() { }) it('should log error', function() { - sinon.assert.calledOnce(this.Logger.error) + sinon.assert.calledOnce(this.logger.error) }) }) @@ -207,7 +200,7 @@ describe('UserCreator', function() { }) it('should log error', function() { - sinon.assert.calledOnce(this.Logger.error) + sinon.assert.calledOnce(this.logger.error) }) }) }) diff --git a/services/web/test/unit/src/User/UserDeleterTests.js b/services/web/test/unit/src/User/UserDeleterTests.js index 0611ede2fa..3675faa3d5 100644 --- a/services/web/test/unit/src/User/UserDeleterTests.js +++ b/services/web/test/unit/src/User/UserDeleterTests.js @@ -1,4 +1,4 @@ -const chai = require('chai') +const { expect } = require('chai') const sinon = require('sinon') const tk = require('timekeeper') const moment = require('moment') @@ -8,8 +8,6 @@ const ObjectId = require('mongoose').Types.ObjectId const { User } = require('../helpers/models/User') const { DeletedUser } = require('../helpers/models/DeletedUser') -const expect = chai.expect - const modulePath = '../../../../app/src/Features/User/UserDeleter.js' describe('UserDeleter', function() { @@ -97,15 +95,7 @@ describe('UserDeleter', function() { '../Subscription/SubscriptionLocator': this.SubscriptionLocator, '../UserMembership/UserMembershipsHandler': this.UserMembershipsHandler, '../Project/ProjectDeleter': this.ProjectDeleter, - '../Institutions/InstitutionsAPI': this.InstitutionsApi, - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - warn: sinon.stub(), - err: sinon.stub() - }) - }, - globals: { - console: console + '../Institutions/InstitutionsAPI': this.InstitutionsApi } }) }) diff --git a/services/web/test/unit/src/User/UserEmailsConfirmationHandlerTests.js b/services/web/test/unit/src/User/UserEmailsConfirmationHandlerTests.js index 3daab130ad..597cac747f 100644 --- a/services/web/test/unit/src/User/UserEmailsConfirmationHandlerTests.js +++ b/services/web/test/unit/src/User/UserEmailsConfirmationHandlerTests.js @@ -10,7 +10,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -26,14 +25,10 @@ const EmailHelper = require('../../../../app/src/Features/Helpers/EmailHelper') describe('UserEmailsConfirmationHandler', function() { beforeEach(function() { this.UserEmailsConfirmationHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': (this.settings = { siteUrl: 'emails.example.com' }), - 'logger-sharelatex': (this.logger = { log: sinon.stub() }), '../Security/OneTimeTokenHandler': (this.OneTimeTokenHandler = {}), './UserUpdater': (this.UserUpdater = {}), './UserGetter': (this.UserGetter = { diff --git a/services/web/test/unit/src/User/UserEmailsControllerTests.js b/services/web/test/unit/src/User/UserEmailsControllerTests.js index da45a6cef7..44f68de6e5 100644 --- a/services/web/test/unit/src/User/UserEmailsControllerTests.js +++ b/services/web/test/unit/src/User/UserEmailsControllerTests.js @@ -1,8 +1,7 @@ const sinon = require('sinon') const assertCalledWith = sinon.assert.calledWith const assertNotCalled = sinon.assert.notCalled -const chai = require('chai') -const { assert, expect } = chai +const { assert, expect } = require('chai') const modulePath = '../../../../app/src/Features/User/UserEmailsController.js' const SandboxedModule = require('sandboxed-module') const MockRequest = require('../helpers/MockRequest') @@ -56,9 +55,6 @@ describe('UserEmailsController', function() { } this.HttpErrorHandler = { conflict: sinon.stub() } this.UserEmailsController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Authentication/AuthenticationController': this .AuthenticationController, @@ -78,12 +74,7 @@ describe('UserEmailsController', function() { } }), '../Institutions/InstitutionsAPI': this.InstitutionsAPI, - '../Errors/HttpErrorHandler': this.HttpErrorHandler, - 'logger-sharelatex': (this.logger = { - log() {}, - warn: sinon.stub(), - err() {} - }) + '../Errors/HttpErrorHandler': this.HttpErrorHandler } }) }) diff --git a/services/web/test/unit/src/User/UserGetterTests.js b/services/web/test/unit/src/User/UserGetterTests.js index fb57f22a94..73898d0263 100644 --- a/services/web/test/unit/src/User/UserGetterTests.js +++ b/services/web/test/unit/src/User/UserGetterTests.js @@ -1,5 +1,4 @@ const { ObjectId } = require('mongodb') -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const moment = require('moment') @@ -45,14 +44,8 @@ describe('UserGetter', function() { this.getUserAffiliations = sinon.stub().resolves([]) this.UserGetter = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Helpers/Mongo': { normalizeQuery, normalizeMultiQuery }, - 'logger-sharelatex': { - log() {} - }, '../../infrastructure/mongodb': this.Mongo, '@overleaf/metrics': { timeAsyncMethod: sinon.stub() @@ -950,7 +943,7 @@ describe('UserGetter', function() { it('should return error if existing user is found', function(done) { this.UserGetter.getUserByAnyEmail.callsArgWith(1, null, this.fakeUser) this.UserGetter.ensureUniqueEmailAddress(this.newEmail, err => { - should.exist(err) + expect(err).to.exist expect(err).to.be.an.instanceof(Errors.EmailExistsError) done() }) @@ -959,7 +952,7 @@ describe('UserGetter', function() { it('should return null if no user is found', function(done) { this.UserGetter.getUserByAnyEmail.callsArgWith(1) this.UserGetter.ensureUniqueEmailAddress(this.newEmail, err => { - should.not.exist(err) + expect(err).not.to.exist done() }) }) diff --git a/services/web/test/unit/src/User/UserHandlerTests.js b/services/web/test/unit/src/User/UserHandlerTests.js index fb35aa2fed..5dd4e90e8e 100644 --- a/services/web/test/unit/src/User/UserHandlerTests.js +++ b/services/web/test/unit/src/User/UserHandlerTests.js @@ -15,9 +15,6 @@ describe('UserHandler', function() { } this.UserHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Subscription/TeamInvitesHandler': this.TeamInvitesHandler } diff --git a/services/web/test/unit/src/User/UserInfoControllerTests.js b/services/web/test/unit/src/User/UserInfoControllerTests.js index 3ce3ae1441..a537a64021 100644 --- a/services/web/test/unit/src/User/UserInfoControllerTests.js +++ b/services/web/test/unit/src/User/UserInfoControllerTests.js @@ -11,10 +11,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const { assert } = require('chai') -const should = chai.should() -const { expect } = chai +const { assert, expect } = require('chai') const modulePath = '../../../../app/src/Features/User/UserInfoController.js' const SandboxedModule = require('sandboxed-module') const events = require('events') @@ -35,17 +32,11 @@ describe('UserInfoController', function() { this.UserGetter = {} this.UserInfoController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, './UserGetter': this.UserGetter, './UserUpdater': this.UserUpdater, './UserDeleter': this.UserDeleter, - 'logger-sharelatex': { - log() {} - }, sanitizer: this.sanitizer, '../Authentication/AuthenticationController': (this.AuthenticationController = { getLoggedInUserId: sinon.stub() diff --git a/services/web/test/unit/src/User/UserPagesControllerTests.js b/services/web/test/unit/src/User/UserPagesControllerTests.js index 94f6a0c638..5cbfd15c51 100644 --- a/services/web/test/unit/src/User/UserPagesControllerTests.js +++ b/services/web/test/unit/src/User/UserPagesControllerTests.js @@ -10,7 +10,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -47,11 +46,6 @@ describe('UserPagesController', function() { this.UserGetter = { getUser: sinon.stub() } this.UserSessionsManager = { getAllUserSessions: sinon.stub() } this.dropboxStatus = {} - this.DropboxHandler = { - getUserRegistrationStatus: sinon - .stub() - .callsArgWith(1, null, this.dropboxStatus) - } this.ErrorController = { notFound: sinon.stub() } this.AuthenticationController = { getLoggedInUserId: sinon.stub().returns(this.user._id), @@ -60,20 +54,11 @@ describe('UserPagesController', function() { setRedirectInSession: sinon.stub() } this.UserPagesController = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log() {}, - warn() {}, - err() {} - }, './UserGetter': this.UserGetter, './UserSessionsManager': this.UserSessionsManager, '../Errors/ErrorController': this.ErrorController, - '../Dropbox/DropboxHandler': this.DropboxHandler, '../Authentication/AuthenticationController': this .AuthenticationController, request: (this.request = sinon.stub()) diff --git a/services/web/test/unit/src/User/UserRegistrationHandlerTests.js b/services/web/test/unit/src/User/UserRegistrationHandlerTests.js index 541fca5034..a1a8455589 100644 --- a/services/web/test/unit/src/User/UserRegistrationHandlerTests.js +++ b/services/web/test/unit/src/User/UserRegistrationHandlerTests.js @@ -11,7 +11,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -40,16 +39,12 @@ describe('UserRegistrationHandler', function() { this.EmailHandler = { sendEmail: sinon.stub().callsArgWith(2) } this.OneTimeTokenHandler = { getNewToken: sinon.stub() } this.handler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/User': { User: this.User }, './UserGetter': this.UserGetter, './UserCreator': this.UserCreator, '../Authentication/AuthenticationManager': this.AuthenticationManager, '../Newsletter/NewsletterManager': this.NewsLetterManager, - 'logger-sharelatex': (this.logger = { log: sinon.stub() }), crypto: (this.crypto = {}), '../Email/EmailHandler': this.EmailHandler, '../Security/OneTimeTokenHandler': this.OneTimeTokenHandler, diff --git a/services/web/test/unit/src/User/UserSessionsManagerTests.js b/services/web/test/unit/src/User/UserSessionsManagerTests.js index 9d2e3947e2..0721e02b33 100644 --- a/services/web/test/unit/src/User/UserSessionsManagerTests.js +++ b/services/web/test/unit/src/User/UserSessionsManagerTests.js @@ -12,9 +12,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/Features/User/UserSessionsManager.js' const SandboxedModule = require('sandboxed-module') @@ -50,23 +48,13 @@ describe('UserSessionsManager', function() { client: () => this.rclient, sessionSetKey: user => `UserSessions:{${user._id}}` } - this.logger = { - err: sinon.stub(), - error: sinon.stub(), - warn: sinon.stub(), - log: sinon.stub() - } this.settings = { redis: { web: {} } } return (this.UserSessionsManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': this.logger, 'settings-sharelatex': this.settings, './UserSessionsRedis': this.UserSessionsRedis } diff --git a/services/web/test/unit/src/User/UserUpdaterTests.js b/services/web/test/unit/src/User/UserUpdaterTests.js index 38b85a14cd..1dee14fefe 100644 --- a/services/web/test/unit/src/User/UserUpdaterTests.js +++ b/services/web/test/unit/src/User/UserUpdaterTests.js @@ -1,4 +1,3 @@ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const path = require('path') const sinon = require('sinon') @@ -27,11 +26,6 @@ describe('UserUpdater', function() { getUser: sinon.stub() } } - this.logger = { - error: sinon.stub(), - log() {}, - warn: sinon.stub() - } this.addAffiliation = sinon.stub().yields() this.removeAffiliation = sinon.stub().callsArgWith(2, null) this.refreshFeatures = sinon.stub().yields() @@ -46,12 +40,8 @@ describe('UserUpdater', function() { } } this.UserUpdater = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../Helpers/Mongo': { normalizeQuery }, - 'logger-sharelatex': this.logger, '../../infrastructure/mongodb': this.mongodb, '@overleaf/metrics': { timeAsyncMethod: sinon.stub() @@ -134,7 +124,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, error => { - should.not.exist(error) + expect(error).not.to.exist sinon.assert.calledOnce(this.UserUpdater.updateUser) sinon.assert.calledWithMatch( this.UserUpdater.updateUser, @@ -165,7 +155,7 @@ describe('UserUpdater', function() { this.newEmail, this.auditLog, err => { - should.not.exist(err) + expect(err).not.to.exist this.UserUpdater.addEmailAddress .calledWith(this.stubbedUser._id, this.newEmail, {}, this.auditLog) .should.equal(true) @@ -192,7 +182,7 @@ describe('UserUpdater', function() { 'foo', this.auditLog, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -205,7 +195,7 @@ describe('UserUpdater', function() { this.newEmail, this.auditLog, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -264,7 +254,7 @@ describe('UserUpdater', function() { affiliationOptions, { initiatorId: this.stubbedUser._id, ipAddress: '127:0:0:0' }, err => { - should.not.exist(err) + expect(err).not.to.exist this.InstitutionsAPI.promises.addAffiliation.calledOnce.should.equal( true ) @@ -285,7 +275,7 @@ describe('UserUpdater', function() { {}, { initiatorId: this.stubbedUser._id, ipAddress: '127:0:0:0' }, err => { - should.exist(err) + expect(err).to.exist this.UserUpdater.promises.updateUser.called.should.equal(false) done() } @@ -299,7 +289,7 @@ describe('UserUpdater', function() { {}, { initiatorId: this.stubbedUser._id, ipAddress: '127:0:0:0' }, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -367,7 +357,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.not.exist(err) + expect(err).not.to.exist this.UserUpdater.updateUser .calledWith( { _id: this.stubbedUser._id, email: { $ne: this.newEmail } }, @@ -384,7 +374,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.not.exist(err) + expect(err).not.to.exist this.removeAffiliation.calledOnce.should.equal(true) const { args } = this.removeAffiliation.lastCall args[0].should.equal(this.stubbedUser._id) @@ -399,7 +389,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.not.exist(err) + expect(err).not.to.exist sinon.assert.calledWith(this.refreshFeatures, this.stubbedUser._id) done() } @@ -415,7 +405,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -428,7 +418,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -440,7 +430,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.exist(err) + expect(err).to.exist this.UserUpdater.updateUser.called.should.equal(false) done() } @@ -449,7 +439,7 @@ describe('UserUpdater', function() { it('validates email', function(done) { this.UserUpdater.removeEmailAddress(this.stubbedUser._id, 'baz', err => { - should.exist(err) + expect(err).to.exist done() }) }) @@ -481,7 +471,7 @@ describe('UserUpdater', function() { false, this.auditLog, err => { - should.not.exist(err) + expect(err).not.to.exist this.UserUpdater.promises.updateUser .calledWith( { _id: this.stubbedUser._id, 'emails.email': this.newEmail }, @@ -502,7 +492,7 @@ describe('UserUpdater', function() { false, this.auditLog, err => { - should.not.exist(err) + expect(err).not.to.exist this.NewsletterManager.promises.changeEmail .calledWith(this.stubbedUser, this.newEmail) .should.equal(true) @@ -523,7 +513,7 @@ describe('UserUpdater', function() { false, this.auditLog, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -538,7 +528,7 @@ describe('UserUpdater', function() { false, this.auditLog, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -551,7 +541,7 @@ describe('UserUpdater', function() { false, this.auditLog, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -725,7 +715,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.stubbedUserEmail, err => { - should.not.exist(err) + expect(err).not.to.exist this.UserUpdater.promises.updateUser .calledWith( { @@ -752,7 +742,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.not.exist(err) + expect(err).not.to.exist this.InstitutionsAPI.promises.addAffiliation.calledOnce.should.equal( true ) @@ -776,7 +766,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -789,7 +779,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.exist(err) + expect(err).to.exist done() } ) @@ -797,7 +787,7 @@ describe('UserUpdater', function() { it('validates email', function(done) { this.UserUpdater.confirmEmail(this.stubbedUser._id, '@', err => { - should.exist(err) + expect(err).to.exist done() }) }) @@ -808,7 +798,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.exist(err) + expect(err).to.exist this.UserUpdater.promises.updateUser.called.should.equal(false) done() } @@ -820,7 +810,7 @@ describe('UserUpdater', function() { this.stubbedUser._id, this.newEmail, err => { - should.not.exist(err) + expect(err).not.to.exist sinon.assert.calledWith( this.FeaturesUpdater.promises.refreshFeatures, this.stubbedUser._id diff --git a/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js b/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js index 6bda8eea37..427628204a 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js +++ b/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js @@ -13,10 +13,7 @@ const sinon = require('sinon') const assertCalledWith = sinon.assert.calledWith const assertNotCalled = sinon.assert.notCalled -const chai = require('chai') -const should = chai.should() -const { assert } = chai -const { expect } = require('chai') +const { assert, expect } = require('chai') const modulePath = '../../../../app/src/Features/UserMembership/UserMembershipController.js' const SandboxedModule = require('sandboxed-module') @@ -71,17 +68,10 @@ describe('UserMembershipController', function() { return (this.UserMembershipController = SandboxedModule.require( modulePath, { - globals: { - console: console - }, requires: { '../Authentication/AuthenticationController': this .AuthenticationController, - './UserMembershipHandler': this.UserMembershipHandler, - 'logger-sharelatex': { - log() {}, - err() {} - } + './UserMembershipHandler': this.UserMembershipHandler } } )) diff --git a/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js b/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js index a3baaf5a67..ddca4fd3d4 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js +++ b/services/web/test/unit/src/UserMembership/UserMembershipHandlerTests.js @@ -11,8 +11,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -const should = chai.should() const { expect } = require('chai') const sinon = require('sinon') const assertCalledWith = sinon.assert.calledWith @@ -68,9 +66,6 @@ describe('UserMembershipHandler', function() { create: sinon.stub().yields(null, this.publisher) } return (this.UserMembershipHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, './UserMembershipViewModel': this.UserMembershipViewModel, @@ -83,10 +78,6 @@ describe('UserMembershipHandler', function() { }, '../../models/Publisher': { Publisher: this.Publisher - }, - 'logger-sharelatex': { - log() {}, - err() {} } } })) @@ -98,7 +89,7 @@ describe('UserMembershipHandler', function() { this.fakeEntityId, EntityConfigs.publisher, (error, subscription) => { - should.not.exist(error) + expect(error).not.to.exist const expectedQuery = { slug: this.fakeEntityId } assertCalledWith(this.Publisher.findOne, expectedQuery) expect(subscription).to.equal(this.publisher) @@ -167,7 +158,7 @@ describe('UserMembershipHandler', function() { this.fakeEntityId, EntityConfigs.publisher, (error, publisher) => { - should.not.exist(error) + expect(error).not.to.exist assertCalledWith(this.Publisher.create, { slug: this.fakeEntityId }) return done() } diff --git a/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js b/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js index 9a154384f7..f1a6000be6 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js +++ b/services/web/test/unit/src/UserMembership/UserMembershipViewModelTests.js @@ -10,8 +10,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const chai = require('chai') -const should = chai.should() const { expect } = require('chai') const sinon = require('sinon') const assertCalledWith = sinon.assert.calledWith @@ -29,9 +27,6 @@ describe('UserMembershipViewModel', function() { beforeEach(function() { this.UserGetter = { getUser: sinon.stub() } this.UserMembershipViewModel = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { mongodb: { ObjectId }, '../Helpers/Mongo': { isObjectIdInstance, normalizeQuery }, @@ -99,13 +94,13 @@ describe('UserMembershipViewModel', function() { return this.UserMembershipViewModel.buildAsync( ObjectId(), (error, viewModel) => { - should.not.exist(error) + expect(error).not.to.exist assertNotCalled(this.UserMembershipViewModel.build) expect(viewModel._id).to.equal(this.user._id) expect(viewModel.email).to.equal(this.user.email) expect(viewModel.first_name).to.equal(this.user.first_name) expect(viewModel.invite).to.equal(false) - should.exist(viewModel.email) + expect(viewModel.email).to.exist return done() } ) @@ -117,10 +112,10 @@ describe('UserMembershipViewModel', function() { return this.UserMembershipViewModel.buildAsync( userId, (error, viewModel) => { - should.not.exist(error) + expect(error).not.to.exist assertNotCalled(this.UserMembershipViewModel.build) expect(viewModel._id).to.equal(userId.toString()) - should.not.exist(viewModel.email) + expect(viewModel.email).not.to.exist return done() } ) diff --git a/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js b/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js index d52fa0e2c2..6da00d79df 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js +++ b/services/web/test/unit/src/UserMembership/UserMembershipsHandlerTests.js @@ -25,9 +25,6 @@ describe('UserMembershipsHandler', function() { this.Subscription = { updateMany: sinon.stub().yields(null) } this.Publisher = { updateMany: sinon.stub().yields(null) } return (this.UserMembershipsHandler = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { '../../models/Institution': { Institution: this.Institution diff --git a/services/web/test/unit/src/infrastructure/CsrfTests.js b/services/web/test/unit/src/infrastructure/CsrfTests.js index d7a7db5cb4..a6aa2c0fc1 100644 --- a/services/web/test/unit/src/infrastructure/CsrfTests.js +++ b/services/web/test/unit/src/infrastructure/CsrfTests.js @@ -10,11 +10,8 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const { assert } = require('chai') +const { assert, expect } = require('chai') const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai const modulePath = '../../../../app/src/infrastructure/Csrf.js' const SandboxedModule = require('sandboxed-module') @@ -24,9 +21,6 @@ describe('Csrf', function() { .stub() .callsArgWith(2, (this.err = { code: 'EBADCSRFTOKEN' })) this.Csrf = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { csurf: sinon.stub().returns(this.csurf_csrf) } diff --git a/services/web/test/unit/src/infrastructure/FeaturesTests.js b/services/web/test/unit/src/infrastructure/FeaturesTests.js index d1a0c48213..3295d0ec7e 100644 --- a/services/web/test/unit/src/infrastructure/FeaturesTests.js +++ b/services/web/test/unit/src/infrastructure/FeaturesTests.js @@ -1,14 +1,10 @@ -const chai = require('chai') -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/infrastructure/Features.js' const SandboxedModule = require('sandboxed-module') describe('Features', function() { beforeEach(function() { this.Features = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': (this.settings = {}) } diff --git a/services/web/test/unit/src/infrastructure/GeoIpLookupTests.js b/services/web/test/unit/src/infrastructure/GeoIpLookupTests.js index 7e826ecdec..d89563f8b5 100644 --- a/services/web/test/unit/src/infrastructure/GeoIpLookupTests.js +++ b/services/web/test/unit/src/infrastructure/GeoIpLookupTests.js @@ -11,7 +11,6 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const should = require('chai').should() const SandboxedModule = require('sandboxed-module') const assert = require('assert') const path = require('path') @@ -33,16 +32,9 @@ describe('GeoIpLookup', function() { } this.request = { get: sinon.stub() } this.GeoIpLookup = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { request: this.request, - 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log() {}, - err() {} - } + 'settings-sharelatex': this.settings } }) this.ipAddress = '123.456.789.123' diff --git a/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js b/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js index 11b2c23f0b..4e995282b4 100644 --- a/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js +++ b/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js @@ -23,9 +23,6 @@ const SandboxedModule = require('sandboxed-module') describe('LockManager - releasing the lock', function() { const deleteStub = sinon.stub().callsArgWith(4) const mocks = { - 'logger-sharelatex': { - log() {} - }, 'settings-sharelatex': { redis: {}, lockManager: { diff --git a/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js b/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js index 48fa105b24..23252c9070 100644 --- a/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js +++ b/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js @@ -14,8 +14,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() const path = require('path') const modulePath = path.join( __dirname, @@ -26,13 +24,7 @@ const SandboxedModule = require('sandboxed-module') describe('LockManager - getting the lock', function() { beforeEach(function() { this.LockManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': { - log() {} - }, './RedisWrapper': { client() { return { auth() {} } diff --git a/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js b/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js index 510479b5c5..ef30a29fd6 100644 --- a/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js +++ b/services/web/test/unit/src/infrastructure/LockManager/tryLockTests.js @@ -11,8 +11,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() const path = require('path') const modulePath = path.join( __dirname, @@ -23,13 +21,7 @@ const SandboxedModule = require('sandboxed-module') describe('LockManager - trying the lock', function() { beforeEach(function() { this.LockManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { - 'logger-sharelatex': { - log() {} - }, './RedisWrapper': { client: () => { return { diff --git a/services/web/test/unit/src/infrastructure/ProxyManagerTests.js b/services/web/test/unit/src/infrastructure/ProxyManagerTests.js index 7ed4c07480..5a8fd06f36 100644 --- a/services/web/test/unit/src/infrastructure/ProxyManagerTests.js +++ b/services/web/test/unit/src/infrastructure/ProxyManagerTests.js @@ -12,9 +12,7 @@ */ const sinon = require('sinon') const assertCalledWith = sinon.assert.calledWith -const chai = require('chai') -const should = chai.should() -const { expect } = chai +const { expect } = require('chai') const modulePath = '../../../../app/src/infrastructure/ProxyManager' const SandboxedModule = require('sandboxed-module') const MockRequest = require('../helpers/MockRequest') @@ -28,14 +26,8 @@ describe('ProxyManager', function() { pipe() {} }) this.proxyManager = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: { 'settings-sharelatex': this.settings, - 'logger-sharelatex': { - log() {} - }, request: this.request } }) diff --git a/services/web/test/unit/src/infrastructure/RateLimterTests.js b/services/web/test/unit/src/infrastructure/RateLimterTests.js index 095d7a0c31..0ce31fd3b1 100644 --- a/services/web/test/unit/src/infrastructure/RateLimterTests.js +++ b/services/web/test/unit/src/infrastructure/RateLimterTests.js @@ -11,11 +11,8 @@ * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const { assert } = require('chai') +const { assert, expect } = require('chai') const sinon = require('sinon') -const chai = require('chai') -const should = chai.should() -const { expect } = chai const modulePath = '../../../../app/src/infrastructure/RateLimiter.js' const SandboxedModule = require('sandboxed-module') @@ -46,10 +43,6 @@ describe('RateLimiter', function() { this.requires = { 'settings-sharelatex': this.settings, - 'logger-sharelatex': (this.logger = { - log: sinon.stub(), - err: sinon.stub() - }), '@overleaf/metrics': (this.Metrics = { inc: sinon.stub() }), './RedisWrapper': this.RedisWrapper } @@ -69,9 +62,6 @@ describe('RateLimiter', function() { return sinon.stub().callsArgWith(1, null, 0, 22) } return (this.limiter = SandboxedModule.require(modulePath, { - globals: { - console: console - }, requires: this.requires })) })