From e27c68c0ab8b0c8ca9efb09a4a95b3d0e3b6b21f Mon Sep 17 00:00:00 2001 From: argshook Date: Fri, 27 May 2022 13:41:14 +0300 Subject: [PATCH 1/2] add test for query run when cursor position is next to ending semicolon --- .../integration/console/editor.spec.js | 39 +++++++++++++++++-- .../browser-tests/cypress/support/commands.js | 14 +++---- packages/browser-tests/snapshots.js | 2 +- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/packages/browser-tests/cypress/integration/console/editor.spec.js b/packages/browser-tests/cypress/integration/console/editor.spec.js index 75962ba51..8ac32141a 100644 --- a/packages/browser-tests/cypress/integration/console/editor.spec.js +++ b/packages/browser-tests/cypress/integration/console/editor.spec.js @@ -1,6 +1,6 @@ /// -const baseUrl = "http://localhost:9999" +const baseUrl = "http://localhost:9999"; describe("appendQuery", () => { const consoleConfiguration = { @@ -128,7 +128,11 @@ describe("&query URL param", () => { it("should append and select multiline query", () => { cy.visit(baseUrl); - cy.runQuery(`select x\nfrom long_sequence(1);\n\n-- a\n-- b\n-- c\n${'{upArrow}'.repeat(5)}`); + cy.runQuery( + `select x\nfrom long_sequence(1);\n\n-- a\n-- b\n-- c\n${"{upArrow}".repeat( + 5 + )}` + ); const query = encodeURIComponent("select x+1\nfrom\nlong_sequence(1);"); cy.visit(`${baseUrl}?query=${query}&executeQuery=true`); cy.getGridRow(0).should("contain", "2").snapshot(); @@ -148,8 +152,7 @@ describe("autocomplete", () => { it("should work when tables list is empty", () => { cy.visit(baseUrl); cy.typeQuery("select * from tel"); - cy.getAutocomplete().should("not.contain", "telemetry"); - cy.getAutocomplete().should("contain", "TABLE"); + cy.getAutocomplete().should("not.be.visible"); cy.clearEditor(); cy.runQuery('create table "my_secrets" ("secret" string)'); cy.typeQuery("select * from my_"); @@ -194,3 +197,31 @@ describe("errors", () => { cy.getErrorMarker().snapshot(); }); }); + +describe("running query with F9", () => { + beforeEach(() => { + Cypress.on("uncaught:exception", (err) => { + // this error can be safely ignored + if (err.message.includes("ResizeObserver loop limit exceeded")) { + return false; + } + }); + }); + + it("should execute correct query, when text cursor is on query which has no semicolon", () => { + cy.visit(baseUrl); + cy.typeQuery("select * from long_sequence(1)").F9(); + cy.getGridRow(0).should("contain", "1"); + cy.clearEditor(); + cy.typeQuery(`select * from long_sequence(2);{leftArrow}`).F9(); + cy.wait(100).getGridRow(1).should("contain", "2"); + }); + + it("should execute correct query, when multiple queries exist", () => { + cy.visit(baseUrl); + cy.typeQuery( + "long_sequence(10) where x = 3;\n\nlong_sequence(5) limit 2;{upArrow}{upArrow}{end}{leftArrow}" + ).F9(); + cy.getGridRow(0).should("contain", "3"); + }); +}); diff --git a/packages/browser-tests/cypress/support/commands.js b/packages/browser-tests/cypress/support/commands.js index 1b2a136ac..4b052804f 100644 --- a/packages/browser-tests/cypress/support/commands.js +++ b/packages/browser-tests/cypress/support/commands.js @@ -9,13 +9,7 @@ Cypress.Commands.add("getGridViewport", () => cy.get(".qg-viewport")); Cypress.Commands.add("getGridRow", (n) => cy.get(".qg-r").eq(n)); Cypress.Commands.add("typeQuery", (query) => - cy - .get(".monaco-editor") - .first() - .click() - .focused() - .type("{ctrl}a") - .type(`${query}`) + cy.get(".monaco-editor").first().click().focused().type("{ctrl}a").type(query) ); Cypress.Commands.add("runQuery", (query) => { @@ -43,3 +37,9 @@ Cypress.Commands.add("getAutocomplete", () => ); Cypress.Commands.add("getErrorMarker", () => cy.get(".squiggly-error")); + +Cypress.Commands.add("F9", () => + cy.getEditor().trigger("keydown", { + keyCode: 120, + }) +); diff --git a/packages/browser-tests/snapshots.js b/packages/browser-tests/snapshots.js index c3aac4751..6f25782c5 100644 --- a/packages/browser-tests/snapshots.js +++ b/packages/browser-tests/snapshots.js @@ -1,5 +1,5 @@ module.exports = { - "__version": "9.5.1", + "__version": "9.6.1", "questdb grid": { "works": { "1": "
\n
\n
1
\n
\n
\n
2
\n
\n
\n
3
\n
\n
\n
4
\n
\n
\n
5
\n
\n
\n
6
\n
\n
\n
7
\n
\n
\n
8
\n
\n
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n
102
\n
\n
\n
103
\n
\n
\n
104
\n
\n
\n
105
\n
\n
\n
106
\n
\n
\n
107
\n
\n
\n
108
\n
\n
\n
109
\n
\n
\n
110
\n
\n
\n
111
\n
\n
\n
112
\n
\n
\n
113
\n
\n
\n
114
\n
\n
\n
115
\n
\n
\n
116
\n
\n
\n
117
\n
\n
\n
118
\n
\n
\n
119
\n
\n
\n
120
\n
\n
\n
121
\n
\n
\n
122
\n
\n
\n
123
\n
\n
\n
124
\n
\n
\n
125
\n
\n
\n
126
\n
\n
\n
127
\n
\n
\n
128
\n
\n
", From ec08c16f334f62daca9651f39ac522d35a8d8df3 Mon Sep 17 00:00:00 2001 From: argshook Date: Fri, 27 May 2022 14:04:32 +0300 Subject: [PATCH 2/2] one more case without second semicolon --- .../browser-tests/cypress/integration/console/editor.spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/browser-tests/cypress/integration/console/editor.spec.js b/packages/browser-tests/cypress/integration/console/editor.spec.js index 8ac32141a..152e4ad17 100644 --- a/packages/browser-tests/cypress/integration/console/editor.spec.js +++ b/packages/browser-tests/cypress/integration/console/editor.spec.js @@ -223,5 +223,10 @@ describe("running query with F9", () => { "long_sequence(10) where x = 3;\n\nlong_sequence(5) limit 2;{upArrow}{upArrow}{end}{leftArrow}" ).F9(); cy.getGridRow(0).should("contain", "3"); + cy.clearEditor(); + cy.typeQuery( + "long_sequence(10) where x = 3;\n\nlong_sequence(5) limit 2{upArrow}{upArrow}{end}{leftArrow}" + ).F9(); + cy.getGridRow(0).should("contain", "3"); }); });