Skip to content

Commit 81b5eb5

Browse files
authored
Merge pull request #2703 from RedisInsight/e2e/feature/RI-4815_portion-of-string
E2e/feature/ri 4815 portion of string
2 parents f429101 + 15bbcaa commit 81b5eb5

File tree

4 files changed

+105
-26
lines changed

4 files changed

+105
-26
lines changed

tests/e2e/common-actions/databases-actions.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,25 @@ export class DatabasesActions {
6969
}
7070
return matchedFiles;
7171
}
72+
73+
/**
74+
* Get files count by name starts from directory
75+
* @param dir The path directory of file
76+
* @param fileStarts The file name should start from
77+
*/
78+
async getFileCount(dir: string, fileStarts: string): Promise<number> {
79+
if (fs.existsSync(dir)) {
80+
const matchedFiles: string[] = [];
81+
const files = fs.readdirSync(dir);
82+
for (const file of files) {
83+
if (file.startsWith(fileStarts)) {
84+
matchedFiles.push(file);
85+
}
86+
}
87+
return matchedFiles.length;
88+
}
89+
return 0;
90+
}
7291
}
7392

7493
/**

tests/e2e/pageObjects/browser-page.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export class BrowserPage extends InstancePage {
107107
clearFilterHistoryBtn = Selector('[data-testid=clear-history-btn]');
108108
guideLinksBtn = Selector('[data-testid^=guide-button-]');
109109
backToBrowserBtn = Selector('[data-testid=back-right-panel-btn]');
110+
loadAllBtn = Selector('[data-testid=load-all-value-btn]');
111+
downloadAllValueBtn = Selector('[data-testid=download-all-value-btn]');
110112
//CONTAINERS
111113
streamGroupsContainer = Selector('[data-testid=stream-groups-container]');
112114
streamConsumersContainer = Selector('[data-testid=stream-consumers-container]');

tests/e2e/tests/web/critical-path/browser/large-data.e2e.ts

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1+
import * as fs from 'fs';
2+
import { join as joinPath } from 'path';
13
import { DatabaseHelper } from '../../../../helpers/database';
24
import { Common } from '../../../../helpers/common';
35
import { rte } from '../../../../helpers/constants';
46
import { BrowserPage } from '../../../../pageObjects';
5-
import { commonUrl, ossStandaloneConfig } from '../../../../helpers/conf';
7+
import { commonUrl, fileDownloadPath, ossStandaloneConfig } from '../../../../helpers/conf';
68
import { DatabaseAPIRequests } from '../../../../helpers/api/api-database';
79
import { APIKeyRequests } from '../../../../helpers/api/api-keys';
10+
import { StringKeyParameters } from '../../../../pageObjects/browser-page';
11+
import { DatabasesActions } from '../../../../common-actions/databases-actions';
812

913
const browserPage = new BrowserPage();
1014
const databaseHelper = new DatabaseHelper();
1115
const databaseAPIRequests = new DatabaseAPIRequests();
1216
const apiKeyRequests = new APIKeyRequests();
17+
const databasesActions = new DatabasesActions();
1318

1419
let keyName = Common.generateWord(10);
20+
let bigKeyName = Common.generateWord(10);
21+
let foundStringDownloadedFiles = 0;
22+
const downloadedFile = 'string_value';
1523

1624
fixture `Cases with large data`
1725
.meta({ type: 'critical_path', rte: rte.standalone })
@@ -46,3 +54,70 @@ test('Verify that user can see relevant information about key size', async t =>
4654
await t.expect(keySizeText).contains('KB', 'Key measure not correct');
4755
await t.expect(+keySize).gt(10, 'Key size value not correct');
4856
});
57+
test
58+
.before(async() => {
59+
await databaseHelper.acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig);
60+
})
61+
.after(async() => {
62+
// Clear and delete database
63+
await apiKeyRequests.deleteKeyByNameApi(keyName, ossStandaloneConfig.databaseName);
64+
await apiKeyRequests.deleteKeyByNameApi(bigKeyName, ossStandaloneConfig.databaseName);
65+
await databaseAPIRequests.deleteStandaloneDatabaseApi(ossStandaloneConfig);
66+
// Delete downloaded file
67+
const foundDownloadedFiles = await databasesActions.findFilesByFileStarts(fileDownloadPath, downloadedFile);
68+
fs.unlinkSync(joinPath(fileDownloadPath, foundDownloadedFiles[0]));
69+
})('Verify that user can download String key value as txt file when it has > 5000 characters', async t => {
70+
const disabledEditTooltip = 'Load the entire value to edit it';
71+
const disabledFormattersTooltip = 'Load the entire value to select a format';
72+
keyName = Common.generateWord(10);
73+
bigKeyName = Common.generateWord(10);
74+
// Create string key with 5000 characters
75+
const length = 5000;
76+
const keyValue = Common.generateWord(length);
77+
const stringKeyParameters: StringKeyParameters = {
78+
keyName: keyName,
79+
value: keyValue
80+
};
81+
const bigStringKeyParameters: StringKeyParameters = {
82+
keyName: bigKeyName,
83+
value: keyValue + 1
84+
};
85+
86+
await apiKeyRequests.addStringKeyApi(stringKeyParameters, ossStandaloneConfig);
87+
await apiKeyRequests.addStringKeyApi(bigStringKeyParameters, ossStandaloneConfig);
88+
await browserPage.reloadPage();
89+
await browserPage.openKeyDetails(keyName);
90+
await t.expect(browserPage.loadAllBtn.exists).notOk('Load All button displayed for 5000 length String key');
91+
await t.expect(browserPage.downloadAllValueBtn.exists).notOk('Download All button displayed for 5000 length String key');
92+
93+
await browserPage.openKeyDetails(bigKeyName);
94+
await t.expect(browserPage.editKeyValueButton.hasAttribute('disabled')).ok('Edit button not disabled for String > 5000');
95+
await t.expect(browserPage.formatSwitcher.hasAttribute('disabled')).ok('Formatters control not disabled for String > 5000');
96+
97+
// Verify that user can see "Load the entire value to edit it." tooltip when hovering on disabled edit button before loading all
98+
await t.hover(browserPage.editKeyValueButton.parent());
99+
await t.expect(browserPage.tooltip.textContent).eql(disabledEditTooltip, 'Edit button tooltip contains invalid message');
100+
101+
// Verify that user can see "Load the entire value to select a format." tooltip when hovering on disabled formatters button before loading all
102+
await t.hover(browserPage.formatSwitcher);
103+
await t.expect(browserPage.tooltip.textContent).eql(disabledFormattersTooltip, 'Edit button tooltip contains invalid message');
104+
105+
// Verify that user can see String key value with only 5000 characters uploaded if length is more than 5000
106+
await t.expect((await browserPage.stringKeyValueInput.textContent).length).eql(stringKeyParameters.value.length, 'String key > 5000 value is fully loaded by default');
107+
108+
await t.click(browserPage.loadAllBtn);
109+
// Verify that user can see "Load all" button for String Key with more than 5000 characters and see full value by clicking on it
110+
await t.expect((await browserPage.stringKeyValueInput.textContent).length).eql(bigStringKeyParameters.value.length, 'String key > 5000 value is not fully loaded after clicking Load All');
111+
await t.expect(browserPage.editKeyValueButton.hasAttribute('disabled')).notOk('Edit button disabled for String > 5000 which is fully loaded');
112+
await t.expect(browserPage.formatSwitcher.hasAttribute('disabled')).notOk('Formatters control disabled for String > 5000 which is fully loaded');
113+
114+
// Verify that user can see not fully loaded String key with > 5000 characters after clicking on Refresh button
115+
await t.click(browserPage.refreshKeyButton);
116+
await t.expect(browserPage.loadAllBtn.exists).ok('Load All button not displayed for 5000 length String key after Refresh');
117+
118+
// Verify that user can download String key value as txt file when it has > 5000 characters
119+
await t.click(browserPage.downloadAllValueBtn);
120+
// Verify that user can see default file name is “string_value” when downloading String key value
121+
foundStringDownloadedFiles = await databasesActions.getFileCount(fileDownloadPath, downloadedFile);
122+
await t.expect(foundStringDownloadedFiles).gt(0, 'String value file not saved');
123+
});

tests/e2e/tests/web/critical-path/monitor/save-commands.e2e.ts

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,29 @@
11
import * as fs from 'fs';
22
import * as os from 'os';
3-
import { join as joinPath } from 'path';
43
import { DatabaseHelper } from '../../../../helpers/database';
54
import { BrowserPage } from '../../../../pageObjects';
65
import {
76
commonUrl,
7+
fileDownloadPath,
88
ossStandaloneConfig
99
} from '../../../../helpers/conf';
1010
import { rte } from '../../../../helpers/constants';
1111
import { DatabaseAPIRequests } from '../../../../helpers/api/api-database';
12+
import { DatabasesActions } from '../../../../common-actions/databases-actions';
1213

1314
const browserPage = new BrowserPage();
1415
const databaseHelper = new DatabaseHelper();
1516
const databaseAPIRequests = new DatabaseAPIRequests();
17+
const databasesActions = new DatabasesActions();
1618

1719
const tempDir = os.tmpdir();
18-
let downloadedFilePath = '';
19-
20-
async function getFileDownloadPath(): Promise<string> {
21-
return joinPath(os.homedir(), 'Downloads');
22-
}
23-
24-
async function findByFileStarts(dir: string): Promise<number> {
25-
if (fs.existsSync(dir)) {
26-
const matchedFiles: string[] = [];
27-
const files = fs.readdirSync(dir);
28-
for (const file of files) {
29-
if (file.startsWith('test_standalone')) {
30-
matchedFiles.push(file);
31-
}
32-
}
33-
return matchedFiles.length;
34-
}
35-
return 0;
36-
}
20+
const fileStarts = 'test_standalone';
3721

3822
fixture `Save commands`
3923
.meta({ type: 'critical_path', rte: rte.standalone })
4024
.page(commonUrl)
4125
.beforeEach(async() => {
4226
await databaseHelper.acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig);
43-
downloadedFilePath = await getFileDownloadPath();
4427
})
4528
.afterEach(async() => {
4629
// Delete database
@@ -111,22 +94,22 @@ test('Verify the Profiler Button panel when toggle was switched to ON and user p
11194
});
11295
test('Verify that when user see the toggle is OFF - Profiler logs are not being saved', async t => {
11396
// Remember the number of files in Temp
114-
const numberOfDownloadFiles = await findByFileStarts(downloadedFilePath);
97+
const numberOfDownloadFiles = await databasesActions.getFileCount(fileDownloadPath, fileStarts);
11598

11699
// Start Monitor without Save logs
117100
await browserPage.Profiler.startMonitor();
118101
await t.wait(3000);
119102
// Check the download files
120-
await t.expect(await findByFileStarts(downloadedFilePath)).eql(numberOfDownloadFiles, 'The Profiler logs are saved');
103+
await t.expect(await databasesActions.getFileCount(fileDownloadPath, fileStarts)).eql(numberOfDownloadFiles, 'The Profiler logs are saved');
121104
});
122105
test('Verify that when user see the toggle is ON - Profiler logs are being saved', async t => {
123106
// Remember the number of files in Temp
124-
const numberOfDownloadFiles = await findByFileStarts(downloadedFilePath);
107+
const numberOfDownloadFiles = await databasesActions.getFileCount(fileDownloadPath, fileStarts);
125108

126109
// Start Monitor with Save logs
127110
await browserPage.Profiler.startMonitorWithSaveLog();
128111
// Download logs and check result
129112
await browserPage.Profiler.stopMonitor();
130113
await t.click(browserPage.Profiler.downloadLogButton);
131-
await t.expect(await findByFileStarts(downloadedFilePath)).gt(numberOfDownloadFiles, 'The Profiler logs not saved', { timeout: 5000 });
114+
await t.expect(await databasesActions.getFileCount(fileDownloadPath, fileStarts)).gt(numberOfDownloadFiles, 'The Profiler logs not saved', { timeout: 5000 });
132115
});

0 commit comments

Comments
 (0)