Skip to content

Commit

Permalink
Address comments and fix test after rebasing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArgusLi committed Dec 19, 2024
1 parent 20fd33a commit 32e3246
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

export const DATASOURCE_NAME = 'data-logs-1';
export const INDEX_NAME = 'data_logs_small_time_1';
export const DEFAULT_TIME_INDEX_PATTERN_NAME = 'data_logs_small_time*';
export const DEFAULT_NO_TIME_INDEX_PATTERN_NAME = 'data_logs_small_no_time*';
export const DEFAULT_TIME_INDEX_PATTERN_NAME = 'data_logs_small_time_1*';
export const DEFAULT_NO_TIME_INDEX_PATTERN_NAME = 'data_logs_small_no_time_1*';
export const INDEX_PATTERN_NAME = `${DATASOURCE_NAME}::${DEFAULT_TIME_INDEX_PATTERN_NAME}`;
export const SEARCH_ABSOLUTE_START_DATE = 'Dec 31, 2020 @ 16:00:00.000';
export const SEARCH_ABSOLUTE_END_DATE = 'Dec 31, 2022 @ 14:14:42.801';
export const SEARCH_ABSOLUTE_START_DATE = 'Jan 1, 2020 @ 00:00:00.000';
export const SEARCH_ABSOLUTE_END_DATE = 'Jan 1, 2024 @ 00:00:00.000';
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { DataExplorerPage } from '../../../../../utils/dashboards/data_explorer/data_explorer_page.po.js';
import { DATA_EXPLORER_PAGE_ELEMENTS } from '../../../../../utils/dashboards/data_explorer/elements.js';
import {
DATASOURCE_NAME,
INDEX_NAME,
Expand All @@ -22,40 +23,76 @@ function selectDataSet(datasetType, language) {
break;
case 'index_pattern':
DataExplorerPage.selectIndexPatternDataset(INDEX_PATTERN_NAME, language);
break;
}
}

function setDateRange(datasetType, language) {
switch (datasetType) {
case 'index_pattern':
if (language !== 'OpenSearch SQL') {
cy.setSearchAbsoluteDateRange(SEARCH_ABSOLUTE_START_DATE, SEARCH_ABSOLUTE_END_DATE);
}
break;
}
}

function checkTableFieldFilterActions(datasetType, language, isEnabled) {
function checkTableFieldFilterActions(datasetType, language, shouldExist) {
selectDataSet(datasetType, language);
setDateRange(datasetType, language);

DataExplorerPage.getDiscoverQueryHits().should('not.exist'); // To ensure it waits until a full table is loaded into the DOM, instead of a bug where table only has 1 hit.

DataExplorerPage.checkDocTableFirstFieldFilterForAndOutButton(isEnabled);
DataExplorerPage.verifyDocTableRowFilterForAndOutButton(0, shouldExist);

if (isEnabled) {
DataExplorerPage.checkDocTableFirstFieldFilterForButtonFiltersCorrectField();
DataExplorerPage.checkDocTableFirstFieldFilterOutButtonFiltersCorrectField();
if (shouldExist) {
DataExplorerPage.verifyDocTableFilterAction(
0,
DATA_EXPLORER_PAGE_ELEMENTS.TABLE_FIELD_FILTER_FOR_BUTTON,
'10,000',
'1',
true
);
DataExplorerPage.verifyDocTableFilterAction(
0,
DATA_EXPLORER_PAGE_ELEMENTS.TABLE_FIELD_FILTER_OUT_BUTTON,
'10,000',
'9,999',
false
);
}
}

function checkExpandedTableFilterActions(datasetType, language, isEnabled) {
selectDataSet(datasetType, language);
setDateRange(datasetType, language);

DataExplorerPage.getDiscoverQueryHits().should('not.exist'); // To ensure it waits until a full table is loaded into the DOM, instead of a bug where table only has 1 hit.
DataExplorerPage.toggleDocTableRow(0);
DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons(
DataExplorerPage.verifyDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons(
isEnabled
);
DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior();
DataExplorerPage.verifyDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior();

if (isEnabled) {
DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForButtonFiltersCorrectField();
DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterOutButtonFiltersCorrectField();
DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowExistsFilterButtonFiltersCorrectField();
DataExplorerPage.verifyDocTableFirstExpandedFieldFirstRowFilterForButtonFiltersCorrectField(
0,
0,
'10,000',
'1'
);
DataExplorerPage.verifyDocTableFirstExpandedFieldFirstRowFilterOutButtonFiltersCorrectField(
0,
0,
'10,000',
'9,999'
);
DataExplorerPage.verifyDocTableFirstExpandedFieldFirstRowExistsFilterButtonFiltersCorrectField(
0,
0,
'10,000',
'10,000'
);
}
}

Expand Down
1 change: 1 addition & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import '../utils/commands.js';
import '../utils/dashboards/data_explorer/commands.js';

// Todo: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5476
const scopedHistoryNavigationError = /^[^(ScopedHistory instance has fell out of navigation scope)]/;
Cypress.on('uncaught:exception', (err) => {
/* returning false here prevents Cypress from failing the test */
Expand Down
32 changes: 10 additions & 22 deletions cypress/utils/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Cypress.Commands.add('getElementsByTestIds', (testIds, options = {}) => {

/**
* Get DOM elements with a data-test-subj id containing the testId.
* @param testId data-test-subj value.
* @param options get options. Default: {}
* @param {string} testId data-test-subj value.
* @param {object} options get options. Default: {}
* @example
* // returns all DOM elements that has a data-test-subj including the string 'table'
* cy.getElementsByTestIdLike('table')
Expand All @@ -54,39 +54,27 @@ Cypress.Commands.add('getElementsByTestIdLike', (partialTestId, options = {}) =>
});

/**
* Find DOM elements with a data-test-subj id containing the testId.
* @param testId data-test-subj value.
* @param options get options. Default: {}
* Find element from previous chained element with a data-test-subj id containing the testId.
* @param {string} subject DOM object to find within.
* @param {string} testId data-test-subj value.
* @param {object} options get options. Default: {}
* @example
* // returns all DOM elements that has a data-test-subj including the string 'table'
* cy.findElementsByTestIdLike('table')
*/
Cypress.Commands.add(
'findElementsByTestIdLike',
'findElementByTestIdLike',
{ prevSubject: true },
(subject, partialTestId, options = {}) => {
return cy.wrap(subject).find(`[data-test-subj*="${partialTestId}"]`, options);
}
);

/**
* Find DOM element with a data-test-subj id containing the testId.
* @param testId data-test-subj value.
* @param options get options. Default: {}
* @example
* // returns all DOM elements that has a data-test-subj including the string 'table'
* cy.findElementsByTestIdLike('table')
*/
Cypress.Commands.add(
'findElementByTestId',
{ prevSubject: true },
(subject, partialTestId, options = {}) => {
return cy.wrap(subject).find(`[data-test-subj="${partialTestId}"]`, options);
}
);

/**
* Find element from previous chained element by data-test-subj id.
* @param {string} subject DOM object to find within.
* @param {string} testId data-test-subj value.
* @param {object} options get options. Default: {}
*/
Cypress.Commands.add(
'findElementByTestId',
Expand Down
Loading

0 comments on commit 32e3246

Please sign in to comment.