Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/e2e/helpers/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ export const keyTypes = [
* Adding keys of each type through the cli
* @param keyData The key data
* @param keyValue The key value
* @param keyField The key field value
*/
export async function addKeysViaCli(keyData: KeyData, keyValue?: string): Promise<void> {
export async function addKeysViaCli(keyData: KeyData, keyValue?: string, keyField?: string): Promise<void> {
await t.click(cliPage.cliExpandButton);
for (const { textType, keyName } of keyData) {
if (textType in COMMANDS_TO_CREATE_KEY) {
await t.typeText(cliPage.cliCommandInput, COMMANDS_TO_CREATE_KEY[textType](keyName, keyValue), { paste: true });
textType === 'Hash' || textType === 'Stream'
? await t.typeText(cliPage.cliCommandInput, COMMANDS_TO_CREATE_KEY[textType](keyName, keyValue, keyField), { paste: true })
: await t.typeText(cliPage.cliCommandInput, COMMANDS_TO_CREATE_KEY[textType](keyName, keyValue), { paste: true });
await t.pressKey('enter');
}
}
Expand Down
18 changes: 16 additions & 2 deletions tests/e2e/pageObjects/browser-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export class BrowserPage {
databaseNames = Selector('[data-testid^=db_name_]');
hashFieldsList = Selector('[data-testid^=hash-field-] span');
hashValuesList = Selector('[data-testid^=hash-field-value-] span');
hashField = Selector('[data-testid^=hash-field-]').nth(0);
hashFieldValue = Selector('[data-testid^=hash-field-value-]');
setMembersList = Selector('[data-testid^=set-member-value-]');
zsetMembersList = Selector('[data-testid^=zset-member-value-]');
Expand Down Expand Up @@ -468,7 +469,9 @@ export class BrowserPage {
// Scan until finding element or all keys scanned
while (true) {
await t.click(this.scanMoreButton);
if (await this.isKeyIsDisplayedInTheList(keyName) || scannedValueText === totalKeysValue) break;
if (await this.isKeyIsDisplayedInTheList(keyName) || scannedValueText === totalKeysValue) {
break;
}
}
}

Expand Down Expand Up @@ -554,6 +557,17 @@ export class BrowserPage {
await t.click(this.saveHashFieldButton);
}

/**
* Edit Hash key value from details
* @param value The value of the key
*/
async editHashKeyValue(value: string): Promise<void> {
await t
.click(this.editHashButton)
.typeText(this.hashFieldValueEditor, value, {replace: true, paste: true})
.click(this.applyButton);
}

/**
* Search by the value in the key details
* @param value The value of the search parameter
Expand Down Expand Up @@ -959,7 +973,7 @@ export type AddKeyArguments = {
fieldValueStartWith?: string,
elementStartWith?: string,
memberStartWith?: string
}
};

/**
* Keys Data parameters
Expand Down
170 changes: 170 additions & 0 deletions tests/e2e/tests/critical-path/browser/formatters.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import { Selector } from 'testcafe';
import { keyLength, rte } from '../../../helpers/constants';
import { addKeysViaCli, deleteKeysViaCli, keyTypes } from '../../../helpers/keys';
import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database';
import { BrowserPage } 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 keysData = keyTypes.map(object => ({ ...object })).filter((v, i) => i <= 6 && i !== 5);
keysData.forEach(key => key.keyName = `${key.keyName}` + '-' + `${common.generateWord(keyLength)}`);
const formatters = [{
format: 'JSON',
fromText: '{ "field": "value" }'
}, {
format: 'Msgpack',
fromText: '{ "field": "value" }',
toText: 'DF00000001A56669656C64A576616C7565'
}, {
format: 'ASCII',
fromText: '山女子水 рус ascii',
toText: '\\xe5\\xb1\\xb1\\xe5\\xa5\\xb3\\xe5\\xad\\x90\\xe6\\xb0\\xb4 \\xd1\\x80\\xd1\\x83\\xd1\\x81 ascii'
}, {
format: 'HEX',
fromText: '山女子水 рус ascii',
toText: 'e5b1b1e5a5b3e5ad90e6b0b420d180d183d181206173636969'
}];

fixture `Formatters`
.meta({
type: 'regression',
rte: rte.standalone
})
.page(commonUrl)
.beforeEach(async() => {
await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName);
// Create new keys
await addKeysViaCli(keysData);
})
.afterEach(async() => {
// Clear keys and database
await deleteKeysViaCli(keysData);
await deleteStandaloneDatabaseApi(ossStandaloneConfig);
});
test
.before(async() => {
await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName);
// Create new keys
await addKeysViaCli(keysData, formatters[0].fromText, formatters[0].fromText);
})('Verify that user can see highlighted key details in JSON format', async t => {
// Verify for Hash, List, Set, ZSet, String, Stream keys
for (let i = 0; i < keysData.length; i++) {
const valueSelector = Selector(`[data-testid^=${keysData[i].keyName.split('-')[0]}-][data-testid*=${keysData[i].data}]`);
await browserPage.openKeyDetailsByKeyName(keysData[i].keyName);
// Verify that json value not formatted with default formatter
await t.expect(valueSelector.find(browserPage.cssJsonValue).exists).notOk(`${keysData[i].textType} Value is formatted to JSON`);
await browserPage.selectFormatter('JSON');
// Verify that json value is formatted and highlighted
await t.expect(valueSelector.find(browserPage.cssJsonValue).exists).ok(`${keysData[i].textType} Value is not formatted to JSON`);
// Verify that Hash field is formatted to json and highlighted
if (keysData[i].keyName === 'hash') {
await t.expect(browserPage.hashField.find(browserPage.cssJsonValue).exists).ok('Hash field is not formatted to JSON');
}
// Verify that Stream field is formatted to json and highlighted
if (keysData[i].keyName === 'stream') {
await t.expect(Selector(browserPage.cssJsonValue).count).eql(2, 'Hash field is not formatted to JSON');
}
}
});
test('Verify that user can edit the values in the key regardless if they are valid in JSON/Msgpack format or not', async t => {
// Verify for JSON and Msgpack formatters
const invalidText = 'invalid text';
for (const formatter of formatters) {
if (formatter.format === 'JSON' || formatter.format === 'Msgpack') {
// Open key details and select formatter
await browserPage.openKeyDetails(keysData[0].keyName);
await browserPage.selectFormatter(formatter.format);
await browserPage.editHashKeyValue(invalidText);
// Verify that invalid value can be saved
await t.expect(browserPage.hashFieldValue.textContent).contains(invalidText, `Invalid ${formatter.format} value is not saved`);
await browserPage.editHashKeyValue(formatter.fromText);
// Verify that valid value can be saved
await t.expect(browserPage.hashFieldValue.innerText).contains(formatter.fromText, `Valid ${formatter.format} value is not saved`);
await t.expect(browserPage.hashFieldValue.find(browserPage.cssJsonValue).exists).ok(`Value is not formatted to ${formatter.format}`);
}
}
});
test('Verify that user can see tooltip with convertion failed message on hover when data is not valid JSON/Msgpack', async t => {
// Verify for JSON and Msgpack formatters
for (const formatter of formatters) {
if (formatter.format === 'JSON' || formatter.format === 'Msgpack') {
const failedMessage = `Failed to convert to ${formatter.format}`;
for (let i = 0; i < keysData.length; i++) {
const valueSelector = Selector(`[data-testid^=${keysData[i].keyName.split('-')[0]}-][data-testid*=${keysData[i].data}]`);
// Open key details and select formatter
await browserPage.openKeyDetailsByKeyName(keysData[i].keyName);
await browserPage.selectFormatter(formatter.format);
// Verify that not valid value is not formatted
await t.expect(valueSelector.find(browserPage.cssJsonValue).exists).notOk(`${keysData[i].textType} Value is formatted to ${formatter.format}`);
await t.hover(valueSelector, { offsetX: 5 });
// Verify that tooltip with convertion failed message displayed
await t.expect(browserPage.tooltip.textContent).contains(failedMessage, `"${failedMessage}" is not displayed in tooltip`);
}
}
}
});
test
.before(async() => {
await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName);
// Create new keys
await addKeysViaCli(keysData, formatters[1].fromText);
})('Verify that user can see highlighted key details in Msgpack format', async t => {
// Open HaSH key details
await browserPage.openKeyDetailsByKeyName(keysData[0].keyName);
// Verify that msgpack value not formatted with default formatter
await t.expect(browserPage.hashFieldValue.find(browserPage.cssJsonValue).exists).notOk('Value is formatted to Msgpack');
// Add valid msgpack in HEX format
await browserPage.selectFormatter('HEX');
await browserPage.editHashKeyValue(formatters[1].toText!);
await browserPage.selectFormatter('Msgpack');
// Verify that msgpack value is formatted and highlighted
await t.expect(browserPage.hashFieldValue.innerText).contains(formatters[1].fromText!, 'Value is not saved as msgpack');
await t.expect(browserPage.hashFieldValue.find(browserPage.cssJsonValue).exists).ok('Value is not formatted to Msgpack');
});
test
.before(async() => {
await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName);
// Create new keys
await addKeysViaCli(keysData, formatters[2].fromText);
})('Verify that user can see key details converted to ASCII/HEX format', async t => {
// Verify for ASCII and HEX formatters
for (const formatter of formatters) {
if (formatter.format === 'ASCII' || formatter.format === 'HEX') {
// Verify for Hash, List, Set, ZSet, String, Stream keys
for (let i = 0; i < keysData.length; i++) {
const valueSelector = Selector(`[data-testid^=${keysData[i].keyName.split('-')[0]}-][data-testid*=${keysData[i].data}]`);
await browserPage.openKeyDetailsByKeyName(keysData[i].keyName);
// Verify that value not formatted with default formatter
await t.expect(valueSelector.innerText).contains(formatter.fromText!, `Value is formatted as ${formatter.format} in Unicode`);
await browserPage.selectFormatter(formatter.format);
// Verify that value is formatted
await t.expect(valueSelector.innerText).contains(formatter.toText!, `Value is formatted to ${formatter.format}`);
// Verify that Hash field is formatted to ASCII/HEX
if (keysData[i].keyName === 'hash') {
await t.expect(browserPage.hashField.innerText).contains(formatter.toText!, `Hash field is not formatted to ${formatter.format}`);
}
}
}
}
});
test('Verify that user can edit value for Hash field in ASCII/HEX and convert then to another format', async t => {
// Verify for ASCII and HEX formaterrs
for (const formatter of formatters) {
if (formatter.format === 'ASCII' || formatter.format === 'HEX') {
// Open key details and select formatter
await browserPage.openKeyDetails(keysData[0].keyName);
await browserPage.selectFormatter(formatter.format);
// Add value in selected format
await browserPage.editHashKeyValue(formatter.toText!);
// Verify that value saved in selected format
await t.expect(browserPage.hashFieldValue.innerText).contains(formatter.toText!, `${formatter.format} value is not saved`);
await browserPage.selectFormatter('Unicode');
// Verify that value converted to Unicode
await t.expect(browserPage.hashFieldValue.innerText).contains(formatter.fromText!, `${formatter.format} value is not converted to Unicode`);
}
}
});
80 changes: 0 additions & 80 deletions tests/e2e/tests/critical-path/browser/json-formatter.e2e.ts

This file was deleted.