Skip to content

Commit 42f606f

Browse files
authored
Merge pull request #587 from RedisInsight/feature/e2e-test-fixes
e2e-fix autoupdate test
2 parents 8a1784c + 633584c commit 42f606f

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed
Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { join } from 'path';
22
import * as os from 'os';
3+
import * as fs from 'fs';
34
import { Chance } from 'chance';
45
import * as editJsonFile from 'edit-json-file';
56
import { acceptLicenseTerms } from '../../../helpers/database';
@@ -12,40 +13,42 @@ const chance = new Chance();
1213

1314
const workingDirectory = process.env.APP_FOLDER_ABSOLUTE_PATH
1415
|| (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 });
2224

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();
2931

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

Comments
 (0)