diff --git a/frontend/test/__support__/e2e/helpers/e2e-ad-hoc-question-helpers.js b/frontend/test/__support__/e2e/helpers/e2e-ad-hoc-question-helpers.js index 6b0ce9fe5df11aeb8c9d671fb7c21485d0e7030d..2ff5a272efe4365a06f15a86a9ff92ecf000d6a3 100644 --- a/frontend/test/__support__/e2e/helpers/e2e-ad-hoc-question-helpers.js +++ b/frontend/test/__support__/e2e/helpers/e2e-ad-hoc-question-helpers.js @@ -36,6 +36,28 @@ export function startNewQuestion() { cy.visit("/question/notebook#" + hash); } + +/** + * This is the query generated by clicking "New" and then choosing the SQL Query". + */ +export function startNewNativeQuestion(alias = "editor") { + const newNativeQuestionQuery = { + dataset_query: { + database: null, + native: { query: "", "template-tags": {} }, + type: "native", + }, + display: "table", + parameters: [], + visualization_settings: {}, + }; + + const hash = adhocQuestionHash(newNativeQuestionQuery); + + cy.visit("/question#" + hash); + return cy.get(".ace_content").as(alias).should("be.visible"); +} + /** * Visit any valid query in an ad-hoc manner. * diff --git a/frontend/test/metabase/scenarios/native/native_subquery.cy.spec.js b/frontend/test/metabase/scenarios/native/native_subquery.cy.spec.js index 3e0c0f5d8db5c64d07004e8f6c2d7bc6aff36d3a..784ec19a3da3cc9cba86ca9102d0097020b70a86 100644 --- a/frontend/test/metabase/scenarios/native/native_subquery.cy.spec.js +++ b/frontend/test/metabase/scenarios/native/native_subquery.cy.spec.js @@ -3,8 +3,12 @@ import { openQuestionActions, restore, visitQuestion, + startNewNativeQuestion, + runNativeQuery, } from "__support__/e2e/helpers"; +import * as SQLFilter from "../native-filters/helpers/e2e-sql-filter-helpers"; + describe("scenarios > question > native subquery", () => { beforeEach(() => { restore(); @@ -263,4 +267,31 @@ describe("scenarios > question > native subquery", () => { cy.contains("41"); }); }); + + it.skip("should be able to reference a nested question (metabase#25988)", () => { + const questionDetails = { + name: "Nested GUI question", + query: { + "source-table": "card__1", + limit: 2, + }, + }; + + cy.createQuestion(questionDetails).then( + ({ body: { id: nestedQuestionId } }) => { + const tagID = `#${nestedQuestionId}`; + + startNewNativeQuestion(); + SQLFilter.enterParameterizedQuery(`SELECT * FROM {{${tagID}`); + + cy.findByTestId("sidebar-header-title") + .invoke("text") + .should("eq", questionDetails.name); + + runNativeQuery(); + + cy.get(".cellData").should("contain", "37.65"); + }, + ); + }); });