From a4521b4621a872e0f717b185894fba683a46208e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 6 Nov 2019 09:13:08 +0100 Subject: [PATCH] Use of mutation `disable` removed - The mutation definition still has to be removed. --- .../softDelete/softDeleteMiddleware.spec.js | 19 +++-- .../schema/resolvers/user_management.spec.js | 8 +- backend/src/seed/seed-db.js | 73 +++++++++++++------ webapp/components/Modal/DisableModal.vue | 8 +- 4 files changed, 73 insertions(+), 35 deletions(-) diff --git a/backend/src/middleware/softDelete/softDeleteMiddleware.spec.js b/backend/src/middleware/softDelete/softDeleteMiddleware.spec.js index 5b04abebd..f656b6e05 100644 --- a/backend/src/middleware/softDelete/softDeleteMiddleware.spec.js +++ b/backend/src/middleware/softDelete/softDeleteMiddleware.spec.js @@ -111,15 +111,22 @@ beforeAll(async () => { mutate = client.mutate authenticatedUser = await moderator.toJson() - const disableMutation = gql` - mutation($id: ID!) { - disable(id: $id) + const decideMutation = gql` + mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) { + decide(resourceId: $resourceId, disable: $disable, closed: $closed) { + disable + } } ` + const disableVariables = { + resourceId: 'undefined-resource', + disable: true, + closed: false, + } await Promise.all([ - mutate({ mutation: disableMutation, variables: { id: 'c1' } }), - mutate({ mutation: disableMutation, variables: { id: 'u2' } }), - mutate({ mutation: disableMutation, variables: { id: 'p2' } }), + mutate({ mutation: decideMutation, variables: { ...disableVariables, resourceId: 'c1' } }), + mutate({ mutation: decideMutation, variables: { ...disableVariables, resourceId: 'u2' } }), + mutate({ mutation: decideMutation, variables: { ...disableVariables, resourceId: 'p2' } }), ]) authenticatedUser = null }) diff --git a/backend/src/schema/resolvers/user_management.spec.js b/backend/src/schema/resolvers/user_management.spec.js index 4fe21f92a..8f0c33572 100644 --- a/backend/src/schema/resolvers/user_management.spec.js +++ b/backend/src/schema/resolvers/user_management.spec.js @@ -19,11 +19,13 @@ const disable = async id => { req = { headers: { authorization: `Bearer ${moderatorBearerToken}` } } await mutate({ mutation: gql` - mutation($id: ID!) { - disable(id: $id) + mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) { + decide(resourceId: $resourceId, disable: $disable, closed: $closed) { + disable + } } `, - variables: { id }, + variables: { resourceId: id, disable: true, closed: false }, }) req = { headers: {} } } diff --git a/backend/src/seed/seed-db.js b/backend/src/seed/seed-db.js index f6c2aee7d..9b5b400ab 100644 --- a/backend/src/seed/seed-db.js +++ b/backend/src/seed/seed-db.js @@ -536,7 +536,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p3', }), factory.create('Comment', { - author: bobDerBaumeister, + author: jennyRostock, id: 'c5', postId: 'p3', }), @@ -639,28 +639,6 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] louie.relateTo(p10, 'shouted'), ]) - const disableMutation = gql` - mutation($id: ID!) { - disable(id: $id) - } - ` - authenticatedUser = await bobDerBaumeister.toJson() - await Promise.all([ - mutate({ - mutation: disableMutation, - variables: { - id: 'p11', - }, - }), - mutate({ - mutation: disableMutation, - variables: { - id: 'c5', - }, - }), - ]) - authenticatedUser = null - // There is no error logged or the 'try' fails if this mutation is wrong. Why? const reportMutation = gql` mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) { @@ -675,6 +653,22 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] ` authenticatedUser = await huey.toJson() await Promise.all([ + mutate({ + mutation: reportMutation, + variables: { + resourceId: 'p11', + reasonCategory: 'discrimination_etc', + reasonDescription: 'I am what I am !!!', + }, + }), + mutate({ + mutation: reportMutation, + variables: { + resourceId: 'c5', + reasonCategory: 'doxing', + reasonDescription: "This shouldn't be shown to anybody else! It's my privat thing!", + }, + }), mutate({ mutation: reportMutation, variables: { @@ -730,6 +724,39 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] ]) authenticatedUser = null + // only decide after report !!! + const decideMutation = gql` + mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) { + decide(resourceId: $resourceId, disable: $disable, closed: $closed) { + disable + } + } + ` + const disableVariables = { + resourceId: 'undefined-resource', + disable: true, + closed: false, + } + authenticatedUser = await bobDerBaumeister.toJson() + await Promise.all([ + mutate({ + mutation: decideMutation, + variables: { + ...disableVariables, + resourceId: 'p11', + }, + }), + mutate({ + mutation: decideMutation, + variables: { + ...disableVariables, + resourceId: 'c5', + closed: true, + }, + }), + ]) + authenticatedUser = null + await Promise.all( [...Array(30).keys()].map(i => { return factory.create('User') diff --git a/webapp/components/Modal/DisableModal.vue b/webapp/components/Modal/DisableModal.vue index 1e778ec68..a231b4e2b 100644 --- a/webapp/components/Modal/DisableModal.vue +++ b/webapp/components/Modal/DisableModal.vue @@ -54,11 +54,13 @@ export default { // await this.modalData.buttons.confirm.callback() await this.$apollo.mutate({ mutation: gql` - mutation($id: ID!) { - disable(id: $id) + mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) { + decide(resourceId: $resourceId, disable: $disable, closed: $closed) { + disable + } } `, - variables: { id: this.id }, + variables: { resourceId: this.id, disable: true, closed: false }, }) this.$toast.success(this.$t('disable.success')) this.isOpen = false