@@ -6,6 +6,71 @@ const baseUrl = `http://localhost:9999${contextPath}`;
66const getTabDragHandleByTitle = ( title ) =>
77 `.chrome-tab[data-tab-title="${ title } "] .chrome-tab-drag-handle` ;
88
9+ describe ( "run query" , ( ) => {
10+ beforeEach ( ( ) => {
11+ cy . loadConsoleWithAuth ( ) ;
12+ cy . getEditorContent ( ) . should ( "be.visible" ) ;
13+ cy . clearEditor ( ) ;
14+ } ) ;
15+
16+ it ( "should correctly run query in the first line" , ( ) => {
17+ cy . typeQuery ( "select 1;\n\nselect 2;" ) ;
18+ cy . clickLine ( 1 ) ;
19+ cy . clickRun ( ) ;
20+ cy . getGridRow ( 0 ) . should ( "contain" , "1" ) ;
21+ } ) ;
22+
23+ it ( "should run the correct query when there are multiple queries in the same line" , ( ) => {
24+ cy . typeQuery (
25+ "with longseq as (\nselect * from long_sequence(100)\n-- comment"
26+ ) ;
27+ cy . typeQuery ( " select count(*) from longseq;select 1;" ) ;
28+
29+ // go to the end of second query
30+ cy . clickLine ( 4 ) ;
31+ cy . clickRun ( ) ;
32+ cy . getGridCol ( 0 ) . should ( "contain" , "1" ) ;
33+ cy . getGridRow ( 0 ) . should ( "contain" , "1" ) ;
34+
35+ // go inside the second query
36+ cy . clickLine ( 4 ) ;
37+ cy . realPress ( "ArrowLeft" ) ;
38+ cy . realPress ( "ArrowLeft" ) ;
39+ cy . clickRun ( ) ;
40+ cy . getColumnName ( 0 ) . should ( "contain" , "1" ) ;
41+ cy . getGridRow ( 0 ) . should ( "contain" , "1" ) ;
42+
43+ // go to the end of first query
44+ cy . clickLine ( 4 ) ;
45+ for ( let i = 0 ; i < 9 ; i ++ ) {
46+ cy . realPress ( "ArrowLeft" ) ;
47+ }
48+ cy . clickRun ( ) ;
49+ cy . getColumnName ( 0 ) . should ( "contain" , "count" ) ;
50+ cy . getGridRow ( 0 ) . should ( "contain" , "100" ) ;
51+
52+ // go inside the first query
53+ cy . clickLine ( 4 ) ;
54+ for ( let i = 0 ; i < 11 ; i ++ ) {
55+ cy . realPress ( "ArrowLeft" ) ;
56+ }
57+ cy . clickRun ( ) ;
58+ cy . getColumnName ( 0 ) . should ( "contain" , "count" ) ;
59+ cy . getGridRow ( 0 ) . should ( "contain" , "100" ) ;
60+ } ) ;
61+
62+ it ( "should not suggest any query for running if the cursor is in an empty line between queries" , ( ) => {
63+ cy . typeQuery ( "select 1;\n\nselect 2;" ) ;
64+ cy . getCursorQueryGlyph ( ) . should ( "be.visible" ) ;
65+
66+ cy . realPress ( "ArrowUp" ) ;
67+ cy . getCursorQueryGlyph ( ) . should ( "not.exist" ) ;
68+
69+ cy . realPress ( "ArrowUp" ) ;
70+ cy . getCursorQueryGlyph ( ) . should ( "be.visible" ) ;
71+ } ) ;
72+ } ) ;
73+
974describe ( "appendQuery" , ( ) => {
1075 const consoleConfiguration = {
1176 savedQueries : [
@@ -158,6 +223,7 @@ describe("&query URL param", () => {
158223 it ( "should not append query if it already exists in editor" , ( ) => {
159224 const query = "select x\nfrom long_sequence(1);\n\n-- a\n-- b\n-- c" ;
160225 cy . typeQuery ( query ) ;
226+ cy . clickLine ( 1 ) ;
161227 cy . clickRun ( ) ;
162228 cy . visit ( `${ baseUrl } ?query=${ encodeURIComponent ( query ) } &executeQuery=true` ) ;
163229 cy . getEditorContent ( ) . should ( "be.visible" ) ;
@@ -167,7 +233,6 @@ describe("&query URL param", () => {
167233 it ( "should append query and scroll to it" , ( ) => {
168234 cy . typeQuery ( "select x from long_sequence(1);" ) ;
169235 cy . typeQuery ( "\n" . repeat ( 20 ) ) ;
170- cy . clickRun ( ) ; // take space so that query is not visible later, save by running
171236
172237 const appendedQuery = "-- hello world" ;
173238 cy . visit ( `${ baseUrl } ?query=${ encodeURIComponent ( appendedQuery ) } ` ) ;
@@ -396,7 +461,7 @@ describe("running query with F9", () => {
396461 "select * from long_sequence(1); -- comment\nselect * from long_sequence(2);{upArrow}{rightArrow}{rightArrow}"
397462 ) ;
398463 cy . F9 ( ) ;
399- cy . getGridRows ( ) . should ( "have.length" , 2 ) ;
464+ cy . getGridRows ( ) . should ( "have.length" , 1 ) ;
400465 cy . getCursorQueryDecoration ( ) . should ( "have.length" , 1 ) ;
401466 } ) ;
402467} ) ;
@@ -487,7 +552,8 @@ describe("editor tabs", () => {
487552 } ) ;
488553} ) ;
489554
490- describe ( "editor tabs history" , ( ) => {
555+ // TODO: This test is flaky because of the IndexedDB calls. Investigate the slow response time in test environment.
556+ describe . skip ( "editor tabs history" , ( ) => {
491557 before ( ( ) => {
492558 cy . loadConsoleWithAuth ( ) ;
493559 cy . getEditorContent ( ) . should ( "be.visible" ) ;
0 commit comments