From 9db4b4314bb224288e46e7a2a76a86599cbefe74 Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 8 Apr 2024 16:48:29 +0100 Subject: [PATCH] fix: ignore null items in API responses (#240) * fix: ignore null items in API responses - configure the talk client to use the production API for tests. - test a talk production search that is known to break the API client. - ignore null response data, so that the tests pass. * clean up loops with forEach * fix indentation * test individual comments * refactor with filter(Boolean) to remove null responses * Mock the Talk API with nock * Move the tests to talk-test.zooniverse.org * Test an empty search --------- Co-authored-by: Mark Bouslog --- .mocharc.js | 5 +- lib/config.js | 2 +- lib/json-api-client/index.js | 27 +- package-lock.json | 278 +++++---- package.json | 5 +- test/support/mockTalkAPI.mjs | 1040 ++++++++++++++++++++++++++++++++++ test/support/setup.mjs | 4 + test/talkClient.mjs | 69 +++ 8 files changed, 1258 insertions(+), 172 deletions(-) create mode 100644 test/support/mockTalkAPI.mjs create mode 100644 test/support/setup.mjs create mode 100644 test/talkClient.mjs diff --git a/.mocharc.js b/.mocharc.js index d514a81..778835a 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -1,5 +1,8 @@ module.exports = { reporter: 'spec', checkLeaks: true, - slow: 300 + slow: 300, + require: [ + 'test/support/setup.mjs' + ] } diff --git a/lib/config.js b/lib/config.js index 69a8995..f5e455d 100644 --- a/lib/config.js +++ b/lib/config.js @@ -25,7 +25,7 @@ var TALK_HOSTS = { production: 'https://talk.zooniverse.org', staging: 'https://talk-staging.zooniverse.org', development: 'https://talk-staging.zooniverse.org', - test: 'https://talk-staging.zooniverse.org' + test: 'https://talk-test.zooniverse.org' }; var SUGAR_HOSTS = { diff --git a/lib/json-api-client/index.js b/lib/json-api-client/index.js index 25b8e22..2cbdd02 100644 --- a/lib/json-api-client/index.js +++ b/lib/json-api-client/index.js @@ -87,32 +87,25 @@ this._handleLinks(response.links); } if ('linked' in response) { - ref1 = response.linked; - for (typeName in ref1) { - linkedResources = ref1[typeName]; - ref2 = [].concat(linkedResources); - for (j = 0, len1 = ref2.length; j < len1; j++) { - resourceData = ref2[j]; + for (typeName in response.linked) { + linkedResources = response.linked[typeName]; + linkedResources.filter(Boolean).forEach((resourceData) => { this.type(typeName).create(resourceData, headers, response.meta); - } + }); } } results = []; if ('data' in response) { - ref3 = [].concat(response.data); - for (k = 0, len2 = ref3.length; k < len2; k++) { - resourceData = ref3[k]; - results.push(this.type(resourceData.type).create(resourceData, headers, response.meta)); - } + response.data.filter(Boolean).forEach((resourceData) => { + results.push(this.type(resourceData.type).create(resourceData, headers, response.meta)); + }); } else { for (typeName in response) { resources = response[typeName]; if (indexOf.call(RESERVED_TOP_LEVEL_KEYS, typeName) < 0) { - ref4 = [].concat(resources); - for (l = 0, len3 = ref4.length; l < len3; l++) { - resourceData = ref4[l]; - results.push(this.type(typeName).create(resourceData, headers, response.meta)); - } + resources.filter(Boolean).forEach((resourceData) => { + results.push(this.type(typeName).create(resourceData, headers, response.meta)); + }); } } } diff --git a/package-lock.json b/package-lock.json index 4920eb9..34cab26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,8 @@ "devDependencies": { "chai": "^5.0.3", "chai-spies": "^1.0.0", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "nock": "^13.5.4" } }, "node_modules/ansi-colors": { @@ -82,13 +83,12 @@ } }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^1.0.0" } }, "node_modules/braces": { @@ -134,9 +134,9 @@ } }, "node_modules/chai": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.0.3.tgz", - "integrity": "sha512-wKGCtYv2kVY5WEjKqQ3fSIZWtTFveZCtzinhTZbx3/trVkxefiwovhpU9kRVCwxvKKCEjTWXPdM1/T7zPoDgow==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.0.tgz", + "integrity": "sha512-kDZ7MZyM6Q1DhR9jy7dalKohXQ2yrlXkk59CR52aRKxJrobmlBNqnFQxX9xOX8w+4mz8SYlKJa/7D7ddltFXCw==", "dev": true, "dependencies": { "assertion-error": "^2.0.1", @@ -263,12 +263,6 @@ "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, "node_modules/cookiejar": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", @@ -424,7 +418,7 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "node_modules/fsevents": { @@ -477,6 +471,25 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -540,7 +553,7 @@ "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "dependencies": { "once": "^1.3.0", @@ -637,6 +650,12 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "dev": true + }, "node_modules/local-storage": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/local-storage/-/local-storage-2.0.0.tgz", @@ -774,10 +793,22 @@ "node": ">= 0.6" } }, + "node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/mocha": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", - "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.4.0.tgz", + "integrity": "sha512-eqhGB8JKapEYcC4ytX/xrzKforgEc3j1pGlAXVy3eRwrtAy5/nIfT1SvgGzfN0XZZxeLq0aQWkOUAmqIJiv+bA==", "dev": true, "dependencies": { "ansi-colors": "4.1.1", @@ -787,13 +818,12 @@ "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.2.0", + "glob": "8.1.0", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", @@ -808,10 +838,6 @@ }, "engines": { "node": ">= 14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mochajs" } }, "node_modules/mocha/node_modules/escape-string-regexp": { @@ -826,38 +852,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mocha/node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/mocha/node_modules/glob/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/mocha/node_modules/minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -870,15 +864,6 @@ "node": ">=10" } }, - "node_modules/mocha/node_modules/minimatch/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, "node_modules/mocha/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -905,16 +890,18 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "node_modules/nanoid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", - "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "node_modules/nock": { + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.4.tgz", + "integrity": "sha512-yAyTfdeNJGGBFxWdzSKCBYxs5FxLbCg5X5Q4ets974hcQzG1+qCxvIyOo4j2Ry6MUlhWVMX4OoYDefAIIwupjw==", "dev": true, - "bin": { - "nanoid": "bin/nanoid.cjs" + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "propagate": "^2.0.0" }, "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + "node": ">= 10.13" } }, "node_modules/normalize-path": { @@ -978,15 +965,6 @@ "node": ">=8" } }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/pathval": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", @@ -1008,6 +986,15 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/qs": { "version": "6.11.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", @@ -1366,13 +1353,12 @@ "dev": true }, "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^1.0.0" } }, "braces": { @@ -1406,9 +1392,9 @@ "dev": true }, "chai": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.0.3.tgz", - "integrity": "sha512-wKGCtYv2kVY5WEjKqQ3fSIZWtTFveZCtzinhTZbx3/trVkxefiwovhpU9kRVCwxvKKCEjTWXPdM1/T7zPoDgow==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.0.tgz", + "integrity": "sha512-kDZ7MZyM6Q1DhR9jy7dalKohXQ2yrlXkk59CR52aRKxJrobmlBNqnFQxX9xOX8w+4mz8SYlKJa/7D7ddltFXCw==", "dev": true, "requires": { "assertion-error": "^2.0.1", @@ -1503,12 +1489,6 @@ "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, "cookiejar": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", @@ -1620,7 +1600,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "fsevents": { @@ -1657,6 +1637,19 @@ "has-symbols": "^1.0.3" } }, + "glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + } + }, "glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -1699,7 +1692,7 @@ "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "requires": { "once": "^1.3.0", @@ -1769,6 +1762,12 @@ "argparse": "^2.0.1" } }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "dev": true + }, "local-storage": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/local-storage/-/local-storage-2.0.0.tgz", @@ -1863,10 +1862,19 @@ "mime-db": "1.52.0" } }, + "minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, "mocha": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", - "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.4.0.tgz", + "integrity": "sha512-eqhGB8JKapEYcC4ytX/xrzKforgEc3j1pGlAXVy3eRwrtAy5/nIfT1SvgGzfN0XZZxeLq0aQWkOUAmqIJiv+bA==", "dev": true, "requires": { "ansi-colors": "4.1.1", @@ -1876,13 +1884,12 @@ "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.2.0", + "glob": "8.1.0", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", @@ -1898,31 +1905,6 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, - "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "dependencies": { - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - } - } - }, "minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -1930,17 +1912,6 @@ "dev": true, "requires": { "brace-expansion": "^2.0.1" - }, - "dependencies": { - "brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - } } }, "ms": { @@ -1965,11 +1936,16 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "nanoid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", - "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", - "dev": true + "nock": { + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.4.tgz", + "integrity": "sha512-yAyTfdeNJGGBFxWdzSKCBYxs5FxLbCg5X5Q4ets974hcQzG1+qCxvIyOo4j2Ry6MUlhWVMX4OoYDefAIIwupjw==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "propagate": "^2.0.0" + } }, "normalize-path": { "version": "3.0.0", @@ -2014,12 +1990,6 @@ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, "pathval": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", @@ -2032,6 +2002,12 @@ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, + "propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true + }, "qs": { "version": "6.11.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", diff --git a/package.json b/package.json index 53f6de8..936c42f 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,10 @@ "devDependencies": { "chai": "^5.0.3", "chai-spies": "^1.0.0", - "mocha": "^10.2.0" + "mocha": "^10.2.0", + "nock": "^13.5.4" }, "scripts": { - "test": "mocha" + "test": "NODE_ENV=test mocha" } } diff --git a/test/support/mockTalkAPI.mjs b/test/support/mockTalkAPI.mjs new file mode 100644 index 0000000..552d16b --- /dev/null +++ b/test/support/mockTalkAPI.mjs @@ -0,0 +1,1040 @@ +/* + Snapshots of responses from the Talk API. +*/ + +// https://talk.zooniverse.org/searches?http_cache=true§ion=zooniverse&types=comments&page=1&page_size=10&query=depression +export const talkSearch = { + "searches": [ + { + "href": "/comments/773449", + "links": {}, + "board_id": "14", + "body": "I'm a very depressive person and some days these classifications are the only thing I can do during the day. Sometimes it's the only thing, I can do positive in weeks. The only thing that can calm down my deep fear for some hours, before it hits back. I just wanted to say this, maybe I'm not alone a crazy one?!\nlook after your beloved ones. tell them that u love them.\n\nRegards\nSyrell", + "category": null, + "created_at": "2017-10-26T13:38:48.433Z", + "discussion_id": "463403", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "773449", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2017-10-26T13:41:10.721Z", + "upvotes": {}, + "user_id": "1680117", + "user_login": "syrell", + "versions": [], + "reply_user_id": null, + "reply_user_login": null, + "reply_user_display_name": null, + "discussion_comments_count": 16, + "discussion_subject_default": false, + "discussion_title": "Little help for a heavily depressed person", + "discussion_updated_at": "2017-11-07T03:16:53.697Z", + "discussion_users_count": 9, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 5262, + "board_description": "For all discussion about the Zooniverse as a whole.", + "board_discussions_count": 775, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Zooniverse", + "board_users_count": 1142, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "syrell", + "type": "Comment" + }, + { + "href": "/comments/782755", + "links": {}, + "board_id": "14", + "body": "At least you spend your depressed hours doing something to help something else. :)", + "category": null, + "created_at": "2017-11-03T16:46:07.780Z", + "discussion_id": "463403", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "782755", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2017-11-03T16:46:07.780Z", + "upvotes": { + "AvastMH": "1509750013" + }, + "user_id": "1711005", + "user_login": "henrysun9074", + "versions": [], + "reply_user_id": null, + "reply_user_login": null, + "reply_user_display_name": null, + "discussion_comments_count": 16, + "discussion_subject_default": false, + "discussion_title": "Little help for a heavily depressed person", + "discussion_updated_at": "2017-11-07T03:16:53.697Z", + "discussion_users_count": 9, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 5262, + "board_description": "For all discussion about the Zooniverse as a whole.", + "board_discussions_count": 775, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Zooniverse", + "board_users_count": 1142, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "henrysun9074", + "type": "Comment" + }, + { + "href": "/comments/738964", + "links": {}, + "board_id": "17", + "body": "Since no one else is reporting the problem this is very likely something on your end, most likely the browser - as depressing as that sounds...\n\nYou can start disabling add-ons and extensions and you may find the issue but it might be better to do a complete reinstall of Chrome then add any extensions etc back in and check each time between add-ons.\n\nAlternately you could install Firefox and make sure that is working \"out of the box\" before you start tearing things up.... \n\nI take it you are having no other issues with other sites?", + "category": null, + "created_at": "2017-09-22T23:42:21.171Z", + "discussion_id": "440149", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "738964", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2017-09-22T23:42:21.171Z", + "upvotes": { + "gardenmaeve": "1506455435" + }, + "user_id": "1365766", + "user_login": "Pmason", + "versions": [], + "reply_user_id": null, + "reply_user_login": null, + "reply_user_display_name": null, + "discussion_comments_count": 13, + "discussion_subject_default": false, + "discussion_title": "Black/White Screen", + "discussion_updated_at": "2024-01-24T23:21:21.260Z", + "discussion_users_count": 6, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 6271, + "board_description": "Having issues with Zooniverse besides just a specific project? Please let us know!", + "board_discussions_count": 943, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Troubleshooting", + "board_users_count": 898, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "Pmason", + "type": "Comment" + }, + { + "href": "/comments/917783", + "links": {}, + "board_id": "14", + "body": "Wow. I just logged in and my first reaction was that I must have hit the +font or done something weird to my monitor. Second reaction was what is this HUGE bar taking up so much real estate on my screen. Third reaction was Ugly Ugly Ugly, gotta jump over to Zooniverse Talk to see if it's just a Notes from Nature change. I stopped by Mapping Change on the way from NfN to Zooniverse and saw that the same change happened there too. And then I found this post at the top of Recent Comments.\n\n**WHY??** This big fat bar with a font size that's way out of proportion to the rest of what's on the screen (and big enough that I instinctively pull my head back from the screen to read the words) and a blurred image of a section of the project image as background... what is the point? It means that in both Talk and Classify, I have to scroll down to read or work, hiding the top menu bar so I can't see my Notifications and Messages and Profile tabs. What a big distraction and waste of space.\n\nThis is *improved*? For me, this is wholly negative. I complain about a lot of aspects of the UI, but the menu bars were one thing that worked. (Admittedly, aside from the frequent confusion from some volunteers when Talk appeared in two menu a bars, which hasn't been solved by this change.) I personally prefer to have a solid color background in a menu bar, but an image can work if it's well-chosen. More contrast is fine, even good (but now the amount of contrast is totally variable from one project to another, depending on the image they've chosen). I like the typography you were already using, but am ok with a change so long as it remains easy to read. Menus should be readily visible - findable *but unobtrusive*. This change, making the project navigation menu SO BIG and IN YOUR FACE has exactly the opposite effect. It looks like the primary function of both Talk and Classify pages IS the navigation, rather than their actual functions.\n\nWith this giant navbar in the way, I am going to be scrolling up and down constantly, distracting me as I compose talk messages and as I classify. I jump frequently to my profile to see my count on the stats ribbon and to use my favorites and collections, as well as checking and responding to notifications.\n\nI know I have a reputation as a complainer and this is just going to multiply that, but for me, this change is a big negative by not only making the screens less attractive but by making my work less productive by putting a big separation between parts of the UI that I use frequently.\n\nI am so depressed. And even more worried than I already was about the frequent hints I've been seeing about upcoming changes to the Classify interface.", + "category": null, + "created_at": "2018-02-21T01:55:56.443Z", + "discussion_id": "553683", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "917783", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "917706", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2018-02-21T01:55:56.443Z", + "upvotes": {}, + "user_id": "1220914", + "user_login": "am.zooni", + "versions": [], + "reply_user_id": 1555227, + "reply_user_login": "beckyrother", + "reply_user_display_name": "Becky Rother", + "discussion_comments_count": 32, + "discussion_subject_default": false, + "discussion_title": "Zooniverse project navigation updates", + "discussion_updated_at": "2022-10-03T17:08:06.554Z", + "discussion_users_count": 15, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 5262, + "board_description": "For all discussion about the Zooniverse as a whole.", + "board_discussions_count": 775, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Zooniverse", + "board_users_count": 1142, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "am.zooni", + "type": "Comment" + }, + { + "href": "/comments/950902", + "links": {}, + "board_id": "14", + "body": "It's not nearly as important to me as eliminating the glaring white and reinstating the legibility of the question fields, but with the solid background in the question area, the Need help, Show Tutorial, and Navigation buttons are now more prominent than the questions. Those items need to be easily discoverable of course, but should not be the outstanding elements on the question side of the screen. Example:\n\n![NfN location/habitat panel](https://i.imgur.com/ofgfRfg.png =240x180) __ ([bigger photo at Imgur](https://imgur.com/ofgfRfg))\n\nI think the relative prominence of all the elements on the classify screens (the area between the top and bottom nav bars) was perfect in the UI before today, with the *possible* (I would want to see before being sure) exceptions that the question text might have been better if made more prominent by using a bold font and the label text on the Need some help and Show tutorial buttons probably would have been better un-bolded.\n\nQuite possibly there are some Zooniverse projects that do have a problematic background image, but I haven't found them yet. I spent a number of hours in the past week looking carefully at the classify pages of around a dozen projects (obviously that's only a small proportion of the total), but I thought each the background image worked very well in each case. The Subjects as well as the Question/Answer area were clearly legible and the balance of screen elements was well-suited to keeping the focus on the image first and the questions second. I did not see anywhere that the questions were difficult to read or where the background was distracting. And the project context (or \"branding\" if you will) was always present due to the background image. Even in the family of Snapshot Safari projects which share the same background image, the image color is unique to each sibling project. In fact, I would like to see the background image used on the Talk pages too, as well as Classify. I have no problem at all if some project owners feel that a solid color background is more effective for their project. I think they should have that choice (including a choice of color). But I also think that if they feel a background image is more effective, they should also have that choice. Some projects (Snapshot*, Treeversity) have a block of \"options\" with relatively little background visible (the whole issue of \"transparent questions\" doesn't even really apply). But other projects have all sorts of question layouts, sometimes with a great deal of visible background. Please allow the project owners (the people who best know the data and the questions) have the freedom to choose the appearance that best suits the tasks they set.\n\nI think the enormous variety of projects, and the uniqueness of both the look and the community atmosphere of different projects is a huge advantage that the Zooniverse had. It's incredibly depressing to see one aspect of the diversity (the appearance) being dismantled and discarded bit by bit, rather than expanded on and emphasized.", + "category": null, + "created_at": "2018-03-13T02:48:34.658Z", + "discussion_id": "573414", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "950902", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2018-03-13T03:08:59.677Z", + "upvotes": { + "octodragon": "1520951232", + "beckyrother": "1520974300" + }, + "user_id": "1220914", + "user_login": "am.zooni", + "versions": [], + "reply_user_id": null, + "reply_user_login": null, + "reply_user_display_name": null, + "discussion_comments_count": 64, + "discussion_subject_default": false, + "discussion_title": "Classify update round two: Neutral Background", + "discussion_updated_at": "2018-05-03T09:22:31.706Z", + "discussion_users_count": 15, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 5262, + "board_description": "For all discussion about the Zooniverse as a whole.", + "board_discussions_count": 775, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Zooniverse", + "board_users_count": 1142, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "am.zooni", + "type": "Comment" + }, + { + "href": "/comments/957331", + "links": {}, + "board_id": "14", + "body": "LOL @Pmason, if I haven't been banned (yet !!! :-) ), you have a looong way to go before you cross that line.\n\nAnd I am pretty shocked that the team working on and testing the beta of GZ Panoptes wasn't informed of and given the opportunity to (more, they should have been urged to) incorporate the impending UI changes. I also wonder that the timing of the UI changes couldn't have been altered to work around the launch of the new version of such a prominent project, to give the volunteers time to settle in to the new platform. \n\nTo Brook's ( @vrooje ) points: as a volunteer who went through the migration to Panoptes just about 2 years ago (Notes from Nature) - very reluctantly - it would be fair to say kicking and screaming - and who still believes that some aspects of our previous UI were more efficient and more volunteer-attuned - it was clear from very early on that on balance the migration was worthwhile. Our project team (as no doubt you have too), explained the benefits, some of which you mentioned in this thread. We understood that the migration had to happen. Some of us, me loud among them, complained a lot, but we did try to learn what could and couldn't be changed in the new environment, and to align our complaints and suggestions to the possible. As you said, the software has to accommodate a variety of research needs. So it's never going to be ideal for any individual project. But between the team (NfN and Zooniverse) and the volunteers, we learned to work with - and in some cases work around - the features and the limitations of the platform.\n\nIt's one story to adjust to a new style of classification interface when it gives benefits like having robust systems support and being able to launch new workflows and datasets with much less effort. It's a very different story to be asked to accept what appears to be a cosmetic change. The reasons we've been told it's necessary, e.g., increases legibility, are not apparent, at least not to many of us. Instead we are experiencing tangibly opposite effects: serious eyestrain and several factors that distract the attention from the Subject image and questions. There's no balance between benefits and drawbacks. On top of that, at least for a few of us, the changes to make every project look close to identical, is wrong in a practical sense: which project am I in anyway? some are similar enough in their Subjects and questions that it's a genuine issue. And it's wrong in a \"philosophical\" sense: what happens to a major attractive feature of the Zooniverse, its wild diversity. Yes, the diversity is still there except in appearance. But if I was new and checking out the Zooniverse today by clicking on half a dozen projects to see what they were about, I probably wouldn't even get as far as half a dozen because they all look the same. In stark contrast to how things looked a month ago, when the awesome variety was in full view at even just a glance. You didn't have to dig deep to realize that even if the first project you try, or the second, or the third, doesn't really appeal to you, that there's sure to be one that will be just what excites you, because there is just so much here.\n\nSigh. I've gotten on my hobbyhorse yet again without even realizing it. This whole thing is so depressing and frustrating. We've got something beautiful and valuable here, so why are we trying to suppress it?", + "category": null, + "created_at": "2018-03-16T23:16:54.880Z", + "discussion_id": "573414", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "957331", + "is_deleted": false, + "mentioning": { + "@Pmason": { + "id": 1365766, + "type": "User" + }, + "@vrooje": { + "id": 2760, + "type": "User" + } + }, + "project_id": "", + "reply_id": "957031", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2018-03-16T23:17:06.035Z", + "upvotes": {}, + "user_id": "1220914", + "user_login": "am.zooni", + "versions": [], + "reply_user_id": 2760, + "reply_user_login": "vrooje", + "reply_user_display_name": "Brooke Simmons", + "discussion_comments_count": 64, + "discussion_subject_default": false, + "discussion_title": "Classify update round two: Neutral Background", + "discussion_updated_at": "2018-05-03T09:22:31.706Z", + "discussion_users_count": 15, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 5262, + "board_description": "For all discussion about the Zooniverse as a whole.", + "board_discussions_count": 775, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Zooniverse", + "board_users_count": 1142, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "am.zooni", + "type": "Comment" + }, + { + "href": "/comments/975877", + "links": {}, + "board_id": "14", + "body": "Ten steps back and one step forward, yet you don't even mention that [you have actually made one change in response to user feedback](https://www.zooniverse.org/talk/14/573414?comment=975218).\n\nNo responses yet? I saw this several hours ago but decided to get away from the Zooniverse and leave it for others to comment. I am the most voluminous voice here, but far from the only voice, and was hoping some of those would speak up first. Or is everyone else feeling like me, exhausted from fighting this tide of one-size-fits-all that is rolling in over us? It's very depressing, but does appear to be inexorable, no matter what we say.\n\nAs to the specific changes noted in Becky's post:\n- On my computer, the menu bar height is identical now as it has been since the blurry version first appeared. If making it responsive helps others, that's great. But it's far too tall, and the fonts of both the project name and links are far too large. and the tone of the white font is too bright, especially in the circle around the check mark: the eye is drawn to that circle as it's the brightest item in the top part of the page. That's just wrong. It's the only non-functional and the least important item in that area. And the background is STILL blurry. It's a major problem in that the eye inevitably wants to focus what it sees, therefore strains to do an impossible task. PLEASE either show the background image in correct focus, or change to a solid color.\n- The NfN menu never collapsed into \"Explore Project\" for me (even with two links there that are now removed), so this change doesn't affect me. I think it's positive if it does happen to fewer people on fewer devices, but I think the cost is too high in the loss of external links. \n- Losing the external links may not be an issue for some projects, but it is for others. I don't have a problem removing them from the Classify page. But the problem is that the same menu bar that is used on the Classify page is also used on Talk, home page, About, Collect, Recents, so those links have been removed from the menu on all pages. It's important to be able to have external links that are both available **and prominent** on the home page and on Talk. They are currently non-existent on Talk and buried *well* \"below the fold\" on the Home Page (or in the case of the Snapshot Safari projects, the Snapshot Safari page) .. to find the links, or even know the links exist, you have to click a series of links and then page down (in my case, at least two presses of the pagedown key). How many users, especially new ones / volunteers exploring for a project that suits them, will get that far? For projects where the blog or other external site contains rich supplementary material that is integral to the project and to supporting the user community, clicking those external links can make the difference to whether they stay to try the project, or move on. (How many times have I posted on Talk: click the Blog link at the top of the page to read more about....? Sigh.)\n\nI can believe that the \"analytics data\" shows that few people clicked on the blog link on the Classify page. I can totally believe that overall, few people click on blog links from *any* Zooniverse page, because while nearly all project have a blog, in a great many cases it's just an artifact: one or a few posts at launch, dormant since then. But a small number of projects have active blogs, and others use some other external site to interact with their volunteers. How many clicked on the external links on Talk? How many clicked on them on the Home page when it was at the top, but will now no longer see them? (Did you even measure clicks on the custom home and menu pages at NfN or other projects with custom pages?) How many people followed the external link in the menu bar once or twice when they were new, but then bookmarked it, and continue to visit the site frequently, but not via a Zooniverse page (you can't have measured that)? That's great for the long tail users who stick with a project, but it's important for the external links to be readily visible , to catch the attention of the much larger volume of new and occasional visitors to a project.\n\nI think project owners should have an option to include zero to three links of their choice to their project's menu bar. Some projects have external links that are significant to the interaction between project team and volunteers; others don't. When building a project, the builder should be informed that the number of links, and the labels they use, may cause the menu bar to collapse for a higher proportion or even all of their users. But the choice should be on them.\n\nWhy are all these changes removing flexibility and choices from the project owners? I like vanilla quite a lot, but others prefer peppermint or pumpkin spice or salted caramel... as do I, on a different day. Bring back the life, the variety, the diversity.\n\nAnd please please please: tone down the bright white background of the question area of the classify screen SOON! It is really really hard having the amount of time I can spend classifying in a day cut back so severely. I want to get back to work!", + "category": null, + "created_at": "2018-03-27T21:10:31.864Z", + "discussion_id": "587140", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "975877", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "975373", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2018-03-28T01:40:13.333Z", + "upvotes": {}, + "user_id": "1220914", + "user_login": "am.zooni", + "versions": [], + "reply_user_id": 1555227, + "reply_user_login": "beckyrother", + "reply_user_display_name": "Becky Rother", + "discussion_comments_count": 17, + "discussion_subject_default": false, + "discussion_title": "Classify update round 2.1: Updates to navigation bar", + "discussion_updated_at": "2018-04-12T16:30:24.742Z", + "discussion_users_count": 5, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 5262, + "board_description": "For all discussion about the Zooniverse as a whole.", + "board_discussions_count": 775, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Zooniverse", + "board_users_count": 1142, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "am.zooni", + "type": "Comment" + }, + { + "href": "/comments/979029", + "links": {}, + "board_id": "14", + "body": "I like your technique! Grab whatever opening you get.\n\nThere are periodic threads here on Zooniverse talk where volunteers grumble about approved projects that are neglected, abandoned, or disappear, and about completed or \"paused/temporarily out of data\" project whose status isn't up to date. It doesn't really help a whole lot to have company in your misery, but you do have company. Some people have made suggestions, mostly regarding trying to stop projects from going public if the researchers aren't prepared to support them adequately. I don't know what's been tried, but similar complaints arise depressingly often. It's incredibly frustrating to put in hard work and/or get very interested in a project, and then find it dissolve into nothing.", + "category": null, + "created_at": "2018-03-29T21:05:59.399Z", + "discussion_id": "587140", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "979029", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "979010", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2018-03-29T21:05:59.399Z", + "upvotes": { + "tagger2018": "1522409947" + }, + "user_id": "1220914", + "user_login": "am.zooni", + "versions": [], + "reply_user_id": 1747630, + "reply_user_login": "deleted-1747630", + "reply_user_display_name": "Deleted user 1747630", + "discussion_comments_count": 17, + "discussion_subject_default": false, + "discussion_title": "Classify update round 2.1: Updates to navigation bar", + "discussion_updated_at": "2018-04-12T16:30:24.742Z", + "discussion_users_count": 5, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 5262, + "board_description": "For all discussion about the Zooniverse as a whole.", + "board_discussions_count": 775, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Zooniverse", + "board_users_count": 1142, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "am.zooni", + "type": "Comment" + }, + { + "href": "/comments/1048415", + "links": {}, + "board_id": "14", + "body": "Ha, I actually meant \"real\" sheep and \"real\" hills :smile: The analogy is that I would rather listen to the silence of nature with sheep where if you listen closely, you can hear music. The silence of nature isn't quiet, but filled with songs of happiness, love, warmth, etc. It was also a play on words referring to the movie Musical with Julie Andrews. Here, the silence used as a force for reckoning among humans are depressing, cold and just plain sad. \nThanks for your reply, I continue to enjoy reading your posts and am looking forward to the next installment :)", + "category": null, + "created_at": "2018-05-12T22:26:57.012Z", + "discussion_id": "615348", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "1048415", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "1048348", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2018-05-12T22:26:57.012Z", + "upvotes": {}, + "user_id": "984820", + "user_login": "WillowSkye", + "versions": [], + "reply_user_id": 1220914, + "reply_user_login": "am.zooni", + "reply_user_display_name": "am.zooni", + "discussion_comments_count": 33, + "discussion_subject_default": false, + "discussion_title": "Classify update 3: Updates to the Dark Theme!", + "discussion_updated_at": "2018-05-15T14:46:31.716Z", + "discussion_users_count": 6, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 5262, + "board_description": "For all discussion about the Zooniverse as a whole.", + "board_discussions_count": 775, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Zooniverse", + "board_users_count": 1142, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "Deleted user 984820", + "type": "Comment" + }, + { + "href": "/comments/25407", + "links": {}, + "board_id": "14", + "body": "That is ... really, really depressing :(\n\nAmong other things, and to take just one example, it means that the millions of hours us citizen scientists have put into patiently attaching hashtags to tens/hundreds of thousands of objects, in the many v2 Talks, has been (mostly) in vain, and of scientific value to no one (short of some heroic efforts, and excluding some serentipitous discoveries), right?\n\nThinking positively, what do you think about a zooite-initiated crowd-funding effort (using KickStarter, say) to get the resources to save this treasure trove of high-quality data? Or perhaps just a tiny amount of resource to a) define and explain the v2 Talk database schema(s), and b) periodically dump them into some cloud, in a form which can be fairly easily queried?\n", + "category": null, + "created_at": "2015-10-19T18:25:24.445Z", + "discussion_id": "12851", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "25407", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "25396", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2015-10-19T18:25:24.445Z", + "upvotes": {}, + "user_id": "184", + "user_login": "JeanTate", + "versions": [], + "reply_user_id": 110, + "reply_user_login": "DZM", + "reply_user_display_name": "DZM", + "discussion_comments_count": 44, + "discussion_subject_default": false, + "discussion_title": "#Tags", + "discussion_updated_at": "2017-05-16T09:28:15.505Z", + "discussion_users_count": 10, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 5262, + "board_description": "For all discussion about the Zooniverse as a whole.", + "board_discussions_count": 775, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Zooniverse", + "board_users_count": 1142, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "Jean Tate", + "type": "Comment" + } + ], + "meta": { + "searches": { + "page": 1, + "page_size": 10, + "count": 42, + "include": [], + "page_count": 5, + "previous_page": null, + "next_page": 2, + "first_href": "/searches?page=1\u0026page_size=10\u0026section=zooniverse\u0026query=depression\u0026types=comments", + "previous_href": null, + "next_href": "/searches?page=2\u0026page_size=10\u0026section=zooniverse\u0026query=depression\u0026types=comments", + "last_href": "/searches?page=5\u0026page_size=10\u0026section=zooniverse\u0026query=depression\u0026types=comments" + } + } +}; + +// https://talk.zooniverse.org/searches?http_cache=true§ion=zooniverse&types=comments&page=3&page_size=10&query=depression +export const talkSearchWithNull = { + "searches": [ + { + "href": "/comments/331234", + "links": {}, + "board_id": "13", + "body": "Why wasn't there fluid on the surface?\n\nI also found evidence for that.\n\nHow is it that fluid from underneath creates depression on the surface? It would create a bulge. I am not saying there isn't fluid on the bottom, but at one point, there definitely was fluid on top.", + "category": null, + "created_at": "2017-02-25T23:44:43.110Z", + "discussion_id": "33908", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "331234", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "323952", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2017-02-25T23:44:43.110Z", + "upvotes": {}, + "user_id": "1377446", + "user_login": "PolishPlanetPursuer", + "versions": [], + "reply_user_id": 852577, + "reply_user_login": "pittbull", + "reply_user_display_name": "pittbull", + "discussion_comments_count": 579, + "discussion_subject_default": false, + "discussion_title": "Pluto's heat source?", + "discussion_updated_at": "2020-12-04T03:05:24.726Z", + "discussion_users_count": 26, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 3221, + "board_description": "Talk about anything and everything here!", + "board_discussions_count": 532, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Chat", + "board_users_count": 678, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "PolishPlanetPursuer", + "type": "Comment" + }, + { + "href": "/comments/331961", + "links": {}, + "board_id": "13", + "body": "> Why wasn't there fluid on the surface?\n\nI assume you're talking about the section to the NW migrating to SP. (Venera Terra to Piri Planitia to Viking terra into SP).\nSeems at one point there was fluid on the surface.\n![Example Alt Text](http://www.plutorules.com/uploads/7/2/6/8/72681811/melted-ice-blocks-nw-of-sp2_orig.jpg)\n\nDon't some of those impact craters with the dark blue center's (top image aka Venera Terra) look like they punched completely through the crust and sunk into a warmish subsurface fluid?\n\n> How is it that fluid from underneath creates depression on the surface?\n\nI certainly don't know the answer to this but my guess is that like Viking Terra which is a bulge from subsurface pressure's, Piri Planita once bulged from subsurface fluids. The fluid ate away at the crust from below then the fluid moved out from beneath which then caused the crust to collapse inward. Just a guess. Do you have a guess on what caused Piri P to become an impression?\n\n> at one point, there definitely was fluid on top\n\nCan you show a picture of the area you are referring to?\nThe fractures leading from Viking terra into Piri Planitia certainly look like a series of rivers that flowed into the basin as they fan out like we see in a river delta scenario but I don't know if this is the area you are referencing.\n\nFluid's on top need heat energy to keep them fluid, remove that heat and things will freeze really quick. Nitrogen reaches it's triple point at 63K, typically Pluto is at 30 to 55K but does have summers and reaches conditions according to NASA that allow for 63K temperatures. To me it seems the most likely source of heat for fluid is from below and the crust tends to act like a blanket. \n\nTake a volcanic hot spot on earth (Hawaii, move that subsurface fluid around or the crust over the hot spot and the fluid spills out on top of the crust then hardens. Thing is, I don't know if the crust is slipping like a loose skin or if the eccentric dance that once existed moved the tidal flexing bulge which weakened or fractured things causing the fluid to migrate toward those fractures.\n\nThere are signs that these hot spots/bulges existed in various locations over time i.e... Venera Terra, Spider, Piri Planitia and now SP and east into the uplands and Tartarus Dorsa. Its all fascinating as heck to me but also perplexing.\n\nPluto's axial tilt does wobble from 102 to 128 degrees Milankovitch cycles (don't know at what time scales), this then means Charon must wobble also as their collective gravitational torque seeks to balance. Perhaps this has caused the subsurface fluids to migrate or even form.\n\nThis says to me that while Pluto/Charon are in circular orbits about their barycenter they are still in the process of finding their optimum point of gyroscopic balance. Our Earth's axis wobbles a mere 2 degrees and it is because of our moon that it is so stable. Our moon has much less of a mass ratio to earth and hence stabilizing effect on Earth than Charon has on Pluto which is half the size of Pluto.\n\nThis again suggest to me that Pluto/Charon have come together recently. If they were orbiting each other for a really long time, their wobbles would be more stable. \n\nThoughts?\n\n", + "category": null, + "created_at": "2017-02-26T10:38:32.231Z", + "discussion_id": "33908", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "331961", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "331234", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2017-02-26T11:30:14.162Z", + "upvotes": {}, + "user_id": "852577", + "user_login": "pittbull", + "versions": [], + "reply_user_id": 1377446, + "reply_user_login": "PolishPlanetPursuer", + "reply_user_display_name": "PolishPlanetPursuer", + "discussion_comments_count": 579, + "discussion_subject_default": false, + "discussion_title": "Pluto's heat source?", + "discussion_updated_at": "2020-12-04T03:05:24.726Z", + "discussion_users_count": 26, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 3221, + "board_description": "Talk about anything and everything here!", + "board_discussions_count": 532, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Chat", + "board_users_count": 678, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "pittbull", + "type": "Comment" + }, + { + "href": "/comments/356926", + "links": {}, + "board_id": "13", + "body": "@PolishPlanetPursuer I don't disagree with your assessment about Piri Planitia having had surface fluids but consider this.\n\nThe name \"Tartarus\" as in Tartarus Dorsa is the name of the deep abyss (hell) that is used as a dungeon of torment and suffering for the wicked and as the prison for the Titans. Tartarus is the place where, according to Plato in Gorgias (c. 400 BC), souls were judged after death and where the wicked received divine punishment.\n\nIn the heart of Siberia's boreal forest gapes a monstrous chasm local Yakutians call a \"gateway to the underworld,\" connecting this life to the next. This is the Batagaika crater. This crater began forming in the 1960's and is believed to have developed by methane deposits in the permafrost escaping collapsing the land into a crater. Perhaps there is a similar process occurring at Piri Planitia. Methane gasses as they warm on Pluto as on Earth may be causing surface land features to collapse into depressions.\n\nBatagaika crater was formed by subsurface erosion processes.\n\n![Example Alt Text](http://www.plutorules.com/uploads/7/2/6/8/72681811/batagaika-crater2_orig.jpg)\n\n![Example Alt Text](http://www.plutorules.com/uploads/7/2/6/8/72681811/batagaika-crater_orig.jpg)", + "category": null, + "created_at": "2017-03-11T19:58:51.804Z", + "discussion_id": "33908", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "356926", + "is_deleted": false, + "mentioning": { + "@PolishPlanetPursuer": { + "id": 1377446, + "type": "User" + } + }, + "project_id": "", + "reply_id": "", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2017-03-11T20:03:06.788Z", + "upvotes": {}, + "user_id": "852577", + "user_login": "pittbull", + "versions": [], + "reply_user_id": null, + "reply_user_login": null, + "reply_user_display_name": null, + "discussion_comments_count": 579, + "discussion_subject_default": false, + "discussion_title": "Pluto's heat source?", + "discussion_updated_at": "2020-12-04T03:05:24.726Z", + "discussion_users_count": 26, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 3221, + "board_description": "Talk about anything and everything here!", + "board_discussions_count": 532, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Chat", + "board_users_count": 678, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "pittbull", + "type": "Comment" + }, + { + "href": "/comments/140298", + "links": {}, + "board_id": "13", + "body": "The problem with solar energy is it cannot be guaranteed to always work. When its cloudy and nighttime, it won't work. Same with wind energy. It is very effective but it has downsides. That is why nuclear energy is most used.\n\n\nI wish I could say we should stop using all polluting sources of energy immediately, but it wouldn't be a very good idea. I believe that it will be best if we faze it out to 20 years. Why? There could be a worldwide recession and depression. US, Russia, and the Middle Eastern econonmies would crash and there might be a depression similar to the great depression for major oil-producing countries and a 2008 like recession for most of the world (I'm terrible at economics so it might be wrong)", + "category": null, + "created_at": "2016-08-08T21:53:36.080Z", + "discussion_id": "47457", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "140298", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "140135", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2016-08-08T21:53:36.080Z", + "upvotes": {}, + "user_id": "1377446", + "user_login": "PolishPlanetPursuer", + "versions": [], + "reply_user_id": 1444297, + "reply_user_login": "PlanetGazer8350", + "reply_user_display_name": "PlanetGazer8350", + "discussion_comments_count": 334, + "discussion_subject_default": false, + "discussion_title": "WE ARE DESTROYING OUR PLANET", + "discussion_updated_at": "2021-07-05T17:33:33.928Z", + "discussion_users_count": 61, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 3221, + "board_description": "Talk about anything and everything here!", + "board_discussions_count": 532, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Chat", + "board_users_count": 678, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "PolishPlanetPursuer", + "type": "Comment" + }, + { + "href": "/comments/146352", + "links": {}, + "board_id": "13", + "body": "> a historic continental goal of 50 percent clean power generation by 2025. Meeting the goal will involve clean energy development and deployment (including renewable, nuclear, and carbon capture and storage technologies)\n\nHeck of a difference between \"Clean energy\" including Nuclear and \"renewable sources\" of the first press release! You have to be a lawyer to read these press releases. By this shite the most populous provinces in Canada are there already and need do nothing (Ontario >50% nuclear, Quebec 90% Hydro). Alberta has to add one nuclear plant (on the books now) and just keep digging up oilsand and it's business as usual - drinks all around!\n\n> greening of government operations to 100 percent clean energy by 2025. \n\nThis must be where I got the impression this was mainly a Federal Government initiative.\n\nThis means the government will pretend the electricity they use is green and that which you use is not - and ignore that only so much power is generated and it all flows through the same wires. This is like the idiots that feel good buying \"their\" power from Bullfrog. This is an outfit that buys so much power from green sources and sell it to the utilities. They then bill their \"environmentally conscious\" customers for the power they use which miraculously is now only green energy. No new generation is involved and every kWhr of green energy bought and sold by Bullfrog would have been produced and used in any case. There is no value added that I can see - zilch zero nada! \nI expect a few solar panels on a few government roofs for show, and a switch to electric gov. vehicles as though that was carbon friendly.\n\n> Notably, all three countries are also taking important cross-cuttings steps, including aligning methods for estimating the social cost of carbon and completing comprehensive Midcentury Strategies for driving down greenhouse gas emissions.\n\nSounds impressive - now can somebody tell me what taking cross-cutting steps, aligning anything, and completing Strategies (as compared to say *implementing* them) actual does to fix anything?\n\nNewspeak for the masses.\n\nI am sorry zutoplan but this sort of blather only reinforces my belief we are unable to react to the problem and too little, much too late will be the result. Frankly while this has been a good, no actually an *excellent* discussion without much of the usual tripe about cell phone chargers and black screen savers, I am totally depressed, and feel we are simply wasting energy.\n\n\n\n\n", + "category": null, + "created_at": "2016-08-16T03:15:05.009Z", + "discussion_id": "47457", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "146352", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2016-08-16T03:25:36.086Z", + "upvotes": {}, + "user_id": "1365766", + "user_login": "Pmason", + "versions": [], + "reply_user_id": null, + "reply_user_login": null, + "reply_user_display_name": null, + "discussion_comments_count": 334, + "discussion_subject_default": false, + "discussion_title": "WE ARE DESTROYING OUR PLANET", + "discussion_updated_at": "2021-07-05T17:33:33.928Z", + "discussion_users_count": 61, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 3221, + "board_description": "Talk about anything and everything here!", + "board_discussions_count": 532, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Chat", + "board_users_count": 678, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "Pmason", + "type": "Comment" + }, + { + "href": "/comments/158003", + "links": {}, + "board_id": "13", + "body": "Agreed. Something many people may not know about is what people want to do to the Grand Canyon. They basically want to turn it into a giant amusement park! I read about it in a NG, and boy was it depressing. ", + "category": null, + "created_at": "2016-08-30T21:28:11.142Z", + "discussion_id": "47457", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "158003", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2016-08-30T21:28:11.142Z", + "upvotes": {}, + "user_id": "1493450", + "user_login": "Clearstream", + "versions": [], + "reply_user_id": null, + "reply_user_login": null, + "reply_user_display_name": null, + "discussion_comments_count": 334, + "discussion_subject_default": false, + "discussion_title": "WE ARE DESTROYING OUR PLANET", + "discussion_updated_at": "2021-07-05T17:33:33.928Z", + "discussion_users_count": 61, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 3221, + "board_description": "Talk about anything and everything here!", + "board_discussions_count": 532, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Chat", + "board_users_count": 678, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "Clearstream", + "type": "Comment" + }, + { + "href": "/comments/206532", + "links": {}, + "board_id": "13", + "body": "A 1.5 hour long depressing [video ](https://www.youtube.com/watch?v=90CkXVF-Q8M)on climate change.\nA 20 minute [video ](https://www.youtube.com/watch?v=-mUJnKI3ipI)on one aspect of Elon Musk's solution ", + "category": null, + "created_at": "2016-10-30T19:56:38.324Z", + "discussion_id": "47457", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "206532", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2016-10-30T19:56:38.324Z", + "upvotes": {}, + "user_id": "852577", + "user_login": "pittbull", + "versions": [], + "reply_user_id": null, + "reply_user_login": null, + "reply_user_display_name": null, + "discussion_comments_count": 334, + "discussion_subject_default": false, + "discussion_title": "WE ARE DESTROYING OUR PLANET", + "discussion_updated_at": "2021-07-05T17:33:33.928Z", + "discussion_users_count": 61, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 3221, + "board_description": "Talk about anything and everything here!", + "board_discussions_count": 532, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Chat", + "board_users_count": 678, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "pittbull", + "type": "Comment" + }, + { + "href": "/comments/209573", + "links": {}, + "board_id": "13", + "body": "> A 1.5 hour long depressing video on climate change.\n\nThat new documentary \"**Before the Flood**\" by Leonardo DiCaprio, also shows the **Canadian Oil Sands**, as I read in the news! I had done some posts concerning \"oil sands\" in this discussion.\n\nPS: I haven't watched the video yet, but I am going to watch it! ", + "category": null, + "created_at": "2016-11-01T20:45:33.616Z", + "discussion_id": "47457", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "209573", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2016-11-01T20:48:20.219Z", + "upvotes": {}, + "user_id": "65326", + "user_login": "zutopian", + "versions": [], + "reply_user_id": null, + "reply_user_login": null, + "reply_user_display_name": null, + "discussion_comments_count": 334, + "discussion_subject_default": false, + "discussion_title": "WE ARE DESTROYING OUR PLANET", + "discussion_updated_at": "2021-07-05T17:33:33.928Z", + "discussion_users_count": 61, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 3221, + "board_description": "Talk about anything and everything here!", + "board_discussions_count": 532, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Chat", + "board_users_count": 678, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "zutopian", + "type": "Comment" + }, + { + "href": "/comments/221362", + "links": {}, + "board_id": "13", + "body": "**In my opinion**, Trump´s success in the USA elections, the 8 th of November, is **extremely bad** and quite **depressing** news, for humanity and the stop of climate change. I think by now, there has certainly been considerable impacts, and now, consequences of global warming have started to be felt worldwide. For sure, optimism is a key element when someone, in this case, every single of us humans, need, have needed, and will find to need, whenever they are trying to solve a problem, dealing with it until the situation has in some way improved. I don´t want to get into politics, or in any way try to offend anyone or get to people´s personal opinions, but Trump´s ideas seem to me totally absurd and digusting, and racist, by the fact that he said that he will not carry out the convenant agreed at Paris against climate change. He said that it was all a hoax, as you said, invented by the Chinese to prejudice American businesses.\n\n\n\n", + "category": null, + "created_at": "2016-11-10T20:06:26.030Z", + "discussion_id": "47457", + "focus_id": "", + "focus_type": null, + "group_mentioning": {}, + "id": "221362", + "is_deleted": false, + "mentioning": {}, + "project_id": "", + "reply_id": "219476", + "section": "zooniverse", + "tagging": {}, + "updated_at": "2016-11-10T20:06:26.030Z", + "upvotes": { + "sergiski": "1478887173" + }, + "user_id": "1444297", + "user_login": "PlanetGazer8350", + "versions": [], + "reply_user_id": 852577, + "reply_user_login": "pittbull", + "reply_user_display_name": "pittbull", + "discussion_comments_count": 334, + "discussion_subject_default": false, + "discussion_title": "WE ARE DESTROYING OUR PLANET", + "discussion_updated_at": "2021-07-05T17:33:33.928Z", + "discussion_users_count": 61, + "discussion_focus_id": "", + "discussion_focus_type": null, + "discussion_locked": false, + "board_comments_count": 3221, + "board_description": "Talk about anything and everything here!", + "board_discussions_count": 532, + "board_parent_id": "", + "board_subject_default": false, + "board_title": "Chat", + "board_users_count": 678, + "board_permissions": { + "read": "all", + "write": "all" + }, + "project_slug": null, + "project_title": null, + "moderatable_actions": [], + "user_display_name": "PlanetGazer8350", + "type": "Comment" + }, + null + ], + "meta": { + "searches": { + "page": 3, + "page_size": 10, + "count": 42, + "include": [], + "page_count": 5, + "previous_page": 2, + "next_page": 4, + "first_href": "/searches?page=1&page_size=10§ion=zooniverse&query=depression&types=comments", + "previous_href": "/searches?page=2&page_size=10§ion=zooniverse&query=depression&types=comments", + "next_href": "/searches?page=4&page_size=10§ion=zooniverse&query=depression&types=comments", + "last_href": "/searches?page=5&page_size=10§ion=zooniverse&query=depression&types=comments" + } + } +}; diff --git a/test/support/setup.mjs b/test/support/setup.mjs new file mode 100644 index 0000000..f1b3f71 --- /dev/null +++ b/test/support/setup.mjs @@ -0,0 +1,4 @@ +import nock from 'nock'; + +// require all net requests to be mocked. +nock.disableNetConnect() diff --git a/test/talkClient.mjs b/test/talkClient.mjs new file mode 100644 index 0000000..16906c0 --- /dev/null +++ b/test/talkClient.mjs @@ -0,0 +1,69 @@ +import { expect } from 'chai'; +import nock from 'nock'; +import talkClient from '../lib/talk-client.js'; +import { talkSearch, talkSearchWithNull } from './support/mockTalkAPI.mjs'; + +describe('talkClient', function () { + describe('search', function () { + specify('should return a list of comments', async function () { + nock('https://talk-test.zooniverse.org') + .get('/searches?http_cache=true&types=comments§ion=zooniverse&page=1&pageSize=10&query=depression') + .reply(200, talkSearch); + + const params = { + types: ['comments'], + section: 'zooniverse', + page: 1, + pageSize: 10, + query: 'depression' + }; + const results = await talkClient.type('searches').get(params); + expect(results).to.be.an('array'); + expect(results).to.have.lengthOf(10); + results.forEach(result => { + expect(result.type).to.equal('Comment'); + expect(result.body).to.be.a('string'); + }); + }); + specify('should ignore null comments', async function () { + // this Talk query returns 9 comments and one null comment. + nock('https://talk-test.zooniverse.org') + .get('/searches?http_cache=true&types=comments§ion=zooniverse&page=3&pageSize=10&query=depression') + .reply(200, talkSearchWithNull); + + const params = { + types: ['comments'], + section: 'zooniverse', + page: 3, + pageSize: 10, + query: 'depression' + }; + const results = await talkClient.type('searches').get(params); + expect(results).to.be.an('array'); + expect(results).to.have.lengthOf(9); + results.forEach(result => { + expect(result.type).to.equal('Comment'); + expect(result.body).to.be.a('string'); + }); + }); + specify('should be empty when all results are null', async function () { + // This is a production Talk query that only returns null results. + nock('https://talk-test.zooniverse.org') + .get('/searches?http_cache=true&types=comments§ion=zooniverse&page=4&pageSize=10&query=depression') + .reply(200, { + searches: [null, null, null, null, null, null, null, null, null, null] + }); + + const params = { + types: ['comments'], + section: 'zooniverse', + page: 4, + pageSize: 10, + query: 'depression' + }; + const results = await talkClient.type('searches').get(params); + expect(results).to.be.an('array'); + expect(results).to.have.lengthOf(0); + }); + }); +});