diff --git a/tests/e2e/pageObjects/browser-page.ts b/tests/e2e/pageObjects/browser-page.ts index cc0047482c..2ac3e231f9 100644 --- a/tests/e2e/pageObjects/browser-page.ts +++ b/tests/e2e/pageObjects/browser-page.ts @@ -164,6 +164,7 @@ export class BrowserPage { listKeyElementEditorInput = Selector('[data-testid=element-value-editor]'); stringKeyValueInput = Selector('[data-testid=string-value]'); jsonKeyValueInput = Selector('[data-mode-id=json]'); + jsonUploadInput = Selector('[data-testid=upload-input-file]'); setMemberInput = Selector('[data-testid=member-name]'); zsetMemberScoreInput = Selector('[data-testid=member-score]'); filterByPatterSearchInput = Selector('[data-testid=search-key]'); diff --git a/tests/e2e/test-data/upload-json/sample.json b/tests/e2e/test-data/upload-json/sample.json new file mode 100644 index 0000000000..f4ba6a28ea --- /dev/null +++ b/tests/e2e/test-data/upload-json/sample.json @@ -0,0 +1,32 @@ +{ + "product": "Live JSON generator", + "version": 3.1, + "releaseDate": "2014-06-25T00:00:00.000Z", + "demo": true, + "person": { + "id": 12345, + "name": "John Doe", + "phones": { + "home": "800-123-4567", + "mobile": "877-123-1234" + }, + "email": [ + "jd@example.com", + "jd@example.org" + ], + "dateOfBirth": "1980-01-02T00:00:00.000Z", + "registered": true, + "emergencyContacts": [ + { + "name": "Jane Doe", + "phone": "888-555-1212", + "relationship": "spouse" + }, + { + "name": "Justin Doe", + "phone": "877-123-1212", + "relationship": "parent" + } + ] + } +} \ No newline at end of file diff --git a/tests/e2e/tests/regression/browser/upload-json-key.e2e.ts b/tests/e2e/tests/regression/browser/upload-json-key.e2e.ts new file mode 100644 index 0000000000..c2fcb03ea2 --- /dev/null +++ b/tests/e2e/tests/regression/browser/upload-json-key.e2e.ts @@ -0,0 +1,45 @@ +import * as path from 'path'; +import { rte } from '../../../helpers/constants'; +import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database'; +import {BrowserPage, CliPage} from '../../../pageObjects'; +import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf'; +import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database'; +import {Common} from '../../../helpers/common'; + +const browserPage = new BrowserPage(); +const common = new Common(); +const cliPage = new CliPage(); + +const filePath = path.join('..', '..', '..', 'test-data', 'upload-json', 'sample.json'); +const jsonValues = ['Live JSON generator', '3.1', '"2014-06-25T00:00:00.000Z"', 'true']; +const keyName = common.generateWord(10); + +fixture `Upload json file` + .meta({ + type: 'regression', + rte: rte.standalone + }) + .page(commonUrl) + .beforeEach(async() => { + await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName); + }) + .afterEach(async() => { + await cliPage.sendCommandInCli(`DEL ${keyName}`); + await deleteStandaloneDatabaseApi(ossStandaloneConfig); + }); +// https://redislabs.atlassian.net/browse/RI-4061 +test('Verify that user can insert a JSON from .json file on the form to add a JSON key', async t => { + await t.click(browserPage.plusAddKeyButton); + await t.click(browserPage.keyTypeDropDown); + await t.click(browserPage.jsonOption); + await t.click(browserPage.addKeyNameInput); + await t.typeText(browserPage.addKeyNameInput, keyName, { replace: true, paste: true }); + await t.setFilesToUpload(browserPage.jsonUploadInput, [filePath]); + await t.click(browserPage.addKeyButton); + const notification = await browserPage.getMessageText(); + await t.expect(notification).contains('Key has been added', 'The key added notification not found'); + // Verify that user can see the JSON value populated from the file when the insert is successful. + for (const el of jsonValues) { + await t.expect(browserPage.jsonScalarValue.withText(el).exists).ok(`${el} is not visible, JSON value not correct`); + } +});