Skip to content

Commit 2230d09

Browse files
committed
e2e/bugfix/RI-5826_fix_json
1 parent ed87c38 commit 2230d09

File tree

3 files changed

+251
-1
lines changed

3 files changed

+251
-1
lines changed

tests/e2e/helpers/common.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path';
22
import * as fs from 'fs';
3-
import * as archiver from 'archiver';
3+
import archiver from 'archiver';
44
import { ClientFunction, RequestMock, t } from 'testcafe';
55
import { Chance } from 'chance';
66
import { apiUrl, commonUrl } from './conf';
@@ -221,6 +221,15 @@ export class Common {
221221
const parsedJson = JSON.parse(fs.readFileSync(path, 'utf-8'));
222222
return parsedJson[property];
223223
}
224+
225+
/**
226+
* Get json file value as a string
227+
* @param filePath Path to json file
228+
*/
229+
static getJsonFileAsString(filePath: string): string {
230+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
231+
}
232+
224233
/**
225234
* Create Zip archive from folder
226235
* @param folderPath Path to folder to archive
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 path from 'path';
12
import { rte } from '../../../../helpers/constants';
23
import { DatabaseHelper } from '../../../../helpers/database';
34
import { BrowserPage } from '../../../../pageObjects';
@@ -15,6 +16,8 @@ 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');
20+
const jsonString = Common.getJsonFileAsString(jsonFilePath);
1821

1922
fixture `JSON Key verification`
2023
.meta({ type: 'smoke', rte: rte.standalone })
@@ -49,3 +52,25 @@ test('Verify that user can add key with value to any level of JSON structure', a
4952
// Check the added key contains json object with added key
5053
await t.expect(browserPage.jsonKeyValue.textContent).eql('{name:"xyz"key1:"value1"key2:{key2222:12345}}', 'The json object value not found');
5154
});
55+
test('Verify that user can add key with value to any level of JSON structure for big JSON object', async t => {
56+
keyName = Common.generateWord(10);
57+
// Add Json key with json object
58+
await browserPage.addJsonKey(keyName, jsonString, keyTTL);
59+
// Check the notification message
60+
const notification = browserPage.Toast.toastHeader.textContent;
61+
await t.expect(notification).contains('Key has been added', 'The notification not found');
62+
// Verify that user can create JSON object
63+
await t.expect(browserPage.addJsonObjectButton.exists).ok('The add Json object button not found', { timeout: 10000 });
64+
await t.expect(browserPage.jsonKeyValue.textContent).eql(jsonObjectValue, 'The json object value not found');
65+
66+
// Add key with value on the same level
67+
await browserPage.addJsonKeyOnTheSameLevel('"key1"', '"value1"');
68+
// Check the added key contains json object with added key
69+
await t.expect(browserPage.addJsonObjectButton.exists).ok('The add Json object button not found', { timeout: 10000 });
70+
await t.expect(browserPage.jsonKeyValue.textContent).eql('{name:"xyz"key1:"value1"}', 'The json object value not found');
71+
// Add key with value inside the json
72+
await browserPage.addJsonKeyOnTheSameLevel('"key2"', '{}');
73+
await browserPage.addJsonKeyInsideStructure('"key2222"', '12345');
74+
// Check the added key contains json object with added key
75+
await t.expect(browserPage.jsonKeyValue.textContent).eql('{name:"xyz"key1:"value1"key2:{key2222:12345}}', 'The json object value not found');
76+
});

0 commit comments

Comments
 (0)