From 1d182979364bd8d5a64f2a8efffccdc70e95bfc4 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Thu, 6 Feb 2020 10:07:24 +0000 Subject: [PATCH] Update dependencies. (#1045) * Update dependencies. * Fix nock usage. --- Makefile | 8 +- package-lock.json | 249 +++++++++--------- package.json | 16 +- src/actions/bots.test.js | 32 +-- src/actions/channels.test.js | 428 +++++++++++++++---------------- src/actions/emojis.test.js | 116 ++++----- src/actions/files.test.js | 16 +- src/actions/integrations.test.js | 220 ++++++++-------- src/actions/posts.test.js | 122 ++++----- src/actions/preferences.test.js | 4 +- src/actions/schemes.test.js | 20 +- src/actions/search.test.js | 8 +- src/actions/teams.test.js | 184 ++++++------- src/actions/users.test.js | 180 ++++++------- src/actions/websocket.test.js | 12 +- test/test_helper.js | 20 +- 16 files changed, 824 insertions(+), 811 deletions(-) diff --git a/Makefile b/Makefile index 221286214..06dd7e77e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: check-style clean pre-run test install +.PHONY: check-style clean pre-run test install update-dependencies node_modules: package.json @if ! [ $(shell which npm) ]; then \ @@ -35,3 +35,9 @@ install: node_modules bundle: | pre-run node_modules npm run build + +update-dependencies: # Updates the dependencies + npm update --depth 9999 + npm audit fix + @echo Automatic dependency update complete. + @echo You should manually inspect changes to package.json and pin exact versions of packages where appropriate. diff --git a/package-lock.json b/package-lock.json index 023d5c1e6..3b4476818 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,12 +5,12 @@ "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", - "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", "dev": true, "requires": { - "@babel/highlight": "^7.0.0" + "@babel/highlight": "^7.8.3" } }, "@babel/core": { @@ -168,12 +168,12 @@ } }, "@babel/helper-module-imports": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz", - "integrity": "sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.8.3.tgz", + "integrity": "sha512-R0Bx3jippsbAEtzkpZ/6FIiuzOURPcMjHp+Z6xPe6DtApDJx+w7UYyOLanZqO8+wKR9G10s/FmHXvxaMd9s6Kg==", "dev": true, "requires": { - "@babel/types": "^7.0.0" + "@babel/types": "^7.8.3" } }, "@babel/helper-module-transforms": { @@ -282,9 +282,9 @@ } }, "@babel/highlight": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", - "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", + "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", "dev": true, "requires": { "chalk": "^2.0.0", @@ -293,9 +293,9 @@ } }, "@babel/parser": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.2.tgz", - "integrity": "sha512-mdFqWrSPCmikBoaBYMuBulzTIKuXVPtEISFbRRVNwMWpCms/hmE2kRq0bblUHaNRKrjRlmVbx1sDHmjmRgD2Xg==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.3.tgz", + "integrity": "sha512-/V72F4Yp/qmHaTALizEm9Gf2eQHV3QyTL3K0cNfijwnMnb1L+LDlAubb/ZnSdGAVzVSWakujHYs1I26x66sMeQ==", "dev": true }, "@babel/plugin-proposal-async-generator-functions": { @@ -871,22 +871,74 @@ } }, "@babel/traverse": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.2.tgz", - "integrity": "sha512-8fRE76xNwNttVEF2TwxJDGBLWthUkHWSldmfuBzVRmEDWOtu4XdINTgN7TDWzuLg4bbeIMLvfMFD9we5YcWkRQ==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.8.3.tgz", + "integrity": "sha512-we+a2lti+eEImHmEXp7bM9cTxGzxPmBiVJlLVD+FuuQMeeO7RaDbutbgeheDkw+Xe3mCfJHnGOWLswT74m2IPg==", "dev": true, "requires": { - "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.6.2", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.6.2", - "@babel/types": "^7.6.0", + "@babel/code-frame": "^7.8.3", + "@babel/generator": "^7.8.3", + "@babel/helper-function-name": "^7.8.3", + "@babel/helper-split-export-declaration": "^7.8.3", + "@babel/parser": "^7.8.3", + "@babel/types": "^7.8.3", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" }, "dependencies": { + "@babel/generator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.3.tgz", + "integrity": "sha512-WjoPk8hRpDRqqzRpvaR8/gDUPkrnOOeuT2m8cNICJtZH6mwaCo3v0OKMI7Y6SM1pBtyijnLtAL0HDi41pf41ug==", + "dev": true, + "requires": { + "@babel/types": "^7.8.3", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + } + }, + "@babel/helper-function-name": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz", + "integrity": "sha512-BCxgX1BC2hD/oBlIFUgOCQDOPV8nSINxCwM3o93xP4P9Fq6aV5sgv2cOOITDMtCfQ+3PvHp3l689XZvAM9QyOA==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.8.3", + "@babel/template": "^7.8.3", + "@babel/types": "^7.8.3" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz", + "integrity": "sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA==", + "dev": true, + "requires": { + "@babel/types": "^7.8.3" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz", + "integrity": "sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA==", + "dev": true, + "requires": { + "@babel/types": "^7.8.3" + } + }, + "@babel/template": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.3.tgz", + "integrity": "sha512-04m87AcQgAFdvuoyiQ2kgELr2tV8B4fP/xJAVUL3Yb3bkNdMedD3d0rlSQr3PegP0cms3eHjl1F7PWlvWbU8FQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.8.3", + "@babel/parser": "^7.8.3", + "@babel/types": "^7.8.3" + } + }, "debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", @@ -905,9 +957,9 @@ } }, "@babel/types": { - "version": "7.6.1", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.6.1.tgz", - "integrity": "sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.3.tgz", + "integrity": "sha512-jBD+G8+LWpMBBWvVcdr4QysjUE4mU/syrhN17o1u3gx0/WzJB1kwiVZAXRtWbsIPOwW8pF/YJV5+nmetPzepXg==", "dev": true, "requires": { "esutils": "^2.0.2", @@ -1167,9 +1219,9 @@ } }, "@react-native-community/netinfo": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@react-native-community/netinfo/-/netinfo-4.4.0.tgz", - "integrity": "sha512-qqNWMOsrDjj/daqV21ID2T8mNUjZD4pdx3PuWyE65gzKh2w+oMnzKb+J0NbLyZPn3wwLwU1+Cpf58A0ff5szjQ==" + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@react-native-community/netinfo/-/netinfo-4.7.0.tgz", + "integrity": "sha512-a/sDB+AsLEUNmhAUlAaTYeXKyQdFGBUfatqKkX5jluBo2CB3OAuTHfm7rSjcaLB9EmG5iSq3fOTpync2E7EYTA==" }, "@types/babel__core": { "version": "7.1.3", @@ -1595,12 +1647,6 @@ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, "assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", @@ -2051,20 +2097,6 @@ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "dev": true }, - "chai": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", - "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", - "dev": true, - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "pathval": "^1.1.0", - "type-detect": "^4.0.5" - } - }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -2082,12 +2114,6 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, "ci-info": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", @@ -2211,9 +2237,9 @@ } }, "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, "commondir": { @@ -2418,15 +2444,6 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "requires": { - "type-detect": "^4.0.0" - } - }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -3770,12 +3787,6 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, "get-params": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/get-params/-/get-params-0.1.2.tgz", @@ -3872,9 +3883,9 @@ "dev": true }, "handlebars": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.2.tgz", - "integrity": "sha512-29Zxv/cynYB7mkT1rVWQnV7mGX6v7H/miQ6dbEpYTKq5eJBN7PsRB+ViYJlcT6JINTSu4dVB9kOqEun78h6Exg==", + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.2.tgz", + "integrity": "sha512-4PwqDL2laXtTWZghzzCtunQUTLbo31pcCJrd/B/9JP8XbhVzpS5ZXuKqlOzsd1rtcaLo4KqAn8nl8mkknS4MHw==", "dev": true, "requires": { "neo-async": "^2.6.0", @@ -5324,9 +5335,9 @@ } }, "magic-string": { - "version": "0.25.3", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.3.tgz", - "integrity": "sha512-6QK0OpF/phMz0Q2AxILkX2mFhi7m+WMwTRg0LQKq/WBB0cDP4rYH3Wp4/d3OTXlrPLVJT/RFqj8tFeAR4nk8AA==", + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.6.tgz", + "integrity": "sha512-3a5LOMSGoCTH5rbqobC2HuDNRtE2glHZ8J7pK+QZYppyWA36yuNpsX994rIY2nCuyP7CZYy7lQq/X2jygiZ89g==", "dev": true, "requires": { "sourcemap-codec": "^1.4.4" @@ -5527,9 +5538,9 @@ "optional": true }, "nanoid": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.1.tgz", - "integrity": "sha512-0YbJdaL4JFoejIOoawgLcYValFGJ2iyUuVDIWL3g8Es87SSOWFbWdRUMV3VMSiyPs3SQ3QxCIxFX00q5DLkMCw==" + "version": "2.1.10", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.10.tgz", + "integrity": "sha512-ZPUHBAwrQ+BSwVV2Xh6hBOEStTzAf8LgohOY0kk22lDiDdI32582KjVPYCqgqj7834hTunGzwZOB4me9T6ZcnA==" }, "nanomatch": { "version": "1.2.13", @@ -5569,12 +5580,11 @@ "dev": true }, "nock": { - "version": "11.3.5", - "resolved": "https://registry.npmjs.org/nock/-/nock-11.3.5.tgz", - "integrity": "sha512-6WGeZcWc3RExkBcMSYSrUm/5YukDo52m/jhwniQyrnuiCnKRljBwwje9vTwJyEi4J6m2bq0Aj6C1vzuM6iuaeg==", + "version": "11.7.2", + "resolved": "https://registry.npmjs.org/nock/-/nock-11.7.2.tgz", + "integrity": "sha512-7swr5bL1xBZ5FctyubjxEVySXOSebyqcL7Vy1bx1nS9IUqQWj81cmKjVKJLr8fHhtzI1MV8nyCdENA/cGcY1+Q==", "dev": true, "requires": { - "chai": "^4.1.2", "debug": "^4.1.0", "json-stringify-safe": "^5.0.1", "lodash": "^4.17.13", @@ -5997,12 +6007,6 @@ "pify": "^2.0.0" } }, - "pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", - "dev": true - }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -6490,9 +6494,9 @@ "integrity": "sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==" }, "resolve": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", - "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz", + "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -6545,9 +6549,9 @@ } }, "rn-host-detect": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/rn-host-detect/-/rn-host-detect-1.1.5.tgz", - "integrity": "sha512-ufk2dFT3QeP9HyZ/xTuMtW27KnFy815CYitJMqQm+pgG3ZAtHBsrU8nXizNKkqXGy3bQmhEoloVbrfbvMJMqkg==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/rn-host-detect/-/rn-host-detect-1.2.0.tgz", + "integrity": "sha512-btNg5kzHcjZZ7t7mvvV/4wNJ9e3MPgrWivkRgWURzXL0JJ0pwWlU4zrbmdlz3HHzHOxhBhHB4D+/dbMFfu4/4A==" }, "rollup": { "version": "1.22.0", @@ -6597,16 +6601,16 @@ } }, "rollup-plugin-terser": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-5.1.2.tgz", - "integrity": "sha512-sWKBCOS+vUkRtHtEiJPAf+WnBqk/C402fBD9AVHxSIXMqjsY7MnYWKYEUqGixtr0c8+1DjzUEPlNgOYQPVrS1g==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-5.2.0.tgz", + "integrity": "sha512-jQI+nYhtDBc9HFRBz8iGttQg7li9klmzR62RG2W2nN6hJ/FI2K2ItYQ7kJ7/zn+vs+BP1AEccmVRjRN989I+Nw==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", - "jest-worker": "^24.6.0", - "rollup-pluginutils": "^2.8.1", - "serialize-javascript": "^1.7.0", - "terser": "^4.1.0" + "@babel/code-frame": "^7.5.5", + "jest-worker": "^24.9.0", + "rollup-pluginutils": "^2.8.2", + "serialize-javascript": "^2.1.2", + "terser": "^4.6.2" } }, "rollup-plugin-typescript2": { @@ -6700,6 +6704,15 @@ "find-up": "^4.0.0" } }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, "rollup-pluginutils": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.1.tgz", @@ -6852,9 +6865,9 @@ } }, "serialize-javascript": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.9.1.tgz", - "integrity": "sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz", + "integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==", "dev": true }, "set-blocking": { @@ -7148,9 +7161,9 @@ "dev": true }, "sourcemap-codec": { - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.6.tgz", - "integrity": "sha512-1ZooVLYFxC448piVLBbtOxFcXwnymH9oUF8nRd3CuYDVvkRBxRl6pB4Mtas5a4drtL+E8LDgFkQNcgIw6tc8Hg==", + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", "dev": true }, "spdx-correct": { @@ -7378,9 +7391,9 @@ } }, "terser": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.3.4.tgz", - "integrity": "sha512-Kcrn3RiW8NtHBP0ssOAzwa2MsIRQ8lJWiBG/K7JgqPlomA3mtb2DEmp4/hrUA+Jujx+WZ02zqd7GYD+QRBB/2Q==", + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.6.3.tgz", + "integrity": "sha512-Lw+ieAXmY69d09IIc/yqeBqXpEQIpDGZqT34ui1QWXIUpR2RjbqEkT8X7Lgex19hslSqcWM5iMN2kM11eMsESQ==", "dev": true, "requires": { "commander": "^2.20.0", @@ -7694,12 +7707,6 @@ "prelude-ls": "~1.1.2" } }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, "type-fest": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", diff --git a/package.json b/package.json index 7e2367bb8..fa5e4d45e 100644 --- a/package.json +++ b/package.json @@ -25,17 +25,17 @@ "dev-mobile:watch": "ttsc --watch --outDir ${MOBILE_DIR:-../mattermost-mobile}/node_modules/mattermost-redux" }, "dependencies": { + "core-js": "3.1.4", "form-data": "2.5.1", "gfycat-sdk": "1.4.18", - "moment-timezone": "0.5.26", "isomorphic-fetch": "2.2.1", + "moment-timezone": "0.5.26", "redux": "4.0.4", "redux-action-buffer": "1.2.0", "redux-offline": "git+https://github.com/enahum/redux-offline.git#885024de96b6ec73650c340c8928066585c413df", "redux-persist": "4.9.1", "redux-persist-node-storage": "2.0.0", "redux-thunk": "2.3.0", - "core-js": "3.1.4", "remote-redux-devtools": "0.5.16", "reselect": "4.0.0", "serialize-error": "5.0.0", @@ -58,12 +58,12 @@ "@babel/preset-env": "7.6.0", "@babel/preset-typescript": "7.6.0", "@babel/runtime": "7.6.0", - "@types/shallow-equals": "1.0.0", - "@typescript-eslint/eslint-plugin": "2.3.1", - "@typescript-eslint/parser": "2.3.1", "@types/jest": "24.9.0", "@types/moment-timezone": "0.5.12", "@types/node": "12.7.11", + "@types/shallow-equals": "1.0.0", + "@typescript-eslint/eslint-plugin": "2.3.1", + "@typescript-eslint/parser": "2.3.1", "@zerollup/ts-transform-paths": "1.7.3", "babel-eslint": "10.0.3", "babel-plugin-module-resolver": "3.2.0", @@ -77,18 +77,18 @@ "jest": "24.8.0", "jest-junit": "6.4.0", "mock-socket": "8.0.5", - "nock": "^11.3.5", + "nock": "11.7.2", "redux-mock-store": "1.5.3", "rollup": "1.22.0", "rollup-plugin-babel": "4.3.3", "rollup-plugin-commonjs": "10.1.0", "rollup-plugin-node-resolve": "5.2.0", - "rollup-plugin-terser": "5.1.2", + "rollup-plugin-terser": "5.2.0", "rollup-plugin-typescript2": "0.24.3", + "source-map-support": "0.5.12", "ts-jest": "24.1.0", "tslib": "1.10.0", "ttypescript": "1.5.7", - "source-map-support": "0.5.12", "typescript": "3.6.3" } } diff --git a/src/actions/bots.test.js b/src/actions/bots.test.js index 0ae904f3b..970c131a5 100644 --- a/src/actions/bots.test.js +++ b/src/actions/bots.test.js @@ -27,8 +27,8 @@ describe('Actions.Bots', () => { it('loadBots', async () => { const bots = [TestHelper.fakeBot(), TestHelper.fakeBot()]; - nock(Client4.getBotsRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/bots'). query(true). reply(201, bots); @@ -41,8 +41,8 @@ describe('Actions.Bots', () => { it('loadBot', async () => { const bot = TestHelper.fakeBot(); - nock(Client4.getBotRoute(bot.user_id)). - get(''). + nock(Client4.getBaseRoute()). + get(`/bots/${bot.user_id}`). query(true). reply(201, bot); @@ -55,8 +55,8 @@ describe('Actions.Bots', () => { it('createBot', async () => { const bot = TestHelper.fakeBot(); - nock(Client4.getBotsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/bots'). reply(200, bot); await store.dispatch(BotActions.createBot(bot)); @@ -67,15 +67,15 @@ describe('Actions.Bots', () => { it('patchBot', async () => { const bot = TestHelper.fakeBot(); - nock(Client4.getBotRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/bots'). reply(200, bot); await store.dispatch(BotActions.createBot(bot)); bot.username = 'mynewusername'; - nock(Client4.getBotRoute(bot.user_id)). - put(''). + nock(Client4.getBaseRoute()). + put(`/bots/${bot.user_id}`). reply(200, bot); await store.dispatch(BotActions.patchBot(bot.user_id, bot)); @@ -86,8 +86,8 @@ describe('Actions.Bots', () => { it('disableBot', async () => { const bot = TestHelper.fakeBot(); - nock(Client4.getBotRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/bots'). reply(200, bot); await store.dispatch(BotActions.createBot(bot)); @@ -115,8 +115,8 @@ describe('Actions.Bots', () => { it('assignBot', async () => { const bot = TestHelper.fakeBot(); - nock(Client4.getBotRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/bots'). reply(200, bot); await store.dispatch(BotActions.createBot(bot)); @@ -134,8 +134,8 @@ describe('Actions.Bots', () => { it('logout', async () => { // Fill redux store with somthing const bot = TestHelper.fakeBot(); - nock(Client4.getBotRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/bots'). reply(200, bot); await store.dispatch(BotActions.createBot(bot)); diff --git a/src/actions/channels.test.js b/src/actions/channels.test.js index e77a19b7c..c6af13fd0 100644 --- a/src/actions/channels.test.js +++ b/src/actions/channels.test.js @@ -41,8 +41,8 @@ describe('Actions.Channels', () => { }); it('createChannel', async () => { - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); await store.dispatch(Actions.createChannel(TestHelper.fakeChannel(TestHelper.basicTeam.id), TestHelper.basicUser.id)); @@ -67,8 +67,8 @@ describe('Actions.Channels', () => { }); it('createDirectChannel', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -79,14 +79,14 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/ids'). + nock(Client4.getBaseRoute()). + post('/users/ids'). reply(200, [user]); await store.dispatch(getProfilesByIds([user.id])); - nock(Client4.getChannelsRoute()). - post('/direct'). + nock(Client4.getBaseRoute()). + post('/channels/direct'). reply(201, {...TestHelper.fakeChannelWithId(), type: 'D'}); const {data: created} = await store.dispatch(Actions.createDirectChannel(TestHelper.basicUser.id, user.id)); @@ -123,8 +123,8 @@ describe('Actions.Channels', () => { }); it('createGroupChannel', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -135,8 +135,8 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -150,14 +150,14 @@ describe('Actions.Channels', () => { TestHelper.mockLogin(); await store.dispatch(login(TestHelper.basicUser.email, TestHelper.basicUser.password)); - nock(Client4.getUsersRoute()). - post('/ids'). + nock(Client4.getBaseRoute()). + post('/users/ids'). reply(200, [user, user2]); await store.dispatch(getProfilesByIds([user.id, user2.id])); - nock(Client4.getChannelsRoute()). - post('/group'). + nock(Client4.getBaseRoute()). + post('/channels/group'). reply(201, {...TestHelper.fakeChannelWithId(), type: 'G'}); const result = await store.dispatch(Actions.createGroupChannel([TestHelper.basicUser.id, user.id, user2.id])); @@ -197,8 +197,8 @@ describe('Actions.Channels', () => { header: 'MM with Redux', }; - nock(Client4.getChannelsRoute()). - put(`/${channel.id}`). + nock(Client4.getBaseRoute()). + put(`/channels/${channel.id}`). reply(200, channel); await store.dispatch(Actions.updateChannel(channel)); @@ -220,8 +220,8 @@ describe('Actions.Channels', () => { header: 'MM with Redux2', }; - nock(Client4.getChannelsRoute()). - put(`/${TestHelper.basicChannel.id}/patch`). + nock(Client4.getBaseRoute()). + put(`/channels/${TestHelper.basicChannel.id}/patch`). reply(200, {...TestHelper.basicChannel, ...channel}); await store.dispatch(Actions.patchChannel(TestHelper.basicChannel.id, channel)); @@ -283,8 +283,8 @@ describe('Actions.Channels', () => { }); it('getChannel', async () => { - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}`). reply(200, TestHelper.basicChannel); await store.dispatch(Actions.getChannel(TestHelper.basicChannel.id)); @@ -305,12 +305,12 @@ describe('Actions.Channels', () => { }); it('getChannelAndMyMember', async () => { - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}`). reply(200, TestHelper.basicChannel); - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}/members/me`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}/members/me`). reply(200, TestHelper.basicChannelMember); await store.dispatch(Actions.getChannelAndMyMember(TestHelper.basicChannel.id)); @@ -321,8 +321,8 @@ describe('Actions.Channels', () => { }); it('fetchMyChannelsAndMembers', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -333,18 +333,18 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getChannelsRoute()). - post('/direct'). + nock(Client4.getBaseRoute()). + post('/channels/direct'). reply(201, {...TestHelper.fakeChannelWithId(), team_id: '', type: 'D'}); const {data: directChannel} = await store.dispatch(Actions.createDirectChannel(TestHelper.basicUser.id, user.id)); - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels`). reply(200, [directChannel, TestHelper.basicChannel]); - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels/members`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels/members`). reply(200, [{user_id: TestHelper.basicUser.id, roles: 'channel_user', channel_id: directChannel.id}, TestHelper.basicChannelMember]); await store.dispatch(Actions.fetchMyChannelsAndMembers(TestHelper.basicTeam.id)); @@ -364,18 +364,18 @@ describe('Actions.Channels', () => { desktop: 'none', }; - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels`). reply(200, [TestHelper.basicChannel]); - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels/members`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels/members`). reply(200, [TestHelper.basicChannelMember]); await store.dispatch(Actions.fetchMyChannelsAndMembers(TestHelper.basicTeam.id)); - nock(Client4.getChannelsRoute()). - put(`/${TestHelper.basicChannel.id}/members/${TestHelper.basicUser.id}/notify_props`). + nock(Client4.getBaseRoute()). + put(`/channels/${TestHelper.basicChannel.id}/members/${TestHelper.basicUser.id}/notify_props`). reply(200, OK_RESPONSE); await store.dispatch(Actions.updateChannelNotifyProps( @@ -393,8 +393,8 @@ describe('Actions.Channels', () => { it('deleteChannel', async () => { const secondClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -405,19 +405,19 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await secondClient.login(user.email, 'password1'); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const secondChannel = await secondClient.createChannel( TestHelper.fakeChannel(TestHelper.basicTeam.id)); - nock(Client4.getChannelsRoute()). - post(`/${secondChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${secondChannel.id}/members`). reply(201, {user_id: TestHelper.basicUser.id, roles: 'channel_user', channel_id: secondChannel.id}); await store.dispatch(Actions.joinChannel( @@ -426,18 +426,18 @@ describe('Actions.Channels', () => { secondChannel.id )); - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels`). reply(200, [secondChannel, TestHelper.basicChannel]); - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels/members`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels/members`). reply(200, [{user_id: TestHelper.basicUser.id, roles: 'channel_user', channel_id: secondChannel.id}, TestHelper.basicChannelMember]); await store.dispatch(Actions.fetchMyChannelsAndMembers(TestHelper.basicTeam.id)); - nock(Client4.getIncomingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/incoming'). reply(201, { id: TestHelper.generateId(), create_at: 1507840900004, @@ -451,8 +451,8 @@ describe('Actions.Channels', () => { }); const incomingHook = await store.dispatch(createIncomingHook({channel_id: secondChannel.id, display_name: 'test', description: 'test'})); - nock(Client4.getOutgoingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/outgoing'). reply(201, { id: TestHelper.generateId(), token: TestHelper.generateId(), @@ -477,8 +477,8 @@ describe('Actions.Channels', () => { callback_urls: ['http://notarealurl']} )); - nock(Client4.getChannelsRoute()). - delete(`/${secondChannel.id}`). + nock(Client4.getBaseRoute()). + delete(`/channels/${secondChannel.id}`). reply(200, OK_RESPONSE); await store.dispatch(Actions.deleteChannel(secondChannel.id)); @@ -492,8 +492,8 @@ describe('Actions.Channels', () => { it('unarchiveChannel', async () => { const secondClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -504,19 +504,19 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await secondClient.login(user.email, 'password1'); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const secondChannel = await secondClient.createChannel( TestHelper.fakeChannel(TestHelper.basicTeam.id)); - nock(Client4.getChannelsRoute()). - post(`/${secondChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${secondChannel.id}/members`). reply(201, {user_id: TestHelper.basicUser.id, roles: 'channel_user', channel_id: secondChannel.id}); await store.dispatch(Actions.joinChannel( @@ -525,18 +525,18 @@ describe('Actions.Channels', () => { secondChannel.id )); - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels`). reply(200, [secondChannel, TestHelper.basicChannel]); - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels/members`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels/members`). reply(200, [{user_id: TestHelper.basicUser.id, roles: 'channel_user', channel_id: secondChannel.id}, TestHelper.basicChannelMember]); await store.dispatch(Actions.fetchMyChannelsAndMembers(TestHelper.basicTeam.id)); - nock(Client4.getIncomingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/incoming'). reply(201, { id: TestHelper.generateId(), create_at: 1507840900004, @@ -550,8 +550,8 @@ describe('Actions.Channels', () => { }); const incomingHook = await store.dispatch(createIncomingHook({channel_id: secondChannel.id, display_name: 'test', description: 'test'})); - nock(Client4.getOutgoingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/outgoing'). reply(201, { id: TestHelper.generateId(), token: TestHelper.generateId(), @@ -576,8 +576,8 @@ describe('Actions.Channels', () => { callback_urls: ['http://notarealurl']} )); - nock(Client4.getChannelsRoute()). - delete(`/${secondChannel.id}`). + nock(Client4.getBaseRoute()). + delete(`/channels/${secondChannel.id}`). reply(200, OK_RESPONSE); await store.dispatch(Actions.unarchiveChannel(secondChannel.id)); @@ -617,8 +617,8 @@ describe('Actions.Channels', () => { }, }); - nock(Client4.getChannelsRoute()). - post('/members/me/view', {channel_id: channelId, prev_channel_id: prevChannelId}). + nock(Client4.getBaseRoute()). + post('/channels/members/me/view', {channel_id: channelId, prev_channel_id: prevChannelId}). reply(200, OK_RESPONSE); const now = Date.now(); @@ -656,8 +656,8 @@ describe('Actions.Channels', () => { }, }); - nock(Client4.getChannelsRoute()). - post('/members/me/view', {channel_id: channelId, prev_channel_id: ''}). + nock(Client4.getBaseRoute()). + post('/channels/members/me/view', {channel_id: channelId, prev_channel_id: ''}). reply(200, OK_RESPONSE); const result = await store.dispatch(Actions.viewChannel(channelId)); @@ -698,8 +698,8 @@ describe('Actions.Channels', () => { }, }); - nock(Client4.getChannelsRoute()). - post('/members/me/view', {channel_id: channelId, prev_channel_id: ''}). + nock(Client4.getBaseRoute()). + post('/channels/members/me/view', {channel_id: channelId, prev_channel_id: ''}). reply(200, OK_RESPONSE); const now = Date.now(); @@ -714,20 +714,20 @@ describe('Actions.Channels', () => { }); it('markChannelAsViewed', async () => { - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const userChannel = await Client4.createChannel( TestHelper.fakeChannel(TestHelper.basicTeam.id) ); - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels`). reply(200, [userChannel, TestHelper.basicChannel]); - nock(Client4.getUsersRoute()). - get(`/me/teams/${TestHelper.basicTeam.id}/channels/members`). + nock(Client4.getBaseRoute()). + get(`/users/me/teams/${TestHelper.basicTeam.id}/channels/members`). reply(200, [{user_id: TestHelper.basicUser.id, roles: 'channel_user', channel_id: userChannel.id}, TestHelper.basicChannelMember]); await store.dispatch(Actions.fetchMyChannelsAndMembers(TestHelper.basicTeam.id)); @@ -1406,8 +1406,8 @@ describe('Actions.Channels', () => { it('getChannels', async () => { const userClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -1418,14 +1418,14 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await userClient.login(user.email, 'password1'); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const userChannel = await userClient.createChannel( @@ -1457,8 +1457,8 @@ describe('Actions.Channels', () => { it('getArchivedChannels', async () => { const userClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -1469,14 +1469,14 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await userClient.login(user.email, 'password1'); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const userChannel = await userClient.createChannel( @@ -1508,8 +1508,8 @@ describe('Actions.Channels', () => { it('getAllChannels', async () => { const userClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -1520,22 +1520,22 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await userClient.login(user.email, 'password1'); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const userChannel = await userClient.createChannel( TestHelper.fakeChannel(TestHelper.basicTeam.id) ); - nock(Client4.getChannelsRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/channels'). query(true). reply(200, [TestHelper.basicChannel, userChannel]); @@ -1552,8 +1552,8 @@ describe('Actions.Channels', () => { it('getAllChannelsWithCount', async () => { const userClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -1564,14 +1564,14 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await userClient.login(user.email, 'password1'); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const userChannel = await userClient.createChannel( @@ -1579,8 +1579,8 @@ describe('Actions.Channels', () => { ); const mockTotalCount = 84; - nock(Client4.getChannelsRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/channels'). query(true). reply(200, {channels: [TestHelper.basicChannel, userChannel], total_count: mockTotalCount}); @@ -1602,8 +1602,8 @@ describe('Actions.Channels', () => { it('searchAllChannels', async () => { const userClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -1614,22 +1614,22 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await userClient.login(user.email, 'password1'); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const userChannel = await userClient.createChannel( TestHelper.fakeChannel(TestHelper.basicTeam.id) ); - nock(Client4.getChannelsRoute()). - post('/search'). + nock(Client4.getBaseRoute()). + post('/channels/search'). reply(200, [TestHelper.basicChannel, userChannel]); const {data} = await store.dispatch(Actions.searchAllChannels('test', 0)); @@ -1639,8 +1639,8 @@ describe('Actions.Channels', () => { throw new Error(JSON.stringify(moreRequest.error)); } - nock(Client4.getChannelsRoute()). - post('/search'). + nock(Client4.getBaseRoute()). + post('/channels/search'). reply(200, {channels: [TestHelper.basicChannel, userChannel], total_count: 2}); const response = await store.dispatch(Actions.searchAllChannels('test', '', false, 0, 100)); @@ -1656,8 +1656,8 @@ describe('Actions.Channels', () => { it('searchArchivedChannels', async () => { const userClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -1668,14 +1668,14 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await userClient.login(user.email, 'password1'); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const userChannel = await userClient.createChannel( @@ -1697,8 +1697,8 @@ describe('Actions.Channels', () => { }); it('getChannelMembers', async () => { - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}/members`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}/members`). query(true). reply(200, [TestHelper.basicChannelMember]); @@ -1712,8 +1712,8 @@ describe('Actions.Channels', () => { }); it('getChannelMember', async () => { - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}/members/${TestHelper.basicUser.id}`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}/members/${TestHelper.basicUser.id}`). reply(200, TestHelper.basicChannelMember); await store.dispatch(Actions.getChannelMember(TestHelper.basicChannel.id, TestHelper.basicUser.id)); @@ -1726,8 +1726,8 @@ describe('Actions.Channels', () => { }); it('getMyChannelMember', async () => { - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}/members/me`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}/members/me`). reply(200, TestHelper.basicChannelMember); await store.dispatch(Actions.getMyChannelMember(TestHelper.basicChannel.id)); @@ -1739,8 +1739,8 @@ describe('Actions.Channels', () => { }); it('getChannelMembersByIds', async () => { - nock(Client4.getChannelsRoute()). - post(`/${TestHelper.basicChannel.id}/members/ids`). + nock(Client4.getBaseRoute()). + post(`/channels/${TestHelper.basicChannel.id}/members/ids`). reply(200, [TestHelper.basicChannelMember]); await store.dispatch(Actions.getChannelMembersByIds(TestHelper.basicChannel.id, [TestHelper.basicUser.id])); @@ -1753,8 +1753,8 @@ describe('Actions.Channels', () => { }); it('getChannelStats', async () => { - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}/stats`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}/stats`). reply(200, {channel_id: TestHelper.basicChannel.id, member_count: 1}); await store.dispatch(Actions.getChannelStats(TestHelper.basicChannel.id)); @@ -1768,8 +1768,8 @@ describe('Actions.Channels', () => { it('addChannelMember', async () => { const channelId = TestHelper.basicChannel.id; - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -1780,14 +1780,14 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getChannelsRoute()). - post(`/${TestHelper.basicChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${TestHelper.basicChannel.id}/members`). reply(201, {channel_id: TestHelper.basicChannel.id, roles: 'channel_user', user_id: TestHelper.basicUser.id}); await store.dispatch(Actions.joinChannel(TestHelper.basicUser.id, TestHelper.basicTeam.id, channelId)); - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}/stats`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}/stats`). reply(200, {channel_id: TestHelper.basicChannel.id, member_count: 1}); await store.dispatch(Actions.getChannelStats(channelId)); @@ -1799,8 +1799,8 @@ describe('Actions.Channels', () => { assert.ok(stats[channelId].member_count, 'member count for channel'); assert.ok(stats[channelId].member_count >= 1, 'incorrect member count for channel'); - nock(Client4.getChannelsRoute()). - post(`/${TestHelper.basicChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${TestHelper.basicChannel.id}/members`). reply(201, {channel_id: TestHelper.basicChannel.id, roles: 'channel_user', user_id: user.id}); await store.dispatch(Actions.addChannelMember(channelId, user.id)); @@ -1825,8 +1825,8 @@ describe('Actions.Channels', () => { it('removeChannelMember', async () => { const channelId = TestHelper.basicChannel.id; - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -1837,20 +1837,20 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getChannelsRoute()). - post(`/${TestHelper.basicChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${TestHelper.basicChannel.id}/members`). reply(201, {channel_id: TestHelper.basicChannel.id, roles: 'channel_user', user_id: TestHelper.basicUser.id}); await store.dispatch(Actions.joinChannel(TestHelper.basicUser.id, TestHelper.basicTeam.id, channelId)); - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}/stats`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}/stats`). reply(200, {channel_id: TestHelper.basicChannel.id, member_count: 1}); await store.dispatch(Actions.getChannelStats(channelId)); - nock(Client4.getChannelsRoute()). - post(`/${TestHelper.basicChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${TestHelper.basicChannel.id}/members`). reply(201, {channel_id: TestHelper.basicChannel.id, roles: 'channel_user', user_id: user.id}); await store.dispatch(Actions.addChannelMember(channelId, user.id)); @@ -1862,8 +1862,8 @@ describe('Actions.Channels', () => { assert.ok(stats[channelId].member_count, 'member count for channel'); assert.ok(stats[channelId].member_count >= 2, 'incorrect member count for channel'); - nock(Client4.getChannelsRoute()). - delete(`/${TestHelper.basicChannel.id}/members/${user.id}`). + nock(Client4.getBaseRoute()). + delete(`/channels/${TestHelper.basicChannel.id}/members/${user.id}`). reply(200, OK_RESPONSE); await store.dispatch(Actions.removeChannelMember(channelId, user.id)); @@ -1886,8 +1886,8 @@ describe('Actions.Channels', () => { }); it('updateChannelMemberRoles', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); @@ -1897,16 +1897,16 @@ describe('Actions.Channels', () => { reply(201, {team_id: TestHelper.basicTeam.id, roles: 'channel_user', user_id: user.id}); await store.dispatch(addUserToTeam(TestHelper.basicTeam.id, user.id)); - nock(Client4.getChannelsRoute()). - post(`/${TestHelper.basicChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${TestHelper.basicChannel.id}/members`). reply(201, {channel_id: TestHelper.basicChannel.id, roles: 'channel_user', user_id: user.id}); await store.dispatch(Actions.addChannelMember(TestHelper.basicChannel.id, user.id)); const roles = General.CHANNEL_USER_ROLE + ' ' + General.CHANNEL_ADMIN_ROLE; - nock(Client4.getChannelsRoute()). - put(`/${TestHelper.basicChannel.id}/members/${user.id}/roles`). + nock(Client4.getBaseRoute()). + put(`/channels/${TestHelper.basicChannel.id}/members/${user.id}/roles`). reply(200, {roles}); await store.dispatch(Actions.updateChannelMemberRoles(TestHelper.basicChannel.id, user.id, roles)); @@ -1918,8 +1918,8 @@ describe('Actions.Channels', () => { }); it('updateChannelHeader', async () => { - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}`). reply(200, TestHelper.basicChannel); await store.dispatch(Actions.getChannel(TestHelper.basicChannel.id)); @@ -1935,8 +1935,8 @@ describe('Actions.Channels', () => { }); it('updateChannelPurpose', async () => { - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}`). reply(200, TestHelper.basicChannel); await store.dispatch(Actions.getChannel(TestHelper.basicChannel.id)); @@ -1953,12 +1953,12 @@ describe('Actions.Channels', () => { async function test() { TestHelper.mockLogin(); await store.dispatch(login(TestHelper.basicUser.email, 'password1')); - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}`). reply(200, TestHelper.basicChannel); - nock(Client4.getChannelsRoute()). - post(`/${TestHelper.basicChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${TestHelper.basicChannel.id}/members`). reply(201, {channel_id: TestHelper.basicChannel.id, roles: 'channel_user', user_id: TestHelper.basicUser.id}); await store.dispatch(Actions.joinChannel(TestHelper.basicUser.id, TestHelper.basicTeam.id, TestHelper.basicChannel.id)); @@ -1967,12 +1967,12 @@ describe('Actions.Channels', () => { assert.ok(channels[TestHelper.basicChannel.id]); assert.ok(myMembers[TestHelper.basicChannel.id]); - nock(Client4.getChannelMemberRoute(TestHelper.basicChannel.id, TestHelper.basicUser.id)). - delete(''). + nock(Client4.getBaseRoute()). + delete(`/channels/${TestHelper.basicChannel.id}/members/${TestHelper.basicUser.id}`). reply(400, {}); - nock(Client4.getChannelMemberRoute(TestHelper.basicChannel.id, TestHelper.basicUser.id)). - delete(''). + nock(Client4.getBaseRoute()). + delete(`/channels/${TestHelper.basicChannel.id}/members/${TestHelper.basicUser.id}`). reply(200, OK_RESPONSE); // This action will retry after 1000ms @@ -2003,16 +2003,16 @@ describe('Actions.Channels', () => { type: 'P', }; - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, {...TestHelper.fakeChannelWithId(TestHelper.basicTeam.id), ...newChannel}); const {data: channel} = await store.dispatch(Actions.createChannel(newChannel, TestHelper.basicUser.id)); let channels = store.getState().entities.channels.channels; assert.ok(channels[channel.id]); - nock(Client4.getChannelsRoute()). - delete(`/${TestHelper.basicChannel.id}/members/${TestHelper.basicUser.id}`). + nock(Client4.getBaseRoute()). + delete(`/channels/${TestHelper.basicChannel.id}/members/${TestHelper.basicUser.id}`). reply(200, OK_RESPONSE); await store.dispatch(Actions.leaveChannel(channel.id)); @@ -2023,12 +2023,12 @@ describe('Actions.Channels', () => { }); it('joinChannel', async () => { - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}`). reply(200, TestHelper.basicChannel); - nock(Client4.getChannelsRoute()). - post(`/${TestHelper.basicChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${TestHelper.basicChannel.id}/members`). reply(201, {channel_id: TestHelper.basicChannel.id, roles: 'channel_user', user_id: TestHelper.basicUser.id}); await store.dispatch(Actions.joinChannel(TestHelper.basicUser.id, TestHelper.basicTeam.id, TestHelper.basicChannel.id)); @@ -2041,8 +2041,8 @@ describe('Actions.Channels', () => { it('joinChannelByName', async () => { const secondClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -2053,14 +2053,14 @@ describe('Actions.Channels', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await secondClient.login(user.email, 'password1'); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const secondChannel = await secondClient.createChannel( @@ -2070,8 +2070,8 @@ describe('Actions.Channels', () => { get(`/${TestHelper.basicTeam.id}/channels/name/${secondChannel.name}?include_deleted=true`). reply(200, secondChannel); - nock(Client4.getChannelsRoute()). - post(`/${secondChannel.id}/members`). + nock(Client4.getBaseRoute()). + post(`/channels/${secondChannel.id}/members`). reply(201, {channel_id: secondChannel.id, roles: 'channel_user', user_id: TestHelper.basicUser.id}); await store.dispatch(Actions.joinChannel( @@ -2087,8 +2087,8 @@ describe('Actions.Channels', () => { }); it('favoriteChannel', async () => { - nock(Client4.getUsersRoute()). - put(`/${TestHelper.basicUser.id}/preferences`). + nock(Client4.getBaseRoute()). + put(`/users/${TestHelper.basicUser.id}/preferences`). reply(200, OK_RESPONSE); await store.dispatch(Actions.favoriteChannel(TestHelper.basicChannel.id)); @@ -2101,8 +2101,8 @@ describe('Actions.Channels', () => { }); it('unfavoriteChannel', async () => { - nock(Client4.getUsersRoute()). - put(`/${TestHelper.basicUser.id}/preferences`). + nock(Client4.getBaseRoute()). + put(`/users/${TestHelper.basicUser.id}/preferences`). reply(200, OK_RESPONSE); await store.dispatch(Actions.favoriteChannel(TestHelper.basicChannel.id)); @@ -2113,8 +2113,8 @@ describe('Actions.Channels', () => { assert.ok(preference); assert.ok(preference.value === 'true'); - nock(Client4.getUsersRoute()). - delete(`/${TestHelper.basicUser.id}/preferences`). + nock(Client4.getBaseRoute()). + delete(`/users/${TestHelper.basicUser.id}/preferences`). reply(200, OK_RESPONSE); store.dispatch(Actions.unfavoriteChannel(TestHelper.basicChannel.id)); @@ -2160,8 +2160,8 @@ describe('Actions.Channels', () => { TestHelper.mockLogin(); await store.dispatch(login(TestHelper.basicChannelMember.email, 'password1')); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); await store.dispatch(Actions.createChannel(TestHelper.fakeChannel(TestHelper.basicTeam.id), TestHelper.basicUser.id)); @@ -2176,8 +2176,8 @@ describe('Actions.Channels', () => { const schemeId = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'; const {id} = channels[Object.keys(channels)[0]]; - nock(Client4.getChannelsRoute()). - put('/' + id + '/scheme'). + nock(Client4.getBaseRoute()). + put('/channels/' + id + '/scheme'). reply(200, OK_RESPONSE); await store.dispatch(Actions.updateChannelScheme(id, schemeId)); @@ -2190,8 +2190,8 @@ describe('Actions.Channels', () => { TestHelper.mockLogin(); await store.dispatch(login(TestHelper.basicChannelMember.email, 'password1')); - nock(Client4.getChannelsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/channels'). reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam.id)); const userId = TestHelper.basicChannelMember.id; @@ -2201,8 +2201,8 @@ describe('Actions.Channels', () => { const {channels} = store.getState().entities.channels; const channelId = channels[Object.keys(channels)[0]].id; - nock(Client4.getChannelsRoute()). - put(`/${channelId}/members/${userId}/schemeRoles`). + nock(Client4.getBaseRoute()). + put(`/channels/${channelId}/members/${userId}/schemeRoles`). reply(200, OK_RESPONSE); await store.dispatch(Actions.updateChannelMemberSchemeRoles(channelId, userId, true, true)); @@ -2211,8 +2211,8 @@ describe('Actions.Channels', () => { assert.equal(update1.scheme_admin, true); assert.equal(update1.scheme_user, true); - nock(Client4.getChannelsRoute()). - put(`/${channelId}/members/${userId}/schemeRoles`). + nock(Client4.getBaseRoute()). + put(`/channels/${channelId}/members/${userId}/schemeRoles`). reply(200, OK_RESPONSE); await store.dispatch(Actions.updateChannelMemberSchemeRoles(channelId, userId, false, false)); @@ -2227,8 +2227,8 @@ describe('Actions.Channels', () => { const channelId = TestHelper.generateId(); const now = new Date().getTime(); - nock(Client4.getUsersRoute()). - put(`/${TestHelper.basicUser.id}/preferences`). + nock(Client4.getBaseRoute()). + put(`/users/${TestHelper.basicUser.id}/preferences`). reply(200, OK_RESPONSE); await Actions.markGroupChannelOpen(channelId)(store.dispatch, store.getState); @@ -2254,8 +2254,8 @@ describe('Actions.Channels', () => { automaticTimezone: 'xoxoxo/blablabla', }; - nock(Client4.getChannelsRoute()). - get(`/${TestHelper.basicChannel.id}/timezones`). + nock(Client4.getBaseRoute()). + get(`/channels/${TestHelper.basicChannel.id}/timezones`). query(true). reply(200, response); diff --git a/src/actions/emojis.test.js b/src/actions/emojis.test.js index 6de2ea6cf..207d497ab 100644 --- a/src/actions/emojis.test.js +++ b/src/actions/emojis.test.js @@ -31,8 +31,8 @@ describe('Actions.Emojis', () => { it('createCustomEmoji', async () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await Actions.createCustomEmoji( @@ -53,8 +53,8 @@ describe('Actions.Emojis', () => { it('getCustomEmojis', async () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await Actions.createCustomEmoji( @@ -65,8 +65,8 @@ describe('Actions.Emojis', () => { testImageData )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/emoji'). query(true). reply(200, [created]); @@ -82,8 +82,8 @@ describe('Actions.Emojis', () => { it('getAllCustomEmojis', async () => { store.dispatch({type: GeneralTypes.RECEIVED_SERVER_VERSION, data: '4.0.0'}); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created1} = await Actions.createCustomEmoji( { @@ -93,8 +93,8 @@ describe('Actions.Emojis', () => { fs.createReadStream('test/assets/images/test.png') )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created2} = await Actions.createCustomEmoji( { @@ -104,18 +104,18 @@ describe('Actions.Emojis', () => { fs.createReadStream('test/assets/images/test.png') )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/emoji'). query(true). reply(200, [created1]); - nock(Client4.getEmojisRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/emoji'). query(true). reply(200, [created2]); - nock(Client4.getEmojisRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/emoji'). query(true). reply(200, []); await Actions.getAllCustomEmojis(1)(store.dispatch, store.getState); @@ -127,20 +127,20 @@ describe('Actions.Emojis', () => { assert.ok(emojis[created1.id]); assert.ok(emojis[created2.id]); - nock(Client4.getEmojisRoute()). - delete(`/${created2.id}`). + nock(Client4.getBaseRoute()). + delete(`/emoji/${created2.id}`). reply(200, OK_RESPONSE); // Should have all emojis minus the deleted one await Client4.deleteCustomEmoji(created2.id); - nock(Client4.getEmojisRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/emoji'). query(true). reply(200, [created1]); - nock(Client4.getEmojisRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/emoji'). query(true). reply(200, []); await Actions.getAllCustomEmojis(1)(store.dispatch, store.getState); @@ -152,8 +152,8 @@ describe('Actions.Emojis', () => { assert.ok(emojis[created1.id]); assert.ok(!emojis[created2.id]); - nock(Client4.getEmojisRoute()). - delete(`/${created1.id}`). + nock(Client4.getBaseRoute()). + delete(`/emoji/${created1.id}`). reply(200, OK_RESPONSE); // Cleanup @@ -163,8 +163,8 @@ describe('Actions.Emojis', () => { it('deleteCustomEmoji', async () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await Actions.createCustomEmoji( { @@ -174,8 +174,8 @@ describe('Actions.Emojis', () => { testImageData )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - delete(`/${created.id}`). + nock(Client4.getBaseRoute()). + delete(`/emoji/${created.id}`). reply(200, OK_RESPONSE); await Actions.deleteCustomEmoji(created.id)(store.dispatch, store.getState); @@ -224,8 +224,8 @@ describe('Actions.Emojis', () => { it('searchCustomEmojis', async () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await Actions.createCustomEmoji( @@ -236,8 +236,8 @@ describe('Actions.Emojis', () => { testImageData )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - post('/search'). + nock(Client4.getBaseRoute()). + post('/emoji/search'). reply(200, [created]); await Actions.searchCustomEmojis(created.name, {prefix_only: true})(store.dispatch, store.getState); @@ -252,8 +252,8 @@ describe('Actions.Emojis', () => { it('autocompleteCustomEmojis', async () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await Actions.createCustomEmoji( @@ -264,8 +264,8 @@ describe('Actions.Emojis', () => { testImageData )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - get('/autocomplete'). + nock(Client4.getBaseRoute()). + get('/emoji/autocomplete'). query(true). reply(200, [created]); @@ -281,8 +281,8 @@ describe('Actions.Emojis', () => { it('getCustomEmoji', async () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await Actions.createCustomEmoji( @@ -293,8 +293,8 @@ describe('Actions.Emojis', () => { testImageData )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - get(`/${created.id}`). + nock(Client4.getBaseRoute()). + get(`/emoji/${created.id}`). reply(200, created); await Actions.getCustomEmoji(created.id)(store.dispatch, store.getState); @@ -309,8 +309,8 @@ describe('Actions.Emojis', () => { it('getCustomEmojiByName', async () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await Actions.createCustomEmoji( @@ -321,8 +321,8 @@ describe('Actions.Emojis', () => { testImageData )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - get(`/name/${created.name}`). + nock(Client4.getBaseRoute()). + get(`/emoji/name/${created.name}`). reply(200, created); await Actions.getCustomEmojiByName(created.name)(store.dispatch, store.getState); @@ -335,8 +335,8 @@ describe('Actions.Emojis', () => { const missingName = TestHelper.generateId(); - nock(Client4.getEmojisRoute()). - get(`/name/${missingName}`). + nock(Client4.getBaseRoute()). + get(`/emoji/name/${missingName}`). reply(404, {message: 'Not found', status_code: 404}); await Actions.getCustomEmojiByName(missingName)(store.dispatch, store.getState); @@ -348,8 +348,8 @@ describe('Actions.Emojis', () => { it('getCustomEmojisByName', async () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await Actions.createCustomEmoji( @@ -360,14 +360,14 @@ describe('Actions.Emojis', () => { testImageData )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - get(`/name/${created.name}`). + nock(Client4.getBaseRoute()). + get(`/emoji/name/${created.name}`). reply(200, created); const missingName = TestHelper.generateId(); - nock(Client4.getEmojisRoute()). - get(`/name/${missingName}`). + nock(Client4.getBaseRoute()). + get(`/emoji/name/${missingName}`). reply(404, {message: 'Not found', status_code: 404}); await Actions.getCustomEmojisByName([created.name, missingName])(store.dispatch, store.getState); @@ -380,8 +380,8 @@ describe('Actions.Emojis', () => { it('getCustomEmojisInText', async () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await Actions.createCustomEmoji( @@ -392,14 +392,14 @@ describe('Actions.Emojis', () => { testImageData )(store.dispatch, store.getState); - nock(Client4.getEmojisRoute()). - get(`/name/${created.name}`). + nock(Client4.getBaseRoute()). + get(`/emoji/name/${created.name}`). reply(200, created); const missingName = TestHelper.generateId(); - nock(Client4.getEmojisRoute()). - get(`/name/${missingName}`). + nock(Client4.getBaseRoute()). + get(`/emoji/name/${missingName}`). reply(404, {message: 'Not found', status_code: 404}); await Actions.getCustomEmojisInText(`some text :${created.name}: :${missingName}:`)(store.dispatch, store.getState); diff --git a/src/actions/files.test.js b/src/actions/files.test.js index 680218ba5..117923815 100644 --- a/src/actions/files.test.js +++ b/src/actions/files.test.js @@ -39,8 +39,8 @@ describe('Actions.Files', () => { imageFormData.append('client_ids', clientId); const formBoundary = imageFormData.getBoundary(); - nock(Client4.getFilesRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/files'). reply(201, {file_infos: [{id: TestHelper.generateId(), user_id: TestHelper.basicUser.id, create_at: 1507921547541, update_at: 1507921547541, delete_at: 0, name: 'test.png', extension: 'png', size: 258428, mime_type: 'image/png', width: 600, height: 600, has_preview_image: true}], client_ids: [TestHelper.generateId()]}); await Actions.uploadFile(basicChannel.id, null, [clientId], imageFormData, formBoundary)(store.dispatch, store.getState); @@ -68,8 +68,8 @@ describe('Actions.Files', () => { imageFormData.append('client_ids', clientId); const formBoundary = imageFormData.getBoundary(); - nock(Client4.getFilesRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/files'). reply(201, {file_infos: [{id: TestHelper.generateId(), user_id: TestHelper.basicUser.id, create_at: 1507921547541, update_at: 1507921547541, delete_at: 0, name: 'test.png', extension: 'png', size: 258428, mime_type: 'image/png', width: 600, height: 600, has_preview_image: true}], client_ids: [TestHelper.generateId()]}); const fileUploadResp = await basicClient4. @@ -79,13 +79,13 @@ describe('Actions.Files', () => { const fakePostForFile = TestHelper.fakePost(basicChannel.id); fakePostForFile.file_ids = [fileId]; - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, {...TestHelper.fakePostWithId(), ...fakePostForFile}); const postForFile = await basicClient4.createPost(fakePostForFile); - nock(Client4.getPostsRoute()). - get(`/${postForFile.id}/files/info`). + nock(Client4.getBaseRoute()). + get(`/posts/${postForFile.id}/files/info`). reply(200, [{id: fileId, user_id: TestHelper.basicUser.id, create_at: 1507921547541, update_at: 1507921547541, delete_at: 0, name: 'test.png', extension: 'png', size: 258428, mime_type: 'image/png', width: 600, height: 600, has_preview_image: true}]); await Actions.getFilesForPost(postForFile.id)(store.dispatch, store.getState); diff --git a/src/actions/integrations.test.js b/src/actions/integrations.test.js index 1dd381f68..71fa13d4c 100644 --- a/src/actions/integrations.test.js +++ b/src/actions/integrations.test.js @@ -28,8 +28,8 @@ describe('Actions.Integrations', () => { }); it('createIncomingHook', async () => { - nock(Client4.getIncomingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/incoming'). reply(201, TestHelper.testIncomingHook()); const {data: created} = await Actions.createIncomingHook( @@ -48,8 +48,8 @@ describe('Actions.Integrations', () => { }); it('getIncomingWebhook', async () => { - nock(Client4.getIncomingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/incoming'). reply(201, TestHelper.testIncomingHook()); const {data: created} = await Actions.createIncomingHook( @@ -60,8 +60,8 @@ describe('Actions.Integrations', () => { }, )(store.dispatch, store.getState); - nock(Client4.getIncomingHooksRoute()). - get(`/${created.id}`). + nock(Client4.getBaseRoute()). + get(`/hooks/incoming/${created.id}`). reply(200, created); await Actions.getIncomingHook(created.id)(store.dispatch, store.getState); @@ -74,8 +74,8 @@ describe('Actions.Integrations', () => { }); it('getIncomingWebhooks', async () => { - nock(Client4.getIncomingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/incoming'). reply(201, TestHelper.testIncomingHook()); const {data: created} = await Actions.createIncomingHook( @@ -86,8 +86,8 @@ describe('Actions.Integrations', () => { }, )(store.dispatch, store.getState); - nock(Client4.getIncomingHooksRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/hooks/incoming'). query(true). reply(200, [created]); @@ -101,8 +101,8 @@ describe('Actions.Integrations', () => { }); it('removeIncomingHook', async () => { - nock(Client4.getIncomingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/incoming'). reply(201, TestHelper.testIncomingHook()); const {data: created} = await Actions.createIncomingHook( @@ -113,8 +113,8 @@ describe('Actions.Integrations', () => { }, )(store.dispatch, store.getState); - nock(Client4.getIncomingHooksRoute()). - delete(`/${created.id}`). + nock(Client4.getBaseRoute()). + delete(`/hooks/incoming/${created.id}`). reply(200, OK_RESPONSE); await Actions.removeIncomingHook(created.id)(store.dispatch, store.getState); @@ -126,8 +126,8 @@ describe('Actions.Integrations', () => { }); it('updateIncomingHook', async () => { - nock(Client4.getIncomingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/incoming'). reply(201, TestHelper.testIncomingHook()); const {data: created} = await Actions.createIncomingHook( @@ -141,8 +141,8 @@ describe('Actions.Integrations', () => { const updated = {...created}; updated.display_name = 'test2'; - nock(Client4.getIncomingHooksRoute()). - put(`/${created.id}`). + nock(Client4.getBaseRoute()). + put(`/hooks/incoming/${created.id}`). reply(200, updated); await Actions.updateIncomingHook(updated)(store.dispatch, store.getState); @@ -154,8 +154,8 @@ describe('Actions.Integrations', () => { }); it('createOutgoingHook', async () => { - nock(Client4.getOutgoingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/outgoing'). reply(201, TestHelper.testOutgoingHook()); const {data: created} = await Actions.createOutgoingHook( @@ -176,8 +176,8 @@ describe('Actions.Integrations', () => { }); it('getOutgoingWebhook', async () => { - nock(Client4.getOutgoingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/outgoing'). reply(201, TestHelper.testOutgoingHook()); const {data: created} = await Actions.createOutgoingHook( @@ -190,8 +190,8 @@ describe('Actions.Integrations', () => { }, )(store.dispatch, store.getState); - nock(Client4.getOutgoingHooksRoute()). - get(`/${created.id}`). + nock(Client4.getBaseRoute()). + get(`/hooks/outgoing/${created.id}`). reply(200, TestHelper.testOutgoingHook()); await Actions.getOutgoingHook(created.id)(store.dispatch, store.getState); @@ -204,8 +204,8 @@ describe('Actions.Integrations', () => { }); it('getOutgoingWebhooks', async () => { - nock(Client4.getOutgoingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/outgoing'). reply(201, TestHelper.testOutgoingHook()); const {data: created} = await Actions.createOutgoingHook( @@ -218,8 +218,8 @@ describe('Actions.Integrations', () => { }, )(store.dispatch, store.getState); - nock(Client4.getOutgoingHooksRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/hooks/outgoing'). query(true). reply(200, [TestHelper.testOutgoingHook()]); @@ -233,8 +233,8 @@ describe('Actions.Integrations', () => { }); it('removeOutgoingHook', async () => { - nock(Client4.getOutgoingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/outgoing'). reply(201, TestHelper.testOutgoingHook()); const {data: created} = await Actions.createOutgoingHook( @@ -247,8 +247,8 @@ describe('Actions.Integrations', () => { }, )(store.dispatch, store.getState); - nock(Client4.getOutgoingHooksRoute()). - delete(`/${created.id}`). + nock(Client4.getBaseRoute()). + delete(`/hooks/outgoing/${created.id}`). reply(200, OK_RESPONSE); await Actions.removeOutgoingHook(created.id)(store.dispatch, store.getState); @@ -260,8 +260,8 @@ describe('Actions.Integrations', () => { }); it('updateOutgoingHook', async () => { - nock(Client4.getOutgoingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/outgoing'). reply(201, TestHelper.testOutgoingHook()); const {data: created} = await Actions.createOutgoingHook( @@ -276,8 +276,8 @@ describe('Actions.Integrations', () => { const updated = {...created}; updated.display_name = 'test2'; - nock(Client4.getOutgoingHooksRoute()). - put(`/${created.id}`). + nock(Client4.getBaseRoute()). + put(`/hooks/outgoing/${created.id}`). reply(200, updated); await Actions.updateOutgoingHook(updated)(store.dispatch, store.getState); @@ -289,8 +289,8 @@ describe('Actions.Integrations', () => { }); it('regenOutgoingHookToken', async () => { - nock(Client4.getOutgoingHooksRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/hooks/outgoing'). reply(201, TestHelper.testOutgoingHook()); const {data: created} = await Actions.createOutgoingHook( @@ -303,8 +303,8 @@ describe('Actions.Integrations', () => { }, )(store.dispatch, store.getState); - nock(Client4.getOutgoingHooksRoute()). - post(`/${created.id}/regen_token`). + nock(Client4.getBaseRoute()). + post(`/hooks/outgoing/${created.id}/regen_token`). reply(200, {...created, token: TestHelper.generateId()}); await Actions.regenOutgoingHookToken(created.id)(store.dispatch, store.getState); @@ -320,8 +320,8 @@ describe('Actions.Integrations', () => { const noSystemCommands = store.getState().entities.integrations.systemCommands; assert.equal(Object.keys({...noTeamCommands, ...noSystemCommands}).length, 0); - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const {data: team} = await TeamsActions.createTeam( @@ -330,16 +330,16 @@ describe('Actions.Integrations', () => { const teamCommand = TestHelper.testCommand(team.id); - nock(Client4.getCommandsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/commands'). reply(201, {...teamCommand, token: TestHelper.generateId(), id: TestHelper.generateId()}); const {data: created} = await Actions.addCommand( teamCommand, )(store.dispatch, store.getState); - nock(Client4.getCommandsRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/commands'). query(true). reply(200, [created, { trigger: 'system-command', @@ -359,8 +359,8 @@ describe('Actions.Integrations', () => { const noSystemCommands = store.getState().entities.integrations.systemCommands; assert.equal(Object.keys({...noTeamCommands, ...noSystemCommands}).length, 0); - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const {data: team} = await TeamsActions.createTeam( @@ -369,16 +369,16 @@ describe('Actions.Integrations', () => { const teamCommandWithAutocomplete = TestHelper.testCommand(team.id); - nock(Client4.getCommandsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/commands'). reply(201, {...teamCommandWithAutocomplete, token: TestHelper.generateId(), id: TestHelper.generateId()}); const {data: createdWithAutocomplete} = await Actions.addCommand( teamCommandWithAutocomplete, )(store.dispatch, store.getState); - nock(`${Client4.getTeamRoute(team.id)}/commands/autocomplete`). - get(''). + nock(Client4.getBaseRoute()). + get(`/teams/${team.id}/commands/autocomplete`). query(true). reply(200, [createdWithAutocomplete, { trigger: 'system-command', @@ -394,16 +394,16 @@ describe('Actions.Integrations', () => { }); it('getCustomTeamCommands', async () => { - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const {data: team} = await TeamsActions.createTeam( TestHelper.fakeTeam(), )(store.dispatch, store.getState); - nock(Client4.getCommandsRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/commands'). query(true). reply(200, []); @@ -416,16 +416,16 @@ describe('Actions.Integrations', () => { const command = TestHelper.testCommand(team.id); - nock(Client4.getCommandsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/commands'). reply(201, {...command, token: TestHelper.generateId(), id: TestHelper.generateId()}); const {data: created} = await Actions.addCommand( command, )(store.dispatch, store.getState); - nock(Client4.getCommandsRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/commands'). query(true). reply(200, []); @@ -442,8 +442,8 @@ describe('Actions.Integrations', () => { }); it('executeCommand', async () => { - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const {data: team} = await TeamsActions.createTeam( @@ -455,16 +455,16 @@ describe('Actions.Integrations', () => { team_id: team.id, }; - nock(`${Client4.getCommandsRoute()}/execute`). - post(''). + nock(Client4.getBaseRoute()). + post('/commands/execute'). reply(200, []); await Actions.executeCommand('/echo message 5', args); }); it('addCommand', async () => { - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const {data: team} = await TeamsActions.createTeam( @@ -473,8 +473,8 @@ describe('Actions.Integrations', () => { const expected = TestHelper.testCommand(team.id); - nock(Client4.getCommandsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/commands'). reply(201, {...expected, token: TestHelper.generateId(), id: TestHelper.generateId()}); const {data: created} = await Actions.addCommand(expected)(store.dispatch, store.getState); @@ -501,8 +501,8 @@ describe('Actions.Integrations', () => { }); it('regenCommandToken', async () => { - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const {data: team} = await TeamsActions.createTeam( @@ -511,16 +511,16 @@ describe('Actions.Integrations', () => { const command = TestHelper.testCommand(team.id); - nock(Client4.getCommandsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/commands'). reply(201, {...command, token: TestHelper.generateId(), id: TestHelper.generateId()}); const {data: created} = await Actions.addCommand( command, )(store.dispatch, store.getState); - nock(Client4.getCommandsRoute()). - put(`/${created.id}/regen_token`). + nock(Client4.getBaseRoute()). + put(`/commands/${created.id}/regen_token`). reply(200, {...created, token: TestHelper.generateId()}); await Actions.regenCommandToken( @@ -551,8 +551,8 @@ describe('Actions.Integrations', () => { }); it('editCommand', async () => { - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const {data: team} = await TeamsActions.createTeam( @@ -561,8 +561,8 @@ describe('Actions.Integrations', () => { const command = TestHelper.testCommand(team.id); - nock(Client4.getCommandsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/commands'). reply(201, {...command, token: TestHelper.generateId(), id: TestHelper.generateId()}); const {data: created} = await Actions.addCommand( @@ -575,8 +575,8 @@ describe('Actions.Integrations', () => { expected.username = 'modified'; expected.auto_complete = false; - nock(Client4.getCommandsRoute()). - put(`/${expected.id}`). + nock(Client4.getBaseRoute()). + put(`/commands/${expected.id}`). reply(200, {...expected, update_at: 123}); await Actions.editCommand( @@ -593,8 +593,8 @@ describe('Actions.Integrations', () => { }); it('deleteCommand', async () => { - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const {data: team} = await TeamsActions.createTeam( @@ -603,16 +603,16 @@ describe('Actions.Integrations', () => { const command = TestHelper.testCommand(team.id); - nock(Client4.getCommandsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/commands'). reply(201, {...command, token: TestHelper.generateId(), id: TestHelper.generateId()}); const {data: created} = await Actions.addCommand( command, )(store.dispatch, store.getState); - nock(Client4.getCommandsRoute()). - delete(`/${created.id}`). + nock(Client4.getBaseRoute()). + delete(`/commands/${created.id}`). reply(200, OK_RESPONSE); await Actions.deleteCommand( @@ -624,8 +624,8 @@ describe('Actions.Integrations', () => { }); it('addOAuthApp', async () => { - nock(Client4.getOAuthAppsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/oauth/apps'). reply(201, TestHelper.fakeOAuthAppWithId()); const {data: created} = await Actions.addOAuthApp(TestHelper.fakeOAuthApp())(store.dispatch, store.getState); @@ -635,14 +635,14 @@ describe('Actions.Integrations', () => { }); it('getOAuthApp', async () => { - nock(Client4.getOAuthAppsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/oauth/apps'). reply(201, TestHelper.fakeOAuthAppWithId()); const {data: created} = await Actions.addOAuthApp(TestHelper.fakeOAuthApp())(store.dispatch, store.getState); - nock(Client4.getOAuthAppsRoute()). - get(`/${created.id}`). + nock(Client4.getBaseRoute()). + get(`/oauth/apps/${created.id}`). reply(200, created); await Actions.getOAuthApp(created.id)(store.dispatch, store.getState); @@ -652,8 +652,8 @@ describe('Actions.Integrations', () => { }); it('editOAuthApp', async () => { - nock(Client4.getOAuthAppsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/oauth/apps'). reply(201, TestHelper.fakeOAuthAppWithId()); const {data: created} = await Actions.addOAuthApp(TestHelper.fakeOAuthApp())(store.dispatch, store.getState); @@ -684,14 +684,14 @@ describe('Actions.Integrations', () => { }); it('getOAuthApps', async () => { - nock(Client4.getOAuthAppsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/oauth/apps'). reply(201, TestHelper.fakeOAuthAppWithId()); const {data: created} = await Actions.addOAuthApp(TestHelper.fakeOAuthApp())(store.dispatch, store.getState); - nock(Client4.getOAuthAppsRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/oauth/apps'). query(true). reply(200, [created]); @@ -702,15 +702,15 @@ describe('Actions.Integrations', () => { }); it('getAuthorizedOAuthApps', async () => { - nock(Client4.getOAuthAppsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/oauth/apps'). reply(201, TestHelper.fakeOAuthAppWithId()); const {data: created} = await Actions.addOAuthApp(TestHelper.fakeOAuthApp())(store.dispatch, store.getState); const user = TestHelper.basicUser; - nock(`${Client4.getUserRoute(user.id)}/oauth/apps/authorized`). - get(''). + nock(Client4.getBaseRoute()). + get(`/users/${user.id}/oauth/apps/authorized`). reply(200, [created]); await Actions.getAuthorizedOAuthApps()(store.dispatch, store.getState); @@ -720,14 +720,14 @@ describe('Actions.Integrations', () => { }); it('deleteOAuthApp', async () => { - nock(Client4.getOAuthAppsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/oauth/apps'). reply(201, TestHelper.fakeOAuthAppWithId()); const {data: created} = await Actions.addOAuthApp(TestHelper.fakeOAuthApp())(store.dispatch, store.getState); - nock(Client4.getOAuthAppsRoute()). - delete(`/${created.id}`). + nock(Client4.getBaseRoute()). + delete(`/oauth/apps/${created.id}`). reply(200, OK_RESPONSE); await Actions.deleteOAuthApp(created.id)(store.dispatch, store.getState); @@ -737,14 +737,14 @@ describe('Actions.Integrations', () => { }); it('regenOAuthAppSecret', async () => { - nock(Client4.getOAuthAppsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/oauth/apps'). reply(201, TestHelper.fakeOAuthAppWithId()); const {data: created} = await Actions.addOAuthApp(TestHelper.fakeOAuthApp())(store.dispatch, store.getState); - nock(Client4.getOAuthAppsRoute()). - post(`/${created.id}/regen_secret`). + nock(Client4.getBaseRoute()). + post(`/oauth/apps/${created.id}/regen_secret`). reply(200, {...created, client_secret: TestHelper.generateId()}); await Actions.regenOAuthAppSecret(created.id)(store.dispatch, store.getState); diff --git a/src/actions/posts.test.js b/src/actions/posts.test.js index a031b7c3d..6f570fac7 100644 --- a/src/actions/posts.test.js +++ b/src/actions/posts.test.js @@ -35,8 +35,8 @@ describe('Actions.Posts', () => { const channelId = TestHelper.basicChannel.id; const post = TestHelper.fakePost(channelId); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, {...post, id: TestHelper.generateId()}); await Actions.createPost(post)(store.dispatch, store.getState); @@ -74,8 +74,8 @@ describe('Actions.Posts', () => { url: 'http://localhost:8065/api/v4/posts', }; - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(400, createPostError); await Actions.createPost(post)(store.dispatch, store.getState); @@ -109,8 +109,8 @@ describe('Actions.Posts', () => { const post = TestHelper.fakePost(channelId); const files = TestHelper.fakeFiles(3); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, {...post, id: TestHelper.generateId(), file_ids: [files[0].id, files[1].id, files[2].id]}); await Actions.createPost( @@ -156,7 +156,7 @@ describe('Actions.Posts', () => { // post('/posts'). // reply(400, {}); - // nock(Client4.getPostsRoute()). + // nock(Client4.getBaseRoute()). // post(''). // reply(201, {...post, id: TestHelper.generateId()}); @@ -204,8 +204,8 @@ describe('Actions.Posts', () => { it('editPost', async () => { const channelId = TestHelper.basicChannel.id; - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(channelId)); const post = await Client4.createPost( @@ -215,8 +215,8 @@ describe('Actions.Posts', () => { post.message = `${message} (edited)`; - nock(Client4.getPostsRoute()). - put(`/${post.id}/patch`). + nock(Client4.getBaseRoute()). + put(`/posts/${post.id}/patch`). reply(200, post); await Actions.editPost( @@ -243,8 +243,8 @@ describe('Actions.Posts', () => { it('deletePost', async () => { const channelId = TestHelper.basicChannel.id; - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(channelId)); await Actions.createPost(TestHelper.fakePost(channelId))(store.dispatch, store.getState); const initialPosts = store.getState().entities.posts; @@ -266,8 +266,8 @@ describe('Actions.Posts', () => { TestHelper.mockLogin(); await login(TestHelper.basicUser.email, 'password1')(store.dispatch, store.getState); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(TestHelper.basicChannel.id)); const post1 = await Client4.createPost( @@ -276,8 +276,8 @@ describe('Actions.Posts', () => { const emojiName = '+1'; - nock(Client4.getReactionsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/reactions'). reply(201, {user_id: TestHelper.basicUser.id, post_id: post1.id, emoji_name: emojiName, create_at: 1508168444721}); await Actions.addReaction(post1.id, emojiName)(store.dispatch, store.getState); @@ -343,8 +343,8 @@ describe('Actions.Posts', () => { TestHelper.mockLogin(); await login(TestHelper.basicUser.email, 'password1')(store.dispatch, store.getState); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(TestHelper.basicChannel.id)); const post1 = await Client4.createPost( TestHelper.fakePost(TestHelper.basicChannel.id) @@ -352,8 +352,8 @@ describe('Actions.Posts', () => { const emojiName = '+1'; - nock(Client4.getReactionsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/reactions'). reply(201, {user_id: TestHelper.basicUser.id, post_id: post1.id, emoji_name: emojiName, create_at: 1508168444721}); await Actions.addReaction(post1.id, emojiName)(store.dispatch, store.getState); @@ -409,8 +409,8 @@ describe('Actions.Posts', () => { }, }; - nock(Client4.getPostsRoute()). - get(`/${post.id}/thread`). + nock(Client4.getBaseRoute()). + get(`/posts/${post.id}/thread`). reply(200, postList); await Actions.getPostThread(post.id)(store.dispatch, store.getState); @@ -1012,8 +1012,8 @@ describe('Actions.Posts', () => { get(`/${channelId}/posts`). query((params) => Boolean(params.before)). reply(200, postsBefore); - nock(Client4.getPostsRoute()). - get(`/${postId}/thread`). + nock(Client4.getBaseRoute()). + get(`/posts/${postId}/thread`). query(true). reply(200, postsThread); @@ -1064,8 +1064,8 @@ describe('Actions.Posts', () => { TestHelper.mockLogin(); await login(TestHelper.basicUser.email, 'password1')(store.dispatch, store.getState); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(TestHelper.basicChannel.id)); const post1 = await Client4.createPost( @@ -1094,8 +1094,8 @@ describe('Actions.Posts', () => { TestHelper.mockLogin(); await login(TestHelper.basicUser.email, 'password1')(store.dispatch, store.getState); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(TestHelper.basicChannel.id)); const post1 = await Client4.createPost( TestHelper.fakePost(channelId) @@ -1173,8 +1173,8 @@ describe('Actions.Posts', () => { it('pinPost', async () => { const {dispatch, getState} = store; - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(TestHelper.basicChannel.id)); const post1 = await Client4.createPost( TestHelper.fakePost(TestHelper.basicChannel.id) @@ -1183,13 +1183,13 @@ describe('Actions.Posts', () => { const postList = {order: [post1.id], posts: {}}; postList.posts[post1.id] = post1; - nock(Client4.getPostsRoute()). - get(`/${post1.id}/thread`). + nock(Client4.getBaseRoute()). + get(`/posts/${post1.id}/thread`). reply(200, postList); await Actions.getPostThread(post1.id)(dispatch, getState); - nock(Client4.getPostsRoute()). - post(`/${post1.id}/pin`). + nock(Client4.getBaseRoute()). + post(`/posts/${post1.id}/pin`). reply(200, OK_RESPONSE); await Actions.pinPost(post1.id)(dispatch, getState); @@ -1202,8 +1202,8 @@ describe('Actions.Posts', () => { it('unpinPost', async () => { const {dispatch, getState} = store; - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(TestHelper.basicChannel.id)); const post1 = await Client4.createPost( TestHelper.fakePost(TestHelper.basicChannel.id) @@ -1212,18 +1212,18 @@ describe('Actions.Posts', () => { const postList = {order: [post1.id], posts: {}}; postList.posts[post1.id] = post1; - nock(Client4.getPostsRoute()). - get(`/${post1.id}/thread`). + nock(Client4.getBaseRoute()). + get(`/posts/${post1.id}/thread`). reply(200, postList); await Actions.getPostThread(post1.id)(dispatch, getState); - nock(Client4.getPostsRoute()). - post(`/${post1.id}/pin`). + nock(Client4.getBaseRoute()). + post(`/posts/${post1.id}/pin`). reply(200, OK_RESPONSE); await Actions.pinPost(post1.id)(dispatch, getState); - nock(Client4.getPostsRoute()). - post(`/${post1.id}/unpin`). + nock(Client4.getBaseRoute()). + post(`/posts/${post1.id}/unpin`). reply(200, OK_RESPONSE); await Actions.unpinPost(post1.id)(dispatch, getState); @@ -1239,8 +1239,8 @@ describe('Actions.Posts', () => { TestHelper.mockLogin(); await login(TestHelper.basicUser.email, 'password1')(dispatch, getState); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(TestHelper.basicChannel.id)); const post1 = await Client4.createPost( TestHelper.fakePost(TestHelper.basicChannel.id) @@ -1248,8 +1248,8 @@ describe('Actions.Posts', () => { const emojiName = '+1'; - nock(Client4.getReactionsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/reactions'). reply(201, {user_id: TestHelper.basicUser.id, post_id: post1.id, emoji_name: emojiName, create_at: 1508168444721}); await Actions.addReaction(post1.id, emojiName)(dispatch, getState); @@ -1265,8 +1265,8 @@ describe('Actions.Posts', () => { TestHelper.mockLogin(); await login(TestHelper.basicUser.email, 'password1')(dispatch, getState); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(TestHelper.basicChannel.id)); const post1 = await Client4.createPost( TestHelper.fakePost(TestHelper.basicChannel.id) @@ -1274,8 +1274,8 @@ describe('Actions.Posts', () => { const emojiName = '+1'; - nock(Client4.getReactionsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/reactions'). reply(201, {user_id: TestHelper.basicUser.id, post_id: post1.id, emoji_name: emojiName, create_at: 1508168444721}); await Actions.addReaction(post1.id, emojiName)(dispatch, getState); @@ -1296,8 +1296,8 @@ describe('Actions.Posts', () => { TestHelper.mockLogin(); await login(TestHelper.basicUser.email, 'password1')(dispatch, getState); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, TestHelper.fakePostWithId(TestHelper.basicChannel.id)); const post1 = await Client4.createPost( TestHelper.fakePost(TestHelper.basicChannel.id) @@ -1305,8 +1305,8 @@ describe('Actions.Posts', () => { const emojiName = '+1'; - nock(Client4.getReactionsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/reactions'). reply(201, {user_id: TestHelper.basicUser.id, post_id: post1.id, emoji_name: emojiName, create_at: 1508168444721}); await Actions.addReaction(post1.id, emojiName)(dispatch, getState); @@ -1315,8 +1315,8 @@ describe('Actions.Posts', () => { data: {user_id: TestHelper.basicUser.id, post_id: post1.id, emoji_name: emojiName}, }); - nock(Client4.getPostsRoute()). - get(`/${post1.id}/reactions`). + nock(Client4.getBaseRoute()). + get(`/posts/${post1.id}/reactions`). reply(200, [{user_id: TestHelper.basicUser.id, post_id: post1.id, emoji_name: emojiName, create_at: 1508168444721}]); await Actions.getReactionsForPost(post1.id)(dispatch, getState); @@ -1331,8 +1331,8 @@ describe('Actions.Posts', () => { const testImageData = fs.createReadStream('test/assets/images/test.png'); const {dispatch, getState} = store; - nock(Client4.getEmojisRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/emoji'). reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser.id, name: TestHelper.generateId()}); const {data: created} = await createCustomEmoji( @@ -1647,8 +1647,8 @@ describe('Actions.Posts', () => { }, }; - nock(Client4.getPostsRoute()). - get(`/${post1.id}/thread`). + nock(Client4.getBaseRoute()). + get(`/posts/${post1.id}/thread`). reply(200, threadList); }); diff --git a/src/actions/preferences.test.js b/src/actions/preferences.test.js index d7a7a376d..eaf0aad80 100644 --- a/src/actions/preferences.test.js +++ b/src/actions/preferences.test.js @@ -169,8 +169,8 @@ describe('Actions.Preferences', () => { it('makeDirectChannelVisibleIfNecessary', async () => { const user = TestHelper.basicUser; - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, TestHelper.fakeUserWithId()); const user2 = await TestHelper.createClient4().createUser(TestHelper.fakeUser()); diff --git a/src/actions/schemes.test.js b/src/actions/schemes.test.js index 45e08d20c..b5e9c882e 100644 --- a/src/actions/schemes.test.js +++ b/src/actions/schemes.test.js @@ -28,8 +28,8 @@ describe('Actions.Schemes', () => { it('getSchemes', async () => { const mockScheme = TestHelper.basicScheme; - nock(Client4.getSchemesRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/schemes'). query(true). reply(200, [mockScheme]); @@ -42,8 +42,8 @@ describe('Actions.Schemes', () => { it('createScheme', async () => { const mockScheme = TestHelper.basicScheme; - nock(Client4.getSchemesRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/schemes'). reply(201, mockScheme); await Actions.createScheme(TestHelper.mockScheme())(store.dispatch, store.getState); @@ -55,8 +55,8 @@ describe('Actions.Schemes', () => { }); it('getScheme', async () => { - nock(Client4.getSchemesRoute()). - get('/' + TestHelper.basicScheme.id). + nock(Client4.getBaseRoute()). + get('/schemes/' + TestHelper.basicScheme.id). reply(200, TestHelper.basicScheme); await Actions.getScheme(TestHelper.basicScheme.id)(store.dispatch, store.getState); @@ -74,8 +74,8 @@ describe('Actions.Schemes', () => { ...patchData, }; - nock(Client4.getSchemesRoute()). - put('/' + TestHelper.basicScheme.id + '/patch'). + nock(Client4.getBaseRoute()). + put('/schemes/' + TestHelper.basicScheme.id + '/patch'). reply(200, scheme); await Actions.patchScheme(TestHelper.basicScheme.id, scheme)(store.dispatch, store.getState); @@ -90,8 +90,8 @@ describe('Actions.Schemes', () => { }); it('deleteScheme', async () => { - nock(Client4.getSchemesRoute()). - delete('/' + TestHelper.basicScheme.id). + nock(Client4.getBaseRoute()). + delete('/schemes/' + TestHelper.basicScheme.id). reply(200, {status: 'OK'}); await Actions.deleteScheme(TestHelper.basicScheme.id)(store.dispatch, store.getState); diff --git a/src/actions/search.test.js b/src/actions/search.test.js index cea18ab7c..dea803c1d 100644 --- a/src/actions/search.test.js +++ b/src/actions/search.test.js @@ -37,13 +37,13 @@ describe('Actions.Search', () => { message: 'return this message in second attempt', }; - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, {...post1, id: TestHelper.generateId()}); post1 = await Client4.createPost(post1); - nock(Client4.getPostsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/posts'). reply(201, {...post2, id: TestHelper.generateId()}); post2 = await Client4.createPost(post2); diff --git a/src/actions/teams.test.js b/src/actions/teams.test.js index 60b07e983..767845493 100644 --- a/src/actions/teams.test.js +++ b/src/actions/teams.test.js @@ -42,8 +42,8 @@ describe('Actions.Teams', () => { TestHelper.mockLogin(); await login(TestHelper.basicUser.email, 'password1')(store.dispatch, store.getState); - nock(Client4.getUsersRoute()). - get('/me/teams'). + nock(Client4.getBaseRoute()). + get('/users/me/teams'). reply(200, [TestHelper.basicTeam]); await Actions.getMyTeams()(store.dispatch, store.getState); @@ -59,8 +59,8 @@ describe('Actions.Teams', () => { }); it('getTeamsForUser', async () => { - nock(Client4.getUsersRoute()). - get(`/${TestHelper.basicUser.id}/teams`). + nock(Client4.getBaseRoute()). + get(`/users/${TestHelper.basicUser.id}/teams`). reply(200, [TestHelper.basicTeam]); await Actions.getTeamsForUser(TestHelper.basicUser.id)(store.dispatch, store.getState); @@ -79,13 +79,13 @@ describe('Actions.Teams', () => { it('getTeams', async () => { let team = {...TestHelper.fakeTeam(), allow_open_invite: true}; - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, {...team, id: TestHelper.generateId()}); team = await Client4.createTeam(team); - nock(Client4.getTeamsRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/teams'). query(true). reply(200, [team]); await Actions.getTeams()(store.dispatch, store.getState); @@ -103,13 +103,13 @@ describe('Actions.Teams', () => { it('getTeams with total count', async () => { let team = {...TestHelper.fakeTeam(), allow_open_invite: true}; - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, {...team, id: TestHelper.generateId()}); team = await Client4.createTeam(team); - nock(Client4.getTeamsRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/teams'). query(true). reply(200, {teams: [team], total_count: 43}); await Actions.getTeams(0, 1, true)(store.dispatch, store.getState); @@ -126,13 +126,13 @@ describe('Actions.Teams', () => { }); it('getTeam', async () => { - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const team = await Client4.createTeam(TestHelper.fakeTeam()); - nock(Client4.getTeamsRoute()). - get(`/${team.id}`). + nock(Client4.getBaseRoute()). + get(`/teams/${team.id}`). reply(200, team); await Actions.getTeam(team.id)(store.dispatch, store.getState); @@ -144,13 +144,13 @@ describe('Actions.Teams', () => { }); it('getTeamByName', async () => { - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const team = await Client4.createTeam(TestHelper.fakeTeam()); - nock(Client4.getTeamsRoute()). - get(`/name/${team.name}`). + nock(Client4.getBaseRoute()). + get(`/teams/name/${team.name}`). reply(200, team); await Actions.getTeamByName(team.name)(store.dispatch, store.getState); @@ -162,8 +162,8 @@ describe('Actions.Teams', () => { }); it('createTeam', async () => { - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); await Actions.createTeam( TestHelper.fakeTeam() @@ -180,8 +180,8 @@ describe('Actions.Teams', () => { it('deleteTeam', async () => { const secondClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -192,19 +192,19 @@ describe('Actions.Teams', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await secondClient.login(user.email, 'password1'); - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const secondTeam = await secondClient.createTeam( TestHelper.fakeTeam()); - nock(Client4.getTeamsRoute()). - delete(`/${secondTeam.id}`). + nock(Client4.getBaseRoute()). + delete(`/teams/${secondTeam.id}`). reply(200, OK_RESPONSE); await Actions.deleteTeam( @@ -225,8 +225,8 @@ describe('Actions.Teams', () => { description, }; - nock(Client4.getTeamsRoute()). - put(`/${team.id}`). + nock(Client4.getBaseRoute()). + put(`/teams/${team.id}`). reply(200, team); await Actions.updateTeam(team)(store.dispatch, store.getState); @@ -247,8 +247,8 @@ describe('Actions.Teams', () => { description, }; - nock(Client4.getTeamsRoute()). - put(`/${team.id}/patch`). + nock(Client4.getBaseRoute()). + put(`/teams/${team.id}/patch`). reply(200, team); await Actions.patchTeam(team)(store.dispatch, store.getState); const {teams} = store.getState().entities.teams; @@ -263,8 +263,8 @@ describe('Actions.Teams', () => { it('Join Open Team', async () => { const client = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); const user = await client.createUser( @@ -274,25 +274,25 @@ describe('Actions.Teams', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await client.login(user.email, 'password1'); - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, {...TestHelper.fakeTeamWithId(), allow_open_invite: true}); const team = await client.createTeam({...TestHelper.fakeTeam(), allow_open_invite: true}); store.dispatch({type: GeneralTypes.RECEIVED_SERVER_VERSION, data: '4.0.0'}); - nock(Client4.getTeamsRoute()). - post('/members/invite'). + nock(Client4.getBaseRoute()). + post('/teams/members/invite'). query(true). reply(201, {user_id: TestHelper.basicUser.id, team_id: team.id}); - nock(Client4.getTeamsRoute()). - get(`/${team.id}`). + nock(Client4.getBaseRoute()). + get(`/teams/${team.id}`). reply(200, team); nock(Client4.getUserRoute('me')). @@ -350,8 +350,8 @@ describe('Actions.Teams', () => { }); it('getTeamMember', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser( @@ -361,8 +361,8 @@ describe('Actions.Teams', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getTeamsRoute()). - get(`/${TestHelper.basicTeam.id}/members/${user.id}`). + nock(Client4.getBaseRoute()). + get(`/teams/${TestHelper.basicTeam.id}/members/${user.id}`). reply(200, {user_id: user.id, team_id: TestHelper.basicTeam.id}); await Actions.getTeamMember(TestHelper.basicTeam.id, user.id)(store.dispatch, store.getState); @@ -373,13 +373,13 @@ describe('Actions.Teams', () => { }); it('getTeamMembers', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, TestHelper.fakeUserWithId()); const user1 = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, TestHelper.fakeUserWithId()); const user2 = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); @@ -393,8 +393,8 @@ describe('Actions.Teams', () => { reply(201, {user_id: user2.id, team_id: TestHelper.basicTeam.id}); const {data: member2} = await Actions.addUserToTeam(TestHelper.basicTeam.id, user2.id)(store.dispatch, store.getState); - nock(Client4.getTeamMembersRoute(TestHelper.basicTeam.id)). - get(''). + nock(Client4.getBaseRoute()). + get(`/teams/${TestHelper.basicTeam.id}/members`). query(true). reply(200, [member1, member2, TestHelper.basicTeamMember]); await Actions.getTeamMembers(TestHelper.basicTeam.id)(store.dispatch, store.getState); @@ -407,8 +407,8 @@ describe('Actions.Teams', () => { }); it('getTeamMembersByIds', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); const user1 = await TestHelper.basicClient4.createUser( @@ -418,8 +418,8 @@ describe('Actions.Teams', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); const user2 = await TestHelper.basicClient4.createUser( @@ -429,8 +429,8 @@ describe('Actions.Teams', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getTeamMembersRoute(TestHelper.basicTeam.id)). - post('/ids'). + nock(Client4.getBaseRoute()). + post(`/teams/${TestHelper.basicTeam.id}/members/ids`). reply(200, [{user_id: user1.id, team_id: TestHelper.basicTeam.id}, {user_id: user2.id, team_id: TestHelper.basicTeam.id}]); await Actions.getTeamMembersByIds( TestHelper.basicTeam.id, @@ -460,8 +460,8 @@ describe('Actions.Teams', () => { }); it('addUserToTeam', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); @@ -476,13 +476,13 @@ describe('Actions.Teams', () => { }); it('addUsersToTeam', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, TestHelper.fakeUserWithId()); const user2 = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); @@ -528,8 +528,8 @@ describe('Actions.Teams', () => { }, }); - nock(Client4.getTeamMemberRoute(team.id, user.id)). - delete(''). + nock(Client4.getBaseRoute()). + delete(`/teams/${team.id}/members/${user.id}`). reply(200, OK_RESPONSE); await store.dispatch(Actions.removeUserFromTeam(team.id, user.id)); @@ -561,8 +561,8 @@ describe('Actions.Teams', () => { }, }); - nock(Client4.getTeamMemberRoute(team.id, user.id)). - delete(''). + nock(Client4.getBaseRoute()). + delete(`/teams/${team.id}/members/${user.id}`). reply(200, OK_RESPONSE); await store.dispatch(Actions.removeUserFromTeam(team.id, user.id)); @@ -588,8 +588,8 @@ describe('Actions.Teams', () => { }, }); - nock(Client4.getTeamMemberRoute(team.id, user.id)). - delete(''). + nock(Client4.getBaseRoute()). + delete(`/teams/${team.id}/members/${user.id}`). reply(200, OK_RESPONSE); await store.dispatch(Actions.removeUserFromTeam(team.id, user.id)); @@ -599,8 +599,8 @@ describe('Actions.Teams', () => { }); it('updateTeamMemberRoles', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); @@ -611,8 +611,8 @@ describe('Actions.Teams', () => { const roles = General.TEAM_USER_ROLE + ' ' + General.TEAM_ADMIN_ROLE; - nock(Client4.getTeamMemberRoute(TestHelper.basicTeam.id, user.id)). - put('/roles'). + nock(Client4.getBaseRoute()). + put(`/teams/${TestHelper.basicTeam.id}/members/${user.id}/roles`). reply(200, {user_id: user.id, team_id: TestHelper.basicTeam.id, roles}); await Actions.updateTeamMemberRoles(TestHelper.basicTeam.id, user.id, roles)(store.dispatch, store.getState); @@ -632,16 +632,16 @@ describe('Actions.Teams', () => { }); it('checkIfTeamExists', async () => { - nock(Client4.getTeamsRoute()). - get(`/name/${TestHelper.basicTeam.name}/exists`). + nock(Client4.getBaseRoute()). + get(`/teams/name/${TestHelper.basicTeam.name}/exists`). reply(200, {exists: true}); let {data: exists} = await Actions.checkIfTeamExists(TestHelper.basicTeam.name)(store.dispatch, store.getState); assert.ok(exists === true); - nock(Client4.getTeamsRoute()). - get('/name/junk/exists'). + nock(Client4.getBaseRoute()). + get('/teams/name/junk/exists'). reply(200, {exists: false}); const {data} = await Actions.checkIfTeamExists('junk')(store.dispatch, store.getState); exists = data; @@ -685,8 +685,8 @@ describe('Actions.Teams', () => { const schemeId = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'; const {id} = TestHelper.basicTeam; - nock(Client4.getTeamsRoute()). - put('/' + id + '/scheme'). + nock(Client4.getBaseRoute()). + put('/teams/' + id + '/scheme'). reply(200, OK_RESPONSE); await Actions.updateTeamScheme(id, schemeId)(store.dispatch, store.getState); @@ -717,8 +717,8 @@ describe('Actions.Teams', () => { it('searchTeams', async () => { const userClient = TestHelper.createClient4(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(201, TestHelper.fakeUserWithId()); @@ -729,22 +729,22 @@ describe('Actions.Teams', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, user); await userClient.login(user.email, 'password1'); - nock(Client4.getTeamsRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/teams'). reply(201, TestHelper.fakeTeamWithId()); const userTeam = await userClient.createTeam( TestHelper.fakeTeam() ); - nock(Client4.getTeamsRoute()). - post('/search'). + nock(Client4.getBaseRoute()). + post('/teams/search'). reply(200, [TestHelper.basicTeam, userTeam]); const {data} = await store.dispatch(Actions.searchTeams('test', 0)); @@ -754,8 +754,8 @@ describe('Actions.Teams', () => { throw new Error(JSON.stringify(moreRequest.error)); } - nock(Client4.getTeamsRoute()). - post('/search'). + nock(Client4.getBaseRoute()). + post('/teams/search'). reply(200, {teams: [TestHelper.basicTeam, userTeam], total_count: 2}); const response = await store.dispatch(Actions.searchTeams('test', '', false, true)); diff --git a/src/actions/users.test.js b/src/actions/users.test.js index f644dda89..f587cfac0 100644 --- a/src/actions/users.test.js +++ b/src/actions/users.test.js @@ -30,8 +30,8 @@ describe('Actions.Users', () => { it('createUser', async () => { const userToCreate = TestHelper.fakeUser(); - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, {...userToCreate, id: TestHelper.generateId()}); const {data: user} = await Actions.createUser(userToCreate)(store.dispatch, store.getState); @@ -46,8 +46,8 @@ describe('Actions.Users', () => { it('login', async () => { const user = TestHelper.basicUser; - nock(Client4.getUsersRoute()). - post('/logout'). + nock(Client4.getBaseRoute()). + post('/users/logout'). reply(200, OK_RESPONSE); await TestHelper.basicClient4.logout(); @@ -82,8 +82,8 @@ describe('Actions.Users', () => { it('loginById', async () => { const user = TestHelper.basicUser; - nock(Client4.getUsersRoute()). - post('/logout'). + nock(Client4.getBaseRoute()). + post('/users/logout'). reply(200, OK_RESPONSE); await TestHelper.basicClient4.logout(); @@ -127,8 +127,8 @@ describe('Actions.Users', () => { it('updateMyTermsOfServiceStatus accept terms', async () => { const user = TestHelper.basicUser; - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, {...TestHelper.fakeUserWithId()}); TestHelper.mockLogin(); @@ -151,8 +151,8 @@ describe('Actions.Users', () => { it('updateMyTermsOfServiceStatus reject terms', async () => { const user = TestHelper.basicUser; - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(201, {...TestHelper.fakeUserWithId()}); TestHelper.mockLogin(); @@ -171,8 +171,8 @@ describe('Actions.Users', () => { }); it('logout', async () => { - nock(Client4.getUsersRoute()). - post('/logout'). + nock(Client4.getBaseRoute()). + post('/users/logout'). reply(200, OK_RESPONSE); await Actions.logout()(store.dispatch, store.getState); @@ -216,15 +216,15 @@ describe('Actions.Users', () => { assert.deepStrictEqual(posts.postsInChannel, {}, 'posts by channel is not empty'); assert.deepStrictEqual(preferences.myPreferences, {}, 'user preferences not empty'); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, TestHelper.basicUser); await TestHelper.basicClient4.login(TestHelper.basicUser.email, 'password1'); }); it('getProfiles', async () => { - nock(Client4.getUsersRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/users'). query(true). reply(200, [TestHelper.basicUser]); @@ -235,14 +235,14 @@ describe('Actions.Users', () => { }); it('getProfilesByIds', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(200, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); - nock(Client4.getUsersRoute()). - post('/ids'). + nock(Client4.getBaseRoute()). + post('/users/ids'). reply(200, [user]); await Actions.getProfilesByIds([user.id])(store.dispatch, store.getState); @@ -252,14 +252,14 @@ describe('Actions.Users', () => { }); it('getMissingProfilesByIds', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(200, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); - nock(Client4.getUsersRoute()). - post('/ids'). + nock(Client4.getBaseRoute()). + post('/users/ids'). reply(200, [user]); await Actions.getMissingProfilesByIds([user.id])(store.dispatch, store.getState); @@ -269,14 +269,14 @@ describe('Actions.Users', () => { }); it('getProfilesByUsernames', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(200, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); - nock(Client4.getUsersRoute()). - post('/usernames'). + nock(Client4.getBaseRoute()). + post('/users/usernames'). reply(200, [user]); await Actions.getProfilesByUsernames([user.username])(store.dispatch, store.getState); @@ -286,8 +286,8 @@ describe('Actions.Users', () => { }); it('getProfilesInTeam', async () => { - nock(Client4.getUsersRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/users'). query(true). reply(200, [TestHelper.basicUser]); @@ -304,14 +304,14 @@ describe('Actions.Users', () => { it('getProfilesNotInTeam', async () => { const team = TestHelper.basicTeam; - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(200, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); - nock(Client4.getUsersRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/users'). query(true). reply(200, [user]); @@ -325,8 +325,8 @@ describe('Actions.Users', () => { }); it('getProfilesWithoutTeam', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(200, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); @@ -364,8 +364,8 @@ describe('Actions.Users', () => { }); it('getProfilesNotInChannel', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(200, TestHelper.fakeUserWithId()); @@ -395,8 +395,8 @@ describe('Actions.Users', () => { }); it('getUser', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(200, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); @@ -431,8 +431,8 @@ describe('Actions.Users', () => { }); it('getUserByUsername', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(200, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); @@ -453,8 +453,8 @@ describe('Actions.Users', () => { }); it('getUserByEmail', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(200, TestHelper.fakeUserWithId()); const user = await TestHelper.basicClient4.createUser(TestHelper.fakeUser()); @@ -578,8 +578,8 @@ describe('Actions.Users', () => { sessions = store.getState().entities.users.mySessions; assert.ok(sessions.length === sessionsLength - 1); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, TestHelper.basicUser); await TestHelper.basicClient4.login(TestHelper.basicUser.email, 'password1'); }); @@ -600,15 +600,15 @@ describe('Actions.Users', () => { const {data: revokeSessionResponse} = await Actions.revokeSession(TestHelper.basicUser.id, sessions[0].id)(store.dispatch, store.getState); assert.deepEqual(revokeSessionResponse, true); - nock(Client4.getUsersRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/users'). reply(401, {}); await Actions.getProfiles(0)(store.dispatch, store.getState); const basicUser = TestHelper.basicUser; - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, basicUser); const response = await TestHelper.basicClient4.login(TestHelper.basicUser.email, 'password1'); assert.deepEqual(response.email, basicUser.email); @@ -616,8 +616,8 @@ describe('Actions.Users', () => { it('revokeAllSessionsForCurrentUser', async () => { const user = TestHelper.basicUser; - nock(Client4.getUsersRoute()). - post('/logout'). + nock(Client4.getBaseRoute()). + post('/users/logout'). reply(200, OK_RESPONSE); await TestHelper.basicClient4.logout(); let sessions = store.getState().entities.users.mySessions; @@ -627,8 +627,8 @@ describe('Actions.Users', () => { TestHelper.mockLogin(); await Actions.loginById(user.id, 'password1')(store.dispatch, store.getState); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, TestHelper.basicUser); await TestHelper.basicClient4.login(TestHelper.basicUser.email, 'password1'); @@ -646,8 +646,8 @@ describe('Actions.Users', () => { const {data} = await Actions.revokeAllSessionsForUser(user.id)(store.dispatch, store.getState); assert.deepEqual(data, true); - nock(Client4.getUsersRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/users'). query(true). reply(401, {}); await Actions.getProfiles(0)(store.dispatch, store.getState); @@ -661,16 +661,16 @@ describe('Actions.Users', () => { assert.strictEqual(sessions.length, 0); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, TestHelper.basicUser); await TestHelper.basicClient4.login(TestHelper.basicUser.email, 'password1'); }); it('revokeSessionsForAllUsers', async () => { const user = TestHelper.basicUser; - nock(Client4.getUsersRoute()). - post('/logout'). + nock(Client4.getBaseRoute()). + post('/users/logout'). reply(200, OK_RESPONSE); await TestHelper.basicClient4.logout(); let sessions = store.getState().entities.users.mySessions; @@ -680,8 +680,8 @@ describe('Actions.Users', () => { TestHelper.mockLogin(); await Actions.loginById(user.id, 'password1')(store.dispatch, store.getState); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, TestHelper.basicUser); await TestHelper.basicClient4.login(TestHelper.basicUser.email, 'password1'); @@ -699,8 +699,8 @@ describe('Actions.Users', () => { const {data} = await Actions.revokeSessionsForAllUsers(user.id)(store.dispatch, store.getState); assert.deepEqual(data, true); - nock(Client4.getUsersRoute()). - get(''). + nock(Client4.getBaseRoute()). + get('/users'). query(true). reply(401, {}); await Actions.getProfiles(0)(store.dispatch, store.getState); @@ -714,15 +714,15 @@ describe('Actions.Users', () => { assert.strictEqual(sessions.length, 0); - nock(Client4.getUsersRoute()). - post('/login'). + nock(Client4.getBaseRoute()). + post('/users/login'). reply(200, TestHelper.basicUser); await TestHelper.basicClient4.login(TestHelper.basicUser.email, 'password1'); }); it('getUserAudits', async () => { - nock(Client4.getUsersRoute()). - get(`/${TestHelper.basicUser.id}/audits`). + nock(Client4.getBaseRoute()). + get(`/users/${TestHelper.basicUser.id}/audits`). query(true). reply(200, [{id: TestHelper.generateId(), create_at: 1497285546645, user_id: TestHelper.basicUser.id, action: '/api/v4/users/login', extra_info: 'success', ip_address: '::1', session_id: ''}]); @@ -735,8 +735,8 @@ describe('Actions.Users', () => { }); it('autocompleteUsers', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). query(true). reply(200, TestHelper.fakeUserWithId()); @@ -747,8 +747,8 @@ describe('Actions.Users', () => { TestHelper.basicTeam.invite_id ); - nock(Client4.getUsersRoute()). - get('/autocomplete'). + nock(Client4.getBaseRoute()). + get('/users/autocomplete'). query(true). reply(200, {users: [TestHelper.basicUser], out_of_channel: [user]}); @@ -780,8 +780,8 @@ describe('Actions.Users', () => { const currentUser = state.entities.users.profiles[state.entities.users.currentUserId]; const notifyProps = currentUser.notify_props; - nock(Client4.getUsersRoute()). - put('/me/patch'). + nock(Client4.getBaseRoute()). + put('/users/me/patch'). query(true). reply(200, { ...currentUser, @@ -829,8 +829,8 @@ describe('Actions.Users', () => { const currentUser = state.entities.users.profiles[currentUserId]; const notifyProps = currentUser.notify_props; - nock(Client4.getUsersRoute()). - put(`/${currentUserId}/patch`). + nock(Client4.getBaseRoute()). + put(`/users/${currentUserId}/patch`). query(true). reply(200, { ...currentUser, @@ -908,8 +908,8 @@ describe('Actions.Users', () => { const beforeTime = new Date().getTime(); const currentUserId = store.getState().entities.users.currentUserId; - nock(Client4.getUsersRoute()). - put(`/${currentUserId}/password`). + nock(Client4.getBaseRoute()). + put(`/users/${currentUserId}/password`). reply(200, OK_RESPONSE); await Actions.updateUserPassword(currentUserId, 'password1', 'password1')(store.dispatch, store.getState); @@ -924,8 +924,8 @@ describe('Actions.Users', () => { it('checkMfa', async () => { const user = TestHelper.basicUser; - nock(Client4.getUsersRoute()). - post('/mfa'). + nock(Client4.getBaseRoute()). + post('/users/mfa'). reply(200, {mfa_required: false}); const {data: mfaRequired} = await Actions.checkMfa(user.email)(store.dispatch, store.getState); @@ -953,16 +953,16 @@ describe('Actions.Users', () => { }); it('updateUserActive', async () => { - nock(Client4.getUsersRoute()). - post(''). + nock(Client4.getBaseRoute()). + post('/users'). reply(200, TestHelper.fakeUserWithId()); const {data: user} = await Actions.createUser(TestHelper.fakeUser())(store.dispatch, store.getState); const beforeTime = new Date().getTime(); - nock(Client4.getUsersRoute()). - put(`/${user.id}/active`). + nock(Client4.getBaseRoute()). + put(`/users/${user.id}/active`). reply(200, OK_RESPONSE); await Actions.updateUserActive(user.id, false)(store.dispatch, store.getState); @@ -1021,8 +1021,8 @@ describe('Actions.Users', () => { const beforeTime = new Date().getTime(); const currentUserId = store.getState().entities.users.currentUserId; - nock(Client4.getUsersRoute()). - post(`/${TestHelper.basicUser.id}/image`). + nock(Client4.getBaseRoute()). + post(`/users/${TestHelper.basicUser.id}/image`). reply(200, OK_RESPONSE); await Actions.uploadProfileImage(currentUserId, testImageData)(store.dispatch, store.getState); @@ -1040,8 +1040,8 @@ describe('Actions.Users', () => { const currentUserId = store.getState().entities.users.currentUserId; - nock(Client4.getUsersRoute()). - delete(`/${TestHelper.basicUser.id}/image`). + nock(Client4.getBaseRoute()). + delete(`/users/${TestHelper.basicUser.id}/image`). reply(200, OK_RESPONSE); await Actions.setDefaultProfileImage(currentUserId)(store.dispatch, store.getState); @@ -1401,8 +1401,8 @@ describe('Actions.Users', () => { const user1 = {id: 'user1', update_at: 1000}; const user2 = {id: 'user2', update_at: 1000}; - nock(Client4.getUsersRoute()). - post('/ids'). + nock(Client4.getBaseRoute()). + post('/users/ids'). query({since: lastDisconnectAt}). reply(200, [{...user2, update_at: 2000}]); diff --git a/src/actions/websocket.test.js b/src/actions/websocket.test.js index 6bb2731ae..0a0780c56 100644 --- a/src/actions/websocket.test.js +++ b/src/actions/websocket.test.js @@ -597,16 +597,16 @@ describe('Actions.Websocket', () => { async function test() { const team = {id: TestHelper.generateId()}; - nock(Client4.getTeamRoute(team.id)). - get(''). + nock(Client4.getBaseRoute()). + get(`/teams/${team.id}`). reply(200, team); - nock(Client4.getUserRoute('me')). - get('/teams/members'). + nock(Client4.getBaseRoute()). + get('/users/me/teams/members'). reply(200, [{team_id: team.id, user_id: TestHelper.basicUser.id}]); - nock(Client4.getUserRoute('me')). - get('/teams/unread'). + nock(Client4.getBaseRoute()). + get('/users/me/teams/unread'). reply(200, [{team_id: team.id, msg_count: 0, mention_count: 0}]); mockServer.emit('message', JSON.stringify({event: WebsocketEvents.ADDED_TO_TEAM, data: {team_id: team.id, user_id: TestHelper.basicUser.id}, broadcast: {omit_users: null, user_id: TestHelper.basicUser.id, channel_id: '', team_id: ''}, seq: 2})); diff --git a/test/test_helper.js b/test/test_helper.js index d805c1c4b..17bc2f2b6 100644 --- a/test/test_helper.js +++ b/test/test_helper.js @@ -331,24 +331,24 @@ class TestHelper { } mockLogin = () => { - nock(this.basicClient4.getUsersRoute()). - post('/login'). + nock(this.basicClient4.getBaseRoute()). + post('/users/login'). reply(200, this.basicUser, {'X-Version-Id': 'Server Version'}); - nock(this.basicClient4.getUserRoute('me')). - get('/teams/members'). + nock(this.basicClient4.getBaseRoute()). + get('/users/me/teams/members'). reply(200, [this.basicTeamMember]); - nock(this.basicClient4.getUserRoute('me')). - get('/teams/unread'). + nock(this.basicClient4.getBaseRoute()). + get('/users/me/teams/unread'). reply(200, [{team_id: this.basicTeam.id, msg_count: 0, mention_count: 0}]); - nock(this.basicClient4.getUserRoute('me')). - get('/teams'). + nock(this.basicClient4.getBaseRoute()). + get('/users/me/teams'). reply(200, [this.basicTeam]); - nock(this.basicClient4.getPreferencesRoute('me')). - get(''). + nock(this.basicClient4.getBaseRoute()). + get('/users/me/preferences'). reply(200, [{user_id: this.basicUser.id, category: 'tutorial_step', name: this.basicUser.id, value: '999'}]); }