Skip to content

Commit 08d2429

Browse files
authored
Merge pull request #1379 from RedisInsight/e2e/feature/RI-3714_Redisearch-context
[E2E] Save context for Search capability
2 parents 1c4510b + c68b0b3 commit 08d2429

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

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

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { t } from 'testcafe';
12
import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database';
2-
import { BrowserPage, CliPage } from '../../../pageObjects';
3+
import { BrowserPage, CliPage, MyRedisDatabasePage } from '../../../pageObjects';
34
import {
45
commonUrl,
56
ossStandaloneBigConfig,
@@ -14,13 +15,21 @@ import { verifyKeysDisplayedInTheList } from '../../../helpers/keys';
1415
const browserPage = new BrowserPage();
1516
const common = new Common();
1617
const cliPage = new CliPage();
18+
const myRedisDatabasePage = new MyRedisDatabasePage();
1719

1820
const patternModeTooltipText = 'Filter by Key Name or Pattern';
1921
const redisearchModeTooltipText = 'Search by Values of Keys';
2022
const notSelectedIndexText = 'Select an index and enter a query to search per values of keys.';
23+
const searchPerValue = '(@name:"Hall School") | (@students:[500, 1000])';
2124
let keyName = common.generateWord(10);
2225
let keyNames: string[];
2326
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+
}
2433

2534
fixture `Search capabilities in Browser`
2635
.meta({ type: 'critical_path', rte: rte.standalone })
@@ -68,7 +77,7 @@ test
6877
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[0])).ok(`The key ${keyNames[0]} not found`);
6978
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[1])).notOk(`Invalid key ${keyNames[1]} is displayed after search`);
7079
// Verify that user can search by index plus multiple key values
71-
await browserPage.searchByKeyName('(@name:"Hall School") | (@students:[500, 1000])');
80+
await browserPage.searchByKeyName(searchPerValue);
7281
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[0])).ok(`The first valid key ${keyNames[0]} not found`);
7382
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[2])).ok(`The second valid key ${keyNames[2]} not found`);
7483
await t.expect(await browserPage.isKeyIsDisplayedInTheList(keyNames[1])).notOk(`Invalid key ${keyNames[1]} is displayed after search`);
@@ -185,3 +194,42 @@ test
185194
await t.click(browserPage.selectIndexDdn);
186195
await browserPage.selectIndexByName(indexName);
187196
});
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)