From 9babc70df7fc8949444d3479eed674f4ce1fab4d Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 15 Jul 2024 12:10:48 +0100 Subject: [PATCH] Merge pull request #17362 from overleaf/bg-chai-object-id-tests fix for chai object id tests GitOrigin-RevId: 98123dbc930c6ee57be3a118177426120482c5f4 --- package-lock.json | 481 ------------------ services/chat/.mocharc.json | 3 + services/chat/test/setup.js | 9 + services/contacts/test/setup.js | 4 + services/docstore/package.json | 1 - .../test/acceptance/js/GettingAllDocsTests.js | 2 +- .../test/acceptance/js/GettingDocsTests.js | 2 +- .../test/acceptance/js/UpdatingDocsTests.js | 2 +- services/docstore/test/setup.js | 5 + .../test/unit/js/DocArchiveManagerTests.js | 2 +- .../docstore/test/unit/js/DocManagerTests.js | 2 +- .../test/unit/js/HttpControllerTests.js | 2 +- .../test/unit/js/MongoManagerTests.js | 2 +- .../test/unit/js/RangeManagerTests.js | 2 +- services/document-updater/package.json | 1 - services/document-updater/test/setup.js | 4 + services/filestore/.mocharc.json | 3 + services/filestore/test/setup.js | 34 ++ .../test/unit/js/ImageOptimiserTests.js | 8 +- services/history-v1/test/setup.js | 3 + services/notifications/package.json | 1 - services/notifications/test/setup.js | 4 + .../test/unit/js/NotificationsTests.js | 2 +- services/project-history/test/setup.js | 5 + 24 files changed, 85 insertions(+), 499 deletions(-) create mode 100644 services/chat/.mocharc.json create mode 100644 services/chat/test/setup.js create mode 100644 services/filestore/.mocharc.json create mode 100644 services/filestore/test/setup.js diff --git a/package-lock.json b/package-lock.json index 29b50190bb..87925dc6db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41974,7 +41974,6 @@ "celebrate": "^15.0.3", "express": "^4.19.2", "lodash": "^4.17.21", - "mongodb": "^6.2.0", "mongodb-legacy": "^6.0.1", "p-map": "^4.0.0", "request": "^2.88.2" @@ -41999,73 +41998,6 @@ "node": ">=0.3.1" } }, - "services/docstore/node_modules/gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "dependencies": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "services/docstore/node_modules/mongodb": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.2.0.tgz", - "integrity": "sha512-d7OSuGjGWDZ5usZPqfvb36laQ9CPhnWkAGHT61x5P95p/8nMVeH8asloMwW6GcYFeB0Vj4CB/1wOTDG2RA9BFA==", - "dependencies": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.2.0", - "mongodb-connection-string-url": "^2.6.0" - }, - "engines": { - "node": ">=16.20.1" - }, - "peerDependencies": { - "@aws-sdk/credential-providers": "^3.188.0", - "@mongodb-js/zstd": "^1.1.0", - "gcp-metadata": "^5.2.0", - "kerberos": "^2.0.1", - "mongodb-client-encryption": ">=6.0.0 <7", - "snappy": "^7.2.2", - "socks": "^2.7.1" - }, - "peerDependenciesMeta": { - "@aws-sdk/credential-providers": { - "optional": true - }, - "@mongodb-js/zstd": { - "optional": true - }, - "gcp-metadata": { - "optional": true - }, - "kerberos": { - "optional": true - }, - "mongodb-client-encryption": { - "optional": true - }, - "snappy": { - "optional": true - }, - "socks": { - "optional": true - } - } - }, - "services/docstore/node_modules/mongodb/node_modules/bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", - "engines": { - "node": ">=16.20.1" - } - }, "services/docstore/node_modules/sinon": { "version": "9.0.3", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.3.tgz", @@ -42114,7 +42046,6 @@ "diff-match-patch": "overleaf/diff-match-patch#89805f9c671a77a263fc53461acd62aa7498f688", "express": "^4.19.2", "lodash": "^4.17.21", - "mongodb": "^6.2.0", "mongodb-legacy": "^6.0.1", "request": "^2.88.2", "requestretry": "^7.1.0" @@ -42131,73 +42062,6 @@ "typescript": "^5.0.4" } }, - "services/document-updater/node_modules/bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", - "engines": { - "node": ">=16.20.1" - } - }, - "services/document-updater/node_modules/gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "dependencies": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "services/document-updater/node_modules/mongodb": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.2.0.tgz", - "integrity": "sha512-d7OSuGjGWDZ5usZPqfvb36laQ9CPhnWkAGHT61x5P95p/8nMVeH8asloMwW6GcYFeB0Vj4CB/1wOTDG2RA9BFA==", - "dependencies": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.2.0", - "mongodb-connection-string-url": "^2.6.0" - }, - "engines": { - "node": ">=16.20.1" - }, - "peerDependencies": { - "@aws-sdk/credential-providers": "^3.188.0", - "@mongodb-js/zstd": "^1.1.0", - "gcp-metadata": "^5.2.0", - "kerberos": "^2.0.1", - "mongodb-client-encryption": ">=6.0.0 <7", - "snappy": "^7.2.2", - "socks": "^2.7.1" - }, - "peerDependenciesMeta": { - "@aws-sdk/credential-providers": { - "optional": true - }, - "@mongodb-js/zstd": { - "optional": true - }, - "gcp-metadata": { - "optional": true - }, - "kerberos": { - "optional": true - }, - "mongodb-client-encryption": { - "optional": true - }, - "snappy": { - "optional": true - }, - "socks": { - "optional": true - } - } - }, "services/filestore": { "name": "@overleaf/filestore", "dependencies": { @@ -42377,7 +42241,6 @@ "bunyan": "^1.8.15", "express": "^4.19.2", "lodash": "^4.17.21", - "mongodb": "^6.1.0", "mongodb-legacy": "^6.0.1", "octonode": "^0.9.5", "p-limit": "^2.2.0", @@ -42394,73 +42257,6 @@ "typescript": "^5.0.4" } }, - "services/github-sync/node_modules/bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", - "engines": { - "node": ">=16.20.1" - } - }, - "services/github-sync/node_modules/gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "dependencies": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "services/github-sync/node_modules/mongodb": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz", - "integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==", - "dependencies": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.1.0", - "mongodb-connection-string-url": "^2.6.0" - }, - "engines": { - "node": ">=16.20.1" - }, - "peerDependencies": { - "@aws-sdk/credential-providers": "^3.188.0", - "@mongodb-js/zstd": "^1.1.0", - "gcp-metadata": "^5.2.0", - "kerberos": "^2.0.1", - "mongodb-client-encryption": ">=6.0.0 <7", - "snappy": "^7.2.2", - "socks": "^2.7.1" - }, - "peerDependenciesMeta": { - "@aws-sdk/credential-providers": { - "optional": true - }, - "@mongodb-js/zstd": { - "optional": true - }, - "gcp-metadata": { - "optional": true - }, - "kerberos": { - "optional": true - }, - "mongodb-client-encryption": { - "optional": true - }, - "snappy": { - "optional": true - }, - "socks": { - "optional": true - } - } - }, "services/github-sync/node_modules/p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -43867,7 +43663,6 @@ "bunyan": "^1.8.15", "express": "^4.19.2", "method-override": "^3.0.0", - "mongodb": "^6.1.0", "mongodb-legacy": "^6.0.1", "request": "^2.88.2" }, @@ -43880,73 +43675,6 @@ "typescript": "^5.0.4" } }, - "services/notifications/node_modules/bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", - "engines": { - "node": ">=16.20.1" - } - }, - "services/notifications/node_modules/gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "dependencies": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "services/notifications/node_modules/mongodb": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz", - "integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==", - "dependencies": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.1.0", - "mongodb-connection-string-url": "^2.6.0" - }, - "engines": { - "node": ">=16.20.1" - }, - "peerDependencies": { - "@aws-sdk/credential-providers": "^3.188.0", - "@mongodb-js/zstd": "^1.1.0", - "gcp-metadata": "^5.2.0", - "kerberos": "^2.0.1", - "mongodb-client-encryption": ">=6.0.0 <7", - "snappy": "^7.2.2", - "socks": "^2.7.1" - }, - "peerDependenciesMeta": { - "@aws-sdk/credential-providers": { - "optional": true - }, - "@mongodb-js/zstd": { - "optional": true - }, - "gcp-metadata": { - "optional": true - }, - "kerberos": { - "optional": true - }, - "mongodb-client-encryption": { - "optional": true - }, - "snappy": { - "optional": true - }, - "socks": { - "optional": true - } - } - }, "services/project-history": { "name": "@overleaf/project-history", "dependencies": { @@ -44309,7 +44037,6 @@ "express": "^4.19.2", "lodash": "^4.17.21", "lru-cache": "^5.1.1", - "mongodb": "^6.1.0", "mongodb-legacy": "^6.0.1", "oauth": "0.9.15", "request": "^2.88.2", @@ -44326,14 +44053,6 @@ "typescript": "^5.0.4" } }, - "services/third-party-references/node_modules/bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", - "engines": { - "node": ">=16.20.1" - } - }, "services/third-party-references/node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -44343,65 +44062,6 @@ "node": ">=0.3.1" } }, - "services/third-party-references/node_modules/gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "dependencies": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "services/third-party-references/node_modules/mongodb": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz", - "integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==", - "dependencies": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.1.0", - "mongodb-connection-string-url": "^2.6.0" - }, - "engines": { - "node": ">=16.20.1" - }, - "peerDependencies": { - "@aws-sdk/credential-providers": "^3.188.0", - "@mongodb-js/zstd": "^1.1.0", - "gcp-metadata": "^5.2.0", - "kerberos": "^2.0.1", - "mongodb-client-encryption": ">=6.0.0 <7", - "snappy": "^7.2.2", - "socks": "^2.7.1" - }, - "peerDependenciesMeta": { - "@aws-sdk/credential-providers": { - "optional": true - }, - "@mongodb-js/zstd": { - "optional": true - }, - "gcp-metadata": { - "optional": true - }, - "kerberos": { - "optional": true - }, - "mongodb-client-encryption": { - "optional": true - }, - "snappy": { - "optional": true - }, - "socks": { - "optional": true - } - } - }, "services/third-party-references/node_modules/sinon": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.2.tgz", @@ -52048,7 +51708,6 @@ "express": "^4.19.2", "lodash": "^4.17.21", "mocha": "^10.2.0", - "mongodb": "^6.2.0", "mongodb-legacy": "^6.0.1", "p-map": "^4.0.0", "request": "^2.88.2", @@ -52064,34 +51723,6 @@ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, - "gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "requires": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - } - }, - "mongodb": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.2.0.tgz", - "integrity": "sha512-d7OSuGjGWDZ5usZPqfvb36laQ9CPhnWkAGHT61x5P95p/8nMVeH8asloMwW6GcYFeB0Vj4CB/1wOTDG2RA9BFA==", - "requires": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.2.0", - "mongodb-connection-string-url": "^2.6.0" - }, - "dependencies": { - "bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==" - } - } - }, "sinon": { "version": "9.0.3", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.3.tgz", @@ -52139,7 +51770,6 @@ "express": "^4.19.2", "lodash": "^4.17.21", "mocha": "^10.2.0", - "mongodb": "^6.2.0", "mongodb-legacy": "^6.0.1", "request": "^2.88.2", "requestretry": "^7.1.0", @@ -52148,34 +51778,6 @@ "sinon-chai": "^3.7.0", "timekeeper": "^2.0.0", "typescript": "^5.0.4" - }, - "dependencies": { - "bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==" - }, - "gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "requires": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - } - }, - "mongodb": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.2.0.tgz", - "integrity": "sha512-d7OSuGjGWDZ5usZPqfvb36laQ9CPhnWkAGHT61x5P95p/8nMVeH8asloMwW6GcYFeB0Vj4CB/1wOTDG2RA9BFA==", - "requires": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.2.0", - "mongodb-connection-string-url": "^2.6.0" - } - } } }, "@overleaf/eslint-plugin": { @@ -52342,7 +51944,6 @@ "express": "^4.19.2", "lodash": "^4.17.21", "mocha": "^10.2.0", - "mongodb": "^6.1.0", "mongodb-legacy": "^6.0.1", "octonode": "^0.9.5", "p-limit": "^2.2.0", @@ -52354,32 +51955,6 @@ "typescript": "^5.0.4" }, "dependencies": { - "bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==" - }, - "gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "requires": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - } - }, - "mongodb": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz", - "integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==", - "requires": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.1.0", - "mongodb-connection-string-url": "^2.6.0" - } - }, "p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -52461,40 +52036,11 @@ "express": "^4.19.2", "method-override": "^3.0.0", "mocha": "^10.2.0", - "mongodb": "^6.1.0", "mongodb-legacy": "^6.0.1", "request": "^2.88.2", "sandboxed-module": "^2.0.4", "sinon": "^9.2.4", "typescript": "^5.0.4" - }, - "dependencies": { - "bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==" - }, - "gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "requires": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - } - }, - "mongodb": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz", - "integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==", - "requires": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.1.0", - "mongodb-connection-string-url": "^2.6.0" - } - } } }, "@overleaf/o-error": { @@ -52975,7 +52521,6 @@ "lodash": "^4.17.21", "lru-cache": "^5.1.1", "mocha": "^10.2.0", - "mongodb": "^6.1.0", "mongodb-legacy": "^6.0.1", "oauth": "0.9.15", "request": "^2.88.2", @@ -52985,38 +52530,12 @@ "typescript": "^5.0.4" }, "dependencies": { - "bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==" - }, "diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, - "gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "optional": true, - "peer": true, - "requires": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - } - }, - "mongodb": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz", - "integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==", - "requires": { - "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.1.0", - "mongodb-connection-string-url": "^2.6.0" - } - }, "sinon": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.2.tgz", diff --git a/services/chat/.mocharc.json b/services/chat/.mocharc.json new file mode 100644 index 0000000000..dc3280aa96 --- /dev/null +++ b/services/chat/.mocharc.json @@ -0,0 +1,3 @@ +{ + "require": "test/setup.js" +} diff --git a/services/chat/test/setup.js b/services/chat/test/setup.js new file mode 100644 index 0000000000..d61deff917 --- /dev/null +++ b/services/chat/test/setup.js @@ -0,0 +1,9 @@ +import chai from 'chai' +import chaiAsPromised from 'chai-as-promised' +import { ObjectId } from 'mongodb' + +// ensure every ObjectId has the id string as a property for correct comparisons +ObjectId.cacheHexString = true + +chai.should() +chai.use(chaiAsPromised) diff --git a/services/contacts/test/setup.js b/services/contacts/test/setup.js index 6b71d8f5ab..023fbc142c 100644 --- a/services/contacts/test/setup.js +++ b/services/contacts/test/setup.js @@ -1,6 +1,10 @@ import chai from 'chai' import chaiAsPromised from 'chai-as-promised' import sinonChai from 'sinon-chai' +import { ObjectId } from 'mongodb' + +// ensure every ObjectId has the id string as a property for correct comparisons +ObjectId.cacheHexString = true chai.should() chai.use(chaiAsPromised) diff --git a/services/docstore/package.json b/services/docstore/package.json index 7e7eb49503..015ca7a90c 100644 --- a/services/docstore/package.json +++ b/services/docstore/package.json @@ -31,7 +31,6 @@ "celebrate": "^15.0.3", "express": "^4.19.2", "lodash": "^4.17.21", - "mongodb": "^6.2.0", "mongodb-legacy": "^6.0.1", "p-map": "^4.0.0", "request": "^2.88.2" diff --git a/services/docstore/test/acceptance/js/GettingAllDocsTests.js b/services/docstore/test/acceptance/js/GettingAllDocsTests.js index d6994cf7d4..8fe5e7d91b 100644 --- a/services/docstore/test/acceptance/js/GettingAllDocsTests.js +++ b/services/docstore/test/acceptance/js/GettingAllDocsTests.js @@ -11,7 +11,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const async = require('async') const DocstoreApp = require('./helpers/DocstoreApp') diff --git a/services/docstore/test/acceptance/js/GettingDocsTests.js b/services/docstore/test/acceptance/js/GettingDocsTests.js index 4710e447dc..121b3c1e24 100644 --- a/services/docstore/test/acceptance/js/GettingDocsTests.js +++ b/services/docstore/test/acceptance/js/GettingDocsTests.js @@ -10,7 +10,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const DocstoreApp = require('./helpers/DocstoreApp') const DocstoreClient = require('./helpers/DocstoreClient') diff --git a/services/docstore/test/acceptance/js/UpdatingDocsTests.js b/services/docstore/test/acceptance/js/UpdatingDocsTests.js index a1e9573b28..8793341483 100644 --- a/services/docstore/test/acceptance/js/UpdatingDocsTests.js +++ b/services/docstore/test/acceptance/js/UpdatingDocsTests.js @@ -10,7 +10,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const sinon = require('sinon') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const DocstoreApp = require('./helpers/DocstoreApp') const DocstoreClient = require('./helpers/DocstoreClient') diff --git a/services/docstore/test/setup.js b/services/docstore/test/setup.js index 92cafdea58..ef16fa6258 100644 --- a/services/docstore/test/setup.js +++ b/services/docstore/test/setup.js @@ -5,6 +5,9 @@ const chaiAsPromised = require('chai-as-promised') const SandboxedModule = require('sandboxed-module') const timersPromises = require('timers/promises') +// ensure every ObjectId has the id string as a property for correct comparisons +require('mongodb-legacy').ObjectId.cacheHexString = true + process.env.BACKEND = 'gcs' // Chai configuration @@ -31,6 +34,8 @@ SandboxedModule.configure({ requires: { '@overleaf/logger': stubs.logger, 'timers/promises': timersPromises, + 'mongodb-legacy': require('mongodb-legacy'), + bson: require('bson'), }, globals: { Buffer, JSON, Math, console, process }, }) diff --git a/services/docstore/test/unit/js/DocArchiveManagerTests.js b/services/docstore/test/unit/js/DocArchiveManagerTests.js index 13f8e0eadd..13046d86fc 100644 --- a/services/docstore/test/unit/js/DocArchiveManagerTests.js +++ b/services/docstore/test/unit/js/DocArchiveManagerTests.js @@ -2,7 +2,7 @@ const sinon = require('sinon') const { expect } = require('chai') const modulePath = '../../../app/js/DocArchiveManager.js' const SandboxedModule = require('sandboxed-module') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../app/js/Errors') describe('DocArchiveManager', function () { diff --git a/services/docstore/test/unit/js/DocManagerTests.js b/services/docstore/test/unit/js/DocManagerTests.js index a0d78ff6bc..be833f4b3f 100644 --- a/services/docstore/test/unit/js/DocManagerTests.js +++ b/services/docstore/test/unit/js/DocManagerTests.js @@ -2,7 +2,7 @@ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') const { expect } = require('chai') const modulePath = require('path').join(__dirname, '../../../app/js/DocManager') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../app/js/Errors') describe('DocManager', function () { diff --git a/services/docstore/test/unit/js/HttpControllerTests.js b/services/docstore/test/unit/js/HttpControllerTests.js index 8a08d7757d..2ed46a9d70 100644 --- a/services/docstore/test/unit/js/HttpControllerTests.js +++ b/services/docstore/test/unit/js/HttpControllerTests.js @@ -5,7 +5,7 @@ const modulePath = require('path').join( __dirname, '../../../app/js/HttpController' ) -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const Errors = require('../../../app/js/Errors') describe('HttpController', function () { diff --git a/services/docstore/test/unit/js/MongoManagerTests.js b/services/docstore/test/unit/js/MongoManagerTests.js index 4f8001f482..da8f59ae07 100644 --- a/services/docstore/test/unit/js/MongoManagerTests.js +++ b/services/docstore/test/unit/js/MongoManagerTests.js @@ -4,7 +4,7 @@ const modulePath = require('path').join( __dirname, '../../../app/js/MongoManager' ) -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const { assert, expect } = require('chai') const Errors = require('../../../app/js/Errors') diff --git a/services/docstore/test/unit/js/RangeManagerTests.js b/services/docstore/test/unit/js/RangeManagerTests.js index 68f85bc882..0d2a353558 100644 --- a/services/docstore/test/unit/js/RangeManagerTests.js +++ b/services/docstore/test/unit/js/RangeManagerTests.js @@ -16,7 +16,7 @@ const modulePath = require('path').join( __dirname, '../../../app/js/RangeManager' ) -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') describe('RangeManager', function () { beforeEach(function () { diff --git a/services/document-updater/package.json b/services/document-updater/package.json index d982dd2973..07de78262b 100644 --- a/services/document-updater/package.json +++ b/services/document-updater/package.json @@ -32,7 +32,6 @@ "diff-match-patch": "overleaf/diff-match-patch#89805f9c671a77a263fc53461acd62aa7498f688", "express": "^4.19.2", "lodash": "^4.17.21", - "mongodb": "^6.2.0", "mongodb-legacy": "^6.0.1", "request": "^2.88.2", "requestretry": "^7.1.0" diff --git a/services/document-updater/test/setup.js b/services/document-updater/test/setup.js index 5c858eee05..f7d47e7b75 100644 --- a/services/document-updater/test/setup.js +++ b/services/document-updater/test/setup.js @@ -4,6 +4,9 @@ const sinonChai = require('sinon-chai') const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') +// ensure every ObjectId has the id string as a property for correct comparisons +require('mongodb-legacy').ObjectId.cacheHexString = true + // Chai configuration chai.should() chai.use(chaiAsPromised) @@ -27,6 +30,7 @@ const stubs = { SandboxedModule.configure({ requires: { '@overleaf/logger': stubs.logger, + 'mongodb-legacy': require('mongodb-legacy'), // for ObjectId comparisons }, globals: { Buffer, JSON, Math, console, process }, }) diff --git a/services/filestore/.mocharc.json b/services/filestore/.mocharc.json new file mode 100644 index 0000000000..dc3280aa96 --- /dev/null +++ b/services/filestore/.mocharc.json @@ -0,0 +1,3 @@ +{ + "require": "test/setup.js" +} diff --git a/services/filestore/test/setup.js b/services/filestore/test/setup.js new file mode 100644 index 0000000000..57a462390f --- /dev/null +++ b/services/filestore/test/setup.js @@ -0,0 +1,34 @@ +const sinon = require('sinon') +const SandboxedModule = require('sandboxed-module') + +// ensure every ObjectId has the id string as a property for correct comparisons +require('mongodb').ObjectId.cacheHexString = true + +const sandbox = sinon.createSandbox() +const stubs = { + logger: { + debug: sandbox.stub(), + log: sandbox.stub(), + info: sandbox.stub(), + warn: sandbox.stub(), + err: sandbox.stub(), + error: sandbox.stub(), + fatal: sandbox.stub(), + }, +} + +SandboxedModule.configure({ + requires: { + '@overleaf/logger': stubs.logger, + }, +}) + +exports.mochaHooks = { + beforeEach() { + this.logger = stubs.logger + }, + + afterEach() { + sandbox.reset() + }, +} diff --git a/services/filestore/test/unit/js/ImageOptimiserTests.js b/services/filestore/test/unit/js/ImageOptimiserTests.js index 874c0a5244..cec7da630e 100644 --- a/services/filestore/test/unit/js/ImageOptimiserTests.js +++ b/services/filestore/test/unit/js/ImageOptimiserTests.js @@ -6,20 +6,16 @@ const { FailedCommandError } = require('../../../app/js/Errors') const SandboxedModule = require('sandboxed-module') describe('ImageOptimiser', function () { - let ImageOptimiser, SafeExec, logger + let ImageOptimiser, SafeExec const sourcePath = '/wombat/potato.eps' beforeEach(function () { SafeExec = { promises: sinon.stub().resolves(), } - logger = { - warn: sinon.stub(), - } ImageOptimiser = SandboxedModule.require(modulePath, { requires: { './SafeExec': SafeExec, - '@overleaf/logger': logger, '@overleaf/metrics': { Timer: sinon.stub().returns({ done: sinon.stub() }), }, @@ -65,7 +61,7 @@ describe('ImageOptimiser', function () { }) it('should log a warning', function () { - expect(logger.warn).to.have.been.calledOnce + expect(this.logger.warn).to.have.been.calledOnce }) }) }) diff --git a/services/history-v1/test/setup.js b/services/history-v1/test/setup.js index 14f5ef0c85..c127661dbc 100644 --- a/services/history-v1/test/setup.js +++ b/services/history-v1/test/setup.js @@ -4,6 +4,9 @@ const config = require('config') const fetch = require('node-fetch') const { knex, mongodb } = require('../storage') +// ensure every ObjectId has the id string as a property for correct comparisons +require('mongodb').ObjectId.cacheHexString = true + chai.use(chaiAsPromised) async function setupPostgresDatabase() { diff --git a/services/notifications/package.json b/services/notifications/package.json index b3e9558abb..076cdc586c 100644 --- a/services/notifications/package.json +++ b/services/notifications/package.json @@ -27,7 +27,6 @@ "bunyan": "^1.8.15", "express": "^4.19.2", "method-override": "^3.0.0", - "mongodb": "^6.1.0", "mongodb-legacy": "^6.0.1", "request": "^2.88.2" }, diff --git a/services/notifications/test/setup.js b/services/notifications/test/setup.js index e95a300d30..0dbbb918c2 100644 --- a/services/notifications/test/setup.js +++ b/services/notifications/test/setup.js @@ -4,6 +4,9 @@ const SandboxedModule = require('sandboxed-module') // Chai configuration chai.should() +// ensure every ObjectId has the id string as a property for correct comparisons +require('mongodb-legacy').ObjectId.cacheHexString = true + // SandboxedModule configuration SandboxedModule.configure({ requires: { @@ -16,6 +19,7 @@ SandboxedModule.configure({ error() {}, fatal() {}, }, + 'mongodb-legacy': require('mongodb-legacy'), // for ObjectId comparisons }, globals: { Buffer, JSON, console, process }, }) diff --git a/services/notifications/test/unit/js/NotificationsTests.js b/services/notifications/test/unit/js/NotificationsTests.js index 3bf145bf29..c5e48433ba 100644 --- a/services/notifications/test/unit/js/NotificationsTests.js +++ b/services/notifications/test/unit/js/NotificationsTests.js @@ -15,7 +15,7 @@ const { expect } = require('chai') const modulePath = '../../../app/js/Notifications.js' const SandboxedModule = require('sandboxed-module') const assert = require('assert') -const { ObjectId } = require('mongodb') +const { ObjectId } = require('mongodb-legacy') const userId = '51dc93e6fb625a261300003b' const notificationId = '574ee8d6f40c3a244e704249' diff --git a/services/project-history/test/setup.js b/services/project-history/test/setup.js index 86309460ca..0bc2ff79b6 100644 --- a/services/project-history/test/setup.js +++ b/services/project-history/test/setup.js @@ -1,6 +1,11 @@ import chai from 'chai' import sinonChai from 'sinon-chai' import chaiAsPromised from 'chai-as-promised' +import mongodb from 'mongodb-legacy' +const { ObjectId } = mongodb + +// ensure every ObjectId has the id string as a property for correct comparisons +ObjectId.cacheHexString = true // Chai configuration chai.should()