mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 12:15:40 +08:00
Using fragment and updated fixtures
This commit is contained in:
@@ -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,12 +8,13 @@ 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;
|
||||
commentCount: number;
|
||||
asset: AssetData;
|
||||
}
|
||||
|
||||
class AppContainer extends React.Component<InnerProps> {
|
||||
@@ -24,25 +25,37 @@ class AppContainer extends React.Component<InnerProps> {
|
||||
public render() {
|
||||
const {
|
||||
local: { activeTab },
|
||||
commentCount,
|
||||
asset,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<App
|
||||
activeTab={activeTab}
|
||||
onTabClick={this.handleSetActiveTab}
|
||||
commentCount={commentCount}
|
||||
commentCount={asset.commentCounts.totalVisible}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const enhanced = withLocalStateContainer(
|
||||
graphql`
|
||||
fragment AppContainerLocal on Local {
|
||||
activeTab
|
||||
}
|
||||
`
|
||||
)(withSetActiveTabMutation(AppContainer));
|
||||
const enhanced = withSetActiveTabMutation(
|
||||
withFragmentContainer<InnerProps>({
|
||||
asset: graphql`
|
||||
fragment AppContainer_asset on Asset {
|
||||
commentCounts {
|
||||
totalVisible
|
||||
}
|
||||
}
|
||||
`,
|
||||
})(
|
||||
withLocalStateContainer(
|
||||
graphql`
|
||||
fragment AppContainerLocal on Local {
|
||||
activeTab
|
||||
}
|
||||
`
|
||||
)(AppContainer)
|
||||
)
|
||||
);
|
||||
|
||||
export default enhanced;
|
||||
|
||||
@@ -32,9 +32,7 @@ export const render = ({
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<AppContainer commentCount={props.asset.commentCounts.totalVisible} />
|
||||
);
|
||||
return <AppContainer asset={props.asset} />;
|
||||
}
|
||||
|
||||
return <Spinner />;
|
||||
@@ -47,9 +45,7 @@ const AppQuery: StatelessComponent<InnerProps> = ({
|
||||
query={graphql`
|
||||
query AppQuery($assetID: ID, $assetURL: String) {
|
||||
asset(id: $assetID, url: $assetURL) {
|
||||
commentCounts {
|
||||
totalVisible
|
||||
}
|
||||
...AppContainer_asset
|
||||
}
|
||||
}
|
||||
`}
|
||||
|
||||
@@ -27,7 +27,7 @@ exports[`cancel edit: edit canceled 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -436,7 +436,7 @@ exports[`edit a comment: edit form 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -920,7 +920,7 @@ exports[`edit a comment: optimistic response 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -1404,7 +1404,7 @@ exports[`edit a comment: render stream 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -1813,7 +1813,7 @@ exports[`edit a comment: server response 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -2231,7 +2231,7 @@ exports[`shows expiry message: edit form closed 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -2640,7 +2640,7 @@ exports[`shows expiry message: edit time expired 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
|
||||
@@ -433,7 +433,7 @@ exports[`renders comment stream 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -27,7 +27,7 @@ exports[`renders permalink view 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
+2
-40
@@ -1,45 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`renders permalink view with unknown asset 1`] = `
|
||||
<div
|
||||
className="HorizontalGutter-root App-root HorizontalGutter-full"
|
||||
>
|
||||
<ul
|
||||
className="TabBar-root TabBar-primary"
|
||||
role="tablist"
|
||||
>
|
||||
<li
|
||||
className="Tab-root"
|
||||
id="tab-COMMENTS"
|
||||
role="presentation"
|
||||
>
|
||||
<button
|
||||
aria-controls="tabPane-COMMENTS"
|
||||
aria-selected={true}
|
||||
className="BaseButton-root Tab-button Tab-primary Tab-active"
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onMouseDown={[Function]}
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<section
|
||||
aria-labelledby="tab-COMMENTS"
|
||||
className="App-tabContent"
|
||||
id="tabPane-COMMENTS"
|
||||
role="tabpanel"
|
||||
>
|
||||
<div>
|
||||
Asset not found
|
||||
</div>
|
||||
</section>
|
||||
<div>
|
||||
Asset not found
|
||||
</div>
|
||||
`;
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ exports[`renders permalink view with unknown comment 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -27,7 +27,7 @@ exports[`post a comment: optimistic response 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
3 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -504,7 +504,7 @@ exports[`post a comment: server response 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
3 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -971,7 +971,7 @@ exports[`renders comment stream 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
|
||||
@@ -27,7 +27,7 @@ exports[`post a reply: open reply form 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
1 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -889,7 +889,7 @@ exports[`post a reply: optimistic response 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
1 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -1824,7 +1824,7 @@ exports[`post a reply: server response 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
1 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -2622,7 +2622,7 @@ exports[`renders comment stream 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
1 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
|
||||
@@ -27,7 +27,7 @@ exports[`post a reply: open reply form 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -547,7 +547,7 @@ exports[`post a reply: optimistic response 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
3 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -1157,7 +1157,7 @@ exports[`post a reply: server response 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
3 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
@@ -1630,7 +1630,7 @@ exports[`renders comment stream 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
|
||||
@@ -27,7 +27,7 @@ exports[`renders comment stream 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
1 Comments
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -27,7 +27,7 @@ exports[`renders comment stream 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -27,7 +27,7 @@ exports[`renders comment stream 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
2 Comments
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -27,7 +27,7 @@ exports[`renders comment stream 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
1 Comments
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -701,7 +701,7 @@ exports[`shows conversation 1`] = `
|
||||
role="tab"
|
||||
type="button"
|
||||
>
|
||||
6 Comments
|
||||
1 Comments
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -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 { comments } from "./fixtures";
|
||||
|
||||
import AppQuery from "../queries/AppQuery";
|
||||
|
||||
export interface CreateParams {
|
||||
logNetwork?: boolean;
|
||||
@@ -54,7 +54,7 @@ export default function create(params: CreateParams) {
|
||||
|
||||
const testRenderer = TestRenderer.create(
|
||||
<TalkContextProvider value={context}>
|
||||
<AppContainer commentCount={comments.length} />
|
||||
<AppQuery />
|
||||
</TalkContextProvider>,
|
||||
{ createNodeMock }
|
||||
);
|
||||
|
||||
@@ -93,6 +93,9 @@ 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 },
|
||||
@@ -160,6 +163,9 @@ export const assetWithReplies = {
|
||||
hasNextPage: false,
|
||||
},
|
||||
},
|
||||
commentCounts: {
|
||||
totalVisible: 1,
|
||||
},
|
||||
};
|
||||
|
||||
export const assetWithDeepReplies = {
|
||||
@@ -178,6 +184,9 @@ export const assetWithDeepReplies = {
|
||||
hasNextPage: false,
|
||||
},
|
||||
},
|
||||
commentCounts: {
|
||||
totalVisible: 1,
|
||||
},
|
||||
};
|
||||
|
||||
export const commentWithDeepestReplies = {
|
||||
@@ -292,4 +301,7 @@ export const assetWithDeepestReplies = {
|
||||
hasNextPage: false,
|
||||
},
|
||||
},
|
||||
commentCounts: {
|
||||
totalVisible: 1,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user