diff --git a/backend/package.json b/backend/package.json index e05b41463..4036430ea 100644 --- a/backend/package.json +++ b/backend/package.json @@ -47,21 +47,21 @@ "apollo-client": "~2.6.3", "apollo-link-context": "~1.0.18", "apollo-link-http": "~1.5.15", - "apollo-server": "~2.6.4", + "apollo-server": "~2.6.7", "bcryptjs": "~2.4.3", "cheerio": "~1.0.0-rc.3", "cors": "~2.8.5", "cross-env": "~5.2.0", - "date-fns": "2.0.0-alpha.37", + "date-fns": "2.0.0-beta.2", "debug": "~4.1.1", "dotenv": "~8.0.0", "express": "~4.17.1", "faker": "Marak/faker.js#master", - "graphql": "~14.3.1", + "graphql": "~14.4.0", "graphql-custom-directives": "~0.2.14", "graphql-iso-date": "~3.6.1", "graphql-middleware": "~3.0.2", - "graphql-shield": "~5.7.1", + "graphql-shield": "~5.6.1", "graphql-tag": "~2.10.1", "graphql-yoga": "~1.18.0", "helmet": "~3.18.0", @@ -88,14 +88,14 @@ "@babel/plugin-proposal-throw-expressions": "^7.2.0", "@babel/preset-env": "~7.4.5", "@babel/register": "~7.4.4", - "apollo-server-testing": "~2.6.6", + "apollo-server-testing": "~2.6.7", "babel-core": "~7.0.0-0", "babel-eslint": "~10.0.2", "babel-jest": "~24.8.0", "chai": "~4.2.0", "cucumber": "~5.1.0", "eslint": "~6.0.1", - "eslint-config-prettier": "~5.0.0", + "eslint-config-prettier": "~6.0.0", "eslint-config-standard": "~12.0.0", "eslint-plugin-import": "~2.18.0", "eslint-plugin-jest": "~22.7.1", diff --git a/backend/src/schema/resolvers/fileUpload/index.js b/backend/src/schema/resolvers/fileUpload/index.js index c37d87e39..fa78238c3 100644 --- a/backend/src/schema/resolvers/fileUpload/index.js +++ b/backend/src/schema/resolvers/fileUpload/index.js @@ -12,7 +12,6 @@ const storeUpload = ({ createReadStream, fileLocation }) => export default async function fileUpload(params, { file, url }, uploadCallback = storeUpload) { const upload = params[file] - if (upload) { const { createReadStream, filename } = await upload const { name } = path.parse(filename) diff --git a/backend/src/schema/resolvers/users.spec.js b/backend/src/schema/resolvers/users.spec.js index 352d38eaa..9df5473bf 100644 --- a/backend/src/schema/resolvers/users.spec.js +++ b/backend/src/schema/resolvers/users.spec.js @@ -143,7 +143,7 @@ describe('users', () => { let deleteUserVariables let asAuthor const deleteUserMutation = gql` - mutation($id: ID!, $resource: [String]) { + mutation($id: ID!, $resource: [Deletable]) { DeleteUser(id: $id, resource: $resource) { id contributions { diff --git a/backend/src/schema/types/scalar/Upload.gql b/backend/src/schema/types/scalar/Upload.gql index fca9ea1fc..cf3965846 100644 --- a/backend/src/schema/types/scalar/Upload.gql +++ b/backend/src/schema/types/scalar/Upload.gql @@ -1 +1 @@ -scalar Upload \ No newline at end of file +scalar Upload diff --git a/backend/src/schema/types/schema.gql b/backend/src/schema/types/schema.gql index bc3daad26..6588bb264 100644 --- a/backend/src/schema/types/schema.gql +++ b/backend/src/schema/types/schema.gql @@ -40,7 +40,6 @@ type Mutation { follow(id: ID!, type: FollowTypeEnum): Boolean! # Unfollow the given Type and ID unfollow(id: ID!, type: FollowTypeEnum): Boolean! - DeleteUser(id: ID!, resource: [String]): User CreatePost( id: ID activityId: String @@ -59,6 +58,7 @@ type Mutation { categoryIds: [ID] contentExcerpt: String ): Post + DeleteUser(id: ID!, resource: [Deletable]): User } type Statistics { @@ -110,6 +110,11 @@ type Report { user: User @relation(name: "REPORTED", direction: "OUT") } +enum Deletable { + Post + Comment +} + enum ShoutTypeEnum { Post Organization diff --git a/backend/yarn.lock b/backend/yarn.lock index dec5d7f4f..b66143b5e 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1110,10 +1110,10 @@ resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.9.tgz#693e76a52f61a2f1e7fb48c0eef167b95ea4ffd0" integrity sha512-sCZy4SxP9rN2w30Hlmg5dtdRwgYQfYRiLo9usw8X9cxlf+H4FqM1xX7+sNH7NNKVdbXMJWqva7iyy+fxh/V7fA== -"@types/yup@0.26.17": - version "0.26.17" - resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.26.17.tgz#5cb7cfc211d8e985b21d88289542591c92cad9dc" - integrity sha512-MN7VHlPsZQ2MTBxLE2Gl+Qfg2WyKsoz+vIr8xN0OSZ4AvJDrrKBlxc8b59UXCCIG9tPn9XhxTXh3j/htHbzC2Q== +"@types/yup@0.26.16": + version "0.26.16" + resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.26.16.tgz#75c428236207c48d9f8062dd1495cda8c5485a15" + integrity sha512-E2RNc7DSeQ+2EIJ1H3+yFjYu6YiyQBUJ7yNpIxomrYJ3oFizLZ5yDS3T1JTUNBC2OCRkgnhLS0smob5UuCHfNA== "@types/zen-observable@^0.5.3": version "0.5.4" @@ -1279,14 +1279,6 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" -apollo-cache-control@0.7.2: - version "0.7.2" - resolved "https://registry.yarnpkg.com/apollo-cache-control/-/apollo-cache-control-0.7.2.tgz#b8852422d973c582493e85c776abc9c660090162" - integrity sha512-7prjFN8H9lRE0npqGG8kM3XICvNCcgQt6eCy8kkcPOIZwM+F8m8ShjEfNF9UWW32i+poOk3G67HegPRyjCc6/Q== - dependencies: - apollo-server-env "2.4.0" - graphql-extensions "0.7.2" - apollo-cache-control@0.7.4: version "0.7.4" resolved "https://registry.yarnpkg.com/apollo-cache-control/-/apollo-cache-control-0.7.4.tgz#0cb5c7be0e0dd0c44b1257144cd7f9f2a3c374e6" @@ -1350,29 +1342,17 @@ apollo-engine-reporting-protobuf@0.3.1: dependencies: protobufjs "^6.8.6" -apollo-engine-reporting@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/apollo-engine-reporting/-/apollo-engine-reporting-1.3.2.tgz#b2569f79eb1a7a7380f49340db61465f449284fe" - integrity sha512-Q9XUZ3CTqddjCswlbn+OD2oYxZ5p4lCAnsWOGMfYnSmCXLagyNK28UFFQodjFOy73p6nlTAg9cwaJ9yMOBeeXA== +apollo-engine-reporting@1.3.5: + version "1.3.5" + resolved "https://registry.yarnpkg.com/apollo-engine-reporting/-/apollo-engine-reporting-1.3.5.tgz#075424d39dfe77a20f96e8e33b7ae52d58c38e1e" + integrity sha512-pSwjPgXK/elFsR22LXALtT3jI4fpEpeTNTHgNwLVLohaolusMYgBc/9FnVyFWFfMFS9k+3RmfeQdHhZ6T7WKFQ== dependencies: apollo-engine-reporting-protobuf "0.3.1" - apollo-graphql "^0.3.2" - apollo-server-core "2.6.4" + apollo-graphql "^0.3.3" + apollo-server-core "2.6.7" apollo-server-env "2.4.0" async-retry "^1.2.1" - graphql-extensions "0.7.3" - -apollo-engine-reporting@1.3.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/apollo-engine-reporting/-/apollo-engine-reporting-1.3.4.tgz#65e12f94221d80b3b1740c26e82ce9bb6bdfb7ee" - integrity sha512-DJdYghyUBzT0/LcPLwuQNXDCw06r1RfxkVfNTGKoTv6a+leVvjhDJmXvc+jSuBPwaNsc+RYRnfyQ2qUn9fmfyA== - dependencies: - apollo-engine-reporting-protobuf "0.3.1" - apollo-graphql "^0.3.2" - apollo-server-core "2.6.6" - apollo-server-env "2.4.0" - async-retry "^1.2.1" - graphql-extensions "0.7.5" + graphql-extensions "0.7.6" apollo-env@0.5.1: version "0.5.1" @@ -1391,10 +1371,10 @@ apollo-errors@^1.9.0: assert "^1.4.1" extendable-error "^0.1.5" -apollo-graphql@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/apollo-graphql/-/apollo-graphql-0.3.2.tgz#8881a87f1d5fcf80837b34dba90737e664eabe9a" - integrity sha512-YbzYGR14GV0023m//EU66vOzZ3i7c04V/SF8Qk+60vf1sOWyKgO6mxZJ4BKhw10qWUayirhSDxq3frYE+qSG0A== +apollo-graphql@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/apollo-graphql/-/apollo-graphql-0.3.3.tgz#ce1df194f6e547ad3ce1e35b42f9c211766e1658" + integrity sha512-t3CO/xIDVsCG2qOvx2MEbuu4b/6LzQjcBBwiVnxclmmFyAxYCIe7rpPlnLHSq7HyOMlCWDMozjoeWfdqYSaLqQ== dependencies: apollo-env "0.5.1" lodash.sortby "^4.7.0" @@ -1442,50 +1422,24 @@ apollo-server-caching@0.4.0: dependencies: lru-cache "^5.0.0" -apollo-server-core@2.6.4: - version "2.6.4" - resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.6.4.tgz#0372e3a28f221b9db83bdfbb0fd0b2960cd29bab" - integrity sha512-GBF+tQoJ/ysaY2CYMkuuAwJM1nk1yLJumrsBTFfcvalSzS64VdS5VN/zox1eRI+LHQQzHM18HYEAgDGa/EX+gw== - dependencies: - "@apollographql/apollo-tools" "^0.3.6" - "@apollographql/graphql-playground-html" "1.6.20" - "@types/ws" "^6.0.0" - apollo-cache-control "0.7.2" - apollo-datasource "0.5.0" - apollo-engine-reporting "1.3.2" - apollo-server-caching "0.4.0" - apollo-server-env "2.4.0" - apollo-server-errors "2.3.0" - apollo-server-plugin-base "0.5.3" - apollo-tracing "0.7.2" - fast-json-stable-stringify "^2.0.0" - graphql-extensions "0.7.3" - graphql-subscriptions "^1.0.0" - graphql-tag "^2.9.2" - graphql-tools "^4.0.0" - graphql-upload "^8.0.2" - sha.js "^2.4.11" - subscriptions-transport-ws "^0.9.11" - ws "^6.0.0" - -apollo-server-core@2.6.6: - version "2.6.6" - resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.6.6.tgz#55fea7980a943948c49dea20d81b9bbfc0e04f87" - integrity sha512-PFSjJbqkV1eetfFJxu11gzklQYC8BrF0RZfvC1d1mhvtxAOKl25uhPHxltN0Omyjp7LW4YeoC6zwl9rLWuhZFQ== +apollo-server-core@2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.6.7.tgz#85b0310f40cfec43a702569c73af16d88776a6f0" + integrity sha512-HfOGLvEwPgDWTvd3ZKRPEkEnICKb7xadn1Mci4+auMTsL/NVkfpjPa8cdzubi/kS2/MvioIn7Bg74gmiSLghGQ== dependencies: "@apollographql/apollo-tools" "^0.3.6" "@apollographql/graphql-playground-html" "1.6.20" "@types/ws" "^6.0.0" apollo-cache-control "0.7.4" apollo-datasource "0.5.0" - apollo-engine-reporting "1.3.4" + apollo-engine-reporting "1.3.5" apollo-server-caching "0.4.0" apollo-server-env "2.4.0" apollo-server-errors "2.3.0" - apollo-server-plugin-base "0.5.5" + apollo-server-plugin-base "0.5.6" apollo-tracing "0.7.3" fast-json-stable-stringify "^2.0.0" - graphql-extensions "0.7.5" + graphql-extensions "0.7.6" graphql-subscriptions "^1.0.0" graphql-tag "^2.9.2" graphql-tools "^4.0.0" @@ -1516,10 +1470,10 @@ apollo-server-errors@2.3.0: resolved "https://registry.yarnpkg.com/apollo-server-errors/-/apollo-server-errors-2.3.0.tgz#700622b66a16dffcad3b017e4796749814edc061" integrity sha512-rUvzwMo2ZQgzzPh2kcJyfbRSfVKRMhfIlhY7BzUfM4x6ZT0aijlgsf714Ll3Mbf5Fxii32kD0A/DmKsTecpccw== -apollo-server-express@2.6.4: - version "2.6.4" - resolved "https://registry.yarnpkg.com/apollo-server-express/-/apollo-server-express-2.6.4.tgz#fc1d661be73fc1880aa53a56e1abe3733d08eada" - integrity sha512-U6hiZxty/rait39V5d+QeueNHlwfl68WbYtsutDUVxnq2Jws2ZDrvIkaWWN6HQ77+nBy5gGVxycvWIyoHHfi+g== +apollo-server-express@2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/apollo-server-express/-/apollo-server-express-2.6.7.tgz#22307e08b75be1553f4099d00028abe52597767d" + integrity sha512-qbCQM+8LxXpwPNN5Sdvcb+Sne8zuCORFt25HJtPJRkHlyBUzOd7JA7SEnUn5e2geTiiGoVIU5leh+++C51udTw== dependencies: "@apollographql/graphql-playground-html" "1.6.20" "@types/accepts" "^1.3.5" @@ -1527,7 +1481,7 @@ apollo-server-express@2.6.4: "@types/cors" "^2.8.4" "@types/express" "4.17.0" accepts "^1.3.5" - apollo-server-core "2.6.4" + apollo-server-core "2.6.7" body-parser "^1.18.3" cors "^2.8.4" graphql-subscriptions "^1.0.0" @@ -1555,42 +1509,29 @@ apollo-server-module-graphiql@^1.3.4, apollo-server-module-graphiql@^1.4.0: resolved "https://registry.yarnpkg.com/apollo-server-module-graphiql/-/apollo-server-module-graphiql-1.4.0.tgz#c559efa285578820709f1769bb85d3b3eed3d8ec" integrity sha512-GmkOcb5he2x5gat+TuiTvabnBf1m4jzdecal3XbXBh/Jg+kx4hcvO3TTDFQ9CuTprtzdcVyA11iqG7iOMOt7vA== -apollo-server-plugin-base@0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-0.5.3.tgz#234c6330c412a2e83ff49305a0c2f991fb40a266" - integrity sha512-Ax043vQTzPgFeJk6m6hmPm9NMfogO3LlTKJfrWHuyZhPNeTLweHNK30vpdzzgPalcryyDMDfLYFzxuDm0W+rRQ== +apollo-server-plugin-base@0.5.6: + version "0.5.6" + resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-0.5.6.tgz#3a7128437a0f845e7d873fa43ef091ff7bf27975" + integrity sha512-wJvcPqfm/kiBwY5JZT85t2A4pcHv24xdQIpWMNt1zsnx77lIZqJmhsc22eSUSrlnYqUMXC4XMVgSUfAO4oI9wg== -apollo-server-plugin-base@0.5.5: - version "0.5.5" - resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-0.5.5.tgz#364e4a2fca4d95ddeb9fd3e78940ed1da58865c2" - integrity sha512-agiuhknyu3lnnEsqUh99tzxwPCGp+TuDK+TSRTkXU1RUG6lY4C3uJp0JGJw03cP+M6ze73TbRjMA4E68g/ks5A== - -apollo-server-testing@~2.6.6: - version "2.6.6" - resolved "https://registry.yarnpkg.com/apollo-server-testing/-/apollo-server-testing-2.6.6.tgz#3d96486ebdb151219183fcb715973a8385c66e0a" - integrity sha512-GfzEAqXGzhWp1YgNJONAijC3mC34E6cI5XiOdLX9FGAnBmZvDURlZwloZbdNgvqvXnwuxuNgo4xvCnTe7kndqg== +apollo-server-testing@~2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/apollo-server-testing/-/apollo-server-testing-2.6.7.tgz#cfc6366921eb99fd0cbc5d02552a8a5b268787d5" + integrity sha512-lqgZuSqBd5hkRILeVEleo2ScJjukR/E71Mv67vPBUs01s0gEHNnjSRnuOJJOM3cAFBQOdKPc42cHGANzf2ZZTw== dependencies: - apollo-server-core "2.6.6" + apollo-server-core "2.6.7" -apollo-server@~2.6.4: - version "2.6.4" - resolved "https://registry.yarnpkg.com/apollo-server/-/apollo-server-2.6.4.tgz#34b3a50135e20b8df8c194a14e4636eb9c2898b2" - integrity sha512-f0TZOc969XNNlSm8sVsU34D8caQfPNwS0oqmWUxb8xXl88HlFzB+HBmOU6ZEKdpMCksTNDbqYo0jXiGJ0rL/0g== +apollo-server@~2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/apollo-server/-/apollo-server-2.6.7.tgz#b707ede529b4d45f2f00a74f3b457658b0e62e83" + integrity sha512-4wk9JykURLed6CnNIj9jhU6ueeTVmGBTyAnnvnlhRrOf50JAFszUErZIKg6lw5vVr5riaByrGFIkMBTySCHgPQ== dependencies: - apollo-server-core "2.6.4" - apollo-server-express "2.6.4" + apollo-server-core "2.6.7" + apollo-server-express "2.6.7" express "^4.0.0" graphql-subscriptions "^1.0.0" graphql-tools "^4.0.0" -apollo-tracing@0.7.2: - version "0.7.2" - resolved "https://registry.yarnpkg.com/apollo-tracing/-/apollo-tracing-0.7.2.tgz#7730159a4670bca465ac1bfa01f9902610a7aba4" - integrity sha512-bT4/n8Vy9DweC3+XWJelJD41FBlKMXR0OVxjLMiCe9clb4yTgKhYxRGTyh9KjmhWsng9gG/DphO0ixWsOgdXmA== - dependencies: - apollo-server-env "2.4.0" - graphql-extensions "0.7.2" - apollo-tracing@0.7.3: version "0.7.3" resolved "https://registry.yarnpkg.com/apollo-tracing/-/apollo-tracing-0.7.3.tgz#8533e3e2dca2d5a25e8439ce498ea33ff4d159ee" @@ -2643,10 +2584,10 @@ data-urls@^1.0.0: whatwg-mimetype "^2.2.0" whatwg-url "^7.0.0" -date-fns@2.0.0-alpha.37: - version "2.0.0-alpha.37" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.37.tgz#c58b3e827da4f860ec8dc123e54019efb4a610e0" - integrity sha512-fyIv/h6fkFd1u2NHXni5LPRPoa9FFh3hY67JSjNfa+k/u4EKvfrpGtoTM16Y/BJOqTb4W05UjcmwBna1ElyxDA== +date-fns@2.0.0-beta.2: + version "2.0.0-beta.2" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-beta.2.tgz#ccd556df832ef761baa88c600f53d2e829245999" + integrity sha512-4cicZF707RNerr3/Q3CcdLo+3OHMCfrRXE7h5iFgn7AMvX07sqKLxSf8Yp+WJW5bvKr2cy9/PkctXLv4iFtOaA== debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: version "2.6.9" @@ -3059,10 +3000,10 @@ escodegen@^1.9.1: optionalDependencies: source-map "~0.6.1" -eslint-config-prettier@~5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-5.0.0.tgz#f7a94b2b8ae7cbf25842c36fa96c6d32cd0a697c" - integrity sha512-c17Aqiz5e8LEqoc/QPmYnaxQFAHTx2KlCZBPxXXjEMmNchOLnV/7j0HoPZuC+rL/tDC9bazUYOKJW9bOhftI/w== +eslint-config-prettier@~6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.0.0.tgz#f429a53bde9fc7660e6353910fd996d6284d3c25" + integrity sha512-vDrcCFE3+2ixNT5H83g28bO/uYAwibJxerXPj+E7op4qzBCsAV36QfvdAyVOoNxKAH2Os/e01T/2x++V0LPukA== dependencies: get-stdin "^6.0.0" @@ -3779,20 +3720,6 @@ graphql-deduplicator@^2.0.1: resolved "https://registry.yarnpkg.com/graphql-deduplicator/-/graphql-deduplicator-2.0.2.tgz#d8608161cf6be97725e178df0c41f6a1f9f778f3" integrity sha512-0CGmTmQh4UvJfsaTPppJAcHwHln8Ayat7yXXxdnuWT+Mb1dBzkbErabCWzjXyKh/RefqlGTTA7EQOZHofMaKJA== -graphql-extensions@0.7.2: - version "0.7.2" - resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.7.2.tgz#8711543f835661eaf24b48d6ac2aad44dbbd5506" - integrity sha512-TuVINuAOrEtzQAkAlCZMi9aP5rcZ+pVaqoBI5fD2k5O9fmb8OuXUQOW028MUhC66tg4E7h4YSF1uYUIimbu4SQ== - dependencies: - "@apollographql/apollo-tools" "^0.3.6" - -graphql-extensions@0.7.3: - version "0.7.3" - resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.7.3.tgz#2ab7331c72ae657e4cbfa4ff004c400b19f56cdf" - integrity sha512-D+FZM0t5gFntJUizeRCurZuUqsyVP13CRejRX+cDJivyGkE6OMWYkCWlzHcbye79q+hYN1m6a3NhlrJRaD9D0w== - dependencies: - "@apollographql/apollo-tools" "^0.3.6" - graphql-extensions@0.7.4: version "0.7.4" resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.7.4.tgz#78327712822281d5778b9210a55dc59c93a9c184" @@ -3800,10 +3727,10 @@ graphql-extensions@0.7.4: dependencies: "@apollographql/apollo-tools" "^0.3.6" -graphql-extensions@0.7.5: - version "0.7.5" - resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.7.5.tgz#fab2b9e53cf6014952e6547456d50680ff0ea579" - integrity sha512-B1m+/WEJa3IYKWqBPS9W/7OasfPmlHOSz5hpEAq2Jbn6T0FQ/d2YWFf2HBETHR3RR2qfT+55VMiYovl2ga3qcg== +graphql-extensions@0.7.6: + version "0.7.6" + resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.7.6.tgz#80cdddf08b0af12525529d1922ee2ea0d0cc8ecf" + integrity sha512-RV00O3YFD1diehvdja180BlKOGWgeigr/8/Wzr6lXwLcFtk6FecQC/7nf6oW1qhuXczHyNjt/uCr0WWbWq6mYg== dependencies: "@apollographql/apollo-tools" "^0.3.6" @@ -3861,12 +3788,12 @@ graphql-request@~1.8.2: dependencies: cross-fetch "2.2.2" -graphql-shield@~5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/graphql-shield/-/graphql-shield-5.7.1.tgz#04095fb8148a463997f7c509d4aeb2a6abf79f98" - integrity sha512-UZ0K1uAqRAoGA1U2DsUu4vIZX2Vents4Xim99GFEUBTgvSDkejiE+k/Dywqfu76lJFEE8qu3vG5fhJN3SmnKbA== +graphql-shield@~5.6.1: + version "5.6.2" + resolved "https://registry.yarnpkg.com/graphql-shield/-/graphql-shield-5.6.2.tgz#27eaad2ce2591ed81b1203e8915df99b28fb5ad5" + integrity sha512-DlS6r39s7AaP07yMM6i7GI87UkfL65O1tUPW4kNqp67fD1BU71Ekl7Kt/1L3rxS/gcQdGufuKka5oKUa5GKo2A== dependencies: - "@types/yup" "0.26.17" + "@types/yup" "0.26.16" lightercollective "^0.3.0" object-hash "^1.3.1" yup "^0.27.0" @@ -3939,10 +3866,10 @@ graphql-yoga@~1.18.0: graphql-upload "^8.0.0" subscriptions-transport-ws "^0.9.8" -"graphql@^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0", graphql@^14.2.1, graphql@~14.3.1: - version "14.3.1" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.3.1.tgz#b3aa50e61a841ada3c1f9ccda101c483f8e8c807" - integrity sha512-FZm7kAa3FqKdXy8YSSpAoTtyDFMIYSpCDOr+3EqlI1bxmtHu+Vv/I2vrSeT1sBOEnEniX3uo4wFhFdS/8XN6gA== +"graphql@^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0", graphql@^14.2.1, graphql@~14.4.0: + version "14.4.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.4.0.tgz#e97086acfc0338e4fdc8f7dba519c6b8a6badfd9" + integrity sha512-E55z1oK6e4cGxCqlSsRWytYDPcIUxky3XkbuQUf6TIjCmn6C7CuBJpmkMF1066q95yPAGOZVPTVT7jABKbRFSA== dependencies: iterall "^1.2.2" diff --git a/package.json b/package.json index 38c5c9a39..856a241de 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "devDependencies": { "codecov": "^3.5.0", "cross-env": "^5.2.0", - "cypress": "^3.3.1", + "cypress": "^3.3.2", "cypress-cucumber-preprocessor": "^1.12.0", "cypress-file-upload": "^3.1.4", "cypress-plugin-retries": "^1.2.2", diff --git a/webapp/components/ContributionForm/ContributionForm.spec.js b/webapp/components/ContributionForm/ContributionForm.spec.js index a282ea085..c781df3a4 100644 --- a/webapp/components/ContributionForm/ContributionForm.spec.js +++ b/webapp/components/ContributionForm/ContributionForm.spec.js @@ -4,11 +4,14 @@ import Styleguide from '@human-connection/styleguide' import Vuex from 'vuex' import PostMutations from '~/graphql/PostMutations.js' import CategoriesSelect from '~/components/CategoriesSelect/CategoriesSelect' +import Filters from '~/plugins/vue-filters' +import TeaserImage from '~/components/TeaserImage/TeaserImage' const localVue = createLocalVue() localVue.use(Vuex) localVue.use(Styleguide) +localVue.use(Filters) config.stubs['no-ssr'] = '' @@ -22,6 +25,10 @@ describe('ContributionForm.vue', () => { let propsData const postTitle = 'this is a title for a post' const postContent = 'this is a post' + const imageUpload = { + file: { filename: 'avataar.svg', previewElement: '' }, + url: 'someUrlToImage', + } beforeEach(() => { mocks = { @@ -107,6 +114,7 @@ describe('ContributionForm.vue', () => { language: 'en', id: null, categoryIds: null, + imageUpload: null, }, } postTitleInput = wrapper.find('.ds-input') @@ -135,6 +143,11 @@ describe('ContributionForm.vue', () => { const categoryIds = ['cat12', 'cat15', 'cat37'] expectedParams.variables.categoryIds = categoryIds wrapper.find(CategoriesSelect).vm.$emit('updateCategories', categoryIds) + }) + + it('supports adding a teaser image', async () => { + expectedParams.variables.imageUpload = imageUpload + wrapper.find(TeaserImage).vm.$emit('addTeaserImage', imageUpload) await wrapper.find('form').trigger('submit') expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams)) }) @@ -158,6 +171,7 @@ describe('ContributionForm.vue', () => { describe('handles errors', () => { beforeEach(async () => { + jest.useFakeTimers() wrapper = Wrapper() postTitleInput = wrapper.find('.ds-input') postTitleInput.setValue(postTitle) @@ -165,6 +179,7 @@ describe('ContributionForm.vue', () => { // second submission causes mutation to reject await wrapper.find('form').trigger('submit') }) + it('shows an error toaster when apollo mutation rejects', async () => { await wrapper.find('form').trigger('submit') await mocks.$apollo.mutate @@ -182,6 +197,7 @@ describe('ContributionForm.vue', () => { title: 'dies ist ein Post', content: 'auf Deutsch geschrieben', language: 'de', + imageUpload, }, } wrapper = Wrapper() @@ -203,10 +219,6 @@ describe('ContributionForm.vue', () => { expect(wrapper.vm.form.content).toEqual(propsData.contribution.content) }) - it('sets language equal to contribution language', () => { - expect(wrapper.vm.form.language).toEqual({ value: propsData.contribution.language }) - }) - it('calls the UpdatePost apollo mutation', async () => { expectedParams = { mutation: PostMutations().UpdatePost, @@ -216,6 +228,7 @@ describe('ContributionForm.vue', () => { language: propsData.contribution.language, id: propsData.contribution.id, categoryIds: null, + imageUpload, }, } postTitleInput = wrapper.find('.ds-input') diff --git a/webapp/components/ContributionForm/index.vue b/webapp/components/ContributionForm/index.vue index 0b09eee70..6af1f0d4b 100644 --- a/webapp/components/ContributionForm/index.vue +++ b/webapp/components/ContributionForm/index.vue @@ -2,6 +2,13 @@ @@ -52,11 +60,13 @@ import orderBy from 'lodash/orderBy' import locales from '~/locales' import PostMutations from '~/graphql/PostMutations.js' import HcCategoriesSelect from '~/components/CategoriesSelect/CategoriesSelect' +import HcTeaserImage from '~/components/TeaserImage/TeaserImage' export default { components: { HcEditor, HcCategoriesSelect, + HcTeaserImage, }, props: { contribution: { type: Object, default: () => {} }, @@ -66,6 +76,7 @@ export default { form: { title: '', content: '', + teaserImage: null, language: null, languageOptions: [], categoryIds: null, @@ -92,7 +103,7 @@ export default { this.slug = contribution.slug this.form.content = contribution.content this.form.title = contribution.title - this.form.language = { value: contribution.language } + this.form.teaserImage = contribution.imageUpload }, }, }, @@ -110,7 +121,15 @@ export default { }, methods: { submit() { - const { title, content, language, categoryIds } = this.form + const { title, content, teaserImage, categoryIds } = this.form + let language + if (this.form.language) { + language = this.form.language.value + } else if (this.contribution && this.contribution.language) { + language = this.contribution.language + } else { + language = this.$i18n.locale() + } this.loading = true this.$apollo .mutate({ @@ -119,8 +138,9 @@ export default { id: this.id, title, content, - language: language ? language.value : this.$i18n.locale(), categoryIds, + language, + imageUpload: teaserImage, }, }) .then(res => { @@ -152,6 +172,9 @@ export default { updateCategories(ids) { this.form.categoryIds = ids }, + addTeaserImage(file) { + this.form.teaserImage = file + }, }, apollo: { User: { @@ -184,8 +207,4 @@ export default { padding-right: 0; } } - -.contribution-form-footer { - border-top: $border-size-base solid $border-color-softest; -} diff --git a/webapp/components/DeleteData/DeleteData.vue b/webapp/components/DeleteData/DeleteData.vue index 14b6bc9c3..293e65221 100644 --- a/webapp/components/DeleteData/DeleteData.vue +++ b/webapp/components/DeleteData/DeleteData.vue @@ -111,7 +111,7 @@ export default { this.$apollo .mutate({ mutation: gql` - mutation($id: ID!, $resource: [String]) { + mutation($id: ID!, $resource: [Deletable]) { DeleteUser(id: $id, resource: $resource) { id } diff --git a/webapp/components/TeaserImage/TeaserImage.spec.js b/webapp/components/TeaserImage/TeaserImage.spec.js new file mode 100644 index 000000000..07b17e16b --- /dev/null +++ b/webapp/components/TeaserImage/TeaserImage.spec.js @@ -0,0 +1,61 @@ +import { mount, createLocalVue } from '@vue/test-utils' +import TeaserImage from './TeaserImage.vue' +import Styleguide from '@human-connection/styleguide' + +const localVue = createLocalVue() + +localVue.use(Styleguide) + +describe('TeaserImage.vue', () => { + let wrapper + let mocks + + beforeEach(() => { + mocks = { + $toast: { + error: jest.fn(), + }, + } + }) + describe('mount', () => { + const Wrapper = () => { + return mount(TeaserImage, { mocks, localVue }) + } + beforeEach(() => { + wrapper = Wrapper() + }) + + describe('File upload', () => { + const imageUpload = [ + { file: { filename: 'avataar.svg', previewElement: '' }, url: 'someUrlToImage' }, + ] + + it('supports adding a teaser image', () => { + wrapper.vm.addTeaserImage(imageUpload) + expect(wrapper.emitted().addTeaserImage[0]).toEqual(imageUpload) + }) + }) + + describe('handles errors', () => { + beforeEach(() => jest.useFakeTimers()) + const message = 'File upload failed' + const fileError = { status: 'error' } + + it('defaults to error false', () => { + expect(wrapper.vm.error).toEqual(false) + }) + + it('shows an error toaster when verror is called', () => { + wrapper.vm.verror(fileError, message) + expect(mocks.$toast.error).toHaveBeenCalledWith(fileError.status, message) + }) + + it('changes error status from false to true to false', () => { + wrapper.vm.verror(fileError, message) + expect(wrapper.vm.error).toEqual(true) + jest.runAllTimers() + expect(wrapper.vm.error).toEqual(false) + }) + }) + }) +}) diff --git a/webapp/components/TeaserImage/TeaserImage.vue b/webapp/components/TeaserImage/TeaserImage.vue new file mode 100644 index 000000000..cb657fe9a --- /dev/null +++ b/webapp/components/TeaserImage/TeaserImage.vue @@ -0,0 +1,197 @@ + + + + diff --git a/webapp/components/Upload/index.vue b/webapp/components/Upload/index.vue index f7f730632..3f84f8a7c 100644 --- a/webapp/components/Upload/index.vue +++ b/webapp/components/Upload/index.vue @@ -9,7 +9,7 @@ @vdropzone-error="verror" >
- +
@@ -22,12 +22,10 @@