From 333e1a6dac6469a6b2e5d45da01060e6b016b1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Curcio?= Date: Fri, 5 Oct 2018 10:05:28 -0300 Subject: [PATCH] Revert "Using fragment and updated fixtures" This reverts commit 8dae12b5ab8d02c282d463dc5555d2ddfafd5599. --- .../client/stream/containers/AppContainer.tsx | 35 +++++----------- src/core/client/stream/queries/AppQuery.tsx | 8 +++- .../__snapshots__/editComment.spec.tsx.snap | 14 +++---- .../__snapshots__/loadMore.spec.tsx.snap | 2 +- .../__snapshots__/permalinkView.spec.tsx.snap | 2 +- .../permalinkViewAssetNotFound.spec.tsx.snap | 42 ++++++++++++++++++- ...permalinkViewCommentNotFound.spec.tsx.snap | 2 +- .../__snapshots__/postComment.spec.tsx.snap | 6 +-- .../postLocalReply.spec.tsx.snap | 8 ++-- .../__snapshots__/postReply.spec.tsx.snap | 8 ++-- .../__snapshots__/renderReplies.spec.tsx.snap | 2 +- .../__snapshots__/renderStream.spec.tsx.snap | 2 +- .../showAllReplies.spec.tsx.snap | 2 +- .../showConversation.spec.tsx.snap | 4 +- src/core/client/stream/test/create.tsx | 6 +-- src/core/client/stream/test/fixtures.ts | 12 ------ 16 files changed, 86 insertions(+), 69 deletions(-) diff --git a/src/core/client/stream/containers/AppContainer.tsx b/src/core/client/stream/containers/AppContainer.tsx index 39cfd6084..ad96b86dc 100644 --- a/src/core/client/stream/containers/AppContainer.tsx +++ b/src/core/client/stream/containers/AppContainer.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { withFragmentContainer } from "talk-framework/lib/relay"; + import { graphql, withLocalStateContainer } from "talk-framework/lib/relay"; import { AppContainerLocal as Local } from "talk-stream/__generated__/AppContainerLocal.graphql"; import { @@ -8,13 +8,12 @@ import { withSetActiveTabMutation, } from "talk-stream/mutations"; -import { AppContainer_asset as AssetData } from "talk-stream/__generated__/AppContainer_asset.graphql"; import App from "../components/App"; interface InnerProps { local: Local; setActiveTab: SetActiveTabMutation; - asset: AssetData; + commentCount: number; } class AppContainer extends React.Component { @@ -25,37 +24,25 @@ class AppContainer extends React.Component { public render() { const { local: { activeTab }, - asset, + commentCount, } = this.props; return ( ); } } -const enhanced = withSetActiveTabMutation( - withFragmentContainer({ - asset: graphql` - fragment AppContainer_asset on Asset { - commentCounts { - totalVisible - } - } - `, - })( - withLocalStateContainer( - graphql` - fragment AppContainerLocal on Local { - activeTab - } - ` - )(AppContainer) - ) -); +const enhanced = withLocalStateContainer( + graphql` + fragment AppContainerLocal on Local { + activeTab + } + ` +)(withSetActiveTabMutation(AppContainer)); export default enhanced; diff --git a/src/core/client/stream/queries/AppQuery.tsx b/src/core/client/stream/queries/AppQuery.tsx index 7e456fe18..b18e8e9d9 100644 --- a/src/core/client/stream/queries/AppQuery.tsx +++ b/src/core/client/stream/queries/AppQuery.tsx @@ -32,7 +32,9 @@ export const render = ({ ); } - return ; + return ( + + ); } return ; @@ -45,7 +47,9 @@ const AppQuery: StatelessComponent = ({ query={graphql` query AppQuery($assetID: ID, $assetURL: String) { asset(id: $assetID, url: $assetURL) { - ...AppContainer_asset + commentCounts { + totalVisible + } } } `} diff --git a/src/core/client/stream/test/comments/__snapshots__/editComment.spec.tsx.snap b/src/core/client/stream/test/comments/__snapshots__/editComment.spec.tsx.snap index d2a122808..a6bae295c 100644 --- a/src/core/client/stream/test/comments/__snapshots__/editComment.spec.tsx.snap +++ b/src/core/client/stream/test/comments/__snapshots__/editComment.spec.tsx.snap @@ -27,7 +27,7 @@ exports[`cancel edit: edit canceled 1`] = ` role="tab" type="button" > - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • diff --git a/src/core/client/stream/test/comments/__snapshots__/permalinkView.spec.tsx.snap b/src/core/client/stream/test/comments/__snapshots__/permalinkView.spec.tsx.snap index aaab7f1d2..df6f281c3 100644 --- a/src/core/client/stream/test/comments/__snapshots__/permalinkView.spec.tsx.snap +++ b/src/core/client/stream/test/comments/__snapshots__/permalinkView.spec.tsx.snap @@ -27,7 +27,7 @@ exports[`renders permalink view 1`] = ` role="tab" type="button" > - ⁨2⁩ Comments + ⁨6⁩ Comments diff --git a/src/core/client/stream/test/comments/__snapshots__/permalinkViewAssetNotFound.spec.tsx.snap b/src/core/client/stream/test/comments/__snapshots__/permalinkViewAssetNotFound.spec.tsx.snap index 1099468ac..0cc370719 100644 --- a/src/core/client/stream/test/comments/__snapshots__/permalinkViewAssetNotFound.spec.tsx.snap +++ b/src/core/client/stream/test/comments/__snapshots__/permalinkViewAssetNotFound.spec.tsx.snap @@ -1,7 +1,45 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`renders permalink view with unknown asset 1`] = ` -
    - Asset not found +
    +
      + +
    +
    +
    + Asset not found +
    +
    `; diff --git a/src/core/client/stream/test/comments/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap b/src/core/client/stream/test/comments/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap index 18657738a..7da665351 100644 --- a/src/core/client/stream/test/comments/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap +++ b/src/core/client/stream/test/comments/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap @@ -27,7 +27,7 @@ exports[`renders permalink view with unknown comment 1`] = ` role="tab" type="button" > - ⁨2⁩ Comments + ⁨6⁩ Comments diff --git a/src/core/client/stream/test/comments/__snapshots__/postComment.spec.tsx.snap b/src/core/client/stream/test/comments/__snapshots__/postComment.spec.tsx.snap index 843b01875..ee6a14314 100644 --- a/src/core/client/stream/test/comments/__snapshots__/postComment.spec.tsx.snap +++ b/src/core/client/stream/test/comments/__snapshots__/postComment.spec.tsx.snap @@ -27,7 +27,7 @@ exports[`post a comment: optimistic response 1`] = ` role="tab" type="button" > - ⁨3⁩ Comments + ⁨6⁩ Comments
  • - ⁨3⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨1⁩ Comments + ⁨6⁩ Comments
  • - ⁨1⁩ Comments + ⁨6⁩ Comments
  • - ⁨1⁩ Comments + ⁨6⁩ Comments
  • - ⁨1⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨3⁩ Comments + ⁨6⁩ Comments
  • - ⁨3⁩ Comments + ⁨6⁩ Comments
  • - ⁨2⁩ Comments + ⁨6⁩ Comments
  • - ⁨1⁩ Comments + ⁨6⁩ Comments
  • diff --git a/src/core/client/stream/test/comments/__snapshots__/renderStream.spec.tsx.snap b/src/core/client/stream/test/comments/__snapshots__/renderStream.spec.tsx.snap index 714bba9c7..5672d8ad6 100644 --- a/src/core/client/stream/test/comments/__snapshots__/renderStream.spec.tsx.snap +++ b/src/core/client/stream/test/comments/__snapshots__/renderStream.spec.tsx.snap @@ -27,7 +27,7 @@ exports[`renders comment stream 1`] = ` role="tab" type="button" > - ⁨2⁩ Comments + ⁨6⁩ Comments diff --git a/src/core/client/stream/test/comments/__snapshots__/showAllReplies.spec.tsx.snap b/src/core/client/stream/test/comments/__snapshots__/showAllReplies.spec.tsx.snap index 84fc3d4eb..cf6642c00 100644 --- a/src/core/client/stream/test/comments/__snapshots__/showAllReplies.spec.tsx.snap +++ b/src/core/client/stream/test/comments/__snapshots__/showAllReplies.spec.tsx.snap @@ -27,7 +27,7 @@ exports[`renders comment stream 1`] = ` role="tab" type="button" > - ⁨2⁩ Comments + ⁨6⁩ Comments diff --git a/src/core/client/stream/test/comments/__snapshots__/showConversation.spec.tsx.snap b/src/core/client/stream/test/comments/__snapshots__/showConversation.spec.tsx.snap index 6fbd0d02b..87d570681 100644 --- a/src/core/client/stream/test/comments/__snapshots__/showConversation.spec.tsx.snap +++ b/src/core/client/stream/test/comments/__snapshots__/showConversation.spec.tsx.snap @@ -27,7 +27,7 @@ exports[`renders comment stream 1`] = ` role="tab" type="button" > - ⁨1⁩ Comments + ⁨6⁩ Comments @@ -701,7 +701,7 @@ exports[`shows conversation 1`] = ` role="tab" type="button" > - ⁨1⁩ Comments + ⁨6⁩ Comments diff --git a/src/core/client/stream/test/create.tsx b/src/core/client/stream/test/create.tsx index 4f32b73c7..486f01422 100644 --- a/src/core/client/stream/test/create.tsx +++ b/src/core/client/stream/test/create.tsx @@ -10,12 +10,12 @@ import { PostMessageService } from "talk-framework/lib/postMessage"; import { RestClient } from "talk-framework/lib/rest"; import { createPromisifiedStorage } from "talk-framework/lib/storage"; import { createUUIDGenerator } from "talk-framework/testHelpers"; +import AppContainer from "talk-stream/containers/AppContainer"; import createEnvironment from "./createEnvironment"; import createFluentBundle from "./createFluentBundle"; import createNodeMock from "./createNodeMock"; - -import AppQuery from "../queries/AppQuery"; +import { comments } from "./fixtures"; export interface CreateParams { logNetwork?: boolean; @@ -54,7 +54,7 @@ export default function create(params: CreateParams) { const testRenderer = TestRenderer.create( - + , { createNodeMock } ); diff --git a/src/core/client/stream/test/fixtures.ts b/src/core/client/stream/test/fixtures.ts index dc58ac4b8..159262d22 100644 --- a/src/core/client/stream/test/fixtures.ts +++ b/src/core/client/stream/test/fixtures.ts @@ -93,9 +93,6 @@ export const assets = [ id: "asset-1", url: "http://localhost/assets/asset-1", isClosed: false, - commentCounts: { - totalVisible: 2, - }, comments: { edges: [ { node: comments[0], cursor: comments[0].createdAt }, @@ -163,9 +160,6 @@ export const assetWithReplies = { hasNextPage: false, }, }, - commentCounts: { - totalVisible: 1, - }, }; export const assetWithDeepReplies = { @@ -184,9 +178,6 @@ export const assetWithDeepReplies = { hasNextPage: false, }, }, - commentCounts: { - totalVisible: 1, - }, }; export const commentWithDeepestReplies = { @@ -301,7 +292,4 @@ export const assetWithDeepestReplies = { hasNextPage: false, }, }, - commentCounts: { - totalVisible: 1, - }, };