Skip to content

Commit

Permalink
[7.x] [Ingest pipelines] Create pipeline functional test (#64945) (#6…
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth authored May 14, 2020
1 parent 2fd58fb commit bffbffc
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type PipelineFormTestSubjects =
| 'versionField'
| 'nameField.input'
| 'descriptionField.input'
| 'processorsField'
| 'processorsEditor'
| 'onFailureToggle'
| 'onFailureEditor'
| 'testPipelineButton'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const PipelineFormFields: React.FunctionComponent<Props> = ({
component={JsonEditorField}
componentProps={{
euiCodeEditorProps: {
['data-test-subj']: 'processorsField',
'data-test-subj': 'processorsEditor',
height: '300px',
'aria-label': i18n.translate('xpack.ingestPipelines.form.processorsFieldAriaLabel', {
defaultMessage: 'Processors JSON editor',
Expand Down Expand Up @@ -217,7 +217,7 @@ export const PipelineFormFields: React.FunctionComponent<Props> = ({
component={JsonEditorField}
componentProps={{
euiCodeEditorProps: {
['data-test-subj']: 'onFailureEditor',
'data-test-subj': 'onFailureEditor',
height: '300px',
'aria-label': i18n.translate('xpack.ingestPipelines.form.onFailureFieldAriaLabel', {
defaultMessage: 'Failure processors JSON editor',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import React, { FunctionComponent, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiInMemoryTable, EuiLink, EuiButton, EuiInMemoryTableProps } from '@elastic/eui';
import {
EuiInMemoryTable,
EuiLink,
EuiButton,
EuiInMemoryTableProps,
EuiTableFieldDataColumnType,
} from '@elastic/eui';

import { BASE_PATH } from '../../../../common/constants';
import { Pipeline } from '../../../../common/types';
Expand Down Expand Up @@ -36,6 +42,16 @@ export const PipelineTable: FunctionComponent<Props> = ({
selection: {
onSelectionChange: setSelection,
},
rowProps: () => ({
'data-test-subj': 'pipelineTableRow',
}),
cellProps: (pipeline, column) => {
const { field } = column as EuiTableFieldDataColumnType<Pipeline>;

return {
'data-test-subj': `pipelineTableRow-${field}`,
};
},
search: {
toolsLeft:
selection.length > 0 ? (
Expand Down
41 changes: 40 additions & 1 deletion x-pack/test/functional/apps/ingest_pipelines/ingest_pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,32 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

const PIPELINE = {
name: 'test_pipeline',
description: 'My pipeline description.',
version: 1,
processors: JSON.stringify([
{
set: {
field: 'foo',
value: 'new',
},
},
]),
onFailureProcessors: JSON.stringify([
{
set: {
field: '_index',
value: 'failed-{{ _index }}',
},
},
]),
};

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'ingestPipelines']);
const log = getService('log');
const es = getService('legacyEs');

describe('Ingest Pipelines', function() {
this.tags('smoke');
Expand All @@ -18,10 +41,26 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

it('Loads the app', async () => {
await log.debug('Checking for section heading to say Ingest Node Pipelines.');
log.debug('Checking for section heading to say Ingest Node Pipelines.');

const headingText = await pageObjects.ingestPipelines.sectionHeadingText();
expect(headingText).to.be('Ingest Node Pipelines');
});

it('Creates a pipeline', async () => {
await pageObjects.ingestPipelines.createNewPipeline(PIPELINE);

const pipelinesList = await pageObjects.ingestPipelines.getPipelinesList();
const newPipelineExists = Boolean(
pipelinesList.find(pipelineName => pipelineName === PIPELINE.name)
);

expect(newPipelineExists).to.be(true);
});

after(async () => {
// Delete the pipeline that was created
await es.ingest.deletePipeline({ id: PIPELINE.name });
});
});
};
53 changes: 52 additions & 1 deletion x-pack/test/functional/page_objects/ingest_pipelines_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,65 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { WebElementWrapper } from 'test/functional/services/lib/web_element_wrapper';
import { FtrProviderContext } from '../ftr_provider_context';

export function IngestPipelinesPageProvider({ getService }: FtrProviderContext) {
export function IngestPipelinesPageProvider({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const pageObjects = getPageObjects(['header']);
const aceEditor = getService('aceEditor');

return {
async sectionHeadingText() {
return await testSubjects.getVisibleText('appTitle');
},

async createNewPipeline({
name,
description,
version,
processors,
onFailureProcessors,
}: {
name: string;
description: string;
version?: number;
processors?: string;
onFailureProcessors?: string;
}) {
await testSubjects.click('createPipelineButton');
await testSubjects.exists('pipelineForm');

await testSubjects.setValue('nameField > input', name);
await testSubjects.setValue('descriptionField > input', description);

if (version) {
await testSubjects.click('versionToggle');
await testSubjects.setValue('versionField > input', version.toString());
}

if (processors) {
await aceEditor.setValue('processorsEditor', processors);
}

if (onFailureProcessors) {
await testSubjects.click('onFailureToggle');
await aceEditor.setValue('onFailureEditor', processors);
}

await testSubjects.click('submitButton');
await pageObjects.header.waitUntilLoadingHasFinished();
},

async getPipelinesList() {
const pipelines = await testSubjects.findAll('pipelineTableRow');

const getPipelineName = async (pipeline: WebElementWrapper) => {
const pipelineNameElement = await pipeline.findByTestSubject('pipelineTableRow-name');
return await pipelineNameElement.getVisibleText();
};

return await Promise.all(pipelines.map(pipeline => getPipelineName(pipeline)));
},
};
}

0 comments on commit bffbffc

Please sign in to comment.