From 593d94ddbbcf5673bc5cc6cfd8e17b5730b524aa Mon Sep 17 00:00:00 2001 From: Kiwi Date: Tue, 4 Jun 2019 19:27:15 +0200 Subject: [PATCH] [CORL-218] In Stream Approve and Reject (#2340) * feat: instream moderation * fix: tests * test: add tests for in stream moderation * fix: lint * fix: snapshots --- .../auth/components/FacebookConfig.tsx | 2 +- .../sections/auth/components/GoogleConfig.tsx | 2 +- .../sections/auth/components/OIDCConfig.tsx | 2 +- .../routes/moderate/components/InReplyTo.tsx | 4 +- .../moderate/components/ModerateCard.tsx | 2 - .../__snapshots__/InReplyTo.spec.tsx.snap | 4 +- .../__snapshots__/ModerateCard.spec.tsx.snap | 7 - .../client/admin/test/auth/signOut.spec.tsx | 2 +- .../admin/test/community/community.spec.tsx | 6 +- .../__snapshots__/auth.spec.tsx.snap | 42 ++++++ .../__snapshots__/moderate.spec.tsx.snap | 39 ++--- .../admin/test/stories/stories.spec.tsx | 4 +- .../components/AcceptedComment.tsx | 8 +- .../components/RejectedComment.tsx | 4 +- .../AcceptedComment.spec.tsx.snap | 6 +- .../RejectedComment.spec.tsx.snap | 6 +- .../restricted/components/Restricted.tsx | 4 +- .../__snapshots__/Restricted.spec.tsx.snap | 4 +- .../common/UserBox/UserBoxAuthenticated.tsx | 4 +- .../UserBoxAuthenticated.spec.tsx.snap | 8 +- src/core/client/stream/local/local.graphql | 21 ++- .../Comment/CommentContainer.spec.tsx | 1 + .../Comments/Comment/CommentContainer.tsx | 53 ++++--- .../EditCommentForm/EditCommentMutation.ts | 5 +- .../tabs/Comments/Comment/InReplyTo.tsx | 4 +- .../AcceptCommentMutation.ts | 46 ++++++ .../ModerationDropdown/CaretContainer.css | 3 + .../ModerationDropdown/CaretContainer.tsx | 69 +++++++++ .../ModerationDropdownContainer.css | 8 ++ .../ModerationDropdownContainer.tsx | 104 ++++++++++++++ .../RejectCommentMutation.ts | 46 ++++++ .../RejectedTombstoneContainer.tsx | 42 ++++++ .../Comment/ModerationDropdown/index.ts | 4 + .../CreateCommentReactionMutation.ts | 4 +- .../RemoveCommentReactionMutation.ts | 4 +- .../CreateCommentReplyMutation.ts | 2 +- .../Comment/ReplyCommentForm/ReplyTo.tsx | 4 +- .../__snapshots__/ReplyTo.spec.tsx.snap | 4 +- .../CommentContainer.spec.tsx.snap | 56 ++++++++ .../__snapshots__/InReplyTo.spec.tsx.snap | 4 +- ...sx => IgnoredTombstoneOrHideContainer.tsx} | 12 +- .../ReplyList/LocalReplyListContainer.tsx | 4 +- .../tabs/Comments/ReplyList/ReplyList.tsx | 10 +- .../ReplyList/ReplyListContainer.spec.tsx | 3 + .../Comments/ReplyList/ReplyListContainer.tsx | 65 +++++---- .../__snapshots__/ReplyList.spec.tsx.snap | 24 ++-- .../ReplyListContainer.spec.tsx.snap | 4 + .../PostCommentForm/CreateCommentMutation.ts | 2 +- .../stream/tabs/Comments/Stream/Stream.tsx | 10 +- .../tabs/Comments/Stream/StreamContainer.tsx | 4 +- .../Stream/__snapshots__/Stream.spec.tsx.snap | 32 ++--- .../client/stream/tabs/Profile/Profile.tsx | 6 +- .../__snapshots__/permalinkView.spec.tsx.snap | 25 ++++ ...permalinkViewLoadMoreParents.spec.tsx.snap | 20 +++ .../__snapshots__/editComment.spec.tsx.snap | 104 ++++++++------ .../__snapshots__/loadMore.spec.tsx.snap | 10 ++ .../__snapshots__/postComment.spec.tsx.snap | 26 ++-- .../postLocalReply.spec.tsx.snap | 61 ++++++-- .../__snapshots__/postReply.spec.tsx.snap | 31 ++-- .../renderCommunityGuidelines.spec.tsx.snap | 10 ++ .../__snapshots__/renderReplies.spec.tsx.snap | 20 +++ .../__snapshots__/renderStream.spec.tsx.snap | 10 ++ .../showAllReplies.spec.tsx.snap | 5 + .../showConversation.spec.tsx.snap | 5 + .../__snapshots__/sortStream.spec.tsx.snap | 10 ++ .../test/comments/stream/moderation.spec.tsx | 135 ++++++++++++++++++ .../client/ui/components/Dropdown/Button.css | 35 ++++- .../client/ui/components/Dropdown/Button.tsx | 20 ++- .../client/ui/components/Dropdown/Divider.css | 3 +- .../__snapshots__/Button.spec.tsx.snap | 8 +- .../client/ui/components/Popover/Popover.css | 1 + .../ui/components/TextLink/TextLink.tsx | 11 +- src/locales/en-US/admin.ftl | 14 +- src/locales/en-US/stream.ftl | 19 ++- 74 files changed, 1106 insertions(+), 297 deletions(-) create mode 100644 src/core/client/stream/tabs/Comments/Comment/ModerationDropdown/AcceptCommentMutation.ts create mode 100644 src/core/client/stream/tabs/Comments/Comment/ModerationDropdown/CaretContainer.css create mode 100644 src/core/client/stream/tabs/Comments/Comment/ModerationDropdown/CaretContainer.tsx create mode 100644 src/core/client/stream/tabs/Comments/Comment/ModerationDropdown/ModerationDropdownContainer.css create mode 100644 src/core/client/stream/tabs/Comments/Comment/ModerationDropdown/ModerationDropdownContainer.tsx create mode 100644 src/core/client/stream/tabs/Comments/Comment/ModerationDropdown/RejectCommentMutation.ts create mode 100644 src/core/client/stream/tabs/Comments/Comment/ModerationDropdown/RejectedTombstoneContainer.tsx create mode 100644 src/core/client/stream/tabs/Comments/Comment/ModerationDropdown/index.ts rename src/core/client/stream/tabs/Comments/{TombstoneOrHideContainer.tsx => IgnoredTombstoneOrHideContainer.tsx} (77%) create mode 100644 src/core/client/stream/test/comments/stream/moderation.spec.tsx diff --git a/src/core/client/admin/routes/configure/sections/auth/components/FacebookConfig.tsx b/src/core/client/admin/routes/configure/sections/auth/components/FacebookConfig.tsx index fcf2e252d..8cd3b093e 100644 --- a/src/core/client/admin/routes/configure/sections/auth/components/FacebookConfig.tsx +++ b/src/core/client/admin/routes/configure/sections/auth/components/FacebookConfig.tsx @@ -51,7 +51,7 @@ const FacebookConfig: FunctionComponent = ({ } + Link={} > To enable the integration with Facebook Authentication, you need to diff --git a/src/core/client/admin/routes/configure/sections/auth/components/GoogleConfig.tsx b/src/core/client/admin/routes/configure/sections/auth/components/GoogleConfig.tsx index 43d82557f..390652e20 100644 --- a/src/core/client/admin/routes/configure/sections/auth/components/GoogleConfig.tsx +++ b/src/core/client/admin/routes/configure/sections/auth/components/GoogleConfig.tsx @@ -49,7 +49,7 @@ const GoogleConfig: FunctionComponent = ({ disabled, callbackURL }) => ( } + Link={} > To enable the integration with Google Authentication you need to diff --git a/src/core/client/admin/routes/configure/sections/auth/components/OIDCConfig.tsx b/src/core/client/admin/routes/configure/sections/auth/components/OIDCConfig.tsx index 89245cc29..a6a9cd52a 100644 --- a/src/core/client/admin/routes/configure/sections/auth/components/OIDCConfig.tsx +++ b/src/core/client/admin/routes/configure/sections/auth/components/OIDCConfig.tsx @@ -70,7 +70,7 @@ const OIDCConfig: FunctionComponent = ({ > {disabledInside => ( - }> + }> {"To learn more: https://openid.net/connect/"} diff --git a/src/core/client/admin/routes/moderate/components/InReplyTo.tsx b/src/core/client/admin/routes/moderate/components/InReplyTo.tsx index 5aeab09c6..5c7e29c10 100644 --- a/src/core/client/admin/routes/moderate/components/InReplyTo.tsx +++ b/src/core/client/admin/routes/moderate/components/InReplyTo.tsx @@ -19,13 +19,13 @@ const InReplyTo: FunctionComponent = ({ children }) => { return ( reply{" "} - }> + }> - {"Reply to "} + {"Reply to "} diff --git a/src/core/client/admin/routes/moderate/components/ModerateCard.tsx b/src/core/client/admin/routes/moderate/components/ModerateCard.tsx index 34542f251..8eb0e17c9 100644 --- a/src/core/client/admin/routes/moderate/components/ModerateCard.tsx +++ b/src/core/client/admin/routes/moderate/components/ModerateCard.tsx @@ -91,7 +91,6 @@ const ModerateCard: FunctionComponent = ({ className={styles.link} href={viewContextHref} target="_blank" - external > View Context @@ -108,7 +107,6 @@ const ModerateCard: FunctionComponent = ({ Moderate Story diff --git a/src/core/client/admin/routes/moderate/components/__snapshots__/InReplyTo.spec.tsx.snap b/src/core/client/admin/routes/moderate/components/__snapshots__/InReplyTo.spec.tsx.snap index b4b6d8cdd..95f23149b 100644 --- a/src/core/client/admin/routes/moderate/components/__snapshots__/InReplyTo.spec.tsx.snap +++ b/src/core/client/admin/routes/moderate/components/__snapshots__/InReplyTo.spec.tsx.snap @@ -11,15 +11,15 @@ exports[`renders correctly 1`] = ` } id="moderate-comment-inReplyTo" - username={} > - Reply to <username><username> + Reply to <Username></Username> diff --git a/src/core/client/admin/routes/moderate/components/__snapshots__/ModerateCard.spec.tsx.snap b/src/core/client/admin/routes/moderate/components/__snapshots__/ModerateCard.spec.tsx.snap index 27dc89ccf..f46f25c76 100644 --- a/src/core/client/admin/routes/moderate/components/__snapshots__/ModerateCard.spec.tsx.snap +++ b/src/core/client/admin/routes/moderate/components/__snapshots__/ModerateCard.spec.tsx.snap @@ -48,7 +48,6 @@ exports[`renders accepted correctly 1`] = ` > @@ -146,7 +145,6 @@ exports[`renders correctly 1`] = ` > @@ -243,7 +241,6 @@ exports[`renders dangling correctly 1`] = ` > @@ -342,7 +339,6 @@ exports[`renders rejected correctly 1`] = ` > @@ -445,7 +441,6 @@ exports[`renders reply correctly 1`] = ` > @@ -542,7 +537,6 @@ exports[`renders story info 1`] = ` > @@ -574,7 +568,6 @@ exports[`renders story info 1`] = ` className="ModerateCard-link" href="/story" onClick={[Function]} - target="_blank" > Moderate Story diff --git a/src/core/client/admin/test/auth/signOut.spec.tsx b/src/core/client/admin/test/auth/signOut.spec.tsx index 7941b1f33..addd6dd41 100644 --- a/src/core/client/admin/test/auth/signOut.spec.tsx +++ b/src/core/client/admin/test/auth/signOut.spec.tsx @@ -72,7 +72,7 @@ it("logs out", async () => { userMenu.props.onClick(); const signOutButton = await waitForElement(() => - within(testRenderer.root).getByText("Sign Out") + within(testRenderer.root).getByText("Sign Out", { selector: "button" }) ); signOutButton.props.onClick(); diff --git a/src/core/client/admin/test/community/community.spec.tsx b/src/core/client/admin/test/community/community.spec.tsx index cca0fc425..a0321605b 100644 --- a/src/core/client/admin/test/community/community.spec.tsx +++ b/src/core/client/admin/test/community/community.spec.tsx @@ -161,7 +161,7 @@ it("change user role", async () => { TestRenderer.act(() => { within(popup) - .getByText("Staff") + .getByText("Staff", { selector: "button" }) .props.onClick(); }); @@ -360,7 +360,7 @@ it("ban user", async () => { TestRenderer.act(() => { within(popup) - .getByText("Ban User") + .getByText("Ban User", { selector: "button" }) .props.onClick(); }); @@ -434,7 +434,7 @@ it("remove user ban", async () => { TestRenderer.act(() => { within(popup) - .getByText("Remove Ban") + .getByText("Remove Ban", { selector: "button" }) .props.onClick(); }); diff --git a/src/core/client/admin/test/configure/__snapshots__/auth.spec.tsx.snap b/src/core/client/admin/test/configure/__snapshots__/auth.spec.tsx.snap index 25972bd98..1876bee69 100644 --- a/src/core/client/admin/test/configure/__snapshots__/auth.spec.tsx.snap +++ b/src/core/client/admin/test/configure/__snapshots__/auth.spec.tsx.snap @@ -61,6 +61,12 @@ exports[`change settings: during submit: oidc without errors 1`] = ` target="_blank" > https://openid.net/connect/ +


https://developers.facebook.com/docs/facebook-login/web + .

@@ -772,6 +784,12 @@ exports[`change settings: enable oidc configure box 1`] = ` target="_blank" > https://openid.net/connect/ +


https://openid.net/connect/ +


https://openid.net/connect/ +


https://developers.google.com/identity/protocols/OAuth2WebServer#creatingcred + .

@@ -3010,6 +3046,12 @@ For more information visit: target="_blank" > https://developers.facebook.com/docs/facebook-login/web + .

diff --git a/src/core/client/admin/test/moderate/__snapshots__/moderate.spec.tsx.snap b/src/core/client/admin/test/moderate/__snapshots__/moderate.spec.tsx.snap index ea281a6c3..a1c5ebb6b 100644 --- a/src/core/client/admin/test/moderate/__snapshots__/moderate.spec.tsx.snap +++ b/src/core/client/admin/test/moderate/__snapshots__/moderate.spec.tsx.snap @@ -67,7 +67,7 @@ exports[`rejected queue accepts comment in rejected queue: dangling 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -88,7 +88,6 @@ exports[`rejected queue accepts comment in rejected queue: dangling 1`] = ` className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -267,7 +266,7 @@ exports[`rejected queue renders rejected queue with comments 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -288,7 +287,6 @@ exports[`rejected queue renders rejected queue with comments 1`] = ` className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -454,7 +452,7 @@ exports[`rejected queue renders rejected queue with comments 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -475,7 +473,6 @@ exports[`rejected queue renders rejected queue with comments 1`] = ` className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -647,7 +644,7 @@ exports[`rejected queue renders rejected queue with comments and load more 1`] = aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -668,7 +665,6 @@ exports[`rejected queue renders rejected queue with comments and load more 1`] = className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -863,7 +859,7 @@ exports[`reported queue accepts comment in reported queue: dangling 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -884,7 +880,6 @@ exports[`reported queue accepts comment in reported queue: dangling 1`] = ` className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -1066,7 +1061,7 @@ exports[`reported queue rejects comment in reported queue: dangling 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -1087,7 +1082,6 @@ exports[`reported queue rejects comment in reported queue: dangling 1`] = ` className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -1287,7 +1281,7 @@ exports[`reported queue renders reported queue with comments 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -1308,7 +1302,6 @@ exports[`reported queue renders reported queue with comments 1`] = ` className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -1474,7 +1467,7 @@ exports[`reported queue renders reported queue with comments 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -1495,7 +1488,6 @@ exports[`reported queue renders reported queue with comments 1`] = ` className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -1677,7 +1669,7 @@ exports[`reported queue renders reported queue with comments 2`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -1698,7 +1690,6 @@ exports[`reported queue renders reported queue with comments 2`] = ` className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -1864,7 +1855,7 @@ exports[`reported queue renders reported queue with comments 2`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -1885,7 +1876,6 @@ exports[`reported queue renders reported queue with comments 2`] = ` className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -2057,7 +2047,7 @@ exports[`reported queue renders reported queue with comments and load more 1`] = aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -2078,7 +2068,6 @@ exports[`reported queue renders reported queue with comments and load more 1`] = className="TextLink-root ModerateCard-link" href="/admin/moderate/story-1" onClick={[Function]} - target="_blank" > Moderate Story @@ -2519,7 +2508,7 @@ exports[`single comment view accepts single comment 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -2687,7 +2676,7 @@ exports[`single comment view rejects single comment 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new @@ -2890,7 +2879,7 @@ exports[`single comment view renders single comment view 1`] = ` aria-hidden="true" className="Icon-root Icon-xs TextLink-icon" > - launch + open_in_new diff --git a/src/core/client/admin/test/stories/stories.spec.tsx b/src/core/client/admin/test/stories/stories.spec.tsx index 84d559f01..65a7d876f 100644 --- a/src/core/client/admin/test/stories/stories.spec.tsx +++ b/src/core/client/admin/test/stories/stories.spec.tsx @@ -191,7 +191,7 @@ it("change story status", async () => { TestRenderer.act(() => { within(popup) - .getByText("Closed") + .getByText("Closed", { selector: "button" }) .props.onClick(); }); @@ -205,7 +205,7 @@ it("change story status", async () => { TestRenderer.act(() => { within(popup) - .getByText("Open") + .getByText("Open", { selector: "button" }) .props.onClick(); }); diff --git a/src/core/client/admin/views/decisionHistory/components/AcceptedComment.tsx b/src/core/client/admin/views/decisionHistory/components/AcceptedComment.tsx index 1d78e948e..923990cdb 100644 --- a/src/core/client/admin/views/decisionHistory/components/AcceptedComment.tsx +++ b/src/core/client/admin/views/decisionHistory/components/AcceptedComment.tsx @@ -22,13 +22,13 @@ const Username: FunctionComponent<{ username: string }> = ({ username }) => ( {username} ); -const ApprovedComment: FunctionComponent = props => ( +const AcceptedComment: FunctionComponent = props => ( }> } + Username={} > - {"Accepted comment by "} + {"Accepted comment by "}