1
1
import * as path from 'path' ;
2
+ import * as fs from 'fs' ;
3
+ import { join as joinPath } from 'path' ;
2
4
import { t } from 'testcafe' ;
3
5
import { ExploreTabs , rte } from '../../../../helpers/constants' ;
4
6
import { DatabaseHelper } from '../../../../helpers/database' ;
5
7
import { BrowserPage , MyRedisDatabasePage , WorkbenchPage } from '../../../../pageObjects' ;
6
- import { commonUrl , ossStandaloneConfig , ossStandaloneRedisearch } from '../../../../helpers/conf' ;
8
+ import { commonUrl , ossStandaloneConfig , ossStandaloneRedisearch , fileDownloadPath } from '../../../../helpers/conf' ;
7
9
import { DatabaseAPIRequests } from '../../../../helpers/api/api-database' ;
8
10
import { Common } from '../../../../helpers/common' ;
9
11
import { deleteAllKeysFromDB , verifyKeysDisplayingInTheList } from '../../../../helpers/keys' ;
12
+ import { DatabasesActions } from '../../../../common-actions/databases-actions' ;
10
13
11
14
const myRedisDatabasePage = new MyRedisDatabasePage ( ) ;
12
15
const workbenchPage = new WorkbenchPage ( ) ;
13
16
const browserPage = new BrowserPage ( ) ;
14
17
const databaseHelper = new DatabaseHelper ( ) ;
15
18
const databaseAPIRequests = new DatabaseAPIRequests ( ) ;
19
+ const databasesActions = new DatabasesActions ( ) ;
16
20
17
21
const zipFolderName = 'customTutorials' ;
18
22
const folderPath = path . join ( '..' , 'test-data' , 'upload-tutorials' , zipFolderName ) ;
@@ -22,6 +26,7 @@ const internalLinkName2 = 'vector-2';
22
26
let tutorialName = `${ zipFolderName } ${ Common . generateWord ( 5 ) } ` ;
23
27
let zipFilePath = path . join ( '..' , 'test-data' , 'upload-tutorials' , `${ tutorialName } .zip` ) ;
24
28
let internalLinkName1 = 'probably-1' ;
29
+ let foundExportedFiles : string [ ] ;
25
30
const verifyCompletedResultText = async ( resultsText : string [ ] ) : Promise < void > => {
26
31
for ( const result of resultsText ) {
27
32
await t . expect ( workbenchPage . Toast . toastBody . textContent ) . contains ( result , 'Bulk upload completed summary not correct' ) ;
168
173
await Common . createZipFromFolder ( folderPath , zipFilePath ) ;
169
174
} )
170
175
. after ( async ( ) => {
176
+ // Delete exported file
177
+ fs . unlinkSync ( joinPath ( fileDownloadPath , foundExportedFiles [ 0 ] ) ) ;
171
178
await Common . deleteFileFromFolder ( zipFilePath ) ;
172
179
await deleteAllKeysFromDB ( ossStandaloneRedisearch . host , ossStandaloneRedisearch . port ) ;
173
180
// Clear and delete database
184
191
const invalidPathes = [ 'Invalid relative' , 'Invalid absolute' ] ;
185
192
const keyNames = [ 'hashkey1' , 'listkey1' , 'setkey1' , 'zsetkey1' , 'stringkey1' , 'jsonkey1' , 'streamkey1' , 'graphkey1' , 'tskey1' , 'stringkey1test' ] ;
186
193
internalLinkName1 = 'probably-1' ;
194
+ const fileStarts = 'bulk' ;
187
195
188
196
// Upload custom tutorial
189
197
await workbenchPage . InsightsPanel . togglePanel ( true ) ;
@@ -201,7 +209,14 @@ test
201
209
await t . expect ( tutorials . scrolledEnablementArea . visible ) . ok ( 'Enablement area is not visible after clicked' ) ;
202
210
203
211
// Verify that user can bulk upload data by relative path
212
+
213
+ // Remember the number of files in Temp
214
+ const numberOfDownloadFiles = await databasesActions . getFileCount ( fileDownloadPath , fileStarts ) ;
204
215
await t . click ( tutorials . uploadDataBulkBtn . withText ( 'Upload relative' ) ) ;
216
+ await t . click ( tutorials . downloadFileBtn ) ;
217
+ foundExportedFiles = await databasesActions . findFilesByFileStarts ( fileDownloadPath , fileStarts ) ;
218
+ await t . expect ( await databasesActions . getFileCount ( fileDownloadPath , fileStarts ) ) . gt ( numberOfDownloadFiles , 'The Profiler logs not saved' , { timeout : 5000 } ) ;
219
+
205
220
await t . click ( tutorials . uploadDataBulkApplyBtn ) ;
206
221
// Verify that user can see the summary when the command execution is completed
207
222
await verifyCompletedResultText ( allKeysResults ) ;
227
242
await browserPage . searchByKeyName ( '*key1*' ) ;
228
243
await verifyKeysDisplayingInTheList ( keyNames , true ) ;
229
244
} ) ;
245
+
0 commit comments