diff --git a/tests/e2e/pageObjects/browser-page.ts b/tests/e2e/pageObjects/browser-page.ts index 7187ff347a..6fb70e51be 100644 --- a/tests/e2e/pageObjects/browser-page.ts +++ b/tests/e2e/pageObjects/browser-page.ts @@ -15,6 +15,7 @@ export class BrowserPage { cssKeyBadge = '[data-testid^=badge-]'; cssKeyTtl = '[data-testid^=ttl-]'; cssKeySize = '[data-testid^=size-]'; + cssRemoveSuggestionItem = '[data-testid^=remove-suggestion-item-]'; //------------------------------------------------------------------------------------------- //DECLARATION OF SELECTORS //*Declare all elements/components of the relevant page. @@ -104,6 +105,8 @@ export class BrowserPage { submitTooltipBtn = Selector('[data-testid=submit-tooltip-btn]'); patternModeBtn = Selector('[data-testid=search-mode-pattern-btn]'); redisearchModeBtn = Selector('[data-testid=search-mode-redisearch-btn]'); + showFilterHistoryBtn = Selector('[data-testid=show-suggestions-btn]'); + clearFilterHistoryBtn = Selector('[data-testid=clear-history-btn]'); //CONTAINERS streamGroupsContainer = Selector('[data-testid=stream-groups-container]'); streamConsumersContainer = Selector('[data-testid=stream-consumers-container]'); @@ -141,6 +144,8 @@ export class BrowserPage { cancelIndexCreationBtn = Selector('[data-testid=create-index-cancel-btn]'); confirmIndexCreationBtn = Selector('[data-testid=create-index-btn]'); resizeTrigger = Selector('[data-testid^=resize-trigger-]'); + filterHistoryOption = Selector('[data-testid^=suggestion-item-]'); + filterHistoryItemText = Selector('[data-testid=suggestion-item-text]'); //TABS streamTabGroups = Selector('[data-testid=stream-tab-Groups]'); streamTabConsumers = Selector('[data-testid=stream-tab-Consumers]'); @@ -1051,6 +1056,13 @@ export class BrowserPage { await t.expect(this.keyListMessage.exists).ok('Database not empty') .expect(this.keysSummary.exists).notOk('Total value is displayed for empty database'); } + + /** + * Clear filter on Browser page + */ + async clearFilter(): Promise { + await t.click(this.clearFilterButton); + } } /** diff --git a/tests/e2e/tests/critical-path/browser/filtering-history.e2e.ts b/tests/e2e/tests/critical-path/browser/filtering-history.e2e.ts new file mode 100644 index 0000000000..ba2df44291 --- /dev/null +++ b/tests/e2e/tests/critical-path/browser/filtering-history.e2e.ts @@ -0,0 +1,69 @@ +import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database'; +import { BrowserPage } from '../../../pageObjects'; +import { + commonUrl, + ossStandaloneBigConfig +} from '../../../helpers/conf'; +import { KeyTypesTexts, rte } from '../../../helpers/constants'; +import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database'; +import { Common } from '../../../helpers/common'; + +const browserPage = new BrowserPage(); +const common = new Common(); + +fixture `Key name filters history` + .meta({ type: 'critical_path', rte: rte.standalone }) + .page(commonUrl) + .beforeEach(async() => { + await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneBigConfig, ossStandaloneBigConfig.databaseName); + }) + .afterEach(async() => { + // Delete database + await deleteStandaloneDatabaseApi(ossStandaloneBigConfig); + }); +test('Recent filters history', async t => { + const keysForSearch = ['device', 'mobile']; + + await browserPage.selectFilterGroupType(KeyTypesTexts.String); + // Verify that user can not see filters per only key type in the history of results + await t.expect(browserPage.showFilterHistoryBtn.exists).notOk('Filter history button displayed for key type search'); + // Search by valid key + await browserPage.searchByKeyName(`${keysForSearch[0]}*`); + await browserPage.clearFilter(); + + // Verify that user can see the history query is automatically run once selected + await t.click(browserPage.showFilterHistoryBtn); + await t.click(browserPage.filterHistoryOption.nth(0)); + for (let i = 0; i < 5; i++) { + // Verify that keys are filtered + await t.expect(browserPage.keyNameInTheList.nth(i).textContent).contains(keysForSearch[0], 'Keys not filtered by key name') + .expect(browserPage.filteringLabel.nth(i).textContent).contains(KeyTypesTexts.String, 'Keys not filtered by key type'); + } + + // Verify that user do not see duplicate history requests + await browserPage.clearFilter(); + await browserPage.selectFilterGroupType(KeyTypesTexts.String); + await browserPage.searchByKeyName(`${keysForSearch[0]}*`); + await t.click(browserPage.showFilterHistoryBtn); + await t.expect(browserPage.filterHistoryItemText.withText(keysForSearch[0]).count).eql(1, 'Filter history requests can be duplicated in list'); + + // Refresh the page + await common.reloadPage(); + // Verify that user can see the list of filters even when reloading page + await t.click(browserPage.showFilterHistoryBtn); + await t.expect(browserPage.filterHistoryItemText.withText(keysForSearch[0]).exists).ok('Filter history requests not saved after reloading page'); + + // Open Tree view to check also there + await t.click(browserPage.treeViewButton); + // Search by 2nd key name + await browserPage.searchByKeyName(`${keysForSearch[1]}*`); + await t.click(browserPage.showFilterHistoryBtn); + // Verify that user can remove saved filter from list by clicking on "X" + await t.hover(browserPage.filterHistoryItemText.withText(keysForSearch[1])); + await t.click(browserPage.filterHistoryOption.withText(keysForSearch[1]).find(browserPage.cssRemoveSuggestionItem)); + await t.expect(browserPage.filterHistoryItemText.withText(keysForSearch[1]).exists).notOk('Filter history request not deleted'); + + // Verify that user can clear the history of requests + await t.click(browserPage.clearFilterHistoryBtn); + await t.expect(browserPage.showFilterHistoryBtn.exists).notOk('Filter history button displayed for key type search'); +}); diff --git a/tests/e2e/tests/critical-path/browser/search-capabilities.e2e.ts b/tests/e2e/tests/critical-path/browser/search-capabilities.e2e.ts index c445b9a4be..46b5113ce7 100644 --- a/tests/e2e/tests/critical-path/browser/search-capabilities.e2e.ts +++ b/tests/e2e/tests/critical-path/browser/search-capabilities.e2e.ts @@ -94,6 +94,12 @@ test await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[2])).ok(`The second valid key ${keyNames[2]} not found`); await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[1])).notOk(`Invalid key ${keyNames[1]} is displayed after search`); + // Verify that user can use filter history for RediSearch query + await t.click(browserPage.showFilterHistoryBtn); + await t.click(browserPage.filterHistoryOption.withText('Hall School')); + await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[0])).ok(`The key ${keyNames[0]} not found`); + await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[1])).notOk(`Invalid key ${keyNames[1]} is displayed after search`); + // Verify that user can clear the search await t.click(browserPage.clearFilterButton); await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[1])).ok(`The key ${keyNames[1]} not found`); diff --git a/tests/e2e/tests/regression/browser/resize-columns.e2e.ts b/tests/e2e/tests/regression/browser/resize-columns.e2e.ts index d4dcf69d9a..00896b72bf 100644 --- a/tests/e2e/tests/regression/browser/resize-columns.e2e.ts +++ b/tests/e2e/tests/regression/browser/resize-columns.e2e.ts @@ -88,8 +88,12 @@ test('Resize of columns in Hash, List, Zset Key details', async t => { await browserPage.openKeyDetails(keys[0].name); await t.expect(field.clientWidth).eql(keys[0].fieldWidthEnd, 'Resize context not saved for key when switching between pages'); + // Apply filter to save it in filter history + await browserPage.searchByKeyName(`${keys[0].name}*`); + // Verify that resize saved when switching between databases await t.click(myRedisDatabasePage.myRedisDBButton); + // Go to 2nd database await myRedisDatabasePage.clickOnDBByName(databasesForAdding[1].databaseName); // Verify that resize saved for specific data type for(const key of keys) { @@ -97,10 +101,16 @@ test('Resize of columns in Hash, List, Zset Key details', async t => { await t.expect(field.clientWidth).eql(key.fieldWidthEnd, `Resize context not saved for ${key.type} key when switching between databases`); } - // Verify that logical db not changed after switching between databases + // Change db index for 2nd database await databaseOverviewPage.changeDbIndex(1); await t.click(myRedisDatabasePage.myRedisDBButton); + // Go back to 1st database await myRedisDatabasePage.clickOnDBByName(databasesForAdding[0].databaseName); + // Verify that user can see the list of filters even when switching between databases + await t.click(browserPage.showFilterHistoryBtn); + await t.expect(browserPage.filterHistoryOption.withText(keys[0].name).exists).ok('Filter history requests not saved after switching between db'); + + // Verify that logical db not changed after switching between databases await t.click(myRedisDatabasePage.myRedisDBButton); await myRedisDatabasePage.clickOnDBByName(databasesForAdding[1].databaseName); await databaseOverviewPage.verifyDbIndexSelected(1);