From 310f2502120ed102da4bc1d133d09300fc00f9f0 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 17 Aug 2018 11:40:31 -0300 Subject: [PATCH] Updated tests and latest changes --- .../client/auth/mutations/SignOffMutation.ts | 28 +++++++++++-------- .../__snapshots__/Stream.spec.tsx.snap | 3 ++ .../stream/queries/PermalinkViewQuery.tsx | 3 +- .../client/stream/queries/StreamQuery.tsx | 4 +-- .../PermalinkViewQuery.spec.tsx.snap | 6 +--- .../test/__snapshots__/loadMore.spec.tsx.snap | 11 ++++++-- .../__snapshots__/permalinkView.spec.tsx.snap | 6 +++- .../permalinkViewAssetNotFound.spec.tsx.snap | 1 + ...permalinkViewCommentNotFound.spec.tsx.snap | 6 +++- .../__snapshots__/renderReplies.spec.tsx.snap | 5 +++- .../__snapshots__/renderStream.spec.tsx.snap | 5 +++- .../showAllReplies.spec.tsx.snap | 11 ++++++-- .../__snapshots__/BaseButton.spec.tsx.snap | 2 ++ .../ui/components/TextField/TextField.tsx | 1 - 14 files changed, 64 insertions(+), 28 deletions(-) diff --git a/src/core/client/auth/mutations/SignOffMutation.ts b/src/core/client/auth/mutations/SignOffMutation.ts index 01aa38cf0..2f34b73fe 100644 --- a/src/core/client/auth/mutations/SignOffMutation.ts +++ b/src/core/client/auth/mutations/SignOffMutation.ts @@ -1,24 +1,30 @@ -import { Environment } from "relay-runtime"; - +import { LOCAL_ID } from "talk-framework/lib/relay/withLocalStateContainer"; import { TalkContext } from "talk-framework/lib/bootstrap"; import { createMutationContainer } from "talk-framework/lib/relay"; -import { signOff, SignOffInput } from "talk-framework/rest"; +import { SignOffInput } from "talk-framework/rest"; +import { commitLocalUpdate, Environment } from "relay-runtime"; export type SignOffMutation = (input: SignOffInput) => Promise; export async function commit( environment: Environment, input: SignOffInput, - { rest, localStorage }: TalkContext + { localStorage }: TalkContext ) { - try { - await signOff(rest, input); + return commitLocalUpdate(environment, store => { + const record = store.get(LOCAL_ID)!; + record.setValue("", "authToken"); localStorage.removeItem("authToken"); - } catch (error) { - localStorage.removeItem("authToken"); - // tslint:disable-next-line:no-console - console.error("error", error); - } + + // Force gc to trigger. + environment + .retain({ + dataID: "tmp", + node: { selections: [] }, + variables: {}, + }) + .dispose(); + }); } export const withSignOffMutation = createMutationContainer("signOff", commit); diff --git a/src/core/client/stream/components/__snapshots__/Stream.spec.tsx.snap b/src/core/client/stream/components/__snapshots__/Stream.spec.tsx.snap index 84cb64ea1..01026fb09 100644 --- a/src/core/client/stream/components/__snapshots__/Stream.spec.tsx.snap +++ b/src/core/client/stream/components/__snapshots__/Stream.spec.tsx.snap @@ -9,6 +9,7 @@ exports[`renders correctly 1`] = ` ; } - return
Loading
; + return ; }; const PermalinkViewQuery: StatelessComponent = ({ diff --git a/src/core/client/stream/queries/StreamQuery.tsx b/src/core/client/stream/queries/StreamQuery.tsx index f3083da0e..9d03c0d49 100644 --- a/src/core/client/stream/queries/StreamQuery.tsx +++ b/src/core/client/stream/queries/StreamQuery.tsx @@ -14,6 +14,7 @@ import { StreamQueryLocal as Local } from "talk-stream/__generated__/StreamQuery import StreamContainer from "../containers/StreamContainer"; import { StatelessComponent } from "enzyme"; +import { Spinner } from "talk-ui/components"; interface InnerProps { local: Local; @@ -25,11 +26,10 @@ export const render = ({ error, props }: ReadyState) => { } if (props) { - console.log(props); return ; } - return
Loading
; + return ; }; const StreamQuery: StatelessComponent = ({ diff --git a/src/core/client/stream/queries/__snapshots__/PermalinkViewQuery.spec.tsx.snap b/src/core/client/stream/queries/__snapshots__/PermalinkViewQuery.spec.tsx.snap index ef1057221..b7d371bd9 100644 --- a/src/core/client/stream/queries/__snapshots__/PermalinkViewQuery.spec.tsx.snap +++ b/src/core/client/stream/queries/__snapshots__/PermalinkViewQuery.spec.tsx.snap @@ -6,11 +6,7 @@ exports[`renders error 1`] = ` `; -exports[`renders loading 1`] = ` -
- Loading -
-`; +exports[`renders loading 1`] = ``; exports[`renders permalink view container 1`] = ` Sign in @@ -40,6 +41,7 @@ exports[`loads more comments 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Register @@ -68,8 +70,9 @@ exports[`loads more comments 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > - Sign In and join the conversation + Sign in and join the conversation
Sign in @@ -252,6 +256,7 @@ exports[`renders comment stream 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Register @@ -280,8 +285,9 @@ exports[`renders comment stream 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > - Sign In and join the conversation + Sign in and join the conversation
Load More diff --git a/src/core/client/stream/test/__snapshots__/permalinkView.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/permalinkView.spec.tsx.snap index 666eaa2a2..9a449985f 100644 --- a/src/core/client/stream/test/__snapshots__/permalinkView.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/permalinkView.spec.tsx.snap @@ -22,6 +22,7 @@ exports[`renders permalink view 1`] = ` onMouseOver={[Function]} onTouchEnd={[Function]} target="_parent" + type="button" > Show all Comments @@ -99,6 +100,7 @@ exports[`show all comments 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Sign in @@ -111,6 +113,7 @@ exports[`show all comments 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Register @@ -139,8 +142,9 @@ exports[`show all comments 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > - Sign In and join the conversation + Sign in and join the conversation
Show all Comments diff --git a/src/core/client/stream/test/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap index 18a0352be..b6f816dbc 100644 --- a/src/core/client/stream/test/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap @@ -22,6 +22,7 @@ exports[`renders permalink view with unknown comment 1`] = ` onMouseOver={[Function]} onTouchEnd={[Function]} target="_parent" + type="button" > Show all Comments @@ -63,6 +64,7 @@ exports[`show all comments 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Sign in @@ -75,6 +77,7 @@ exports[`show all comments 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Register @@ -103,8 +106,9 @@ exports[`show all comments 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > - Sign In and join the conversation + Sign in and join the conversation
Sign in @@ -40,6 +41,7 @@ exports[`renders comment stream 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Register @@ -68,8 +70,9 @@ exports[`renders comment stream 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > - Sign In and join the conversation + Sign in and join the conversation
Sign in @@ -40,6 +41,7 @@ exports[`renders comment stream 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Register @@ -68,8 +70,9 @@ exports[`renders comment stream 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > - Sign In and join the conversation + Sign in and join the conversation
Sign in @@ -40,6 +41,7 @@ exports[`renders comment stream 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Register @@ -68,8 +70,9 @@ exports[`renders comment stream 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > - Sign In and join the conversation + Sign in and join the conversation
Show All Replies @@ -220,6 +224,7 @@ exports[`show all replies 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Sign in @@ -232,6 +237,7 @@ exports[`show all replies 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Register @@ -260,8 +266,9 @@ exports[`show all replies 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > - Sign In and join the conversation + Sign in and join the conversation
Push Me @@ -23,6 +24,7 @@ exports[`renders correctly 1`] = ` onMouseOut={[Function]} onMouseOver={[Function]} onTouchEnd={[Function]} + type="button" > Push Me diff --git a/src/core/client/ui/components/TextField/TextField.tsx b/src/core/client/ui/components/TextField/TextField.tsx index 56894ba2f..05b1f7bc6 100644 --- a/src/core/client/ui/components/TextField/TextField.tsx +++ b/src/core/client/ui/components/TextField/TextField.tsx @@ -84,7 +84,6 @@ const TextField: StatelessComponent = props => { TextField.defaultProps = { color: "regular", - fullWidth: true, placeholder: "", };