Skip to content

Commit 3d4669d

Browse files
authored
Merge pull request #3507 from RedisInsight/e2e/bugfix/RI-5826_fix_json
E2e/bugfix/ri 5826 fix json
2 parents ed87c38 + fc887d6 commit 3d4669d

File tree

5 files changed

+260
-7
lines changed

5 files changed

+260
-7
lines changed

tests/e2e/helpers/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as path from 'path';
22
import * as fs from 'fs';
3-
import * as archiver from 'archiver';
43
import { ClientFunction, RequestMock, t } from 'testcafe';
54
import { Chance } from 'chance';
65
import { apiUrl, commonUrl } from './conf';
6+
const archiver = require('archiver');
77

88
const chance = new Chance();
99

@@ -221,6 +221,7 @@ export class Common {
221221
const parsedJson = JSON.parse(fs.readFileSync(path, 'utf-8'));
222222
return parsedJson[property];
223223
}
224+
224225
/**
225226
* Create Zip archive from folder
226227
* @param folderPath Path to folder to archive

tests/e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"build:ui": "yarn --cwd ../../ build:ui",
1414
"redis:last": "docker run --name redis-last-version -p 7777:6379 -d redislabs/redismod",
1515
"start:app": "cross-env yarn start:api",
16-
"test:chrome": "testcafe --compiler-options typescript.configPath=tsconfig.testcafe.json --cache --allow-insecure-localhost --ignore-certificate-errors --disable-multiple-windows --concurrency 1 chrome tests/ -r html:./report/report.html,spec -e -s takeOnFails=true,path=report/screenshots/,pathPattern=${OS}_${BROWSER}/${DATE}_${TIME}/${FIXTURE}_${TEST}_${FILE_INDEX}.png",
16+
"test:chrome": "testcafe --compiler-options typescript.configPath=tsconfig.testcafe.json --cache --allow-insecure-localhost --disable-multiple-windows --concurrency 1 chrome tests/ -r html:./report/report.html,spec -e -s takeOnFails=true,path=report/screenshots/,pathPattern=${OS}_${BROWSER}/${DATE}_${TIME}/${FIXTURE}_${TEST}_${FILE_INDEX}.png",
1717
"test:chrome:ci": "ts-node ./web.runner.ts",
1818
"test": "yarn test:chrome",
1919
"lint": "eslint . --ext .ts,.js,.tsx,.jsx",

tests/e2e/pageObjects/browser-page.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,8 @@ export class BrowserPage extends InstancePage {
841841
*/
842842
async addJsonKeyOnTheSameLevel(jsonKey: string, jsonKeyValue: string): Promise<void> {
843843
await t.click(this.addJsonObjectButton);
844-
await t.typeText(this.jsonKeyInput, jsonKey, { replace: true, paste: true });
845-
await t.typeText(this.jsonValueInput, jsonKeyValue, { replace: true, paste: true });
844+
await t.typeText(this.jsonKeyInput, jsonKey, { paste: true });
845+
await t.typeText(this.jsonValueInput, jsonKeyValue, { paste: true });
846846
await t.click(this.applyButton);
847847
}
848848

@@ -854,8 +854,19 @@ export class BrowserPage extends InstancePage {
854854
async addJsonKeyInsideStructure(jsonKey: string, jsonKeyValue: string): Promise<void> {
855855
await t.click(this.expandJsonObject);
856856
await t.click(this.addJsonFieldButton);
857-
await t.typeText(this.jsonKeyInput, jsonKey, { replace: true, paste: true });
858-
await t.typeText(this.jsonValueInput, jsonKeyValue, { replace: true, paste: true });
857+
await t.typeText(this.jsonKeyInput, jsonKey, { paste: true });
858+
await t.typeText(this.jsonValueInput, jsonKeyValue, { paste: true });
859+
await t.click(this.applyButton);
860+
}
861+
862+
/**
863+
* Add json value inside the Json structure
864+
* @param jsonKeyValue The value of the json key
865+
*/
866+
async addJsonValueInsideStructure(jsonKeyValue: string): Promise<void> {
867+
await t.click(this.expandJsonObject);
868+
await t.click(this.addJsonFieldButton);
869+
await t.typeText(this.jsonValueInput, jsonKeyValue, { paste: true });
859870
await t.click(this.applyButton);
860871
}
861872

@@ -868,7 +879,7 @@ export class BrowserPage extends InstancePage {
868879
await t.click(this.expandJsonObject);
869880
}
870881
await t.click(this.editJsonObjectButton);
871-
await t.typeText(this.jsonValueInput, jsonStructure, { replace: true, paste: true });
882+
await t.typeText(this.jsonValueInput, jsonStructure, { paste: true });
872883
await t.click(this.applyEditButton);
873884
}
874885

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
{
2+
"_id": "666c56b9f4f88278244b6dc8",
3+
"index": 0,
4+
"guid": "1743c04d-b95a-4ab9-9e8c-51b0e9b7e009",
5+
"isActive": true,
6+
"balance": "$2,469.16",
7+
"picture": "http://placehold.it/32x32",
8+
"age": 32,
9+
"eyeColor": "green",
10+
"name": "Camille Sims",
11+
"gender": "female",
12+
"company": "ZBOO",
13+
"email": "[email protected]",
14+
"phone": "+1 (942) 411-2857",
15+
"address": "817 Graham Avenue, Ezel, South Carolina, 5845",
16+
"about": "Ut mollit elit eu veniam non do ut in aliquip. Lorem culpa laborum non aliqua non eiusmod amet cupidatat sunt officia elit elit. Ut officia elit adipisicing labore ex deserunt. Amet sit excepteur quis ut adipisicing occaecat proident occaecat in minim.\r\n",
17+
"registered": "2017-08-30T02:25:04 -02:00",
18+
"latitude": 7.648678,
19+
"longitude": 109.700128,
20+
"tags": [
21+
"sit",
22+
"irure",
23+
"nisi",
24+
"ullamco",
25+
"sint",
26+
"consequat",
27+
"do",
28+
"ad",
29+
"elit",
30+
"deserunt",
31+
"ipsum",
32+
"nisi",
33+
"pariatur",
34+
"sit",
35+
"non",
36+
"ad",
37+
"do",
38+
"nulla",
39+
"ad",
40+
"irure",
41+
"ipsum",
42+
"incididunt",
43+
"Lorem",
44+
"enim",
45+
"proident",
46+
"veniam",
47+
"in",
48+
"reprehenderit",
49+
"irure",
50+
"pariatur",
51+
"cupidatat",
52+
"ipsum",
53+
"sit",
54+
"nisi",
55+
"irure",
56+
"ipsum",
57+
"cillum",
58+
"adipisicing",
59+
"reprehenderit",
60+
"occaecat",
61+
"irure",
62+
"irure",
63+
"amet",
64+
"reprehenderit",
65+
"voluptate",
66+
"veniam",
67+
"cillum",
68+
"incididunt",
69+
"magna",
70+
"laboris",
71+
"nisi",
72+
"duis",
73+
"irure",
74+
"do",
75+
"amet",
76+
"aliquip",
77+
"commodo",
78+
"nisi",
79+
"pariatur",
80+
"sunt",
81+
"dolor",
82+
"ut",
83+
"ea",
84+
"voluptate",
85+
"laboris",
86+
"pariatur",
87+
"qui",
88+
"duis",
89+
"commodo",
90+
"deserunt"
91+
],
92+
"friends": [
93+
{
94+
"id": 0,
95+
"name": "Erna Lynch"
96+
},
97+
{
98+
"id": 1,
99+
"name": "Vicky Vega"
100+
},
101+
{
102+
"id": 2,
103+
"name": "Haley Meyer"
104+
},
105+
{
106+
"id": 3,
107+
"name": "Darlene Knight"
108+
},
109+
{
110+
"id": 4,
111+
"name": "Odonnell Cain"
112+
},
113+
{
114+
"id": 5,
115+
"name": "Hopper Sellers"
116+
},
117+
{
118+
"id": 6,
119+
"name": "Knapp Barry"
120+
},
121+
{
122+
"id": 7,
123+
"name": "Alvarado Clements"
124+
},
125+
{
126+
"id": 8,
127+
"name": "Wolfe Taylor"
128+
},
129+
{
130+
"id": 9,
131+
"name": "Janell Chambers"
132+
},
133+
{
134+
"id": 10,
135+
"name": "Merle Wood"
136+
},
137+
{
138+
"id": 11,
139+
"name": "Ellen Savage"
140+
},
141+
{
142+
"id": 12,
143+
"name": "Elliott Humphrey"
144+
},
145+
{
146+
"id": 13,
147+
"name": "Ayers Chase"
148+
},
149+
{
150+
"id": 14,
151+
"name": "Robbie Kirkland"
152+
},
153+
{
154+
"id": 15,
155+
"name": "Whitney Perkins"
156+
},
157+
{
158+
"id": 16,
159+
"name": "Marisa Lloyd"
160+
},
161+
{
162+
"id": 17,
163+
"name": "Helene Case"
164+
},
165+
{
166+
"id": 18,
167+
"name": "Berry Tyler"
168+
},
169+
{
170+
"id": 19,
171+
"name": "Frieda Cannon"
172+
},
173+
{
174+
"id": 20,
175+
"name": "Sonya Leon"
176+
},
177+
{
178+
"id": 21,
179+
"name": "Wilda Glass"
180+
},
181+
{
182+
"id": 22,
183+
"name": "Sims Kaufman"
184+
},
185+
{
186+
"id": 23,
187+
"name": "Ballard Preston"
188+
},
189+
{
190+
"id": 24,
191+
"name": "Carroll Clay"
192+
},
193+
{
194+
"id": 25,
195+
"name": "Medina Curry"
196+
},
197+
{
198+
"id": 26,
199+
"name": "Beatriz Herrera"
200+
},
201+
{
202+
"id": 27,
203+
"name": "Marianne Vargas"
204+
},
205+
{
206+
"id": 28,
207+
"name": "Galloway Stanton"
208+
},
209+
{
210+
"id": 29,
211+
"name": "Rhea Marshall"
212+
}
213+
],
214+
"greeting": "Hello, Camille Sims! You have 10 unread messages.",
215+
"favoriteFruit": "strawberry"
216+
}

tests/e2e/tests/web/smoke/browser/json-key.e2e.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as path from 'path';
12
import { rte } from '../../../../helpers/constants';
23
import { DatabaseHelper } from '../../../../helpers/database';
34
import { BrowserPage } from '../../../../pageObjects';
@@ -15,6 +16,7 @@ let keyName = Common.generateWord(10);
1516
const keyTTL = '2147476121';
1617
const value = '{"name":"xyz"}';
1718
const jsonObjectValue = '{name:"xyz"}';
19+
const jsonFilePath = path.join('..', '..', '..', '..', 'test-data', 'big-json', 'big-json.json');
1820

1921
fixture `JSON Key verification`
2022
.meta({ type: 'smoke', rte: rte.standalone })
@@ -49,3 +51,26 @@ test('Verify that user can add key with value to any level of JSON structure', a
4951
// Check the added key contains json object with added key
5052
await t.expect(browserPage.jsonKeyValue.textContent).eql('{name:"xyz"key1:"value1"key2:{key2222:12345}}', 'The json object value not found');
5153
});
54+
test('Verify that user can add key with value to any level of JSON structure for big JSON object', async t => {
55+
keyName = Common.generateWord(10);
56+
// Add Json key with json object
57+
await t.click(browserPage.plusAddKeyButton);
58+
await t.click(browserPage.keyTypeDropDown);
59+
await t.click(browserPage.jsonOption);
60+
await t.click(browserPage.addKeyNameInput);
61+
await t.typeText(browserPage.addKeyNameInput, keyName, { replace: true, paste: true });
62+
await t.setFilesToUpload(browserPage.jsonUploadInput, [jsonFilePath]);
63+
await t.click(browserPage.addKeyButton);
64+
// Check the notification message
65+
const notification = browserPage.Toast.toastHeader.textContent;
66+
await t.expect(notification).contains('Key has been added', 'The notification not found');
67+
// Add key with value on the same level
68+
await browserPage.addJsonKeyOnTheSameLevel('"key1"', '"value1"');
69+
// Check the added key contains json object with added key
70+
await t.expect(browserPage.addJsonObjectButton.exists).ok('The add Json object button not found', { timeout: 10000 });
71+
await t.expect(browserPage.jsonKeyValue.textContent).contains('"key1:"value1"}', 'The json object value not found');
72+
// Add value inside the json array
73+
await browserPage.addJsonValueInsideStructure('12345');
74+
// Check the added key contains json object with added key
75+
await t.expect(browserPage.jsonKeyValue.textContent).contains('"70:12345]', 'The json object value not found');
76+
});

0 commit comments

Comments
 (0)