1
1
import * as path from 'path' ;
2
- import { ClientFunction } from 'testcafe' ;
3
2
import { rte } from '../../../helpers/constants' ;
4
3
import { AddRedisDatabasePage , BrowserPage , MyRedisDatabasePage } from '../../../pageObjects' ;
5
4
import { commonUrl } from '../../../helpers/conf' ;
6
5
import { acceptLicenseTerms , clickOnEditDatabaseByName } from '../../../helpers/database' ;
7
6
import { deleteStandaloneDatabasesByNamesApi } from '../../../helpers/api/api-database' ;
8
7
import { DatabasesActions } from '../../../common-actions/databases-actions' ;
8
+ import { Common } from '../../../helpers/common' ;
9
9
10
10
const browserPage = new BrowserPage ( ) ;
11
11
const myRedisDatabasePage = new MyRedisDatabasePage ( ) ;
12
12
const databasesActions = new DatabasesActions ( ) ;
13
13
const addRedisDatabasePage = new AddRedisDatabasePage ( ) ;
14
+ const common = new Common ( ) ;
14
15
15
- const racompassValidJson = 'racompass-valid.json' ;
16
- const racompassInvalidJson = 'racompass-invalid.json' ;
17
- const rdmFullJson = 'rdm-full.json' ;
18
- const rdmCertsJson = 'rdm-certificates.json' ;
19
- const ardmValidAno = 'ardm-valid.ano' ;
20
- const racompFullSSHJson = 'racompFullSSH.json' ;
21
- const racompassInvalidJsonPath = path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , racompassInvalidJson ) ;
16
+ const fileNames = {
17
+ racompassValidJson : 'racompass-valid.json' ,
18
+ racompassInvalidJson : 'racompass-invalid.json' ,
19
+ rdmFullJson : 'rdm-full.json' ,
20
+ rdmCertsJson : 'rdm-certificates.json' ,
21
+ ardmValidAno : 'ardm-valid.ano' ,
22
+ racompFullSSHJson : 'racompFullSSH.json'
23
+ } ;
24
+ const filePathes = {
25
+ ardmValidPath : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , fileNames . ardmValidAno ) ,
26
+ racompassInvalidJsonPath : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , fileNames . racompassInvalidJson ) ,
27
+ rdmPath : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , fileNames . rdmFullJson ) ,
28
+ rdmCertsPath : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , fileNames . rdmCertsJson ) ,
29
+ racompassValidJson : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , fileNames . racompassValidJson ) ,
30
+ racompassSshPath : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , fileNames . racompFullSSHJson )
31
+ }
32
+
33
+ const rdmListOfDB = databasesActions . parseDbJsonByPath ( path . join ( 'test-data' , 'import-databases' , fileNames . rdmFullJson ) ) ;
34
+ const rdmListOfCertsDB = databasesActions . parseDbJsonByPath ( path . join ( 'test-data' , 'import-databases' , fileNames . rdmCertsJson ) ) ;
35
+ const racompListOfSSHDB = databasesActions . parseDbJsonByPath ( path . join ( 'test-data' , 'import-databases' , fileNames . racompFullSSHJson ) ) ;
36
+ const rdmResults = {
37
+ successNames : myRedisDatabasePage . getDatabaseNamesFromListByResult ( rdmListOfDB , 'success' ) ,
38
+ partialNames : myRedisDatabasePage . getDatabaseNamesFromListByResult ( rdmListOfDB , 'partial' ) ,
39
+ failedNames : myRedisDatabasePage . getDatabaseNamesFromListByResult ( rdmListOfDB , 'failed' )
40
+ } ;
41
+ const racompassSshResults = {
42
+ successNames : myRedisDatabasePage . getDatabaseNamesFromListByResult ( racompListOfSSHDB , 'success' ) ,
43
+ partialNames : myRedisDatabasePage . getDatabaseNamesFromListByResult ( racompListOfSSHDB , 'partial' ) ,
44
+ failedNames : myRedisDatabasePage . getDatabaseNamesFromListByResult ( racompListOfSSHDB , 'failed' )
22
45
23
- const rdmListOfDB = databasesActions . parseDbJsonByPath ( path . join ( 'test-data' , 'import-databases' , rdmFullJson ) ) ;
24
- const rdmCertsListOfDB = databasesActions . parseDbJsonByPath ( path . join ( 'test-data' , 'import-databases' , rdmCertsJson ) ) ;
25
- const rdmSuccessNames = myRedisDatabasePage . getDatabaseNamesFromListByResult ( rdmListOfDB , 'success' ) ;
26
- const rdmPartialNames = myRedisDatabasePage . getDatabaseNamesFromListByResult ( rdmListOfDB , 'partial' ) ;
27
- const rdmFailedNames = myRedisDatabasePage . getDatabaseNamesFromListByResult ( rdmListOfDB , 'failed' ) ;
28
- const rdmCertsNames = myRedisDatabasePage . getDatabaseNamesFromListByResult ( rdmCertsListOfDB , 'success' ) ;
46
+ } ;
47
+ const rdmCertsNames = myRedisDatabasePage . getDatabaseNamesFromListByResult ( rdmListOfCertsDB , 'success' ) ;
29
48
30
- const racompListOfSSHDB = databasesActions . parseDbJsonByPath ( path . join ( 'test-data' , 'import-databases' , racompFullSSHJson ) ) ;
31
- const racompSSHSuccessNames = myRedisDatabasePage . getDatabaseNamesFromListByResult ( racompListOfSSHDB , 'success' ) ;
32
- const racompSSHPartialNames = myRedisDatabasePage . getDatabaseNamesFromListByResult ( racompListOfSSHDB , 'partial' ) ;
33
- const racompSSHFailedNames = myRedisDatabasePage . getDatabaseNamesFromListByResult ( racompListOfSSHDB , 'failed' ) ;
34
- const importedSSHdbNames = [ ...racompSSHSuccessNames , ...racompSSHPartialNames ] ;
35
49
const rdmData = {
36
50
type : 'rdm' ,
37
- path : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , rdmFullJson ) ,
51
+ path : filePathes . rdmPath ,
52
+ sshPath : filePathes . rdmCertsPath ,
38
53
connectionType : 'Cluster' ,
39
- successNumber : rdmSuccessNames . length ,
40
- partialNumber : rdmPartialNames . length ,
41
- failedNumber : rdmFailedNames . length ,
42
- dbImportedNames : [ ...rdmSuccessNames , ...rdmPartialNames ]
43
- } ;
44
- const rdmCertsData = {
45
- type : 'rdm' ,
46
- path : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , rdmCertsJson )
54
+ successNumber : rdmResults . successNames . length ,
55
+ partialNumber : rdmResults . partialNames . length ,
56
+ failedNumber : rdmResults . failedNames . length ,
57
+ dbImportedNames : [ ...rdmResults . successNames , ...rdmResults . partialNames ]
47
58
} ;
48
59
const racompSSHData = {
49
60
type : 'racompass' ,
50
- path : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , racompFullSSHJson ) ,
51
- successNumber : racompSSHSuccessNames . length ,
52
- partialNumber : racompSSHPartialNames . length ,
53
- failedNumber : racompSSHFailedNames . length
61
+ path : filePathes . racompassSshPath ,
62
+ successNumber : racompassSshResults . successNames . length ,
63
+ partialNumber : racompassSshResults . partialNames . length ,
64
+ failedNumber : racompassSshResults . failedNames . length ,
65
+ importedSSHdbNames : [ ...racompassSshResults . successNames , ...racompassSshResults . partialNames ]
54
66
} ;
55
67
const dbData = [
56
68
{
57
69
type : 'racompass' ,
58
- path : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , racompassValidJson ) ,
70
+ path : filePathes . racompassValidJson ,
59
71
dbNames : [ 'racompassCluster' , 'racompassDbWithIndex:8100 [1]' ]
60
72
} ,
61
73
{
62
74
type : 'ardm' ,
63
- path : path . join ( '..' , '..' , '..' , 'test-data' , 'import-databases' , ardmValidAno ) ,
75
+ path : filePathes . ardmValidPath ,
64
76
dbNames : [ 'ardmNoName:12001' , 'ardmWithPassAndUsername' , 'ardmSentinel' ]
65
77
}
66
78
] ;
@@ -70,10 +82,8 @@ const databasesToDelete = [
70
82
...dbData [ 1 ] . dbNames
71
83
] ;
72
84
const findImportedRdmDbNameInList = async ( dbName : string ) : Promise < string > => rdmData . dbImportedNames . find ( item => item === dbName ) ! ;
73
- // Returns the URL of the current web page
74
- const getPageUrl = ClientFunction ( ( ) => window . location . href ) ;
75
85
76
- fixture `Import databases`
86
+ fixture . only `Import databases`
77
87
. meta ( { type : 'critical_path' , rte : rte . none } )
78
88
. page ( commonUrl )
79
89
. beforeEach ( async ( ) => {
@@ -83,7 +93,7 @@ test('Connection import modal window', async t => {
83
93
const tooltipText = 'Import Database Connections' ;
84
94
const defaultText = 'Select or drag and drop a file' ;
85
95
const parseFailedMsg = 'Failed to add database connections' ;
86
- const parseFailedMsg2 = `Unable to parse ${ racompassInvalidJson } ` ;
96
+ const parseFailedMsg2 = `Unable to parse ${ fileNames . racompassInvalidJson } ` ;
87
97
88
98
// Verify that user can see the “Import Database Connections” tooltip
89
99
await t . expect ( myRedisDatabasePage . importDatabasesBtn . visible ) . ok ( 'The import databases button not displayed' ) ;
@@ -98,7 +108,7 @@ test('Connection import modal window', async t => {
98
108
99
109
// Verify that user see the message when parse error appears
100
110
await t
101
- . setFilesToUpload ( myRedisDatabasePage . importDatabaseInput , [ racompassInvalidJsonPath ] )
111
+ . setFilesToUpload ( myRedisDatabasePage . importDatabaseInput , [ filePathes . racompassInvalidJsonPath ] )
102
112
. click ( myRedisDatabasePage . submitImportBtn )
103
113
. expect ( myRedisDatabasePage . failedImportMessage . exists ) . ok ( 'Failed to add database message not displayed' )
104
114
. expect ( myRedisDatabasePage . failedImportMessage . textContent ) . contains ( parseFailedMsg )
@@ -108,7 +118,7 @@ test('Connection import modal window', async t => {
108
118
await t . click ( myRedisDatabasePage . closeDialogBtn ) ;
109
119
await t . click ( myRedisDatabasePage . importDatabasesBtn ) ;
110
120
await t . setFilesToUpload ( myRedisDatabasePage . importDatabaseInput , [ rdmData . path ] ) ;
111
- await t . expect ( myRedisDatabasePage . importDbDialog . textContent ) . contains ( rdmFullJson , 'Filename not displayed in import input' ) ;
121
+ await t . expect ( myRedisDatabasePage . importDbDialog . textContent ) . contains ( fileNames . rdmFullJson , 'Filename not displayed in import input' ) ;
112
122
// Click on remove button
113
123
await t . click ( myRedisDatabasePage . removeImportedFileBtn ) ;
114
124
await t . expect ( myRedisDatabasePage . importDbDialog . textContent ) . contains ( defaultText , 'File not removed from import input' ) ;
@@ -184,48 +194,48 @@ test
184
194
await clickOnEditDatabaseByName ( dbData [ 1 ] . dbNames [ 2 ] ) ;
185
195
await t . expect ( addRedisDatabasePage . sentinelForm . textContent ) . contains ( 'Sentinel' , 'Sentinel connection type import incorrect' ) ;
186
196
await myRedisDatabasePage . clickOnDBByName ( dbData [ 1 ] . dbNames [ 2 ] ) ;
187
- await t . expect ( getPageUrl ( ) ) . contains ( 'browser' , 'Sentinel connection not opened ') ;
197
+ await common . checkURLContainsText ( 'browser' ) ;
188
198
} ) ;
189
199
test
190
200
. after ( async ( ) => {
191
201
// Delete databases
192
202
await deleteStandaloneDatabasesByNamesApi ( rdmCertsNames ) ;
193
203
} ) ( 'Certificates import with/without path' , async t => {
194
- await databasesActions . importDatabase ( rdmCertsData ) ;
204
+ await databasesActions . importDatabase ( { path : rdmData . sshPath } ) ;
195
205
await t . click ( myRedisDatabasePage . okDialogBtn ) ;
196
206
197
207
// Verify that when user imports a certificate and the same certificate body already exists, the existing certificate (with its name) is applied
198
- await clickOnEditDatabaseByName ( rdmCertsListOfDB [ 0 ] . name ) ;
199
- await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( rdmCertsListOfDB [ 0 ] . caCert . name , 'CA certificate import incorrect' ) ;
200
- await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( rdmCertsListOfDB [ 0 ] . clientCert . name , 'Client certificate import incorrect' ) ;
208
+ await clickOnEditDatabaseByName ( rdmListOfCertsDB [ 0 ] . name ) ;
209
+ await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( rdmListOfCertsDB [ 0 ] . caCert . name , 'CA certificate import incorrect' ) ;
210
+ await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( rdmListOfCertsDB [ 0 ] . clientCert . name , 'Client certificate import incorrect' ) ;
201
211
202
- await clickOnEditDatabaseByName ( rdmCertsListOfDB [ 1 ] . name ) ;
203
- await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( rdmCertsListOfDB [ 0 ] . caCert . name , 'CA certificate name with the same body is incorrect' ) ;
204
- await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( rdmCertsListOfDB [ 0 ] . clientCert . name , 'Client certificate name with the same body is incorrect' ) ;
212
+ await clickOnEditDatabaseByName ( rdmListOfCertsDB [ 1 ] . name ) ;
213
+ await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( rdmListOfCertsDB [ 0 ] . caCert . name , 'CA certificate name with the same body is incorrect' ) ;
214
+ await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( rdmListOfCertsDB [ 0 ] . clientCert . name , 'Client certificate name with the same body is incorrect' ) ;
205
215
206
216
// Verify that when user imports a certificate and the same certificate name exists but with a different body, the certificate imported with "({incremental_number})_certificate_name" name
207
- await clickOnEditDatabaseByName ( rdmCertsListOfDB [ 2 ] . name ) ;
208
- await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( `1_${ rdmCertsListOfDB [ 0 ] . caCert . name } ` , 'CA certificate name with the same body is incorrect' ) ;
209
- await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( `1_${ rdmCertsListOfDB [ 0 ] . clientCert . name } ` , 'Client certificate name with the same body is incorrect' ) ;
217
+ await clickOnEditDatabaseByName ( rdmListOfCertsDB [ 2 ] . name ) ;
218
+ await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( `1_${ rdmListOfCertsDB [ 0 ] . caCert . name } ` , 'CA certificate name with the same body is incorrect' ) ;
219
+ await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( `1_${ rdmListOfCertsDB [ 0 ] . clientCert . name } ` , 'Client certificate name with the same body is incorrect' ) ;
210
220
211
221
// Verify that when user imports a certificate by path and the same certificate body already exists, the existing certificate (with its name) is applied
212
- await clickOnEditDatabaseByName ( rdmCertsListOfDB [ 3 ] . name ) ;
222
+ await clickOnEditDatabaseByName ( rdmListOfCertsDB [ 3 ] . name ) ;
213
223
await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( 'caPath' , 'CA certificate import incorrect' ) ;
214
224
await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( 'clientPath' , 'Client certificate import incorrect' ) ;
215
225
216
- await clickOnEditDatabaseByName ( rdmCertsListOfDB [ 4 ] . name ) ;
226
+ await clickOnEditDatabaseByName ( rdmListOfCertsDB [ 4 ] . name ) ;
217
227
await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( 'caPath' , 'CA certificate import incorrect' ) ;
218
228
await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( 'clientPath' , 'Client certificate import incorrect' ) ;
219
229
220
230
// Verify that when user imports a certificate by path and the same certificate name exists but with a different body, the certificate imported with "({incremental_number})certificate_name" name
221
- await clickOnEditDatabaseByName ( rdmCertsListOfDB [ 5 ] . name ) ;
231
+ await clickOnEditDatabaseByName ( rdmListOfCertsDB [ 5 ] . name ) ;
222
232
await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( '1_caPath' , 'CA certificate import incorrect' ) ;
223
233
await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( '1_clientPath' , 'Client certificate import incorrect' ) ;
224
234
} ) ;
225
235
test
226
236
. after ( async ( ) => {
227
237
// Delete databases
228
- await deleteStandaloneDatabasesByNamesApi ( importedSSHdbNames ) ;
238
+ await deleteStandaloneDatabasesByNamesApi ( racompSSHData . importedSSHdbNames ) ;
229
239
} ) ( 'Import SSH parameters' , async t => {
230
240
const sshAgentsResult = 'SSH Agents are not supported' ;
231
241
const sshPrivateKey = '-----BEGIN OPENSSH PRIVATE KEY-----' ;
0 commit comments