Skip to content

Commit

Permalink
fix(discover-log-explorer): update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Antonio Ghiani committed Aug 10, 2023
1 parent 62929b8 commit 1a8bfff
Show file tree
Hide file tree
Showing 5 changed files with 837 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

const defaultLogColumns = ['@timestamp', 'message'];

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const retry = getService('retry');
const PageObjects = getPageObjects([
'common',
'discover',
'discoverLogExplorer',
'unifiedFieldList',
]);

const defaultLogColumns = ['@timestamp', 'message'];
const PageObjects = getPageObjects(['common', 'discover', 'discoverLogExplorer']);

describe('Columns selection initialization and update', () => {
before(async () => {
Expand Down Expand Up @@ -58,70 +53,5 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});
});

describe('when switching datasets using the dataset selector', () => {
it('should set the table columns to logs default selection', async () => {
await PageObjects.common.navigateToApp('discover', {
hash: '/p/log-explorer',
});

await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage();

await retry.try(async () => {
expect(await PageObjects.discover.getColumnHeaders()).to.eql(defaultLogColumns);
});

// Remove message column, it shows Document since nothing is selected
await PageObjects.unifiedFieldList.clickFieldListItemRemove('message');
await retry.try(async () => {
expect(await PageObjects.discover.getColumnHeaders()).to.eql(['@timestamp', 'Document']);
});

// Switch to other dataset and verify columns are restored
await PageObjects.discoverLogExplorer.openDatasetSelector();
const button = await PageObjects.discoverLogExplorer.getUnmanagedDatasetsButton();
await button.click();

await retry.try(async () => {
const menuEntries = await PageObjects.discoverLogExplorer.getCurrentPanelEntries();
menuEntries[0].click();
});

await retry.try(async () => {
expect(await PageObjects.discover.getColumnHeaders()).to.eql(defaultLogColumns);
});
});

it('should keep the current table columns selection if exists', async () => {
await PageObjects.common.navigateToApp('discover', {
hash: '/p/log-explorer?_a=(columns:!(message,data_stream.namespace))',
});

await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage();

await retry.try(async () => {
expect(await PageObjects.discover.getColumnHeaders()).to.eql([
...defaultLogColumns,
'data_stream.namespace',
]);
});

await PageObjects.discoverLogExplorer.openDatasetSelector();
const button = await PageObjects.discoverLogExplorer.getUnmanagedDatasetsButton();
await button.click();

await retry.try(async () => {
const menuEntries = await PageObjects.discoverLogExplorer.getCurrentPanelEntries();
menuEntries[0].click();
});

await retry.try(async () => {
expect(await PageObjects.discover.getColumnHeaders()).to.eql([
...defaultLogColumns,
'data_stream.namespace',
]);
});
});
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ const expectedUncategorized = ['logs-gaming-*', 'logs-manufacturing-*', 'logs-re
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const browser = getService('browser');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const logger = getService('log');
const retry = getService('retry');
const supertest = getService('supertest');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';

const defaultLogColumns = ['@timestamp', 'message'];

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const retry = getService('retry');
const PageObjects = getPageObjects(['common', 'discover', 'discoverLogExplorer']);

describe('Columns selection initialization and update', () => {
before(async () => {
await esArchiver.load(
'x-pack/test/functional/es_archives/discover_log_explorer/data_streams'
);
});

after(async () => {
await esArchiver.unload(
'x-pack/test/functional/es_archives/discover_log_explorer/data_streams'
);
});

describe('when the log explorer profile loads', () => {
it("should initialize the table columns to logs' default selection", async () => {
await PageObjects.common.navigateToApp('discover', { hash: '/p/log-explorer' });

await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage();

await retry.try(async () => {
expect(await PageObjects.discover.getColumnHeaders()).to.eql(defaultLogColumns);
});
});

it('should restore the table columns from the URL state if exists', async () => {
await PageObjects.common.navigateToApp('discover', {
hash: '/p/log-explorer?_a=(columns:!(message,data_stream.namespace))',
});

await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage();

await retry.try(async () => {
expect(await PageObjects.discover.getColumnHeaders()).to.eql([
...defaultLogColumns,
'data_stream.namespace',
]);
});
});
});
});
}
Loading

0 comments on commit 1a8bfff

Please sign in to comment.