1
+ import { t } from 'testcafe' ;
1
2
import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database' ;
2
- import { BrowserPage , CliPage } from '../../../pageObjects' ;
3
+ import { BrowserPage , CliPage , MyRedisDatabasePage } from '../../../pageObjects' ;
3
4
import {
4
5
commonUrl ,
5
6
ossStandaloneBigConfig ,
@@ -14,13 +15,21 @@ import { verifyKeysDisplayedInTheList } from '../../../helpers/keys';
14
15
const browserPage = new BrowserPage ( ) ;
15
16
const common = new Common ( ) ;
16
17
const cliPage = new CliPage ( ) ;
18
+ const myRedisDatabasePage = new MyRedisDatabasePage ( ) ;
17
19
18
20
const patternModeTooltipText = 'Filter by Key Name or Pattern' ;
19
21
const redisearchModeTooltipText = 'Search by Values of Keys' ;
20
22
const notSelectedIndexText = 'Select an index and enter a query to search per values of keys.' ;
23
+ const searchPerValue = '(@name:"Hall School") | (@students:[500, 1000])' ;
21
24
let keyName = common . generateWord ( 10 ) ;
22
25
let keyNames : string [ ] ;
23
26
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
+ }
24
33
25
34
fixture `Search capabilities in Browser`
26
35
. meta ( { type : 'critical_path' , rte : rte . standalone } )
68
77
await t . expect ( await browserPage . isKeyIsDisplayedInTheList ( keyNames [ 0 ] ) ) . ok ( `The key ${ keyNames [ 0 ] } not found` ) ;
69
78
await t . expect ( await browserPage . isKeyIsDisplayedInTheList ( keyNames [ 1 ] ) ) . notOk ( `Invalid key ${ keyNames [ 1 ] } is displayed after search` ) ;
70
79
// 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 ) ;
72
81
await t . expect ( await browserPage . isKeyIsDisplayedInTheList ( keyNames [ 0 ] ) ) . ok ( `The first valid key ${ keyNames [ 0 ] } not found` ) ;
73
82
await t . expect ( await browserPage . isKeyIsDisplayedInTheList ( keyNames [ 2 ] ) ) . ok ( `The second valid key ${ keyNames [ 2 ] } not found` ) ;
74
83
await t . expect ( await browserPage . isKeyIsDisplayedInTheList ( keyNames [ 1 ] ) ) . notOk ( `Invalid key ${ keyNames [ 1 ] } is displayed after search` ) ;
@@ -185,3 +194,42 @@ test
185
194
await t . click ( browserPage . selectIndexDdn ) ;
186
195
await browserPage . selectIndexByName ( indexName ) ;
187
196
} ) ;
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