Skip to content

Commit

Permalink
[Data Explorer][Discover][Functional Test] Fix ciGroup7
Browse files Browse the repository at this point in the history
Issue Resolve
#5129

Signed-off-by: Anan Zhuang <ananzh@amazon.com>
  • Loading branch information
ananzh committed Sep 27, 2023
1 parent c283945 commit b9ad527
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 108 deletions.
5 changes: 2 additions & 3 deletions test/functional/apps/context/_discover_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ export default function ({ getService, getPageObjects }) {
});

it('should open the context view with the same columns', async () => {
const data = await dataGrid.getDataGridTableData();

expect(data.columns).to.eql(['', 'Time (@timestamp)', ...TEST_COLUMN_NAMES]);
const data = await dataGrid.getHeaderFields();
expect(data.columns).to.eql(['Time (@timestamp)', ...TEST_COLUMN_NAMES]);
});

it('should open the context view with the filters disabled', async () => {
Expand Down
24 changes: 7 additions & 17 deletions test/functional/apps/management/_index_pattern_results_sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export default function ({ getService, getPageObjects }) {
before(async function () {
// delete .kibana index and then wait for OpenSearch Dashboards to re-create it
await opensearchDashboardsServer.uiSettings.replace({});
await PageObjects.settings.navigateTo();
await PageObjects.settings.createIndexPattern();
});

after(async function () {
return await PageObjects.settings.removeIndexPattern();
});

const columns = [
Expand All @@ -64,14 +70,6 @@ export default function ({ getService, getPageObjects }) {

columns.forEach(function (col) {
describe('sort by heading - ' + col.heading, function indexPatternCreation() {
before(async function () {
await PageObjects.settings.createIndexPattern();
});

after(async function () {
return await PageObjects.settings.removeIndexPattern();
});

it('should sort ascending', async function () {
await PageObjects.settings.sortBy(col.heading);
const rowText = await col.selector();
Expand All @@ -85,17 +83,9 @@ export default function ({ getService, getPageObjects }) {
});
});
});

describe('field list pagination', function () {
const EXPECTED_FIELD_COUNT = 86;

before(async function () {
await PageObjects.settings.createIndexPattern();
});

after(async function () {
return await PageObjects.settings.removeIndexPattern();
});

it('makelogs data should have expected number of fields', async function () {
await retry.try(async function () {
const TabCount = await PageObjects.settings.getFieldsTabCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default function ({ getService, getPageObjects }) {
before(async function () {
// delete .kibana index and then wait for OpenSearch Dashboards to re-create it
await opensearchDashboardsServer.uiSettings.replace({});
await PageObjects.settings.createIndexPattern('logstash-*');
await PageObjects.settings.navigateTo();
await PageObjects.settings.createIndexPattern('logstash-*');
});

after(async function afterAll() {
Expand Down
171 changes: 87 additions & 84 deletions test/functional/apps/management/_scripted_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Sep 17, 2015 @ 06:31:44.000';
const toTime = 'Sep 18, 2015 @ 18:31:44.000';
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('logstash-*');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);

await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName);
Expand All @@ -169,31 +170,31 @@ export default function ({ getService, getPageObjects }) {
});
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\n18');
});
const rowData = await PageObjects.discover.getDataGridTableValues();
expect(rowData[0][0]).to.be('Sep 18, 2015 @ 18:20:57.916');
expect(rowData[0][1]).to.be('18');
});

//add a test to sort numeric scripted field
it('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click(`dataGridHeaderCell-${scriptedPainlessFieldName}`);
await PageObjects.discover.clickTableHeaderListItem(scriptedPainlessFieldName, 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 10:53:14.181\n-1');
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName}`);
await testSubjects.click('dataGridHeaderCell-@timestamp');
await PageObjects.discover.clickTableHeaderListItem('@timestamp', 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 06:32:29.479\n20');
});
const sortedDataByTimeField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByTimeField[0][0]).contain('Sep 17, 2015 @ 10:53:14.181');
expect(sortedDataByTimeField[0][1]).contain('-1');

// click the column sorting button to remove painless field sort
// should sort only by time field
await testSubjects.click('dataGridColumnSortingButton');
await PageObjects.discover.removeSort(`${scriptedPainlessFieldName}`);
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByPainlessField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByPainlessField[0][0]).contain('Sep 17, 2015 @ 06:32:29.479');
expect(sortedDataByPainlessField[0][1]).contain('20');
});

it('should filter by scripted field value in Discover', async function () {
Expand Down Expand Up @@ -278,6 +279,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Sep 17, 2015 @ 06:31:44.000';
const toTime = 'Sep 18, 2015 @ 18:31:44.000';
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('logstash-*');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);

await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
Expand All @@ -286,31 +288,31 @@ export default function ({ getService, getPageObjects }) {
});
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\ngood');
});
const rowData = await PageObjects.discover.getDataGridTableValues();
expect(rowData[0][0]).to.be('Sep 18, 2015 @ 18:20:57.916');
expect(rowData[0][1]).to.be('good');
});

//add a test to sort string scripted field
it('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click(`dataGridHeaderCell-${scriptedPainlessFieldName2}`);
await PageObjects.discover.clickTableHeaderListItem(scriptedPainlessFieldName2, 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 09:48:40.594\nbad');
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
await testSubjects.click('dataGridHeaderCell-@timestamp');
await PageObjects.discover.clickTableHeaderListItem('@timestamp', 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 06:32:29.479\ngood');
});
const sortedDataByTimeField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByTimeField[0][0]).contain('Sep 17, 2015 @ 09:48:40.594');
expect(sortedDataByTimeField[0][1]).contain('bad');

// click the column sorting button to remove painless field sort
// should sort only by time field
await testSubjects.click('dataGridColumnSortingButton');
await PageObjects.discover.removeSort(`${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByPainlessField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByPainlessField[0][0]).contain('Sep 17, 2015 @ 06:32:29.479');
expect(sortedDataByPainlessField[0][1]).contain('good');
});

it('should filter by scripted field value in Discover', async function () {
Expand Down Expand Up @@ -373,6 +375,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Sep 17, 2015 @ 06:31:44.000';
const toTime = 'Sep 18, 2015 @ 18:31:44.000';
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('logstash-*');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);

await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
Expand All @@ -381,10 +384,33 @@ export default function ({ getService, getPageObjects }) {
});
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\ntrue');
});
const rowData = await PageObjects.discover.getDataGridTableValues();
expect(rowData[0][0]).to.be('Sep 18, 2015 @ 18:20:57.916');
expect(rowData[0][1]).to.be('true');
});

// existing bug: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5126 hence the issue is skipped
// TODO: replace updateExpectedResultHere with actual data value once bug is fixed
it.skip('should sort scripted field value in Discover', async function () {
await testSubjects.click(`dataGridHeaderCell-${scriptedPainlessFieldName2}`);
await PageObjects.discover.clickTableHeaderListItem(
scriptedPainlessFieldName2,
'Sort True-False'
);
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.click('dataGridHeaderCell-@timestamp');
await PageObjects.discover.clickTableHeaderListItem('@timestamp', 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByTimeField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByTimeField[0][0]).contain('updateExpectedResultHere');
expect(sortedDataByTimeField[0][1]).contain('true');

await testSubjects.click('dataGridColumnSortingButton');
await PageObjects.discover.removeSort(`${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByPainlessField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByPainlessField[0][0]).contain('updateExpectedResultHere');
expect(sortedDataByPainlessField[0][1]).contain('false');
});

it('should filter by scripted field value in Discover', async function () {
Expand All @@ -399,28 +425,6 @@ export default function ({ getService, getPageObjects }) {
await filterBar.removeAllFilters();
});

//add a test to sort boolean
//existing bug: https://github.com/elastic/kibana/issues/75519 hence the issue is skipped.
it.skip('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('updateExpectedResultHere\ntrue');
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('updateExpectedResultHere\nfalse');
});
});

it('should visualize scripted field in vertical bar chart', async function () {
await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2);
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -469,6 +473,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Sep 17, 2015 @ 19:22:00.000';
const toTime = 'Sep 18, 2015 @ 07:00:00.000';
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('logstash-*');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);

await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
Expand All @@ -477,32 +482,30 @@ export default function ({ getService, getPageObjects }) {
});
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 06:52:55.953\n2015-09-18 07:00');
});
const rowData = await PageObjects.discover.getDataGridTableValues();
expect(rowData[0][0]).to.be('Sep 18, 2015 @ 06:52:55.953');
expect(rowData[0][1]).to.be('2015-09-18 07:00');
});

//add a test to sort date scripted field
//https://github.com/elastic/kibana/issues/75711
// existing bug: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5127 hence the issue is skipped
// TODO: replace updateExpectedResultHere with actual data value once bug is fixed
it.skip('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click(`dataGridHeaderCell-${scriptedPainlessFieldName2}`);
await PageObjects.discover.clickTableHeaderListItem(scriptedPainlessFieldName2, 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('updateExpectedResultHere\n2015-09-18 07:00');
});
await testSubjects.click('dataGridHeaderCell-@timestamp');
await PageObjects.discover.clickTableHeaderListItem('@timestamp', 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByTimeField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByTimeField[0][0]).contain('updateExpectedResultHere');
expect(sortedDataByTimeField[0][1]).contain('2015-09-18 07:00');

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
await testSubjects.click('dataGridColumnSortingButton');
await PageObjects.discover.removeSort(`${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('updateExpectedResultHere\n2015-09-18 07:00');
});
const sortedDataByPainlessField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByPainlessField[0][0]).contain('updateExpectedResultHere');
expect(sortedDataByPainlessField[0][1]).contain('2015-09-18 07:00');
});

it('should filter by scripted field value in Discover', async function () {
Expand Down
3 changes: 1 addition & 2 deletions test/functional/apps/management/_scripted_fields_preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ export default function ({ getService, getPageObjects }) {
describe('scripted fields preview', () => {
before(async function () {
await browser.setWindowSize(1200, 800);
await PageObjects.settings.createIndexPattern();

await PageObjects.settings.navigateTo();
await PageObjects.settings.createIndexPattern();
await PageObjects.settings.clickOpenSearchDashboardsIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
await PageObjects.settings.clickScriptedFieldsTab();
Expand Down
Loading

0 comments on commit b9ad527

Please sign in to comment.