1
1
import { join } from 'path' ;
2
2
import * as os from 'os' ;
3
+ import * as fs from 'fs' ;
3
4
import { Chance } from 'chance' ;
4
5
import * as editJsonFile from 'edit-json-file' ;
5
6
import { acceptLicenseTerms } from '../../../helpers/database' ;
@@ -12,40 +13,42 @@ const chance = new Chance();
12
13
13
14
const workingDirectory = process . env . APP_FOLDER_ABSOLUTE_PATH
14
15
|| ( join ( os . homedir ( ) , process . env . APP_FOLDER_NAME || '.redisinsight-v2' ) ) ;
15
- const buildPath = `${ workingDirectory } /content/build.json` ;
16
- const createRedisPath = `${ workingDirectory } /content/create-redis.json` ;
17
- const buildFilePath = editJsonFile ( buildPath ) ;
18
- const createRedisFilePath = editJsonFile ( createRedisPath ) ;
19
- const timestampBeforeUpdate = buildFilePath . get ( 'timestamp' ) ;
20
- const timestampForEdit = timestampBeforeUpdate - 1 ;
21
- const cloudValueForEdit = chance . word ( { length : 10 } ) ;
16
+ if ( fs . existsSync ( workingDirectory ) ) {
17
+ const buildPath = `${ workingDirectory } /content/build.json` ;
18
+ const createRedisPath = `${ workingDirectory } /content/create-redis.json` ;
19
+ const buildFilePath = editJsonFile ( buildPath ) ;
20
+ const createRedisFilePath = editJsonFile ( createRedisPath ) ;
21
+ const timestampBeforeUpdate = buildFilePath . get ( 'timestamp' ) ;
22
+ const timestampForEdit = timestampBeforeUpdate - 1 ;
23
+ const cloudValueForEdit = chance . word ( { length : 10 } ) ;
22
24
23
- //Edit json file values
24
- createRedisFilePath . set ( 'cloud.title' , cloudValueForEdit ) ;
25
- createRedisFilePath . set ( 'cloud.description' , cloudValueForEdit ) ;
26
- createRedisFilePath . save ( ) ;
27
- buildFilePath . set ( 'timestamp' , timestampForEdit ) ;
28
- buildFilePath . save ( ) ;
25
+ //Edit json file values
26
+ createRedisFilePath . set ( 'cloud.title' , cloudValueForEdit ) ;
27
+ createRedisFilePath . set ( 'cloud.description' , cloudValueForEdit ) ;
28
+ createRedisFilePath . save ( ) ;
29
+ buildFilePath . set ( 'timestamp' , timestampForEdit ) ;
30
+ buildFilePath . save ( ) ;
29
31
30
- fixture `Automatically update information`
31
- . meta ( { type : 'critical_path' } )
32
- . page ( commonUrl )
33
- . beforeEach ( async ( ) => {
34
- await acceptLicenseTerms ( ) ;
35
- } ) ;
36
- test
37
- . meta ( { rte : rte . standalone , env : env . desktop } ) ( 'Verify that user has the ability to update "Create free database" button without changing the app' , async t => {
38
- //Create new file paths due to cache-ability
39
- const buildFilePathNew = editJsonFile ( buildPath ) ;
40
- const createRedisFilePathNew = editJsonFile ( createRedisPath ) ;
41
- //Check the promo button after the opening of app
42
- await t . expect ( myRedisDatabasePage . promoButton . textContent ) . notContains ( cloudValueForEdit , 'Promo button text is updated' ) ;
43
- //Get the values from build.json and create-redis.json files
44
- const timestampAfterUpdate = await buildFilePathNew . get ( 'timestamp' ) ;
45
- const cloudTitle = await createRedisFilePathNew . get ( 'cloud.title' ) ;
46
- const cloudDescription = await createRedisFilePathNew . get ( 'cloud.description' ) ;
47
- //Check the json files are automatically updated
48
- await t . expect ( timestampAfterUpdate ) . notEql ( timestampForEdit , 'The timestamp in the build.json file is automatically updated' ) ;
49
- await t . expect ( cloudTitle ) . notEql ( cloudValueForEdit , 'The cloud title in the create-redis.json file is automatically updated' ) ;
50
- await t . expect ( cloudDescription ) . notEql ( cloudValueForEdit , 'The cloud description in the create-redis.json file is automatically updated' ) ;
51
- } ) ;
32
+ fixture `Automatically update information`
33
+ . meta ( { type : 'critical_path' } )
34
+ . page ( commonUrl )
35
+ . beforeEach ( async ( ) => {
36
+ await acceptLicenseTerms ( ) ;
37
+ } ) ;
38
+ test
39
+ . meta ( { rte : rte . standalone , env : env . desktop } ) ( 'Verify that user has the ability to update "Create free database" button without changing the app' , async t => {
40
+ //Create new file paths due to cache-ability
41
+ const buildFilePathNew = editJsonFile ( buildPath ) ;
42
+ const createRedisFilePathNew = editJsonFile ( createRedisPath ) ;
43
+ //Check the promo button after the opening of app
44
+ await t . expect ( myRedisDatabasePage . promoButton . textContent ) . notContains ( cloudValueForEdit , 'Promo button text is updated' ) ;
45
+ //Get the values from build.json and create-redis.json files
46
+ const timestampAfterUpdate = await buildFilePathNew . get ( 'timestamp' ) ;
47
+ const cloudTitle = await createRedisFilePathNew . get ( 'cloud.title' ) ;
48
+ const cloudDescription = await createRedisFilePathNew . get ( 'cloud.description' ) ;
49
+ //Check the json files are automatically updated
50
+ await t . expect ( timestampAfterUpdate ) . notEql ( timestampForEdit , 'The timestamp in the build.json file is automatically updated' ) ;
51
+ await t . expect ( cloudTitle ) . notEql ( cloudValueForEdit , 'The cloud title in the create-redis.json file is automatically updated' ) ;
52
+ await t . expect ( cloudDescription ) . notEql ( cloudValueForEdit , 'The cloud description in the create-redis.json file is automatically updated' ) ;
53
+ } ) ;
54
+ }
0 commit comments