Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Dec 10, 2019
1 parent 9889858 commit 2785df3
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('DraggableWrapper', () => {
test('it renders against the snapshot', () => {
const wrapper = shallow(
<TestProviders>
<MockedProvider mocks={{}} addTypename={false}>
<MockedProvider mocks={[]} addTypename={false}>
<DragDropContextWrapper browserFields={mockBrowserFields}>
<DraggableWrapper dataProvider={dataProvider} render={() => message} />
</DragDropContextWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('DroppableWrapper', () => {

const wrapper = shallow(
<TestProviders>
<MockedProvider mocks={{}} addTypename={false}>
<MockedProvider mocks={[]} addTypename={false}>
<DragDropContextWrapper browserFields={mockBrowserFields}>
<DroppableWrapper droppableId="testing">{message}</DroppableWrapper>
</DragDropContextWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import ApolloClient from '@apollo/client';
import { ApolloClient } from '@apollo/client';
import React, { useEffect, useState, useCallback } from 'react';
import { connect } from 'react-redux';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import ApolloClient from '@apollo/client';
import { ApolloClient } from '@apollo/client';
import { ActionCreator } from 'typescript-fsa';
import { IIndexPattern, Query, esFilters } from 'src/plugins/data/public';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import { AnomaliesOverTimeProps, OwnProps } from './types';

const ID = 'anomaliesOverTimeQuery';

const AnomaliesOverTimeComponentQuery = ({
const AnomaliesOverTimeComponentQuery: React.FC<AnomaliesOverTimeProps> = ({
children,
endDate,
filterQuery,
id = ID,
isInspected,
sourceId,
startDate,
}: AnomaliesOverTimeProps) => {
}) => {
const variables = {
filterQuery,
sourceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface AnomaliesArgs {

export interface OwnProps extends Omit<QueryTemplateProps, 'filterQuery'> {
filterQuery?: string;
children?: (args: AnomaliesArgs) => React.ReactNode;
children?: (args: AnomaliesArgs) => React.ReactElement;
type: hostsModel.HostsType | networkModel.NetworkType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { MockedResponse } from '@apollo/react-testing';
import { MockedResponse } from '@apollo/client/testing';
import { defaultIndexPattern } from '../../../../default_index_pattern';
import { GetHostFirstLastSeenQuery } from '../../../graphql/types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import { getOr } from 'lodash/fp';
import React, { useMemo } from 'react';
import { useQuery } from '@apollo/client';
import { connect } from 'react-redux';
import { compose } from 'redux';
import chrome from 'ui/chrome';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@
import { isEqual } from 'lodash/fp';
import { mount } from 'enzyme';
import React from 'react';
import { MockedProvider, wait } from '@apollo/client/testing';
import { MockedProvider } from '@apollo/client/testing';
import { act } from 'react-dom/test-utils';

// import { wait } from '../../lib/helpers';

import '../../mock/ui_settings';

import { WithSource, indicesExistOrDataTemporarilyUnavailable } from '.';
import { mockBrowserFields, mockIndexFields, mocksSource } from './mock';

describe.skip('Index Fields & Browser Fields', () => {
test('Index Fields', async () => {
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
const wrapper = mount(
<MockedProvider mocks={[]} addTypename={false}>
Expand Down
3 changes: 1 addition & 2 deletions x-pack/legacy/plugins/siem/public/containers/users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/

import { getOr } from 'lodash/fp';
import React, { useMemo } from 'react';
import { useQuery } from '@apollo/client';
import React from 'react';
import { connect } from 'react-redux';

import chrome from 'ui/chrome';
Expand Down
40 changes: 20 additions & 20 deletions x-pack/legacy/plugins/siem/public/lib/compose/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { InMemoryCache } from '@apollo/client';
import { errorLink, reTryOneTimeOnErrorLink } from '../../containers/errors';
import { getLinks } from './helpers';
// import { InMemoryCache } from '@apollo/client';
// import { errorLink, reTryOneTimeOnErrorLink } from '../../containers/errors';
// import { getLinks } from './helpers';
// import * as apolloLinkHttp from 'apollo-link-http';
// import introspectionQueryResultData from '../../graphql/introspection.json';

jest.mock('apollo-cache-inmemory');
// jest.mock('apollo-cache-inmemory');
// jest.mock('apollo-link-http');
jest.mock('../../containers/errors');
// jest.mock('../../containers/errors');
// const mockHttpLink = { mockHttpLink: 'mockHttpLink' };

// @ts-ignore
// // @ts-ignore
// apolloLinkHttp.HttpLink.mockImplementation(() => mockHttpLink);

describe('getLinks helper', () => {
test('It should return links in correct order', () => {
const mockCache = new InMemoryCache({
dataIdFromObject: () => null,
// possibleTypes: new IntrospectionFragmentMatcher({
// introspectionQueryResultData,
// }),
});
const links = getLinks(mockCache);
expect(links[0]).toEqual(errorLink);
expect(links[1]).toEqual(reTryOneTimeOnErrorLink);
// expect(links[3]).toEqual(mockHttpLink);
});
});
// describe('getLinks helper', () => {
// test('It should return links in correct order', () => {
// const mockCache = new InMemoryCache({
// dataIdFromObject: () => null,
// possibleTypes: new IntrospectionFragmentMatcher({
// introspectionQueryResultData,
// }),
// });
// const links = getLinks(mockCache);
// expect(links[0]).toEqual(errorLink);
// expect(links[1]).toEqual(reTryOneTimeOnErrorLink);
// expect(links[3]).toEqual(mockHttpLink);
// });
// });
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/siem/public/lib/compose/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { HttpLink, InMemoryCache } from '@apollo/client';
import chrome from 'ui/chrome';

import { errorLink, reTryOneTimeOnErrorLink } from '../../containers/errors';
// import { errorLink, reTryOneTimeOnErrorLink } from '../../containers/errors';

export const getLinks = (cache: InMemoryCache) =>
// [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/siem/public/lib/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { IScope } from 'angular';
import { NormalizedCacheObject } from 'apollo-cache-inmemory';
import ApolloClient from '@apollo/client';
import { ApolloClient } from '@apollo/client';

export interface AppFrontendLibs {
apolloClient: AppApolloClient;
Expand Down
3 changes: 1 addition & 2 deletions x-pack/legacy/plugins/siem/public/mock/timeline_results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { MockedResponse } from '@apollo/react-testing';
import { OpenTimelineResult } from '../components/open_timeline/types';
import { SortFieldTimeline, Direction } from '../graphql/types';
import { allTimelinesQuery } from '../containers/timeline/all/index.gql_query';

/** Mocks results of a query run by the `OpenTimeline` component */
export const mockOpenTimelineQueryResults: MockedResponse[] = [
export const mockOpenTimelineQueryResults = [
{
request: {
query: allTimelinesQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,7 @@ jest.mock('../../../components/query_bar', () => ({
QueryBar: () => null,
}));

let localSource: Array<{
request: {};
result: {
data: {
source: {
status: {
indicesExist: boolean;
};
};
};
};
}>;
let localSource: typeof mocksSource;

const getMockHistory = (ip: string) => ({
length: 2,
Expand Down
13 changes: 1 addition & 12 deletions x-pack/legacy/plugins/siem/public/pages/network/network.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,7 @@ jest.mock('../../components/query_bar', () => ({
QueryBar: () => null,
}));

let localSource: Array<{
request: {};
result: {
data: {
source: {
status: {
indicesExist: boolean;
};
};
};
};
}>;
let localSource: typeof mocksSource;

type Action = 'PUSH' | 'POP' | 'REPLACE';
const pop: Action = 'POP';
Expand Down
15 changes: 2 additions & 13 deletions x-pack/legacy/plugins/siem/public/pages/overview/overview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,9 @@ jest.mock('ui/documentation_links', () => ({
},
}));

let localSource: Array<{
request: {};
result: {
data: {
source: {
status: {
indicesExist: boolean;
};
};
};
};
}>;

describe.skip('Overview', () => {
let localSource: typeof mocksSource;

describe('rendering', () => {
beforeEach(() => {
localSource = cloneDeep(mocksSource);
Expand Down

0 comments on commit 2785df3

Please sign in to comment.