1
+ import { t } from 'testcafe' ;
1
2
import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database' ;
2
3
import { BrowserPage , CliPage , MyRedisDatabasePage } from '../../../pageObjects' ;
3
4
import {
@@ -19,9 +20,16 @@ const myRedisDatabasePage = new MyRedisDatabasePage();
19
20
const patternModeTooltipText = 'Filter by Key Name or Pattern' ;
20
21
const redisearchModeTooltipText = 'Search by Values of Keys' ;
21
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])' ;
22
24
let keyName = common . generateWord ( 10 ) ;
23
25
let keyNames : string [ ] ;
24
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
+ }
25
33
26
34
fixture `Search capabilities in Browser`
27
35
. meta ( { type : 'critical_path' , rte : rte . standalone } )
46
54
`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"` ,
47
55
`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`
48
56
] ;
49
- const searchPerValue = '(@name:"Hall School") | (@students:[500, 1000])' ;
50
57
51
58
// Create 3 keys and index
52
59
await cliPage . sendCommandsInCli ( commands ) ;
75
82
await t . expect ( await browserPage . isKeyIsDisplayedInTheList ( keyNames [ 2 ] ) ) . ok ( `The second valid key ${ keyNames [ 2 ] } not found` ) ;
76
83
await t . expect ( await browserPage . isKeyIsDisplayedInTheList ( keyNames [ 1 ] ) ) . notOk ( `Invalid key ${ keyNames [ 1 ] } is displayed after search` ) ;
77
84
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
-
95
85
// Verify that user can clear the search
96
86
await t . click ( browserPage . clearFilterButton ) ;
97
87
await t . expect ( await browserPage . isKeyIsDisplayedInTheList ( keyNames [ 1 ] ) ) . ok ( `The key ${ keyNames [ 1 ] } not found` ) ;
105
95
await verifyKeysDisplayedInTheList ( keyNames ) ;
106
96
await t . expect ( await browserPage . isKeyIsDisplayedInTheList ( keyName ) ) . notOk ( 'Key without index displayed after search' ) ;
107
97
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
-
112
98
// Verify that user see the database scanned when he switch to Pattern search mode
113
99
await t . click ( browserPage . patternModeBtn ) ;
114
100
await t . click ( browserPage . browserViewButton ) ;
@@ -208,3 +194,42 @@ test
208
194
await t . click ( browserPage . selectIndexDdn ) ;
209
195
await browserPage . selectIndexByName ( indexName ) ;
210
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