Skip to content

Commit d52987b

Browse files
authored
Merge pull request #1750 from RedisInsight/e2e/feature/RI-4061_upload_json
E2e/feature/ri 4061 upload json
2 parents 0812da5 + c48f913 commit d52987b

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

tests/e2e/pageObjects/browser-page.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export class BrowserPage {
164164
listKeyElementEditorInput = Selector('[data-testid=element-value-editor]');
165165
stringKeyValueInput = Selector('[data-testid=string-value]');
166166
jsonKeyValueInput = Selector('[data-mode-id=json]');
167+
jsonUploadInput = Selector('[data-testid=upload-input-file]');
167168
setMemberInput = Selector('[data-testid=member-name]');
168169
zsetMemberScoreInput = Selector('[data-testid=member-score]');
169170
filterByPatterSearchInput = Selector('[data-testid=search-key]');
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"product": "Live JSON generator",
3+
"version": 3.1,
4+
"releaseDate": "2014-06-25T00:00:00.000Z",
5+
"demo": true,
6+
"person": {
7+
"id": 12345,
8+
"name": "John Doe",
9+
"phones": {
10+
"home": "800-123-4567",
11+
"mobile": "877-123-1234"
12+
},
13+
"email": [
14+
15+
16+
],
17+
"dateOfBirth": "1980-01-02T00:00:00.000Z",
18+
"registered": true,
19+
"emergencyContacts": [
20+
{
21+
"name": "Jane Doe",
22+
"phone": "888-555-1212",
23+
"relationship": "spouse"
24+
},
25+
{
26+
"name": "Justin Doe",
27+
"phone": "877-123-1212",
28+
"relationship": "parent"
29+
}
30+
]
31+
}
32+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import * as path from 'path';
2+
import { rte } from '../../../helpers/constants';
3+
import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database';
4+
import {BrowserPage, CliPage} from '../../../pageObjects';
5+
import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf';
6+
import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database';
7+
import {Common} from '../../../helpers/common';
8+
9+
const browserPage = new BrowserPage();
10+
const common = new Common();
11+
const cliPage = new CliPage();
12+
13+
const filePath = path.join('..', '..', '..', 'test-data', 'upload-json', 'sample.json');
14+
const jsonValues = ['Live JSON generator', '3.1', '"2014-06-25T00:00:00.000Z"', 'true'];
15+
const keyName = common.generateWord(10);
16+
17+
fixture `Upload json file`
18+
.meta({
19+
type: 'regression',
20+
rte: rte.standalone
21+
})
22+
.page(commonUrl)
23+
.beforeEach(async() => {
24+
await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName);
25+
})
26+
.afterEach(async() => {
27+
await cliPage.sendCommandInCli(`DEL ${keyName}`);
28+
await deleteStandaloneDatabaseApi(ossStandaloneConfig);
29+
});
30+
// https://redislabs.atlassian.net/browse/RI-4061
31+
test('Verify that user can insert a JSON from .json file on the form to add a JSON key', async t => {
32+
await t.click(browserPage.plusAddKeyButton);
33+
await t.click(browserPage.keyTypeDropDown);
34+
await t.click(browserPage.jsonOption);
35+
await t.click(browserPage.addKeyNameInput);
36+
await t.typeText(browserPage.addKeyNameInput, keyName, { replace: true, paste: true });
37+
await t.setFilesToUpload(browserPage.jsonUploadInput, [filePath]);
38+
await t.click(browserPage.addKeyButton);
39+
const notification = await browserPage.getMessageText();
40+
await t.expect(notification).contains('Key has been added', 'The key added notification not found');
41+
// Verify that user can see the JSON value populated from the file when the insert is successful.
42+
for (const el of jsonValues) {
43+
await t.expect(browserPage.jsonScalarValue.withText(el).exists).ok(`${el} is not visible, JSON value not correct`);
44+
}
45+
});

0 commit comments

Comments
 (0)