Skip to content

Commit f86a2f2

Browse files
authored
Merge pull request #1188 from RedisInsight/e2e/feature/RI-3507-workbench-group
Group Mode e2e tests
2 parents ee4e7fd + aa23d27 commit f86a2f2

File tree

3 files changed

+80
-3
lines changed

3 files changed

+80
-3
lines changed

redisinsight/ui/src/components/query-card/QueryCardHeader/QueryCardHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ const QueryCardHeader = (props: Props) => {
232232
aria-label="Copy query"
233233
className="copy-btn"
234234
onClick={(event: React.MouseEvent) => handleCopy(event, query || '')}
235+
data-testid="copy-command"
235236
/>
236237
</div>
237238
</EuiFlexItem>

tests/e2e/pageObjects/workbench-page.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export class WorkbenchPage {
1111
cssTableViewTypeOption = '[data-testid=view-type-selected-Plugin-redisearch__redisearch]';
1212
cssMonacoCommandPaletteLine = '[aria-label="Command Palette"]';
1313
cssQueryTextResult = '[data-testid=query-cli-result]';
14+
cssWorkbenchCommandInHistory = '[data-testid=wb-command]';
15+
cssWorkbenchCommandResultInHistory = '[data-testid=wb-command-result]';
1416
cssQueryTableResult = '[data-testid^=query-table-result-]';
1517
cssQueryPluginResult = '[data-testid^=query-table-result-]';
1618
queryGraphContainer = '[data-testid=query-graph-container]';
@@ -57,6 +59,8 @@ export class WorkbenchPage {
5759
showSalesPerRegiomButton = Selector('[data-testid="preselect-Show all sales per region"]');
5860
queryCardNoModuleButton = Selector('[data-testid=query-card-no-module-button] a');
5961
rawModeBtn = Selector('[data-testid="btn-change-mode"]');
62+
groupMode = Selector('[data-testid=btn-change-group-mode]');
63+
copyCommand = Selector('[data-testid=copy-command]');
6064
//ICONS
6165
noCommandHistoryIcon = Selector('[data-testid=wb_no-results__icon]');
6266
//LINKS
@@ -97,6 +101,8 @@ export class WorkbenchPage {
97101
runButtonToolTip = Selector('[data-testid=run-query-tooltip]');
98102
loadedCommand = Selector('[class=euiLoadingContent__singleLine]');
99103
runButtonSpinner = Selector('[data-testid=loading-spinner]');
104+
workbenchCommandInHistory = Selector(this.cssWorkbenchCommandInHistory);
105+
workbenchCommandResultInHistory = Selector(this.cssWorkbenchCommandInHistory);
100106
//MONACO ELEMENTS
101107
monacoCommandDetails = Selector('div.suggest-details-container');
102108
monacoCloseCommandDetails = Selector('span.codicon-close');
@@ -166,13 +172,14 @@ export class WorkbenchPage {
166172
* Check the last command and result in workbench
167173
* @param command The command to check
168174
* @param result The result to check
175+
* @param childNum Indicator which command result need to check
169176
*/
170-
async checkWorkbenchCommandResult(command: string, result: string): Promise<void> {
177+
async checkWorkbenchCommandResult(command: string, result: string, childNum = 0): Promise<void> {
171178
//Compare the command with executed command
172-
const actualCommand = await this.queryCardContainer.nth(0).find(this.cssQueryCardCommand).textContent;
179+
const actualCommand = await this.queryCardContainer.nth(childNum).find(this.cssQueryCardCommand).textContent;
173180
await t.expect(actualCommand).eql(command);
174181
//Compare the command result with executed command
175-
const actualCommandResult = await this.queryCardContainer.nth(0).find(this.cssQueryTextResult).textContent;
182+
const actualCommandResult = await this.queryCardContainer.nth(childNum).find(this.cssQueryTextResult).textContent;
176183
await t.expect(actualCommandResult).eql(result);
177184
}
178185
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { Selector } from 'testcafe';
2+
import { rte } from '../../../helpers/constants';
3+
import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database';
4+
import { MyRedisDatabasePage, WorkbenchPage } from '../../../pageObjects';
5+
import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf';
6+
import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database';
7+
8+
const myRedisDatabasePage = new MyRedisDatabasePage();
9+
const workbenchPage = new WorkbenchPage();
10+
const counter = 7;
11+
const command = 'info';
12+
const commands = ['set key test', 'get key', 'del key'];
13+
const commandsResult = ['OK', 'test', '1'];
14+
const commandsNumber = commands.length;
15+
const commandsString = commands.join('\n');
16+
17+
fixture `Workbench Group Mode`
18+
.meta({ rte: rte.standalone, type: 'regression' })
19+
.page(commonUrl)
20+
.beforeEach(async t => {
21+
await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName);
22+
//Go to Workbench page
23+
await t.click(myRedisDatabasePage.workbenchButton);
24+
})
25+
.afterEach(async() => {
26+
//Delete database
27+
await deleteStandaloneDatabaseApi(ossStandaloneConfig);
28+
});
29+
test('Verify that user can run the commands from the Editor in the group mode', async t => {
30+
await t.click(workbenchPage.groupMode);
31+
// Verify that user can run a command with quantifier and see results in group(10 info)
32+
await workbenchPage.sendCommandInWorkbench(`${counter} ${command}`);
33+
// Verify that user can see number of total commands in group, success commands, number of failed commands in header summary in Workbench
34+
await t.expect(workbenchPage.queryCardCommand.textContent).eql(`${counter} Command(s) - ${counter} success, 0 error(s)`, 'Not valid summary');
35+
// Verify that user can see full list of commands with results run in group
36+
await t.expect(workbenchPage.queryTextResult.find(workbenchPage.cssWorkbenchCommandInHistory).withText(`> ${command}`).count).eql(counter, 'Number of commands is not correct');
37+
await t.expect(workbenchPage.queryTextResult.find(workbenchPage.cssWorkbenchCommandResultInHistory).count).eql(counter, 'Number of command result is not correct');
38+
// Verify that if the only one command is executed in group, the result will be displayed as for group mode
39+
await workbenchPage.sendCommandInWorkbench(`${command}`);
40+
await t.expect(workbenchPage.queryCardCommand.textContent).eql('1 Command(s) - 1 success, 0 error(s)', 'Not valid summary for 1 command');
41+
// Verify that user can use keyboard shortcut Ctrl+Shift+G to enable the group mode
42+
await t.click(workbenchPage.queryInput);
43+
await t.pressKey('shift+ctrl+g');
44+
await workbenchPage.sendCommandInWorkbench(commandsString);
45+
await t.expect(workbenchPage.queryCardCommand.textContent).notEql(`${commandsNumber} Command(s) - ${commandsNumber} success, 0 error(s)`, 'Commands are sent in groups');
46+
for (let i = 0; i++; i < commandsNumber) {
47+
await workbenchPage.checkWorkbenchCommandResult(command[i], commandsResult[i], i);
48+
}
49+
});
50+
// Skip due to testcafe doesn't work with clipboard buffer. Need to add client function to check this test
51+
test.skip('Verify that when user clicks on copy icon for group result, all commands are copied', async t => {
52+
await t.click(workbenchPage.groupMode);
53+
await workbenchPage.sendCommandInWorkbench(`${commandsString}`); // 3 commands are sent in group mode
54+
// Copy commands from group result
55+
await t.click(workbenchPage.copyCommand);
56+
await t.rightClick(workbenchPage.queryInputScriptArea);
57+
await t.click(Selector('span').withAttribute('aria-label', 'Paste'));
58+
await t.pressKey('ctrl+enter');
59+
await t.expect(workbenchPage.queryCardCommand.textContent).eql(`${commandsNumber} Command(s) - ${commandsNumber} success, 0 error(s)`, 'Not valid summary');
60+
});
61+
test('Verify that user can see group results in full mode', async t => {
62+
await t.click(workbenchPage.groupMode);
63+
await workbenchPage.sendCommandInWorkbench(`${commandsString}`); // 3 commands are sent in group mode
64+
// Open full mode
65+
await t.click(workbenchPage.fullScreenButton);
66+
await t.expect(workbenchPage.queryCardCommand.textContent).eql(`${commandsNumber} Command(s) - ${commandsNumber} success, 0 error(s)`, 'Not valid summary');
67+
await t.expect(workbenchPage.queryTextResult.find(workbenchPage.cssWorkbenchCommandInHistory).withText('> ').count).eql(commandsNumber, 'Number of commands is not correct');
68+
await t.expect(workbenchPage.queryTextResult.find(workbenchPage.cssWorkbenchCommandResultInHistory).count).eql(commandsNumber, 'Number of command result is not correct');
69+
});

0 commit comments

Comments
 (0)