1
1
import { browser } from '@wdio/globals' ;
2
2
import { before } from 'mocha' ;
3
3
import { Workbench } from 'wdio-vscode-service' ;
4
+ import { Key } from 'webdriverio' ;
4
5
import {
5
6
checkResultsContent ,
6
7
executeFile ,
@@ -14,6 +15,14 @@ suite('Params panel testing', () => {
14
15
workbench = await browser . getWorkbench ( ) ;
15
16
} ) ;
16
17
18
+ async function escapeModal ( count : number ) {
19
+ for ( let i = 0 ; i < count ; i ++ ) {
20
+ await browser . pause ( 500 ) ;
21
+ await browser . keys ( [ Key . Escape ] ) ;
22
+ await waitUntilNotification ( browser , 'Parameter value cannot be empty.' ) ;
23
+ }
24
+ }
25
+
17
26
async function addParamWithInputBox ( ) {
18
27
await browser . executeWorkbench ( async ( vscode ) => {
19
28
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
@@ -100,10 +109,13 @@ suite('Params panel testing', () => {
100
109
await clearParams ( ) ;
101
110
102
111
await executeFile ( workbench , 'params.cypher' ) ;
112
+
113
+ await escapeModal ( 4 ) ;
114
+
103
115
await checkResultsContent ( workbench , async ( ) => {
104
116
const text = await ( await $ ( '#query-error' ) ) . getText ( ) ;
105
117
await expect ( text ) . toContain (
106
- 'Error executing query RETURN $a, $b, $`some param`, $`some-param`:\nExpected parameter(s): a, b, some param, some-param' ,
118
+ 'Error executing query RETURN $a, $b, $`some param`, $`some-param`, $a + $b; :\nExpected parameter(s): a, b, some param, some-param' ,
107
119
) ;
108
120
} ) ;
109
121
} ) ;
@@ -155,10 +167,13 @@ suite('Params panel testing', () => {
155
167
await forceDeleteParam ( 'b' ) ;
156
168
157
169
await executeFile ( workbench , 'params.cypher' ) ;
170
+
171
+ await escapeModal ( 2 ) ;
172
+
158
173
await checkResultsContent ( workbench , async ( ) => {
159
174
const text = await ( await $ ( '#query-error' ) ) . getText ( ) ;
160
175
await expect ( text ) . toContain (
161
- 'Error executing query RETURN $a, $b, $`some param`, $`some-param`:\nExpected parameter(s): a, b' ,
176
+ 'Error executing query RETURN $a, $b, $`some param`, $`some-param`, $a + $b; :\nExpected parameter(s): a, b' ,
162
177
) ;
163
178
} ) ;
164
179
} ) ;
@@ -187,11 +202,41 @@ suite('Params panel testing', () => {
187
202
// to execute the file we need to be on the user database
188
203
await forceSwitchDatabase ( 'neo4j' ) ;
189
204
await executeFile ( workbench , 'params.cypher' ) ;
205
+
206
+ await escapeModal ( 4 ) ;
207
+
190
208
await checkResultsContent ( workbench , async ( ) => {
191
209
const text = await ( await $ ( '#query-error' ) ) . getText ( ) ;
192
210
await expect ( text ) . toContain (
193
- 'Error executing query RETURN $a, $b, $`some param`, $`some-param`:\nExpected parameter(s): a, b, some param, some-param ' ,
211
+ 'Error executing query RETURN $a, $b, $`some param`, $`some-param`, $a + $b; :\nExpected parameter(s): a, b' ,
194
212
) ;
195
213
} ) ;
196
214
} ) ;
215
+
216
+ test ( 'Should trigger parameter add pop-up when running a query with an unknown parameter' , async ( ) => {
217
+ await clearParams ( ) ;
218
+ await forceAddParam ( 'a' , '1998' ) ;
219
+ await executeFile ( workbench , 'params.cypher' ) ;
220
+
221
+ // initial pop-up for param b
222
+ await browser . pause ( 1000 ) ;
223
+ await browser . keys ( [ '1' , '2' , Key . Enter ] ) ;
224
+
225
+ // initial pop-up for param `some param`
226
+ await browser . pause ( 1000 ) ;
227
+ await browser . keys ( [ 'f' , 'a' , 'l' , 's' , 'e' , Key . Enter ] ) ;
228
+
229
+ // initial pop-up for param `some-param`
230
+ await browser . pause ( 1000 ) ;
231
+ await browser . keys ( [ '5' , Key . Enter ] ) ;
232
+
233
+ await checkResultsContent ( workbench , async ( ) => {
234
+ const queryResult = await ( await $ ( '#query-result' ) ) . getText ( ) ;
235
+ await expect ( queryResult ) . toContain ( '1998' ) ;
236
+ await expect ( queryResult ) . toContain ( '12' ) ;
237
+ await expect ( queryResult ) . toContain ( 'false' ) ;
238
+ await expect ( queryResult ) . toContain ( '5' ) ;
239
+ await expect ( queryResult ) . toContain ( '2010' ) ;
240
+ } ) ;
241
+ } ) ;
197
242
} ) ;
0 commit comments