Skip to content

Commit aa3a145

Browse files
committed
add test for enhance command helper ui
1 parent 8adc81c commit aa3a145

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

tests/e2e/pageObjects/cli-page.ts

Lines changed: 18 additions & 5 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
@@ -129,7 +130,7 @@ export class CliPage {
129130
}
130131

131132
/**
132-
* Check URL of command opened from command helper
133+
* Check list of commands searched
133134
* @param searchedCommand Searched command in Command Helper
134135
* @param listToCompare The list with commands to compare with opened in Command Helper
135136
*/
@@ -141,4 +142,16 @@ export class CliPage {
141142
await t.expect(this.cliHelperOutputTitles.nth(i).textContent).eql(listToCompare[i], 'Results in the output contains searched value');
142143
}
143144
}
145+
146+
/**
147+
* Check commands list
148+
* @param listToCompare The list with commands to compare with opened in Command Helper
149+
*/
150+
async checkCommandsInCommandHelper(listToCompare: string[]): Promise<void> {
151+
//Verify results in the output
152+
const commandsCount = await this.cliHelperOutputTitles.count;
153+
for (let i = 0; i < commandsCount; i++) {
154+
await t.expect(this.cliHelperOutputTitles.nth(i).textContent).eql(listToCompare[i], 'Results in the output not contain searched value');
155+
}
156+
}
144157
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ test
116116
//Select group from list and remember commands
117117
await cliPage.selectFilterGroupType(COMMAND_GROUP_TIMESERIES);
118118
const commandsFilterCount = await cliPage.cliHelperOutputTitles.count;
119-
const timeSeriesCommands = [];
119+
const timeSeriesCommands: string[] = [];
120120
for(let i = 0; i < commandsFilterCount; i++) {
121121
timeSeriesCommands.push(await cliPage.cliHelperOutputTitles.nth(i).textContent);
122122
}
@@ -137,7 +137,7 @@ test
137137
//Select group from list and remember commands
138138
await cliPage.selectFilterGroupType(COMMAND_GROUP_GRAPH);
139139
const commandsFilterCount = await cliPage.cliHelperOutputTitles.count;
140-
const graphCommands = [];
140+
const graphCommands: string[] = [];
141141
for(let i = 0; i < commandsFilterCount; i++) {
142142
graphCommands.push(await cliPage.cliHelperOutputTitles.nth(i).textContent);
143143
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,27 @@ test
247247
i++;
248248
}
249249
});
250+
test
251+
.meta({ rte: rte.standalone })('Verify that user can go back to list of commands for group in Command Helper', async t => {
252+
filteringGroup = 'Search';
253+
commandToCheck = 'FT.EXPLAIN';
254+
const commandForSearch = 'EXPLAIN';
255+
//Open Command Helper
256+
await t.click(cliPage.expandCommandHelperButton);
257+
//Select one command from the list
258+
await t.typeText(cliPage.cliHelperSearch, commandForSearch);
259+
await cliPage.selectFilterGroupType(filteringGroup);
260+
// Remember found commands
261+
const commandsFilterCount = await cliPage.cliHelperOutputTitles.count;
262+
const filteredCommands: string[] = [];
263+
for (let i = 0; i < commandsFilterCount; i++) {
264+
filteredCommands.push(await cliPage.cliHelperOutputTitles.nth(i).textContent);
265+
}
266+
// Select command
267+
await t.click(cliPage.cliHelperOutputTitles.withExactText(commandToCheck));
268+
// Click return button
269+
await t.click(cliPage.returnToList);
270+
// Check that user returned to list with filter and search applied
271+
await cliPage.checkCommandsInCommandHelper(filteredCommands);
272+
await t.expect(cliPage.returnToList.exists).notOk('Return to list button still displayed');
273+
});

0 commit comments

Comments
 (0)