[Logs UI] Add smoke tests for log rate and categories tabs (#55088)

This adds function smoke tests for the new log rate and categories tabs in the Logs UI.
This commit is contained in:
Felix Stürmer 2020-02-03 16:00:17 +01:00 committed by GitHub
parent 7dc8c6f9ba
commit 1c849acdd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 182 additions and 33 deletions

View file

@ -12,6 +12,8 @@ export default ({ loadTestFile }: FtrProviderContext) => {
loadTestFile(require.resolve('./home_page'));
loadTestFile(require.resolve('./feature_controls'));
loadTestFile(require.resolve('./log_entry_categories_tab'));
loadTestFile(require.resolve('./log_entry_rate_tab'));
loadTestFile(require.resolve('./logs_source_configuration'));
loadTestFile(require.resolve('./metrics_source_configuration'));
loadTestFile(require.resolve('./link_to'));

View file

@ -0,0 +1,28 @@
/*
* 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 '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default ({ getService }: FtrProviderContext) => {
const logsUi = getService('logsUi');
const retry = getService('retry');
describe('Log Entry Categories Tab', function() {
this.tags('smoke');
describe('with a trial license', () => {
it('is visible', async () => {
await logsUi.logEntryCategoriesPage.navigateTo();
await retry.try(async () => {
expect(await logsUi.logEntryCategoriesPage.getSetupScreen()).to.be.ok();
});
});
});
});
};

View file

@ -0,0 +1,28 @@
/*
* 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 '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default ({ getService }: FtrProviderContext) => {
const logsUi = getService('logsUi');
const retry = getService('retry');
describe('Log Entry Rate Tab', function() {
this.tags('smoke');
describe('with a trial license', () => {
it('is visible', async () => {
await logsUi.logEntryRatePage.navigateTo();
await retry.try(async () => {
expect(await logsUi.logEntryRatePage.getSetupScreen()).to.be.ok();
});
});
});
});
};

View file

@ -10,12 +10,14 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default ({ getPageObjects, getService }: FtrProviderContext) => {
const esArchiver = getService('esArchiver');
const infraLogStream = getService('infraLogStream');
const logsUi = getService('logsUi');
const infraSourceConfigurationForm = getService('infraSourceConfigurationForm');
const pageObjects = getPageObjects(['common', 'infraLogs']);
const retry = getService('retry');
describe('Logs Source Configuration', function() {
this.tags('smoke');
before(async () => {
await esArchiver.load('empty_kibana');
});
@ -32,8 +34,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
it('can change the log indices to a pattern that matches nothing', async () => {
await pageObjects.common.navigateToActualUrl('infraLogs', 'logs/settings');
await infraSourceConfigurationForm.getForm();
await pageObjects.infraLogs.navigateToTab('settings');
await retry.try(async () => {
await infraSourceConfigurationForm.getForm();
});
const nameInput = await infraSourceConfigurationForm.getNameInput();
await nameInput.clearValueWithKeyboard({ charByChar: true });
@ -47,13 +52,19 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
it('renders the no indices screen when no indices match the pattern', async () => {
await pageObjects.common.navigateToActualUrl('infraLogs', 'logs/stream');
await pageObjects.infraLogs.getNoLogsIndicesPrompt();
await logsUi.logStreamPage.navigateTo();
await retry.try(async () => {
await logsUi.logStreamPage.getNoLogsIndicesPrompt();
});
});
it('can change the log indices back to a pattern that matches something', async () => {
await pageObjects.common.navigateToActualUrl('infraLogs', 'logs/settings');
await infraSourceConfigurationForm.getForm();
await pageObjects.infraLogs.navigateToTab('settings');
await retry.try(async () => {
await infraSourceConfigurationForm.getForm();
});
const logIndicesInput = await infraSourceConfigurationForm.getLogIndicesInput();
await logIndicesInput.clearValueWithKeyboard({ charByChar: true });
@ -63,16 +74,19 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
it('renders the default log columns with their headers', async () => {
await pageObjects.common.navigateToActualUrl('infraLogs', 'logs/stream');
const columnHeaderLabels = await infraLogStream.getColumnHeaderLabels();
await logsUi.logStreamPage.navigateTo();
expect(columnHeaderLabels).to.eql(['Oct 17, 2018', 'event.dataset', 'Message']);
await retry.try(async () => {
const columnHeaderLabels = await logsUi.logStreamPage.getColumnHeaderLabels();
const logStreamEntries = await infraLogStream.getStreamEntries();
expect(columnHeaderLabels).to.eql(['Oct 17, 2018', 'event.dataset', 'Message']);
});
const logStreamEntries = await logsUi.logStreamPage.getStreamEntries();
expect(logStreamEntries.length).to.be.greaterThan(0);
const firstLogStreamEntry = logStreamEntries[0];
const logStreamEntryColumns = await infraLogStream.getLogColumnsOfStreamEntry(
const logStreamEntryColumns = await logsUi.logStreamPage.getLogColumnsOfStreamEntry(
firstLogStreamEntry
);
@ -80,32 +94,34 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
it('can change the log columns', async () => {
await pageObjects.common.navigateToActualUrl('infraLogs', 'logs/settings');
await infraSourceConfigurationForm.getForm();
await pageObjects.infraLogs.navigateToTab('settings');
await retry.try(async () => {
await infraSourceConfigurationForm.getForm();
});
await infraSourceConfigurationForm.removeAllLogColumns();
await infraSourceConfigurationForm.addTimestampLogColumn();
await infraSourceConfigurationForm.addFieldLogColumn('host.name');
// await infraSourceConfigurationForm.moveLogColumn(0, 1);
await infraSourceConfigurationForm.saveConfiguration();
});
it('renders the changed log columns with their headers', async () => {
await pageObjects.common.navigateToActualUrl('infraLogs', 'logs/stream');
const columnHeaderLabels = await infraLogStream.getColumnHeaderLabels();
await logsUi.logStreamPage.navigateTo();
// TODO: make test more robust
// expect(columnHeaderLabels).to.eql(['host.name', 'Timestamp']);
expect(columnHeaderLabels).to.eql(['Oct 17, 2018', 'host.name']);
await retry.try(async () => {
const columnHeaderLabels = await logsUi.logStreamPage.getColumnHeaderLabels();
const logStreamEntries = await infraLogStream.getStreamEntries();
expect(columnHeaderLabels).to.eql(['Oct 17, 2018', 'host.name']);
});
const logStreamEntries = await logsUi.logStreamPage.getStreamEntries();
expect(logStreamEntries.length).to.be.greaterThan(0);
const firstLogStreamEntry = logStreamEntries[0];
const logStreamEntryColumns = await infraLogStream.getLogColumnsOfStreamEntry(
const logStreamEntryColumns = await logsUi.logStreamPage.getLogColumnsOfStreamEntry(
firstLogStreamEntry
);

View file

@ -18,12 +18,14 @@ export function InfraLogsPageProvider({ getPageObjects, getService }: FtrProvide
await pageObjects.common.navigateToApp('infraLogs');
},
async navigateToTab(logsUiTab: LogsUiTab) {
await pageObjects.common.navigateToActualUrl('infraLogs', `/logs/${logsUiTab}`);
},
async getLogStream() {
return await testSubjects.find('logStream');
},
async getNoLogsIndicesPrompt() {
return await testSubjects.find('noLogsIndicesPrompt');
},
};
}
type LogsUiTab = 'log-categories' | 'log-rate' | 'settings' | 'stream';

View file

@ -46,7 +46,7 @@ import { GrokDebuggerProvider } from './grok_debugger';
import { UserMenuProvider } from './user_menu';
import { UptimeProvider } from './uptime';
import { InfraSourceConfigurationFormProvider } from './infra_source_configuration_form';
import { InfraLogStreamProvider } from './infra_log_stream';
import { LogsUiProvider } from './logs_ui';
import { MachineLearningProvider } from './ml';
import { TransformProvider } from './transform';
@ -88,7 +88,7 @@ export const services = {
userMenu: UserMenuProvider,
uptime: UptimeProvider,
infraSourceConfigurationForm: InfraSourceConfigurationFormProvider,
infraLogStream: InfraLogStreamProvider,
logsUi: LogsUiProvider,
ml: MachineLearningProvider,
transform: TransformProvider,
};

View file

@ -0,0 +1,18 @@
/*
* 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 { FtrProviderContext } from '../../ftr_provider_context';
import { LogEntryCategoriesPageProvider } from './log_entry_categories';
import { LogEntryRatePageProvider } from './log_entry_rate';
import { LogStreamPageProvider } from './log_stream';
export function LogsUiProvider(context: FtrProviderContext) {
return {
logEntryCategoriesPage: LogEntryCategoriesPageProvider(context),
logEntryRatePage: LogEntryRatePageProvider(context),
logStreamPage: LogStreamPageProvider(context),
};
}

View file

@ -0,0 +1,23 @@
/*
* 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 { WebElementWrapper } from '../../../../../test/functional/services/lib/web_element_wrapper';
import { FtrProviderContext } from '../../ftr_provider_context';
export function LogEntryCategoriesPageProvider({ getPageObjects, getService }: FtrProviderContext) {
const pageObjects = getPageObjects(['infraLogs']);
const testSubjects = getService('testSubjects');
return {
async navigateTo() {
pageObjects.infraLogs.navigateToTab('log-categories');
},
async getSetupScreen(): Promise<WebElementWrapper> {
return await testSubjects.find('logEntryCategoriesSetupPage');
},
};
}

View file

@ -0,0 +1,23 @@
/*
* 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 { WebElementWrapper } from '../../../../../test/functional/services/lib/web_element_wrapper';
import { FtrProviderContext } from '../../ftr_provider_context';
export function LogEntryRatePageProvider({ getPageObjects, getService }: FtrProviderContext) {
const pageObjects = getPageObjects(['infraLogs']);
const testSubjects = getService('testSubjects');
return {
async navigateTo() {
pageObjects.infraLogs.navigateToTab('log-rate');
},
async getSetupScreen(): Promise<WebElementWrapper> {
return await testSubjects.find('logEntryRateSetupPage');
},
};
}

View file

@ -4,14 +4,19 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { FtrProviderContext } from '../ftr_provider_context';
import { WebElementWrapper } from '../../../../test/functional/services/lib/web_element_wrapper';
import { FtrProviderContext } from '../../ftr_provider_context';
import { WebElementWrapper } from '../../../../../test/functional/services/lib/web_element_wrapper';
export function InfraLogStreamProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
export function LogStreamPageProvider({ getPageObjects, getService }: FtrProviderContext) {
const pageObjects = getPageObjects(['infraLogs']);
const retry = getService('retry');
const testSubjects = getService('testSubjects');
return {
async navigateTo() {
pageObjects.infraLogs.navigateToTab('stream');
},
async getColumnHeaderLabels(): Promise<string[]> {
const columnHeaderElements: WebElementWrapper[] = await testSubjects.findAll(
'~logColumnHeader'
@ -35,5 +40,9 @@ export function InfraLogStreamProvider({ getService }: FtrProviderContext) {
): Promise<WebElementWrapper[]> {
return await testSubjects.findAllDescendant('~logColumn', entryElement);
},
async getNoLogsIndicesPrompt() {
return await testSubjects.find('noLogsIndicesPrompt');
},
};
}