Skip to content

Commit abe2bbb

Browse files
e2e - automatically update
1 parent 8ebb179 commit abe2bbb

File tree

4 files changed

+110
-0
lines changed

4 files changed

+110
-0
lines changed

tests/e2e/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
},
2727
"devDependencies": {
2828
"@types/chance": "1.1.3",
29+
"@types/edit-json-file": "^1.7.0",
2930
"@typescript-eslint/eslint-plugin": "^2.25.0",
3031
"@typescript-eslint/parser": "^2.25.0",
3132
"chance": "1.1.8",
3233
"cross-env": "^7.0.3",
3334
"dotenv-cli": "^5.0.0",
35+
"edit-json-file": "^1.7.0",
3436
"eslint": "^6.8.0",
3537
"eslint-config-airbnb": "^18.2.0",
3638
"eslint-config-airbnb-typescript": "^9.0.0",

tests/e2e/pageObjects/my-redis-databases-page.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class MyRedisDatabasePage {
3838
moduleTooltip: Selector
3939
moduleQuantifier: Selector
4040
redisStackIcon: Selector
41+
promoButton: Selector
4142

4243
constructor() {
4344
//-------------------------------------------------------------------------------------------
@@ -73,6 +74,7 @@ export class MyRedisDatabasePage {
7374
this.moduleTooltip = Selector('.euiToolTipPopover');
7475
this.moduleQuantifier = Selector('[data-testid=_module]');
7576
this.redisStackIcon = Selector('[data-testid=redis-stack-icon]');
77+
this.promoButton = Selector('[data-testid=promo-btn]');
7678
// TEXT INPUTS (also referred to as 'Text fields')
7779
this.dbNameList = Selector('[data-testid^=instance-name]');
7880
this.tableRowContent = Selector('[data-test-subj=database-alias-column]');
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { acceptLicenseTerms } from '../../../helpers/database';
2+
import { MyRedisDatabasePage } from '../../../pageObjects';
3+
import { commonUrl } from '../../../helpers/conf';
4+
import { rte, env } from '../../../helpers/constants';
5+
import { Chance } from 'chance';
6+
import { join } from 'path';
7+
import * as os from 'os';
8+
import * as editJsonFile from 'edit-json-file';
9+
10+
const myRedisDatabasePage = new MyRedisDatabasePage();
11+
const chance = new Chance();
12+
13+
const workingDirectory = join(os.homedir(), '.redisinsight-v2-stage');
14+
const buildPath = `${workingDirectory}/content/build.json`;
15+
const createRedisPath = `${workingDirectory}/content/create-redis.json`;
16+
const buildFilePath = editJsonFile(buildPath);
17+
const createRedisFilePath = editJsonFile(createRedisPath);
18+
const timestampBeforeUpdate = buildFilePath.get("timestamp");
19+
const timestampForEdit = timestampBeforeUpdate - 1;
20+
const cloudValueForEdit = chance.word({ length: 10 });
21+
22+
//Edit json file values
23+
createRedisFilePath.set('cloud.title', cloudValueForEdit);
24+
createRedisFilePath.set('cloud.description', cloudValueForEdit);
25+
createRedisFilePath.save();
26+
buildFilePath.set('timestamp', timestampForEdit);
27+
buildFilePath.save();
28+
29+
fixture `Automatically update information`
30+
.meta({type: 'critical_path'})
31+
.page(commonUrl)
32+
.beforeEach(async () => {
33+
await acceptLicenseTerms();
34+
})
35+
test
36+
.meta({ rte: rte.standalone, env: env.desktop })
37+
('Verify that user has the ability to update "Create free database" button without changing the app', async t => {
38+
const buildFilePathNew = editJsonFile(buildPath);
39+
const createRedisFilePathNew = editJsonFile(createRedisPath);
40+
//Check the promo button
41+
await t.expect(myRedisDatabasePage.promoButton.textContent).notContains(cloudValueForEdit, 'Promo button text is updated');
42+
//Check the json files are automatically updated
43+
const timestampAfterUpdate = await buildFilePathNew.get('timestamp');
44+
const cloudTitle = await createRedisFilePathNew.get('cloud.title');
45+
const cloudDescription = await createRedisFilePathNew.get('cloud.description');
46+
await t.expect(timestampAfterUpdate).notEql(timestampForEdit);
47+
await t.expect(cloudTitle).notEql(cloudValueForEdit);
48+
await t.expect(cloudDescription).notEql(cloudValueForEdit);
49+
});

tests/e2e/yarn.lock

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,14 @@
10711071
resolved "https://registry.yarnpkg.com/@types/chance/-/chance-1.1.3.tgz#d19fe9391288d60fdccd87632bfc9ab2b4523fea"
10721072
integrity sha512-X6c6ghhe4/sQh4XzcZWSFaTAUOda38GQHmq9BUanYkOE/EO7ZrkazwKmtsj3xzTjkLWmwULE++23g3d3CCWaWw==
10731073

1074+
"@types/edit-json-file@^1.7.0":
1075+
version "1.7.0"
1076+
resolved "https://registry.yarnpkg.com/@types/edit-json-file/-/edit-json-file-1.7.0.tgz#c3ab99b33ca8f018d412b2b6a1e3c7bf1a05f732"
1077+
integrity sha512-yZrbGD4Qp92s6xU80MWBdz9vJE8k8EbO+gLWYb4W1UL9WYVUMOtUr5zvKlKgbcc2veYmFLO9dPnYA9Mxul0lOw==
1078+
dependencies:
1079+
"@types/node" "*"
1080+
"@types/set-value" "*"
1081+
10741082
"@types/error-stack-parser@^1.3.18":
10751083
version "1.3.18"
10761084
resolved "https://registry.yarnpkg.com/@types/error-stack-parser/-/error-stack-parser-1.3.18.tgz#e01c9f8c85ca83b610320c62258b0c9026ade0f7"
@@ -1119,6 +1127,11 @@
11191127
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.13.tgz#e743bae112bd779ac9650f907197dd2caa7f0364"
11201128
integrity sha512-1x8W5OpxPq+T85OUsHRP6BqXeosKmeXRtjoF39STcdf/UWLqUsoehstZKOi0CunhVqHG17AyZgpj20eRVooK6A==
11211129

1130+
"@types/set-value@*":
1131+
version "4.0.1"
1132+
resolved "https://registry.yarnpkg.com/@types/set-value/-/set-value-4.0.1.tgz#7caf185556a67c2d9051080931853047423c93bd"
1133+
integrity sha512-mP/CLy6pdrhsDVrz1+Yp5Ly6Tcel2IAEejhyI5NxY6WnBUdWN+AAfGa0HHsdgCdsPWWcd/4D5J2X2TrRYcYRag==
1134+
11221135
"@typescript-eslint/eslint-plugin@^2.25.0":
11231136
version "2.34.0"
11241137
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz#6f8ce8a46c7dea4a6f1d171d2bb8fbae6dac2be9"
@@ -2083,6 +2096,17 @@ easy-stack@^1.0.1:
20832096
resolved "https://registry.yarnpkg.com/easy-stack/-/easy-stack-1.0.1.tgz#8afe4264626988cabb11f3c704ccd0c835411066"
20842097
integrity sha512-wK2sCs4feiiJeFXn3zvY0p41mdU5VUgbgs1rNsc/y5ngFUijdWd+iIN8eoyuZHKB8xN6BL4PdWmzqFmxNg6V2w==
20852098

2099+
edit-json-file@^1.7.0:
2100+
version "1.7.0"
2101+
resolved "https://registry.yarnpkg.com/edit-json-file/-/edit-json-file-1.7.0.tgz#b0bfb626169890568c2668369a8e5202f5c49150"
2102+
integrity sha512-eIkLJ9i4ija7b2TbaLHy3scyjWFLzwM2Wa6kHbV4ppVLcCqn7FzqnO1vmCG3dLrkd+teWE3mvACfv166mO0VZg==
2103+
dependencies:
2104+
find-value "^1.0.12"
2105+
iterate-object "^1.3.4"
2106+
r-json "^1.2.10"
2107+
set-value "^4.1.0"
2108+
w-json "^1.3.10"
2109+
20862110
electron-to-chromium@^1.3.723:
20872111
version "1.3.743"
20882112
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.743.tgz#fcec24d6d647cb84fd796b42caa1b4039a180894"
@@ -2559,6 +2583,11 @@ find-up@^3.0.0:
25592583
dependencies:
25602584
locate-path "^3.0.0"
25612585

2586+
find-value@^1.0.12:
2587+
version "1.0.12"
2588+
resolved "https://registry.yarnpkg.com/find-value/-/find-value-1.0.12.tgz#68b6cec84e5b2d51272965e0bf09b26c9159c26e"
2589+
integrity sha512-OCpo8LTk8eZ2sdDCwbU2Lc3ivYsdM6yod6jP2jHcNEFcjPhkgH0+POzTIol7xx1LZgtbI5rkO5jqxsG5MWtPjQ==
2590+
25622591
flat-cache@^2.0.1:
25632592
version "2.0.1"
25642593
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0"
@@ -3155,6 +3184,11 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4:
31553184
dependencies:
31563185
isobject "^3.0.1"
31573186

3187+
is-primitive@^3.0.1:
3188+
version "3.0.1"
3189+
resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-3.0.1.tgz#98c4db1abff185485a657fc2905052b940524d05"
3190+
integrity sha512-GljRxhWvlCNRfZyORiH77FwdFwGcMO620o37EOYC0ORWdq+WYNVqW0w2Juzew4M+L81l6/QS3t5gkkihyRqv9w==
3191+
31583192
is-regex@^1.1.3:
31593193
version "1.1.3"
31603194
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.3.tgz#d029f9aff6448b93ebbe3f33dac71511fdcbef9f"
@@ -3212,6 +3246,11 @@ isobject@^3.0.0, isobject@^3.0.1:
32123246
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
32133247
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
32143248

3249+
iterate-object@^1.3.4:
3250+
version "1.3.4"
3251+
resolved "https://registry.yarnpkg.com/iterate-object/-/iterate-object-1.3.4.tgz#fa50b1d9e58e340a7dd6b4c98c8a5e182e790096"
3252+
integrity sha512-4dG1D1x/7g8PwHS9aK6QV5V94+ZvyP4+d19qDv43EzImmrndysIl4prmJ1hWWIGCqrZHyaHBm6BSEWHOLnpoNw==
3253+
32153254
32163255
version "1.0.7"
32173256
resolved "https://registry.yarnpkg.com/js-message/-/js-message-1.0.7.tgz#fbddd053c7a47021871bb8b2c95397cc17c20e47"
@@ -4005,6 +4044,11 @@ queue-microtask@^1.2.2:
40054044
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
40064045
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
40074046

4047+
r-json@^1.2.10:
4048+
version "1.2.10"
4049+
resolved "https://registry.yarnpkg.com/r-json/-/r-json-1.2.10.tgz#62a73d9cafa7eabf670e5c2812c27bdb220a968b"
4050+
integrity sha512-hu9vyLjSlHXT62NAS7DjI9WazDlvjN0lgp3n431dCVnirVcLkZIpzSwA3orhZEKzdDD2jqNYI+w0yG0aFf4kpA==
4051+
40084052
read-file-relative@^1.2.0:
40094053
version "1.2.0"
40104054
resolved "https://registry.yarnpkg.com/read-file-relative/-/read-file-relative-1.2.0.tgz#98f7d96eaa21d2b4c7a2febd63d2fc8cf35e9f9b"
@@ -4299,6 +4343,14 @@ set-value@^2.0.0, set-value@^2.0.1:
42994343
is-plain-object "^2.0.3"
43004344
split-string "^3.0.1"
43014345

4346+
set-value@^4.1.0:
4347+
version "4.1.0"
4348+
resolved "https://registry.yarnpkg.com/set-value/-/set-value-4.1.0.tgz#aa433662d87081b75ad88a4743bd450f044e7d09"
4349+
integrity sha512-zTEg4HL0RwVrqcWs3ztF+x1vkxfm0lP+MQQFPiMJTKVceBwEV0A569Ou8l9IYQG8jOZdMVI1hGsc0tmeD2o/Lw==
4350+
dependencies:
4351+
is-plain-object "^2.0.4"
4352+
is-primitive "^3.0.1"
4353+
43024354
shebang-command@^1.2.0:
43034355
version "1.2.0"
43044356
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
@@ -5116,6 +5168,11 @@ validate-npm-package-license@^3.0.1:
51165168
spdx-correct "^3.0.0"
51175169
spdx-expression-parse "^3.0.0"
51185170

5171+
w-json@^1.3.10:
5172+
version "1.3.10"
5173+
resolved "https://registry.yarnpkg.com/w-json/-/w-json-1.3.10.tgz#ac448a19ca22376e2753a684b52369c7b1e83313"
5174+
integrity sha512-XadVyw0xE+oZ5FGApXsdswv96rOhStzKqL53uSe5UaTadABGkWIg1+DTx8kiZ/VqTZTBneoL0l65RcPe4W3ecw==
5175+
51195176
webauth@^1.1.0:
51205177
version "1.1.0"
51215178
resolved "https://registry.yarnpkg.com/webauth/-/webauth-1.1.0.tgz#64704f6b8026986605bc3ca629952e6e26fdd100"

0 commit comments

Comments
 (0)