Skip to content

Commit

Permalink
Add file data visualizer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pheyos committed Mar 17, 2020
1 parent baaca89 commit b1efa95
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* 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 path from 'path';

import { FtrProviderContext } from '../../../ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function({ getService }: FtrProviderContext) {
const ml = getService('ml');

const testDataListPositive = [
{
suiteSuffix: 'with an artificial server log',
filePath: path.join(__dirname, 'files_to_import', 'artificial_server_log'),
indexName: 'user-import_1',
createIndexPattern: false,
expected: {
results: {
title: 'artificial_server_log',
},
},
},
];

const testDataListNegative = [
{
suiteSuffix: 'with a non-log file',
filePath: path.join(__dirname, 'files_to_import', 'not_a_log_file'),
},
];

describe('file based', function() {
this.tags(['smoke', 'mlqa']);
before(async () => {
await ml.securityUI.loginAsMlPowerUser();
await ml.navigation.navigateToMl();
});

for (const testData of testDataListPositive) {
describe(testData.suiteSuffix, function() {
after(async () => {
await ml.api.deleteIndices(testData.indexName);
});

it('loads the data visualizer selector page', async () => {
await ml.navigation.navigateToDataVisualizer();
});

it('loads the file upload page', async () => {
await ml.dataVisualizer.navigateToFileUpload();
});

it('selects a file and loads visualizer results', async () => {
await ml.dataVisualizerFileBased.selectFile(testData.filePath);
});

it('displays the components of the file details page', async () => {
await ml.dataVisualizerFileBased.assertFileTitle(testData.expected.results.title);
await ml.dataVisualizerFileBased.assertFileContentPanelExists();
await ml.dataVisualizerFileBased.assertSummaryPanelExists();
await ml.dataVisualizerFileBased.assertFileStatsPanelExists();
});

it('loads the import settings page', async () => {
await ml.dataVisualizerFileBased.navigateToFileImport();
});

it('sets the index name', async () => {
await ml.dataVisualizerFileBased.setIndexName(testData.indexName);
});

it('sets the create index pattern checkbox', async () => {
await ml.dataVisualizerFileBased.setCreateIndexPatternCheckboxState(
testData.createIndexPattern
);
});

it('imports the file', async () => {
await ml.dataVisualizerFileBased.startImportAndWaitForProcessing();
});
});
}

for (const testData of testDataListNegative) {
describe(testData.suiteSuffix, function() {
it('loads the data visualizer selector page', async () => {
await ml.navigation.navigateToDataVisualizer();
});

it('loads the file upload page', async () => {
await ml.dataVisualizer.navigateToFileUpload();
});

it('selects a file and displays an error', async () => {
await ml.dataVisualizerFileBased.selectFile(testData.filePath, true);
});
});
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export default function({ loadTestFile }: FtrProviderContext) {
this.tags(['skipFirefox']);

loadTestFile(require.resolve('./index_data_visualizer'));
loadTestFile(require.resolve('./file_data_visualizer'));
});
}

0 comments on commit b1efa95

Please sign in to comment.