From bce84f24fd57e959816f9aaaad989f479da246da Mon Sep 17 00:00:00 2001 From: Benjamin Goering Date: Tue, 28 Feb 2017 15:55:19 +0800 Subject: [PATCH] Embed can remove best tag --- .../graphql/mutations/index.js | 3 +- .../mutations/removeCommentTag.graphql | 15 +++++---- client/coral-plugin-best/BestButton.js | 6 ++-- test/e2e/tests/Moderator/BestCommentTest.js | 32 +++++++++++++------ 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/client/coral-framework/graphql/mutations/index.js b/client/coral-framework/graphql/mutations/index.js index 6f6cdc04b..f25bddbd6 100644 --- a/client/coral-framework/graphql/mutations/index.js +++ b/client/coral-framework/graphql/mutations/index.js @@ -139,9 +139,10 @@ export const addCommentTag = graphql(ADD_COMMENT_TAG, { export const removeCommentTag = graphql(REMOVE_COMMENT_TAG, { props: ({mutate}) => ({ - removeCommentTag: (tag) => { + removeCommentTag: ({id, tag}) => { return mutate({ variables: { + id, tag } }); diff --git a/client/coral-framework/graphql/mutations/removeCommentTag.graphql b/client/coral-framework/graphql/mutations/removeCommentTag.graphql index 2871a2fae..3826b0703 100644 --- a/client/coral-framework/graphql/mutations/removeCommentTag.graphql +++ b/client/coral-framework/graphql/mutations/removeCommentTag.graphql @@ -1,10 +1,11 @@ -mutation RemoveCommentTag ($comment_id: ID!, $tag: String!) { - removeCommentTag(comment_id:$comment_id, tag:$tag) { - comment { - tags { - name - } - } +mutation RemoveCommentTag ($id: ID!, $tag: String!) { + removeCommentTag(id:$id, tag:$tag) { + comment { + id + tags { + name + } + } errors { translation_key } diff --git a/client/coral-plugin-best/BestButton.js b/client/coral-plugin-best/BestButton.js index 52367c4e0..bcf0bae10 100644 --- a/client/coral-plugin-best/BestButton.js +++ b/client/coral-plugin-best/BestButton.js @@ -54,8 +54,7 @@ export class BestButton extends Component { console.warn('BestButton#onClickAddBest called even though there is no addBest prop. doing nothing'); return; } - const addBestRet = await addBest(); - console.log('addBestRet', addBestRet); + await addBest(); } async onClickRemoveBest(e) { @@ -65,8 +64,7 @@ export class BestButton extends Component { console.warn('BestButton#onClickAddBest called even though there is no removeBest prop. doing nothing'); return; } - const removeBestRet = await removeBest(); - console.log('removeBestRet', removeBestRet); + await removeBest(); } render() { diff --git a/test/e2e/tests/Moderator/BestCommentTest.js b/test/e2e/tests/Moderator/BestCommentTest.js index b4c9e1356..8b8be708d 100644 --- a/test/e2e/tests/Moderator/BestCommentTest.js +++ b/test/e2e/tests/Moderator/BestCommentTest.js @@ -11,24 +11,38 @@ module.exports = { embedStreamPage .login(users.moderator); }, - 'Moderator marks their comment as BEST': client => { + 'Moderator marks/unmarks their comment as BEST': client => { const embedStreamPage = client.page.embedStreamPage(); - const setBestCommentButton = '@setBestButton'; - const unsetBestCommentButton = '@unsetBestButton'; + const setBestCommentButton = '.e2e__set-best-comment'; + const unsetBestCommentButton = '.e2e__unset-best-comment'; embedStreamPage - .postComment('Hi everyone. Isn\'t this the BEST comment!?') + .postComment(`Hi everyone. Isn't this the BEST comment!? ${String(Math.random()).slice(2)}`) .waitForElementVisible(setBestCommentButton, 2000) .click(setBestCommentButton) - .waitForElementVisible(unsetBestCommentButton, 2000, () => { - client.assert.elementNotPresent(setBestCommentButton); - }); + .waitForElementVisible(unsetBestCommentButton, 2000); // on refresh, it should still be tagged as best :) client.refresh(); - client.page.embedStreamPage().ready() - .waitForElementVisible('.e2e__unset-best-comment', 2000); + embedStreamPage.ready() + + // (bengo) I have no idea why, but if the selector here is '@unsetBestButton', it doesn't find it... I think nightwatch bug? + // this is why I am not using @elements. Advice appreciated. + .waitForElementVisible(unsetBestCommentButton, 2000); + + // now remove the best tag + embedStreamPage + .click(unsetBestCommentButton); + + embedStreamPage + .waitForElementVisible(setBestCommentButton, 2000); + + // on refresh it should still be untagged best + client.refresh(); + embedStreamPage.ready() + .waitForElementVisible(setBestCommentButton); + }, after: client => { client.end();