Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover 2.0 Testing] TestId-69: Filtering #9047

Open
wants to merge 32 commits into
base: cypress-unification
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dfd1962
Add utils to select a data source.
ArgusLi Dec 3, 2024
de6870d
Add support for different languages when creating dataset. Filter Out…
ArgusLi Dec 4, 2024
79ad0e2
Mitigate the incorrect layout of Discover due to a race condition bet…
AMoo-Miki Nov 26, 2024
7f8889a
[Workspace] feat: optimize recent items and filter out items whose wo…
raintygao Nov 27, 2024
ba397e6
[Auto Suggest] SQL Syntax Highlighting fix (#8951)
paulstn Nov 27, 2024
851e615
Bump `@opensearch-project/opensearch` from 2.9.0 to 2.13.0 (#8886)
AMoo-Miki Nov 27, 2024
d26248c
[workspace]fix: Change some of the http link in settings page to http…
Qxisylolo Nov 28, 2024
0c8102c
[Workspace]Support search dev tools by its category name (#8920)
Hailong-am Nov 28, 2024
f4eb1cf
[Workspace] Isolate objects based on workspace when calling get/bulkG…
yubonluo Dec 2, 2024
0fa9db8
[Discover] Fix Initialization if No Saved Query (#8930)
sejli Dec 3, 2024
678392b
[Workspace][Bug] Check if workspaces exists when creating saved objec…
yubonluo Dec 3, 2024
67c3c05
[Discover] fix PPL to not throw error if aggregation query fails (#8992)
joshuali925 Dec 3, 2024
3dc82ba
Reformat to match OSD-functional-tests.
ArgusLi Dec 4, 2024
1da2863
Upgrade Cypress to v12 (#8995)
d-rowe Dec 3, 2024
a727acb
[Query enhancements] use status 503 if search strategy throws 500 (#8…
joshuali925 Dec 3, 2024
788d2c7
Revert "[augmenter] do not support datasources with no version (#8915…
ohltyler Dec 4, 2024
5024678
Complete test suite filter actions in table field.
ArgusLi Dec 5, 2024
02534c3
Fix filter_label.test.tsx failing due to added data-test-subj
ArgusLi Dec 5, 2024
77e69b5
[Workspace] Clear the attribute of error objects (#9003)
yubonluo Dec 5, 2024
4d096c4
bump `url` to 0.11.4 (#8611)
joshuali925 Dec 5, 2024
d0d5665
Address comments.
ArgusLi Dec 5, 2024
5e9ab73
[Discover] use roundUp when converting timestamp for PPL (#8935)
joshuali925 Dec 5, 2024
7d1c48c
Reformat to use POM.
ArgusLi Dec 5, 2024
4d40309
Add support for expanded row filters.
ArgusLi Dec 10, 2024
a4ec7c2
Change constants to discussed constants.
ArgusLi Dec 10, 2024
998b496
Refactor to use absolute dates, move the constants to the spec and us…
ArgusLi Dec 10, 2024
28d9b41
Fix Buttons not detecting if disabled.
ArgusLi Dec 10, 2024
825d88a
Add support for expanded table toggleColumnButton Checks.
ArgusLi Dec 11, 2024
444dbbe
Add Exists Filter functionality.
ArgusLi Dec 11, 2024
3a5166a
Remove conflicting Cypress config file.
ArgusLi Dec 11, 2024
d694a24
Merge branch 'cypress-unification' into testid-69-filtering-suite-exp…
ArgusLi Dec 12, 2024
e48a294
Reorganize tests within spec to reduce code duplication. Make small c…
ArgusLi Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/8611.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Bump url to 0.11.4 ([#8611](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8611))
2 changes: 2 additions & 0 deletions changelogs/fragments/8739.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- [Workspace] [Bug] Check if workspaces exists when creating saved objects. ([#8739](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8739))
2 changes: 2 additions & 0 deletions changelogs/fragments/8886.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chore:
- Bump `@opensearch-project/opensearch` from 2.9.0 to 2.13.0 ([#8886](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8886))
2 changes: 2 additions & 0 deletions changelogs/fragments/8888.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
refactor:
- [Workspace] Isolate objects based on workspace when calling get/bulkGet ([#8888](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8888))
2 changes: 2 additions & 0 deletions changelogs/fragments/8900.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Optimize recent items and filter out items whose workspace is deleted ([#8900](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8900))
2 changes: 0 additions & 2 deletions changelogs/fragments/8915.yml

This file was deleted.

2 changes: 2 additions & 0 deletions changelogs/fragments/8919.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Change some of the http link in settings page to https link ([#8919](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8919))
2 changes: 2 additions & 0 deletions changelogs/fragments/8920.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [workspace]support search dev tools by its category name ([#8920](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8920))
2 changes: 2 additions & 0 deletions changelogs/fragments/8930.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Update saved search initialization logic to use current query instead of default query ([#8930](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8930))
2 changes: 2 additions & 0 deletions changelogs/fragments/8935.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Use roundUp when converting timestamp for PPL ([#8935](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8935))
2 changes: 2 additions & 0 deletions changelogs/fragments/8951.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- SQL syntax highlighting double quotes ([#8951](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8951))
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = defineConfig({
responseTimeout: 60000,
viewportWidth: 2000,
viewportHeight: 1320,
retries: 2,
env: {
openSearchUrl: 'http://localhost:9200',
SECURITY_ENABLED: false,
Expand All @@ -27,6 +28,7 @@ module.exports = defineConfig({
},
e2e: {
baseUrl: 'http://localhost:5601',
supportFile: 'cypress/support/e2e.{js,jsx,ts,tsx}',
specPattern: 'cypress/integration/**/*_spec.{js,jsx,ts,tsx}',
testIsolation: false,
setupNodeEvents,
Expand Down
10 changes: 10 additions & 0 deletions cypress/integration/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export const INDEX_CLUSTER_NAME = 'data-logs-1';
export const INDEX_NAME = 'data_logs_small_time_1';
export const INDEX_PATTERN_NAME = 'data-logs-1::data_logs_small_time_1*';
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';
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { DataExplorerPage } from '../../utils/dashboards/data_explorer/data_explorer_page.po';
import {
INDEX_CLUSTER_NAME,
INDEX_NAME,
INDEX_PATTERN_NAME,
SEARCH_ABSOLUTE_START_DATE,
SEARCH_ABSOLUTE_END_DATE,
} from '../constants.js';

const miscUtils = new MiscUtils(cy);

function selectDataSet(datasetType, language) {
switch (datasetType) {
case 'index':
DataExplorerPage.selectIndexDataset(INDEX_CLUSTER_NAME, INDEX_NAME, language);
break;
case 'index_pattern':
DataExplorerPage.selectIndexPatternDataset(INDEX_PATTERN_NAME, language);
if (language !== 'OpenSearch SQL') {
cy.setSearchAbsoluteDateRange(SEARCH_ABSOLUTE_START_DATE, SEARCH_ABSOLUTE_END_DATE);
}
break;
}
}

function checkTableFieldFilterActions(datasetType, language, isEnabled) {
selectDataSet(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);

if (isEnabled) {
DataExplorerPage.checkDocTableFirstFieldFilterForButtonFiltersCorrectField();
DataExplorerPage.checkDocTableFirstFieldFilterOutButtonFiltersCorrectField();
}
}

function checkExpandedTableFilterActions(datasetType, language, isEnabled) {
selectDataSet(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(
isEnabled
);
DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior();

if (isEnabled) {
DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForButtonFiltersCorrectField();
DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterOutButtonFiltersCorrectField();
DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowExistsFilterButtonFiltersCorrectField();
}
}

describe('filter for value spec', () => {
beforeEach(() => {
cy.localLogin(Cypress.env('username'), Cypress.env('password'));
miscUtils.visitPage('app/data-explorer/discover');
cy.getNewSearchButton().click();
});
describe('filter actions in table field', () => {
describe('index pattern dataset', () => {
// filter actions should exist for DQL
it('DQL', () => {
checkTableFieldFilterActions('index_pattern', 'DQL', true);
});
// filter actions should exist for Lucene
it('Lucene', () => {
checkTableFieldFilterActions('index_pattern', 'Lucene', true);
});
// filter actions should not exist for SQL
it('SQL', () => {
checkTableFieldFilterActions('index_pattern', 'OpenSearch SQL', false);
});
// filter actions should not exist for PPL
it('PPL', () => {
checkTableFieldFilterActions('index_pattern', 'PPL', false);
});
});
describe('index dataset', () => {
// filter actions should not exist for SQL
it('SQL', () => {
checkTableFieldFilterActions('index', 'OpenSearch SQL', false);
});
// filter actions should not exist for PPL
it('PPL', () => {
checkTableFieldFilterActions('index', 'PPL', false);
});
});
});

describe('filter actions in expanded table', () => {
describe('index pattern dataset', () => {
// filter actions should exist for DQL
it('DQL', () => {
checkExpandedTableFilterActions('index_pattern', 'DQL', true);
});
// filter actions should exist for Lucene
it('Lucene', () => {
checkExpandedTableFilterActions('index_pattern', 'Lucene', true);
});
// filter actions should not exist for SQL
it('SQL', () => {
checkExpandedTableFilterActions('index_pattern', 'OpenSearch SQL', false);
});
// filter actions should not exist for PPL
it('PPL', () => {
checkExpandedTableFilterActions('index_pattern', 'PPL', false);
});
});
describe('index dataset', () => {
// filter actions should not exist for SQL
it('SQL', () => {
checkExpandedTableFilterActions('index', 'OpenSearch SQL', false);
});
// filter actions should not exist for PPL
it('PPL', () => {
checkExpandedTableFilterActions('index', 'OpenSearch SQL', false);
});
});
});
});
15 changes: 14 additions & 1 deletion cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,17 @@
* SPDX-License-Identifier: Apache-2.0
*/

import '../utils/commands';
import '../utils/commands.js';
import '../utils/dashboards/data_explorer/commands.js';

// Alternatively you can use CommonJS syntax:
// require('./commands')

const scopedHistoryNavigationError =

Check failure on line 12 in cypress/support/e2e.js

View workflow job for this annotation

GitHub Actions / Lint and validate

Delete `⏎·`
/^[^(ScopedHistory instance has fell out of navigation scope)]/;
Cypress.on('uncaught:exception', (err) => {
/* returning false here prevents Cypress from failing the test */
if (scopedHistoryNavigationError.test(err.message)) {
return false;
}
});
84 changes: 83 additions & 1 deletion cypress/utils/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,95 @@
* SPDX-License-Identifier: Apache-2.0
*/

// --- Typed commands --
import {
MiscUtils,
LoginPage,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const miscUtils = new MiscUtils(cy);
const loginPage = new LoginPage(cy);

/**
* Get DOM element by data-test-subj id.
*/
Cypress.Commands.add('getElementByTestId', (testId, options = {}) => {
return cy.get(`[data-test-subj="${testId}"]`, options);
});

/**
* Get multiple DOM elements by data-test-subj ids.
*/
Cypress.Commands.add('getElementsByTestIds', (testIds, options = {}) => {
const selectors = [testIds].flat(Infinity).map((testId) => `[data-test-subj="${testId}"]`);
return cy.get(selectors.join(','), options);
});

/**
* Get DOM elements 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.getElementsByTestIdLike('table')
*/
Cypress.Commands.add('getElementsByTestIdLike', (partialTestId, options = {}) => {
return cy.get(`[data-test-subj*="${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: {}
* @example
* // returns all DOM elements that has a data-test-subj including the string 'table'
* cy.findElementsByTestIdLike('table')
*/
Cypress.Commands.add(
'findElementsByTestIdLike',
{ 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.
*/
Cypress.Commands.add(
'findElementByTestId',
{ prevSubject: true },
(subject, testId, options = {}) => {
return cy.wrap(subject).find(`[data-test-subj="${testId}"]`, options);
}
);

/**
* Go to the local instance of OSD's home page and login if needed.
*/
Cypress.Commands.add('localLogin', (username, password) => {
miscUtils.visitPage('/app/home');
cy.url().then(($url) => {
if ($url.includes('login')) {
loginPage.enterUserName(username);
loginPage.enterPassword(password);
loginPage.submit();
}
cy.url().should('contain', '/app/home');
});
});
Loading
Loading