Skip to content

Commit 22921d9

Browse files
committed
updates for test
1 parent 2230d09 commit 22921d9

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

tests/e2e/helpers/common.ts

Lines changed: 1 addition & 9 deletions
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 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

@@ -222,14 +222,6 @@ export class Common {
222222
return parsedJson[property];
223223
}
224224

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-
233225
/**
234226
* Create Zip archive from folder
235227
* @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: 5 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,8 @@ 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 });
859859
await t.click(this.applyButton);
860860
}
861861

@@ -868,7 +868,7 @@ export class BrowserPage extends InstancePage {
868868
await t.click(this.expandJsonObject);
869869
}
870870
await t.click(this.editJsonObjectButton);
871-
await t.typeText(this.jsonValueInput, jsonStructure, { replace: true, paste: true });
871+
await t.typeText(this.jsonValueInput, jsonStructure, { paste: true });
872872
await t.click(this.applyEditButton);
873873
}
874874

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import * as path from 'path';
22
import { rte } from '../../../../helpers/constants';
33
import { DatabaseHelper } from '../../../../helpers/database';
44
import { BrowserPage } from '../../../../pageObjects';
@@ -17,7 +17,6 @@ const keyTTL = '2147476121';
1717
const value = '{"name":"xyz"}';
1818
const jsonObjectValue = '{name:"xyz"}';
1919
const jsonFilePath = path.join('..', '..', '..', '..', 'test-data', 'big-json', 'big-json.json');
20-
const jsonString = Common.getJsonFileAsString(jsonFilePath);
2120

2221
fixture `JSON Key verification`
2322
.meta({ type: 'smoke', rte: rte.standalone })
@@ -55,15 +54,18 @@ test('Verify that user can add key with value to any level of JSON structure', a
5554
test('Verify that user can add key with value to any level of JSON structure for big JSON object', async t => {
5655
keyName = Common.generateWord(10);
5756
// Add Json key with json object
58-
await browserPage.addJsonKey(keyName, jsonString, keyTTL);
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);
5964
// Check the notification message
6065
const notification = browserPage.Toast.toastHeader.textContent;
6166
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-
6667
// Add key with value on the same level
68+
await t.debug()
6769
await browserPage.addJsonKeyOnTheSameLevel('"key1"', '"value1"');
6870
// Check the added key contains json object with added key
6971
await t.expect(browserPage.addJsonObjectButton.exists).ok('The add Json object button not found', { timeout: 10000 });

0 commit comments

Comments
 (0)