Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Remove all disabled tests
Browse files Browse the repository at this point in the history
Since we've been running with them disabled for quite some time,
let's get rid of them.
  • Loading branch information
hwillson committed Mar 22, 2019
1 parent 1186726 commit 5c72f51
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 415 deletions.
190 changes: 0 additions & 190 deletions test/client/graphql/mutations/queries.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,194 +298,4 @@ describe('graphql(mutation) query integration', () => {
</ApolloProvider>,
);
});
// 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<ChildProps<{}, QueryData, QueryVariables>> {
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<WithQueryChildProps, MutationData, MutationVariables>(
setPlanMutation,
);
type WithMutationChildProps = ChildProps<WithQueryChildProps, MutationData, MutationVariables>;

let count = 0;
class PaymentDetail extends React.Component<WithMutationChildProps> {
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(
<ApolloProvider client={client}>
<Boundary>
<RelatedUIComponentWithData>
<PaymentDetailWithData />
</RelatedUIComponentWithData>
</Boundary>
</ApolloProvider>,
);
});
});
Loading

0 comments on commit 5c72f51

Please sign in to comment.