Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IndexManagement - IngestPipelines] Remove leftover axios dependencies #130089

Merged
merged 4 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import React from 'react';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import axios from 'axios';
import sinon from 'sinon';
import { findTestSubject } from '@elastic/eui/lib/test';
import axiosXhrAdapter from 'axios/lib/adapters/xhr';

/**
* The below import is required to avoid a console error warn from brace package
Expand All @@ -20,8 +17,9 @@ import axiosXhrAdapter from 'axios/lib/adapters/xhr';
at createWorker (/<path-to-repo>/node_modules/brace/index.js:17992:5)
*/
import { mountWithIntl, stubWebWorker } from '@kbn/test-jest-helpers'; // eslint-disable-line no-unused-vars
import { init as initHttpRequests } from '../client_integration/helpers/http_requests';

import { BASE_PATH, API_BASE_PATH } from '../../common/constants';
import { BASE_PATH } from '../../common/constants';
import { AppWithoutRouter } from '../../public/application/app';
import { AppContextProvider } from '../../public/application/app_context';
import { loadIndicesSuccess } from '../../public/application/store/actions';
Expand All @@ -40,9 +38,6 @@ import {
executionContextServiceMock,
} from '../../../../../src/core/public/mocks';

const mockHttpClient = axios.create({ adapter: axiosXhrAdapter });

let server = null;
let store = null;
const indices = [];

Expand Down Expand Up @@ -149,6 +144,8 @@ const getActionMenuButtons = (rendered) => {
.map((span) => span.text());
};
describe('index table', () => {
const { httpSetup, httpRequestsMockHelpers } = initHttpRequests();

beforeEach(() => {
// Mock initialization of services
const services = {
Expand All @@ -159,8 +156,7 @@ describe('index table', () => {
setExtensionsService(services.extensionsService);
setUiMetricService(services.uiMetricService);

// @ts-ignore
httpService.setup(mockHttpClient);
httpService.setup(httpSetup);
breadcrumbService.setup(() => undefined);
notificationService.setup(notificationServiceMock.createStartContract());

Expand All @@ -186,33 +182,9 @@ describe('index table', () => {
);

store.dispatch(loadIndicesSuccess({ indices }));
server = sinon.fakeServer.create();

server.respondWith(`${API_BASE_PATH}/indices`, [
200,
{ 'Content-Type': 'application/json' },
JSON.stringify(indices),
]);

server.respondWith([
200,
{ 'Content-Type': 'application/json' },
JSON.stringify({ acknowledged: true }),
]);

server.respondWith(`${API_BASE_PATH}/indices/reload`, [
200,
{ 'Content-Type': 'application/json' },
JSON.stringify(indices),
]);

server.respondImmediately = true;
});
afterEach(() => {
if (!server) {
return;
}
server.restore();

httpRequestsMockHelpers.setLoadIndicesResponse(indices);
httpRequestsMockHelpers.setReloadIndicesResponse(indices);
});

test('should change pages when a pagination link is clicked on', async () => {
Expand Down Expand Up @@ -476,22 +448,17 @@ describe('index table', () => {
});

test('close index button works from context menu', async () => {
const rendered = mountWithIntl(component);
await runAllPromises();
rendered.update();

const modifiedIndices = indices.map((index) => {
return {
...index,
status: index.name === 'testy0' ? 'close' : index.status,
};
});
httpRequestsMockHelpers.setReloadIndicesResponse(modifiedIndices);

server.respondWith(`${API_BASE_PATH}/indices/reload`, [
200,
{ 'Content-Type': 'application/json' },
JSON.stringify(modifiedIndices),
]);
const rendered = mountWithIntl(component);
await runAllPromises();
rendered.update();

testAction(rendered, 'closeIndexMenuButton');
});
Expand All @@ -503,16 +470,12 @@ describe('index table', () => {
status: index.name === 'testy1' ? 'closed' : index.status,
};
});

server.respondWith(`${API_BASE_PATH}/indices`, [
200,
{ 'Content-Type': 'application/json' },
JSON.stringify(modifiedIndices),
]);
httpRequestsMockHelpers.setLoadIndicesResponse(modifiedIndices);

const rendered = mountWithIntl(component);
await runAllPromises();
rendered.update();

testAction(rendered, 'openIndexMenuButton', 'testy1');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

const APPEND_TYPE = 'append';

describe('Processor: Append', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;

const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
});
Expand All @@ -26,7 +28,7 @@ describe('Processor: Append', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

const BYTES_TYPE = 'bytes';

describe('Processor: Bytes', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;
const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
Expand All @@ -26,7 +27,7 @@ describe('Processor: Bytes', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

const CIRCLE_TYPE = 'circle';

describe('Processor: Circle', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;
const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
Expand All @@ -26,7 +27,7 @@ describe('Processor: Circle', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

const BYTES_TYPE = 'bytes';

describe('Processor: Common Fields For All Processors', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;
const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
Expand All @@ -26,7 +27,7 @@ describe('Processor: Common Fields For All Processors', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

const COMMUNITY_ID_TYPE = 'community_id';

describe('Processor: Community id', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;
const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
Expand All @@ -26,7 +27,7 @@ describe('Processor: Community id', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

// Default parameter values automatically added to the `convert processor` when saved
const defaultConvertParameters = {
Expand All @@ -23,6 +23,7 @@ const CONVERT_TYPE = 'convert';
describe('Processor: Convert', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;
const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
Expand All @@ -36,7 +37,7 @@ describe('Processor: Convert', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

// Default parameter values automatically added to the CSV processor when saved
const defaultCSVParameters = {
Expand All @@ -26,6 +26,7 @@ const CSV_TYPE = 'csv';
describe('Processor: CSV', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;
const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
Expand All @@ -39,7 +40,7 @@ describe('Processor: CSV', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

const DATE_TYPE = 'date';

describe('Processor: Date', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;
const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
Expand All @@ -26,7 +27,7 @@ describe('Processor: Date', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

const DATE_INDEX_TYPE = 'date_index_name';

describe('Processor: Date Index Name', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;
const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
Expand All @@ -26,7 +27,7 @@ describe('Processor: Date Index Name', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/

import { act } from 'react-dom/test-utils';
import { setup, SetupResult, getProcessorValue } from './processor.helpers';
import { setup, SetupResult, getProcessorValue, setupEnvironment } from './processor.helpers';

const DOT_EXPANDER_TYPE = 'dot_expander';

describe('Processor: Dot Expander', () => {
let onUpdate: jest.Mock;
let testBed: SetupResult;
const { httpSetup } = setupEnvironment();

beforeAll(() => {
jest.useFakeTimers();
Expand All @@ -26,7 +27,7 @@ describe('Processor: Dot Expander', () => {
onUpdate = jest.fn();

await act(async () => {
testBed = await setup({
testBed = await setup(httpSetup, {
value: {
processors: [],
},
Expand Down
Loading