Skip to content

Commit ac6f4ad

Browse files
authored
Merge pull request #1085 from RedisInsight/e2e/enhance-command-helper-ui
E2e/enhance command helper UI
2 parents a0636ee + 10c3e41 commit ac6f4ad

File tree

4 files changed

+70
-22
lines changed

4 files changed

+70
-22
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { t } from 'testcafe';
2+
import { CliPage } from '../pageObjects';
3+
4+
const cliPage = new CliPage();
5+
6+
export class CliActions {
7+
8+
/**
9+
* Check list of commands searched
10+
* @param searchedCommand Searched command in Command Helper
11+
* @param listToCompare The list with commands to compare with opened in Command Helper
12+
*/
13+
async checkSearchedCommandInCommandHelper(searchedCommand: string, listToCompare: string[]): Promise<void> {
14+
await t.typeText(cliPage.cliHelperSearch, searchedCommand, { speed: 0.5 });
15+
//Verify results in the output
16+
const commandsCount = await cliPage.cliHelperOutputTitles.count;
17+
for (let i = 0; i < commandsCount; i++) {
18+
await t.expect(cliPage.cliHelperOutputTitles.nth(i).textContent).eql(listToCompare[i], 'Results in the output contains searched value');
19+
}
20+
}
21+
22+
/**
23+
* Check commands list
24+
* @param listToCompare The list with commands to compare with opened in Command Helper
25+
*/
26+
async checkCommandsInCommandHelper(listToCompare: string[]): Promise<void> {
27+
//Verify results in the output
28+
const commandsCount = await cliPage.cliHelperOutputTitles.count;
29+
for (let i = 0; i < commandsCount; i++) {
30+
await t.expect(cliPage.cliHelperOutputTitles.nth(i).textContent).eql(listToCompare[i], 'Results in the output not contain searched value');
31+
}
32+
}
33+
}

tests/e2e/pageObjects/cli-page.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class CliPage {
2727
commandHelperBadge = Selector('[data-testid=expand-command-helper] span');
2828
cliResizeButton = Selector('[data-test-subj=resize-btn-browser-cli]');
2929
workbenchLink = Selector('[data-test-subj=cli-workbench-page-btn]');
30+
returnToList = Selector('[data-testid=cli-helper-back-to-list-btn]');
3031
//TEXT INPUTS (also referred to as 'Text fields')
3132
cliCommandInput = Selector('[data-testid=cli-command]');
3233
cliArea = Selector('[data-testid=cli');
@@ -58,7 +59,7 @@ export class CliPage {
5859
* Select filter group type
5960
* @param groupName The group name
6061
*/
61-
async selectFilterGroupType(groupName: string): Promise<void>{
62+
async selectFilterGroupType(groupName: string): Promise<void> {
6263
await t.click(this.filterGroupTypeButton);
6364
await t.click(this.filterOptionGroupType.withExactText(groupName));
6465
}
@@ -69,7 +70,7 @@ export class CliPage {
6970
* @param amount The amount of the keys
7071
* @param keyName The name of the keys. The default value is keyName
7172
*/
72-
async addKeysFromCli(keyCommand: string, amount: number, keyName = 'keyName'): Promise<void>{
73+
async addKeysFromCli(keyCommand: string, amount: number, keyName = 'keyName'): Promise<void> {
7374
//Open CLI
7475
await t.click(this.cliExpandButton);
7576
//Add keys
@@ -83,7 +84,7 @@ export class CliPage {
8384
* Send command in Cli
8485
* @param command The command to send
8586
*/
86-
async sendCommandInCli(command: string): Promise<void>{
87+
async sendCommandInCli(command: string): Promise<void> {
8788
//Open CLI
8889
await t.click(this.cliExpandButton);
8990
await t.typeText(this.cliCommandInput, command, { paste: true });
@@ -95,7 +96,7 @@ export class CliPage {
9596
* Get command result execution
9697
* @param command The command for send in CLI
9798
*/
98-
async getSuccessCommandResultFromCli(command: string): Promise<string>{
99+
async getSuccessCommandResultFromCli(command: string): Promise<string> {
99100
//Open CLI
100101
await t.click(this.cliExpandButton);
101102
//Add keys
@@ -127,18 +128,4 @@ export class CliPage {
127128
await t.click(this.readMoreButton);
128129
await t.expect(getPageUrl()).eql(url, 'The opened page');
129130
}
130-
131-
/**
132-
* Check URL of command opened from command helper
133-
* @param searchedCommand Searched command in Command Helper
134-
* @param listToCompare The list with commands to compare with opened in Command Helper
135-
*/
136-
async checkSearchedCommandInCommandHelper(searchedCommand: string, listToCompare: string[]): Promise<void> {
137-
await t.typeText(this.cliHelperSearch, searchedCommand, { speed: 0.5 });
138-
//Verify results in the output
139-
const commandsCount = await this.cliHelperOutputTitles.count;
140-
for (let i = 0; i < commandsCount; i++) {
141-
await t.expect(this.cliHelperOutputTitles.nth(i).textContent).eql(listToCompare[i], 'Results in the output contains searched value');
142-
}
143-
}
144131
}

tests/e2e/tests/critical-path/cli/cli-command-helper.e2e.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database';
33
import { CliPage } from '../../../pageObjects';
44
import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf';
55
import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database';
6+
import { CliActions } from '../../../common-actions/cli-actions';
67

78
const cliPage = new CliPage();
9+
const cliActions = new CliActions();
810

911
const defaultHelperText = 'Enter any command in CLI or use search to see detailed information.';
1012
const COMMAND_APPEND = 'APPEND';
@@ -116,14 +118,14 @@ test
116118
//Select group from list and remember commands
117119
await cliPage.selectFilterGroupType(COMMAND_GROUP_TIMESERIES);
118120
const commandsFilterCount = await cliPage.cliHelperOutputTitles.count;
119-
const timeSeriesCommands = [];
121+
const timeSeriesCommands: string[] = [];
120122
for(let i = 0; i < commandsFilterCount; i++) {
121123
timeSeriesCommands.push(await cliPage.cliHelperOutputTitles.nth(i).textContent);
122124
}
123125
//Unselect group from list
124126
await cliPage.selectFilterGroupType(COMMAND_GROUP_TIMESERIES);
125127
//Search per part of command and check all opened commands
126-
await cliPage.checkSearchedCommandInCommandHelper(commandForSearch, timeSeriesCommands);
128+
await cliActions.checkSearchedCommandInCommandHelper(commandForSearch, timeSeriesCommands);
127129
//Check the first command documentation url
128130
await cliPage.checkURLCommand(timeSeriesCommands[0], `https://redis.io/commands/${timeSeriesCommands[0].toLowerCase()}/`);
129131
await t.switchToParentWindow();
@@ -137,14 +139,14 @@ test
137139
//Select group from list and remember commands
138140
await cliPage.selectFilterGroupType(COMMAND_GROUP_GRAPH);
139141
const commandsFilterCount = await cliPage.cliHelperOutputTitles.count;
140-
const graphCommands = [];
142+
const graphCommands: string[] = [];
141143
for(let i = 0; i < commandsFilterCount; i++) {
142144
graphCommands.push(await cliPage.cliHelperOutputTitles.nth(i).textContent);
143145
}
144146
//Unselect group from list
145147
await cliPage.selectFilterGroupType(COMMAND_GROUP_GRAPH);
146148
//Search per part of command and check all opened commands
147-
await cliPage.checkSearchedCommandInCommandHelper(commandForSearch, graphCommands);
149+
await cliActions.checkSearchedCommandInCommandHelper(commandForSearch, graphCommands);
148150
//Check the first command documentation url
149151
await cliPage.checkURLCommand(graphCommands[0], externalPageLink);
150152
await t.switchToParentWindow();

tests/e2e/tests/regression/cli/cli-command-helper.e2e.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import {
88
} from '../../../helpers/conf';
99
import { env, rte } from '../../../helpers/constants';
1010
import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database';
11+
import { CliActions } from '../../../common-actions/cli-actions';
1112

1213
const cliPage = new CliPage();
1314
const common = new Common();
15+
const cliActions = new CliActions();
1416
let filteringGroup = '';
1517
let filteringGroups: string[] = [];
1618
let commandToCheck = '';
@@ -247,3 +249,27 @@ test
247249
i++;
248250
}
249251
});
252+
test
253+
.meta({ rte: rte.standalone })('Verify that user can go back to list of commands for group in Command Helper', async t => {
254+
filteringGroup = 'Search';
255+
commandToCheck = 'FT.EXPLAIN';
256+
const commandForSearch = 'EXPLAIN';
257+
//Open Command Helper
258+
await t.click(cliPage.expandCommandHelperButton);
259+
//Select one command from the list
260+
await t.typeText(cliPage.cliHelperSearch, commandForSearch);
261+
await cliPage.selectFilterGroupType(filteringGroup);
262+
// Remember found commands
263+
const commandsFilterCount = await cliPage.cliHelperOutputTitles.count;
264+
const filteredCommands: string[] = [];
265+
for (let i = 0; i < commandsFilterCount; i++) {
266+
filteredCommands.push(await cliPage.cliHelperOutputTitles.nth(i).textContent);
267+
}
268+
// Select command
269+
await t.click(cliPage.cliHelperOutputTitles.withExactText(commandToCheck));
270+
// Click return button
271+
await t.click(cliPage.returnToList);
272+
// Check that user returned to list with filter and search applied
273+
await cliActions.checkCommandsInCommandHelper(filteredCommands);
274+
await t.expect(cliPage.returnToList.exists).notOk('Return to list button still displayed');
275+
});

0 commit comments

Comments
 (0)