Skip to content

Commit

Permalink
Rollup job Functional UI test (#30280) (#30571)
Browse files Browse the repository at this point in the history
  • Loading branch information
rashmivkulkarni authored Feb 8, 2019
1 parent e82c94f commit 90820a5
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export class JobCreateUi extends Component {
!this.canGoToStep(stepId)
|| stepIds.indexOf(stepId) > stepIds.indexOf(checkpointStepId)
),
'data-test-subj': index === indexOfCurrentStep ? `createRollupStep${index + 1}--active` : `createRollupStep${index + 1}`,
}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const NavigationUi = ({
<EuiButtonEmpty
iconType="arrowLeft"
onClick={goToPreviousStep}
data-test-subj="rollupJobBackButton"
>
<FormattedMessage
id="xpack.rollupJobs.create.backButton.label"
Expand All @@ -72,6 +73,7 @@ const NavigationUi = ({
onClick={goToNextStep}
isDisabled={!canGoToNextStep}
fill
data-test-subj="rollupJobNextButton"
>
<FormattedMessage
id="xpack.rollupJobs.create.nextButton.label"
Expand All @@ -88,6 +90,7 @@ const NavigationUi = ({
iconType="check"
onClick={save}
fill
data-test-subj="rollupJobSaveButton"
>
<FormattedMessage
id="xpack.rollupJobs.create.saveButton.label"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export class StepDateHistogramUi extends Component {
onChange={e => onFieldsChange({ dateHistogramInterval: e.target.value })}
isInvalid={Boolean(areStepErrorsVisible && errorDateHistogramInterval)}
fullWidth
data-test-subj="rollupJobInterval"
/>
</EuiFormRow>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class StepLogisticsUi extends Component {

if(!isValidatingIndexPattern && hasMatchingIndices) {
return (
<EuiTextColor color="secondary">
<EuiTextColor color="secondary" data-test-subj="fieldIndexPatternSuccessMessage">
<p>
<FormattedMessage
id="xpack.rollupJobs.create.stepLogistics.fieldIndexPattern.helpHasMatchesLabel"
Expand Down Expand Up @@ -323,6 +323,7 @@ export class StepLogisticsUi extends Component {
value={id}
onChange={e => onFieldsChange({ id: e.target.value })}
fullWidth
data-test-subj="rollupJobName"
/>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down Expand Up @@ -364,6 +365,7 @@ export class StepLogisticsUi extends Component {
isInvalid={Boolean(areStepErrorsVisible && errorIndexPattern) || Boolean(indexPatternAsyncErrors)}
isLoading={isValidatingIndexPattern}
fullWidth
data-test-subj="rollupIndexPattern"
/>
</EuiFormRow>

Expand All @@ -390,6 +392,7 @@ export class StepLogisticsUi extends Component {
onChange={e => onFieldsChange({ rollupIndex: e.target.value })}
isInvalid={Boolean(areStepErrorsVisible && errorRollupIndex)}
fullWidth
data-test-subj="rollupIndexName"
/>
</EuiFormRow>
</EuiDescribedFormGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export class JobListUi extends Component {
}
actions={
<EuiButton
data-test-subj="createRollupJobButton"
{...getRouterLinkProps(`${CRUD_APP_BASE_PATH}/create`)}
fill
iconType="plusInCircle"
Expand Down Expand Up @@ -278,4 +279,3 @@ export class JobListUi extends Component {
}

export const JobList = injectI18n(JobListUi);

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { i18n } from '@kbn/i18n';
import { injectI18n } from '@kbn/i18n/react';
import _ from 'lodash';

import {
EuiCheckbox,
Expand Down Expand Up @@ -253,7 +254,6 @@ export class JobTableUi extends Component {
if (name === 'ID') {
content = (
<EuiLink
data-test-subj="rollupTableJobLink"
onClick={() => {
openDetailPanel(job.id);
}}
Expand All @@ -280,7 +280,7 @@ export class JobTableUi extends Component {
return (
<EuiTableRowCell
key={`${job.id}-${name}`}
data-test-subj={`jobTableCell-${name}`}
data-test-subj={`jobTableCell-${_.camelCase(name)}`}
truncateText={truncateText}
>
{wrappedContent}
Expand All @@ -298,6 +298,7 @@ export class JobTableUi extends Component {
return (
<EuiTableRow
key={`${id}-row`}
data-test-subj="jobTableRow"
>
<EuiTableRowCellCheckbox key={`checkbox-${id}`}>
<EuiCheckbox
Expand Down
13 changes: 13 additions & 0 deletions x-pack/test/functional/apps/rollup_job/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export default function ({ loadTestFile }) {
describe('rollup job', function () {
this.tags('ciGroup1');

loadTestFile(require.resolve('./rollup_jobs'));
});
}
68 changes: 68 additions & 0 deletions x-pack/test/functional/apps/rollup_job/rollup_jobs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from 'expect.js';
import { indexBy } from 'lodash';

export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const log = getService('log');
const PageObjects = getPageObjects(['security', 'rollup', 'common', 'header']);

describe('rollup job', async () => {
before(async () => {
// init data
await Promise.all([
esArchiver.loadIfNeeded('logstash_functional'),
esArchiver.load('canvas/default'),
]);
await PageObjects.common.navigateToApp('rollupJob');
});

after(async () => await esArchiver.unload('logstash_functional'));

it('create and save a new job', async () => {
const jobName = 'Testjob1';
const indexPattern = '.kibana*';
const indexName = 'rollup_index';
const interval = '1000ms';

await PageObjects.rollup.createNewRollUpJob();
await PageObjects.rollup.verifyStepIsActive(1);
await PageObjects.rollup.addRoleNameandIndexPattern(jobName, indexPattern);
await PageObjects.rollup.verifyIndexPatternAccepted();
await PageObjects.rollup.setIndexName(indexName);
await PageObjects.rollup.moveToNextStep();

//now navigate to histogram
await PageObjects.rollup.verifyStepIsActive(2);
await PageObjects.rollup.setJobInterval(interval);
await PageObjects.rollup.moveToNextStep();

//Terms (optional)
await PageObjects.rollup.verifyStepIsActive(3);
await PageObjects.rollup.moveToNextStep();

//Histogram(optional)
await PageObjects.rollup.verifyStepIsActive(4);
await PageObjects.rollup.moveToNextStep();

//Metrics(optional)
await PageObjects.rollup.verifyStepIsActive(5);
await PageObjects.rollup.moveToNextStep();

//saveJob and verify the name in the list
await PageObjects.rollup.verifyStepIsActive(6);
await PageObjects.rollup.saveJob();

// verify jobListTitle
const jobList = indexBy(await PageObjects.rollup.getJobList(), 'jobName');
log.debug(JSON.stringify(jobList));
log.debug(Object.keys(jobList));
expect(Object.keys(jobList)).to.have.length(1);
});
});
}
11 changes: 11 additions & 0 deletions x-pack/test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import {
GisPageProvider,
StatusPagePageProvider,
UpgradeAssistantProvider,
RollupPageProvider,
UptimePageProvider,

} from './page_objects';

import {
Expand Down Expand Up @@ -54,6 +56,7 @@ import {
GrokDebuggerProvider,
UserMenuProvider,
UptimeProvider,

} from './services';

// the default export of config files must be a config provider
Expand Down Expand Up @@ -82,6 +85,7 @@ export default async function ({ readConfigFile }) {
resolve(__dirname, './apps/logstash'),
resolve(__dirname, './apps/grok_debugger'),
resolve(__dirname, './apps/infra'),
resolve(__dirname, './apps/rollup_job'),
resolve(__dirname, './apps/maps'),
resolve(__dirname, './apps/status_page'),
resolve(__dirname, './apps/upgrade_assistant'),
Expand Down Expand Up @@ -122,6 +126,7 @@ export default async function ({ readConfigFile }) {
grokDebugger: GrokDebuggerProvider,
userMenu: UserMenuProvider,
uptime: UptimeProvider,
rollup: RollupPageProvider,
},

// just like services, PageObjects are defined as a map of
Expand All @@ -142,6 +147,7 @@ export default async function ({ readConfigFile }) {
statusPage: StatusPagePageProvider,
upgradeAssistant: UpgradeAssistantProvider,
uptime: UptimePageProvider,
rollup: RollupPageProvider
},

servers: kibanaFunctionalConfig.get('servers'),
Expand Down Expand Up @@ -205,6 +211,10 @@ export default async function ({ readConfigFile }) {
},
uptime: {
pathname: '/app/uptime',
},
rollupJob: {
pathname: '/app/kibana',
hash: '/management/elasticsearch/rollup_jobs/'
}
},

Expand All @@ -223,4 +233,5 @@ export default async function ({ readConfigFile }) {
rootDirectory: resolve(__dirname, '../../'),
},
};

}
1 change: 1 addition & 0 deletions x-pack/test/functional/page_objects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export { InfraHomePageProvider } from './infra_home_page';
export { GisPageProvider } from './gis_page';
export { StatusPagePageProvider } from './status_page';
export { UpgradeAssistantProvider } from './upgrade_assistant';
export { RollupPageProvider } from './rollup_page';
export { UptimePageProvider } from './uptime_page';
82 changes: 82 additions & 0 deletions x-pack/test/functional/page_objects/rollup_page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from 'expect.js';
import { map as mapAsync } from 'bluebird';

export function RollupPageProvider({ getService, getPageObjects }) {
const testSubjects = getService('testSubjects');
const log = getService('log');
const PageObjects = getPageObjects(['header', 'common']);


class RollupJobPage {
async createNewRollUpJob() {
await testSubjects.click('createRollupJobButton');
}

async verifyStepIsActive(stepNumber) {
await testSubjects.exists(`createRollupStep${stepNumber}--active`);
}

async addRoleNameandIndexPattern(name, indexPattern) {
log.debug(`Adding name ${name} to form`);
await testSubjects.setValue('rollupJobName', name);
await testSubjects.setValue('rollupIndexPattern', indexPattern);
}

async verifyIndexPatternAccepted() {
const span = await testSubjects.find('fieldIndexPatternSuccessMessage');
const message = await span.findByCssSelector('p');
const text = await message.getVisibleText();
expect(text).to.be.equal('Success! Index pattern has matching indices.');
}

async setIndexName(name) {
await testSubjects.setValue('rollupIndexName', name);
}

async moveToNextStep() {
await testSubjects.click('rollupJobNextButton');
}

async setJobInterval(time) {
await testSubjects.setValue('rollupJobInterval', time);
}

async saveJob() {
await testSubjects.click('rollupJobSaveButton');
await PageObjects.header.waitUntilLoadingHasFinished();
}

async getJobList() {
const jobs = await testSubjects.findAll('jobTableRow');
return mapAsync(jobs, async job => {
const jobNameElement = await job.findByCssSelector('[data-test-subj="jobTableCell-id"]');
const jobStatusElement = await job.findByCssSelector('[data-test-subj="jobTableCell-status"]');
const jobIndexPatternElement = await job.findByCssSelector('[data-test-subj="jobTableCell-indexPattern"]');
const jobRollUpIndexPatternElement = await job.findByCssSelector('[data-test-subj="jobTableCell-rollupIndex"]');
const jobDelayElement = await job.findByCssSelector('[data-test-subj="jobTableCell-delay"]');
const jobIntervalElement = await job.findByCssSelector('[data-test-subj="jobTableCell-interval"]');
const jobGroupElement = await job.findByCssSelector('[data-test-subj="jobTableCell-groups"]');
const jobMetricsElement = await job.findByCssSelector('[data-test-subj="jobTableCell-metrics"]');

return {
jobName: await jobNameElement.getVisibleText(),
jobStatus: await jobStatusElement.getVisibleText(),
jobIndexPattern: await jobIndexPatternElement.getVisibleText(),
jobRollUpIndexPattern: await jobRollUpIndexPatternElement.getVisibleText(),
jobDelayElement: await jobDelayElement.getVisibleText(),
jobInterval: await jobIntervalElement.getVisibleText(),
jobGroup: await jobGroupElement.getVisibleText(),
jobMetrics: await jobMetricsElement.getVisibleText()
};
});
}

}
return new RollupJobPage();
}

0 comments on commit 90820a5

Please sign in to comment.