Skip to content

Commit 13e988e

Browse files
Merge pull request #383 from RedisInsight/feature/e2e-cypher-tests
e2e - cypher tests
2 parents 1239adc + d7e61ef commit 13e988e

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed

redisinsight/ui/src/utils/monacoUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export const createSyntaxWidget = (text: string, shortcutText: string) => {
187187

188188
const shortcut = document.createElement('span')
189189
shortcut.classList.add('monaco-widget__shortcut')
190+
widget.setAttribute('data-testid', 'monaco-widget')
190191
shortcut.innerHTML = shortcutText
191192

192193
widget.append(title, shortcut)

tests/e2e/pageObjects/workbench-page.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ export class WorkbenchPage {
7676
preselectCreateHashIndex: Selector
7777
commandExecutionResult: Selector
7878
commandExecutionResultFailed: Selector
79+
monacoWidget: Selector
80+
cancelButton: Selector
81+
applyButton: Selector
7982

8083
constructor() {
8184
//CSS selectors
@@ -123,6 +126,8 @@ export class WorkbenchPage {
123126
this.enablementAreaPagination = Selector('[data-testid=enablement-area__pagination-popover-btn]');
124127
this.paginationPopoverButtons = Selector('[data-testid=enablement-area__pagination-popover] button');
125128
this.fullScreenButton = Selector('[data-testid=toggle-full-screen]');
129+
this.cancelButton = Selector('[data-testid=cancel-btn]');
130+
this.applyButton = Selector('[data-testid=apply-btn]');
126131
// TEXT INPUTS (also referred to as 'Text fields')
127132
this.queryInput = Selector('[data-testid=query-input-container]');
128133
this.scriptsLines = Selector('[data-testid=query-input-container] .view-lines');
@@ -157,6 +162,7 @@ export class WorkbenchPage {
157162
this.customPluginsViewType = Selector('[data-test-subj*=clients-list]');
158163
this.commandExecutionResult = Selector('[data-testid=query-common-result]');
159164
this.commandExecutionResultFailed = Selector('[data-testid=cli-output-response-fail]');
165+
this.monacoWidget = Selector('[data-testid=monaco-widget]');
160166
}
161167

162168
/**
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { rte } from '../../../helpers/constants';
2+
import { acceptLicenseTermsAndAddDatabase, deleteDatabase } from '../../../helpers/database';
3+
import { MyRedisDatabasePage, WorkbenchPage } from '../../../pageObjects';
4+
import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf';
5+
6+
const myRedisDatabasePage = new MyRedisDatabasePage();
7+
const workbenchPage = new WorkbenchPage();
8+
9+
fixture `Cypher syntax at Workbench`
10+
.meta({type: 'critical_path'})
11+
.page(commonUrl)
12+
.beforeEach(async t => {
13+
await acceptLicenseTermsAndAddDatabase(ossStandaloneConfig, ossStandaloneConfig.databaseName);
14+
//Go to Workbench page
15+
await t.click(myRedisDatabasePage.workbenchButton);
16+
})
17+
.afterEach(async() => {
18+
//Drop database
19+
await deleteDatabase(ossStandaloneConfig.databaseName);
20+
})
21+
test
22+
.meta({ rte: rte.standalone })
23+
('Verify that user can see popover Editor when clicks on “Use Cypher Syntax” popover in the Editor or “Shift+Space”', async t => {
24+
const command = 'GRAPH.QUERY graph';
25+
//Type command and put the cursor inside
26+
await t.typeText(workbenchPage.queryInput, `${command} "query"`, { replace: true });
27+
await t.pressKey('left');
28+
//Open popover editor by clicks on “Use Cypher Syntax”
29+
await t.click(workbenchPage.monacoWidget);
30+
await t.expect(await workbenchPage.queryInput.nth(1).visible).ok('The user can see opened popover Editor');
31+
//Close popover editor and re-open by shortcut
32+
await t.pressKey('esc');
33+
await t.expect(await workbenchPage.queryInput.nth(1).visible).notOk('The popover Editor is closed');
34+
await t.pressKey('shift+space');
35+
await t.expect(await workbenchPage.queryInput.nth(1).visible).ok('The user can see opened popover Editor');
36+
});
37+
test
38+
.meta({ rte: rte.standalone })
39+
('Verify that popover Editor is populated with the script that was detected between the quotes or it is blank if quotes were empty', async t => {
40+
const command = 'GRAPH.QUERY graph';
41+
const script = 'query'
42+
//Type command with empty script and open popover
43+
await t.typeText(workbenchPage.queryInput, `${command} ""`, { replace: true });
44+
await t.pressKey('left');
45+
await t.click(workbenchPage.monacoWidget);
46+
//Verify that the Editor is blank
47+
await t.expect(workbenchPage.scriptsLines.nth(1).textContent).eql('', 'The user can see blank Editor');
48+
//Close popover editor and re-open with added script
49+
await t.pressKey('esc');
50+
await t.typeText(workbenchPage.queryInput, `${command} "${script}`, { replace: true });
51+
await t.pressKey('left');
52+
await t.click(workbenchPage.monacoWidget);
53+
//Verify that the Editor is populated with the script
54+
await t.expect(workbenchPage.scriptsLines.nth(1).textContent).eql(script, 'The user can see editor populated with the script that was detected between the quotes');
55+
});
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { rte } from '../../../helpers/constants';
2+
import { acceptLicenseTermsAndAddDatabase, deleteDatabase } from '../../../helpers/database';
3+
import { MyRedisDatabasePage, WorkbenchPage } from '../../../pageObjects';
4+
import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf';
5+
6+
const myRedisDatabasePage = new MyRedisDatabasePage();
7+
const workbenchPage = new WorkbenchPage();
8+
9+
fixture `Cypher syntax at Workbench`
10+
.meta({type: 'regression'})
11+
.page(commonUrl)
12+
.beforeEach(async t => {
13+
await acceptLicenseTermsAndAddDatabase(ossStandaloneConfig, ossStandaloneConfig.databaseName);
14+
//Go to Workbench page
15+
await t.click(myRedisDatabasePage.workbenchButton);
16+
})
17+
.afterEach(async() => {
18+
//Drop database
19+
await deleteDatabase(ossStandaloneConfig.databaseName);
20+
})
21+
test
22+
.meta({ rte: rte.standalone })
23+
('Verify that user can see popover “Use Cypher Syntax” when cursor is inside the query argument double/single quotes in the GRAPH command', async t => {
24+
const command = 'GRAPH.QUERY graph';
25+
//Type command and put the cursor inside
26+
await t.typeText(workbenchPage.queryInput, `${command} "query"`, { replace: true });
27+
await t.pressKey('left');
28+
//Check that user can see popover
29+
await t.expect(await workbenchPage.monacoWidget.textContent).contains('Use Cypher Editor', 'The user can see popover Use Cypher Syntax');
30+
await t.expect(await workbenchPage.monacoWidget.textContent).contains('Shift+Space', 'The user can see shortcut for Cypher Syntax');
31+
//Verify the popover with single quotes
32+
await t.typeText(workbenchPage.queryInput, `${command} ''`, { replace: true });
33+
await t.pressKey('left');
34+
await t.expect(await workbenchPage.monacoWidget.textContent).contains('Use Cypher Editor', 'The user can see popover Use Cypher Syntax');
35+
});
36+
test
37+
.meta({ rte: rte.standalone })
38+
('Verify that when user clicks on the “X” control or use shortcut “ESC” popover Editor is closed and changes are not saved', async t => {
39+
const command = 'GRAPH.QUERY graph "query"';
40+
//Type command and open the popover editor
41+
await t.typeText(workbenchPage.queryInput, command, { replace: true });
42+
await t.pressKey('left');
43+
await t.click(workbenchPage.monacoWidget);
44+
//Do some changes in the Editor and close by “X” control
45+
await t.typeText(workbenchPage.queryInput.nth(1), 'test', { replace: true });
46+
await t.click(workbenchPage.cancelButton);
47+
//Verify that editor is closed and changes are not saved
48+
let commandAfter = await workbenchPage.scriptsLines.textContent;
49+
await t.expect(workbenchPage.queryInput.nth(1).exists).notOk('The popover Editor is closed');
50+
await t.expect(commandAfter.replace(/\s/g, ' ')).eql(command, 'The changes are not saved from the Editor');
51+
//Re-open the Editor and do some changes and close by shortcut “ESC”
52+
await t.click(workbenchPage.monacoWidget);
53+
await t.typeText(workbenchPage.queryInput.nth(1), 'test', { replace: true });
54+
await t.pressKey('esc');
55+
//Verify that editor is closed and changes are not saved
56+
commandAfter = await workbenchPage.scriptsLines.textContent;
57+
await t.expect(commandAfter.replace(/\s/g, ' ')).eql(command, 'The changes are not saved from the Editor');
58+
});
59+
test
60+
.meta({ rte: rte.standalone })
61+
('Verify that when user use shortcut “CTRL+ENTER” or clicks on the “V” control popover Editor is closed and changes are saved', async t => {
62+
let script = 'query';
63+
const command = 'GRAPH.QUERY graph';
64+
//Type command and open the popover editor
65+
await t.typeText(workbenchPage.queryInput, `${command} "${script}`, { replace: true });
66+
await t.pressKey('left');
67+
await t.click(workbenchPage.monacoWidget);
68+
//Do some changes in the Editor and click on the “V” control
69+
script = 'test';
70+
await t.pressKey('ctrl+a');
71+
await t.typeText(workbenchPage.queryInput.nth(1), script, { replace: true });
72+
await t.click(workbenchPage.applyButton);
73+
//Verify that editor is closed and changes are saved
74+
let commandAfter = await workbenchPage.scriptsLines.textContent;
75+
await t.expect(workbenchPage.queryInput.nth(1).exists).notOk('The popover Editor is closed');
76+
await t.expect(commandAfter.replace(/\s/g, ' ')).eql(`${command} "${script}"`, 'The changes are not saved from the Editor');
77+
//Re-open the Editor and do some changes and use keyboard shortcut “CTRL+ENTER”
78+
await t.click(workbenchPage.monacoWidget);
79+
script = 'test2';
80+
await t.pressKey('ctrl+a');
81+
await t.typeText(workbenchPage.queryInput.nth(1), 'test2', { paste: true, replace: true });
82+
await t.pressKey('ctrl+enter');
83+
//Verify that editor is closed and changes are not saved
84+
commandAfter = await workbenchPage.scriptsLines.textContent;
85+
await t.expect(commandAfter.replace(/\s/g, ' ')).eql(`${command} "${script}"`, 'The changes are not saved from the Editor');
86+
});

0 commit comments

Comments
 (0)