From 5c72f51612d158eb66162843615173445cecf4fc Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 22 Mar 2019 10:53:59 -0400 Subject: [PATCH] Remove all disabled tests Since we've been running with them disabled for quite some time, let's get rid of them. --- .../client/graphql/mutations/queries.test.tsx | 190 --------------- .../graphql/queries/observableQuery.test.tsx | 225 ------------------ 2 files changed, 415 deletions(-) diff --git a/test/client/graphql/mutations/queries.test.tsx b/test/client/graphql/mutations/queries.test.tsx index ca486a77c1..a787f7e912 100644 --- a/test/client/graphql/mutations/queries.test.tsx +++ b/test/client/graphql/mutations/queries.test.tsx @@ -298,194 +298,4 @@ describe('graphql(mutation) query integration', () => { , ); }); - // this test is flaky, find out why and turn it back on - xit('handles refetchingQueries after a mutation', done => { - // reproduction of query from Apollo Engine - const accountId = '1234'; - - const billingInfoQuery: DocumentNode = gql` - query Account__PaymentDetailQuery($accountId: ID!) { - account(id: $accountId) { - id - currentPlan { - id - name - } - } - } - `; - - const overlappingQuery: DocumentNode = gql` - query Account__PaymentQuery($accountId: ID!) { - account(id: $accountId) { - id - currentPlan { - id - name - } - } - } - `; - - const data1 = { - account: { - id: accountId, - currentPlan: { - id: 'engine-77', - name: 'Utility', - }, - }, - }; - const data2 = { - account: { - id: accountId, - currentPlan: { - id: 'engine-78', - name: 'Free', - }, - }, - }; - - type QueryData = typeof data1; - - interface QueryVariables { - accountId: string; - } - - const setPlanMutation: DocumentNode = gql` - mutation Account__SetPlanMutation($accountId: ID!, $planId: ID!) { - accountSetPlan(accountId: $accountId, planId: $planId) - } - `; - - const mutationData = { - accountSetPlan: true, - }; - - type MutationData = typeof mutationData; - - interface MutationVariables { - accountId: string; - planId: string; - } - - const variables = { - accountId, - }; - - const link = mockSingleLink( - { - request: { query: billingInfoQuery, variables }, - result: { data: data1 }, - }, - { - request: { query: overlappingQuery, variables }, - result: { data: data1 }, - }, - { - request: { - query: setPlanMutation, - variables: { accountId, planId: 'engine-78' }, - }, - result: { data: mutationData }, - }, - { - request: { query: billingInfoQuery, variables }, - result: { data: data2 }, - }, - ); - const cache = new Cache({ addTypename: false }); - const client = new ApolloClient({ link, cache }); - - class Boundary extends React.Component { - componentDidCatch(e: any) { - done.fail(e); - } - render() { - return this.props.children; - } - } - - let refetched = false; - class RelatedUIComponent extends React.Component> { - componentWillReceiveProps(props: ChildProps<{}, QueryData, QueryVariables>) { - if (refetched) { - expect(props.data!.account!.currentPlan.name).toBe('Free'); - done(); - } - } - render() { - return this.props.children; - } - } - - const RelatedUIComponentWithData = graphql<{}, QueryData, QueryVariables>(overlappingQuery, { - options: { variables: { accountId } }, - })(RelatedUIComponent); - - const withQuery = graphql<{}, QueryData, QueryVariables>(billingInfoQuery, { - options: { variables: { accountId } }, - }); - type WithQueryChildProps = ChildProps<{}, QueryData, QueryVariables>; - - const withMutation = graphql( - setPlanMutation, - ); - type WithMutationChildProps = ChildProps; - - let count = 0; - class PaymentDetail extends React.Component { - componentWillReceiveProps(props: WithMutationChildProps) { - if (count === 1) { - expect(props.data!.account!.currentPlan.name).toBe('Free'); - done(); - } - count++; - } - async onPaymentInfoChanged() { - try { - refetched = true; - await this.props.mutate!({ - refetchQueries: [ - { - query: billingInfoQuery, - variables: { - accountId, - }, - }, - ], - variables: { - accountId, - planId: 'engine-78', - }, - }); - } catch (e) { - done.fail(e); - } - } - - componentDidMount() { - setTimeout(() => { - // trigger mutation and future updates - this.onPaymentInfoChanged(); - }, 10); - } - - render() { - return null; - } - } - - const PaymentDetailWithData = withQuery(withMutation(PaymentDetail)); - - renderer.create( - - - - - - - , - ); - }); }); diff --git a/test/client/graphql/queries/observableQuery.test.tsx b/test/client/graphql/queries/observableQuery.test.tsx index ccc2563914..9bba1c7fc0 100644 --- a/test/client/graphql/queries/observableQuery.test.tsx +++ b/test/client/graphql/queries/observableQuery.test.tsx @@ -149,231 +149,6 @@ describe('[queries] observableQuery', () => { ); }); - xit('will not try to refetch recycled `ObservableQuery`s when resetting the client store', done => { - const query: DocumentNode = gql` - query people { - allPeople(first: 1) { - people { - name - } - } - } - `; - - let finish = () => {}; // tslint:disable-line - let called = 0; - const link = new ApolloLink((o, f) => { - called++; - setTimeout(finish, 5); - return f ? f(o) : null; - }).concat( - mockSingleLink({ - request: { query }, - result: { data: { allPeople: null } }, - }), - ); - const client = new ApolloClient({ - link, - cache: new Cache({ addTypename: false }), - }); - - // make sure that the in flight query is done before resetting store - finish = () => { - client.resetStore(); - - // The query should not have been fetch again - expect(called).toBe(1); - - done(); - }; - - const Container = graphql(query)( - class extends React.Component { - render() { - return null; - } - }, - ); - - const wrapper1 = renderer.create( - - - , - ); - - // let keys = Array.from((client.queryManager as any).queries.keys()); - // expect(keys).toEqual(['1']); - // const queryObservable1 = (client.queryManager as any).queries.get('1') - // .observableQuery; - - // The query should only have been invoked when first mounting and not when resetting store - expect(called).toBe(1); - - wrapper1.unmount(); - - // keys = Array.from((client.queryManager as any).queries.keys()); - // expect(keys).toEqual(['1']); - // const queryObservable2 = (client.queryManager as any).queries.get('1') - // .observableQuery; - - // expect(queryObservable1).toBe(queryObservable2); - }); - - xit('will recycle `ObservableQuery`s when re-rendering a portion of the tree', done => { - const query: DocumentNode = gql` - query people { - allPeople(first: 1) { - people { - name - } - } - } - `; - const data = { allPeople: { people: [{ name: 'Luke Skywalker' }] } }; - - const link = mockSingleLink( - { request: { query }, result: { data } }, - { request: { query }, result: { data } }, - ); - const client = new ApolloClient({ - link, - cache: new Cache({ addTypename: false }), - }); - let remount: any; - - class Remounter extends React.Component { - state = { - showChildren: true, - }; - - componentDidMount() { - remount = () => { - this.setState({ showChildren: false }, () => { - setTimeout(() => { - this.setState({ showChildren: true }); - }, 5); - }); - }; - } - - render() { - return this.state.showChildren ? this.props.children : null; - } - } - - const Container = graphql(query)( - class extends React.Component { - render() { - return null; - } - }, - ); - - const wrapper = renderer.create( - - - - - , - ); - - // let keys = Array.from((client.queryManager as any).queries.keys()); - // expect(keys).toEqual(['1']); - // const queryObservable1 = (client.queryManager as any).queries.get('1') - // .observableQuery; - - remount(); - - setTimeout(() => { - // keys = Array.from((client.queryManager as any).queries.keys()); - // expect(keys).toEqual(['1']); - // const queryObservable2 = (client.queryManager as any).queries.get('1') - // .observableQuery; - // expect(queryObservable1).toBe(queryObservable2); - - remount(); - - setTimeout(() => { - // keys = Array.from((client.queryManager as any).queries.keys()); - // expect(keys).toEqual(['1']); - // const queryObservable3 = (client.queryManager as any).queries.get('1') - // .observableQuery; - // expect(queryObservable1).toBe(queryObservable3); - - wrapper.unmount(); - done(); - }, 10); - }, 10); - }); - - xit('will not recycle parallel GraphQL container `ObservableQuery`s', done => { - const query: DocumentNode = gql` - query people { - allPeople(first: 1) { - people { - name - } - } - } - `; - const data = { allPeople: { people: [{ name: 'Luke Skywalker' }] } }; - const link = mockSingleLink( - { request: { query }, result: { data } }, - { request: { query }, result: { data } }, - ); - const client = new ApolloClient({ - link, - cache: new Cache({ addTypename: false }), - }); - let remount: any; - - class Remounter extends React.Component { - state = { - showChildren: true, - }; - - componentDidMount() { - remount = () => { - this.setState({ showChildren: false }, () => { - setTimeout(() => { - this.setState({ showChildren: true }); - }, 5); - }); - }; - } - - render() { - return this.state.showChildren ? this.props.children : null; - } - } - - const Container = graphql(query)( - class extends React.Component { - render() { - return null; - } - }, - ); - - const wrapper = renderer.create( - -
- - - - -
-
, - ); - - remount(); - - setTimeout(() => { - wrapper.unmount(); - done(); - }, 10); - }); - it("will recycle `ObservableQuery`s when re-rendering a portion of the tree but not return stale data if variables don't match", done => { const query: DocumentNode = gql` query people($first: Int!) {