Skip to content

Commit c68b0b3

Browse files
committed
updates
1 parent a74c4ce commit c68b0b3

File tree

1 file changed

+47
-22
lines changed

1 file changed

+47
-22
lines changed

tests/e2e/tests/critical-path/browser/search-capabilities.e2e.ts

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { t } from 'testcafe';
12
import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database';
23
import { BrowserPage, CliPage, MyRedisDatabasePage } from '../../../pageObjects';
34
import {
@@ -19,9 +20,16 @@ const myRedisDatabasePage = new MyRedisDatabasePage();
1920
const patternModeTooltipText = 'Filter by Key Name or Pattern';
2021
const redisearchModeTooltipText = 'Search by Values of Keys';
2122
const notSelectedIndexText = 'Select an index and enter a query to search per values of keys.';
23+
const searchPerValue = '(@name:"Hall School") | (@students:[500, 1000])';
2224
let keyName = common.generateWord(10);
2325
let keyNames: string[];
2426
let indexName = common.generateWord(5);
27+
async function verifyContext(): Promise<void> {
28+
await t
29+
.expect(browserPage.selectIndexDdn.withText(indexName).exists).ok('Index selection not saved')
30+
.expect(browserPage.filterByPatterSearchInput.value).eql(searchPerValue, 'Search per Value not saved in input')
31+
.expect(browserPage.keyNameFormDetails.withExactText(keyName).exists).ok('Key details not opened');
32+
}
2533

2634
fixture `Search capabilities in Browser`
2735
.meta({ type: 'critical_path', rte: rte.standalone })
@@ -46,7 +54,6 @@ test
4654
`HSET ${keyNames[2]} "name" "Gillford School" "description" "Gillford School is a centre" "class" "private" "type" "democratic; waldorf" "address_city" "Goudhurst" "address_street" "Goudhurst" "students" 721 "location" "51.112685, 0.451076"`,
4755
`FT.CREATE ${indexName} ON HASH PREFIX 1 "${keyName}:" SCHEMA name TEXT NOSTEM description TEXT class TAG type TAG SEPARATOR ";" address_city AS city TAG address_street AS address TEXT NOSTEM students NUMERIC SORTABLE location GEO`
4856
];
49-
const searchPerValue = '(@name:"Hall School") | (@students:[500, 1000])';
5057

5158
// Create 3 keys and index
5259
await cliPage.sendCommandsInCli(commands);
@@ -75,23 +82,6 @@ test
7582
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[2])).ok(`The second valid key ${keyNames[2]} not found`);
7683
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[1])).notOk(`Invalid key ${keyNames[1]} is displayed after search`);
7784

78-
// Verify that Redisearch context (inputs, key selected, scroll, key details) saved after switching between pages
79-
await t
80-
.click(myRedisDatabasePage.workbenchButton)
81-
.click(myRedisDatabasePage.browserButton)
82-
.expect(browserPage.selectIndexDdn.withText(indexName).exists).ok('Index selection not saved')
83-
.expect(browserPage.filterByPatterSearchInput.value).eql(searchPerValue, 'Search per Value not saved in input');
84-
85-
// Verify that Redisearch context saved when switching between browser/tree view
86-
await t
87-
.click(browserPage.treeViewButton)
88-
.expect(browserPage.selectIndexDdn.withText(indexName).exists).ok('Index selection not saved')
89-
.expect(browserPage.filterByPatterSearchInput.value).eql(searchPerValue, 'Search per Value not saved in input');
90-
await t
91-
.click(browserPage.browserViewButton)
92-
.expect(browserPage.selectIndexDdn.withText(indexName).exists).ok('Index selection not saved')
93-
.expect(browserPage.filterByPatterSearchInput.value).eql(searchPerValue, 'Search per Value not saved in input');
94-
9585
// Verify that user can clear the search
9686
await t.click(browserPage.clearFilterButton);
9787
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[1])).ok(`The key ${keyNames[1]} not found`);
@@ -105,10 +95,6 @@ test
10595
await verifyKeysDisplayedInTheList(keyNames);
10696
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyName)).notOk('Key without index displayed after search');
10797

108-
// Verify that Search control opened after reloading page
109-
await common.reloadPage();
110-
await t.expect(browserPage.keyListTable.textContent).contains(notSelectedIndexText, 'Search by Values of Keys section not opened');
111-
11298
// Verify that user see the database scanned when he switch to Pattern search mode
11399
await t.click(browserPage.patternModeBtn);
114100
await t.click(browserPage.browserViewButton);
@@ -208,3 +194,42 @@ test
208194
await t.click(browserPage.selectIndexDdn);
209195
await browserPage.selectIndexByName(indexName);
210196
});
197+
test
198+
.before(async() => {
199+
await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName);
200+
})
201+
.after(async() => {
202+
// Clear and delete database
203+
await cliPage.sendCommandInCli(`FT.DROPINDEX ${indexName}`);
204+
await deleteStandaloneDatabaseApi(ossStandaloneConfig);
205+
})('Context for RediSearch capability', async t => {
206+
keyName = common.generateWord(10);
207+
indexName = `idx:${keyName}`;
208+
const commands = [
209+
`HSET ${keyName} "name" "Hall School" "description" " Spanning 10 states" "class" "independent" "type" "traditional" "address_city" "London" "address_street" "Manor Street" "students" 342 "location" "51.445417, -0.258352"`,
210+
`FT.CREATE ${indexName} ON HASH PREFIX 1 "${keyName}" SCHEMA name TEXT NOSTEM description TEXT class TAG type TAG SEPARATOR ";" address_city AS city TAG address_street AS address TEXT NOSTEM students NUMERIC SORTABLE location GEO`
211+
];
212+
213+
await cliPage.sendCommandsInCli(commands);
214+
await t.click(browserPage.redisearchModeBtn);
215+
await browserPage.selectIndexByName(indexName);
216+
await browserPage.searchByKeyName(searchPerValue);
217+
// Select key
218+
await t.click(await browserPage.getKeySelectorByName(keyName));
219+
220+
// Verify that Redisearch context (inputs, key selected, scroll, key details) saved after switching between pages
221+
await t
222+
.click(myRedisDatabasePage.workbenchButton)
223+
.click(myRedisDatabasePage.browserButton);
224+
await verifyContext();
225+
226+
// Verify that Redisearch context saved when switching between browser/tree view
227+
await t.click(browserPage.treeViewButton);
228+
await verifyContext();
229+
await t.click(browserPage.browserViewButton);
230+
await verifyContext();
231+
232+
// Verify that Search control opened after reloading page
233+
await common.reloadPage();
234+
await t.expect(browserPage.keyListTable.textContent).contains(notSelectedIndexText, 'Search by Values of Keys section not opened');
235+
});

0 commit comments

Comments
 (0)