Skip to content

Commit

Permalink
[IndexManagement - IngestPipelines] Remove leftover axios dependencies (
Browse files Browse the repository at this point in the history
#130089) (#130111)

* Remove last axios dep from ingest pipelines

* Remove last axios dep from index management

* commit using @elastic.co

* Fix linter errors

(cherry picked from commit aa14fd0)

# Conflicts:
#	x-pack/plugins/index_management/__jest__/components/index_table.test.js

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
sabarasaba and kibanamachine authored Apr 13, 2022
1 parent a80fc36 commit 68ba36e
Show file tree
Hide file tree
Showing 20 changed files with 75 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@
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
* console.warn ../node_modules/brace/index.js:3999
Could not load worker ReferenceError: Worker is not defined
at createWorker (/<path-to-repo>/node_modules/brace/index.js:17992:5)
*/

import { mountWithIntl, stubWebWorker } from '@kbn/test/jest'; // 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 @@ -38,9 +37,6 @@ import { kibanaVersion } from '../client_integration/helpers';
/* eslint-disable @kbn/eslint/no-restricted-paths */
import { notificationServiceMock } from '../../../../../src/core/public/notifications/notifications_service.mock';

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

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

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

beforeEach(() => {
// Mock initialization of services
const services = {
Expand All @@ -157,8 +155,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 @@ -177,33 +174,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 @@ -467,22 +440,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 @@ -494,16 +462,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

0 comments on commit 68ba36e

Please sign in to comment.