Skip to content
Snippets Groups Projects
Unverified Commit cbda131e authored by Ryan Laurie's avatar Ryan Laurie Committed by GitHub
Browse files

Combine native e2e specs (#43844)

parent 121054b2
No related branches found
No related tags found
No related merge requests found
Showing
with 957 additions and 713 deletions
import {
restore,
openNativeEditor,
openQuestionActions,
popover,
entityPickerModal,
} from "e2e/support/helpers";
describe("scenarios > native question > data reference sidebar", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("should show tables", () => {
openNativeEditor();
cy.icon("reference").click();
cy.get("[data-testid='sidebar-header-title']").findByText(
"Sample Database",
);
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("ORDERS").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(
"Confirmed Sample Company orders for a product, from a user.",
);
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("9 columns");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("QUANTITY").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Number of products bought.");
// clicking the title should navigate back
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("QUANTITY").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("ORDERS").click();
cy.get("[data-testid='sidebar-header-title']")
.findByText("Sample Database")
.click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Data Reference");
});
it("should show models", () => {
cy.createNativeQuestion(
{
name: "Native Products Model",
description: "A model of the Products table",
native: { query: "select id as renamed_id from products" },
type: "model",
},
{ visitQuestion: true },
);
// Move question to personal collection
openQuestionActions();
popover().findByTestId("move-button").click();
entityPickerModal().within(() => {
cy.findByRole("tab", { name: /Collections/ }).click();
cy.findByText("Bobby Tables's Personal Collection").click();
cy.button("Move").click();
});
openNativeEditor();
cy.icon("reference").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("2 models");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Native Products Model").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("A model of the Products table"); // description
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Bobby Tables's Personal Collection"); // collection
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("1 column");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("RENAMED_ID").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("No description");
});
});
......@@ -5,6 +5,7 @@ import {
addPostgresDatabase,
POPOVER_ELEMENT,
setTokenFeatures,
openNativeEditor,
} from "e2e/support/helpers";
const PG_DB_ID = 2;
......@@ -244,6 +245,139 @@ describe("mongo as the default database", { tags: "@mongo" }, () => {
});
});
describe("scenatios > question > native > mysql", { tags: "@external" }, () => {
const MYSQL_DB_NAME = "QA MySQL8";
beforeEach(() => {
cy.intercept("POST", "/api/card").as("createQuestion");
cy.intercept("POST", "/api/dataset").as("dataset");
restore("mysql-8");
cy.signInAsAdmin();
});
it("can write a native MySQL query with a field filter", () => {
// Write Native query that includes a filter
openNativeEditor({ databaseName: MYSQL_DB_NAME }).type(
"SELECT TOTAL, CATEGORY FROM ORDERS LEFT JOIN PRODUCTS ON ORDERS.PRODUCT_ID = PRODUCTS.ID [[WHERE PRODUCTS.ID = {{id}}]];",
{
parseSpecialCharSequences: false,
},
);
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.wait("@dataset");
cy.findByTestId("query-visualization-root").as("queryPreview");
cy.get("@queryPreview").should("be.visible").contains("Widget");
// Filter by Product ID = 1 (its category is Gizmo)
cy.findByPlaceholderText(/Id/i).click().type("1");
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.get("@queryPreview").contains("Widget").should("not.exist");
cy.get("@queryPreview").contains("Gizmo");
});
it("can save a native MySQL query", () => {
openNativeEditor({ databaseName: MYSQL_DB_NAME }).type(
"SELECT * FROM ORDERS",
);
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.wait("@dataset");
cy.findByTextEnsureVisible("SUBTOTAL");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("37.65");
// Save the query
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("Save").click();
cy.findByTestId("save-question-modal").within(() => {
cy.findByLabelText("Name").focus().type("sql count");
cy.findByText("Save").should("not.be.disabled").click();
});
cy.wait("@createQuestion");
cy.findByTextEnsureVisible("Not now").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("Save").should("not.exist");
cy.url().should("match", /\/question\/\d+-[a-z0-9-]*$/);
});
});
describe("scenarios > question > native > mongo", { tags: "@mongo" }, () => {
const MONGO_DB_NAME = "QA Mongo";
const MONGO_DB_ID = 2;
before(() => {
cy.intercept("POST", "/api/card").as("createQuestion");
cy.intercept("POST", "/api/dataset").as("dataset");
restore("mongo-5");
cy.signInAsAdmin();
cy.updatePermissionsGraph({
[ALL_USERS_GROUP]: {
[MONGO_DB_ID]: {
"view-data": "unrestricted",
"create-queries": "query-builder-and-native",
},
},
});
cy.signInAsNormalUser();
cy.visit("/");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("New").click();
// Reproduces metabase#20499 issue
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Native query").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(MONGO_DB_NAME).click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Select a table").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders").click();
});
it("can save a native MongoDB query", () => {
cy.get(".ace_content")
.should("be.visible")
.type('[ { $count: "Total" } ]', {
parseSpecialCharSequences: false,
});
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.wait("@dataset");
cy.findByTextEnsureVisible("18,760");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Save").click();
cy.findByTextEnsureVisible("Save new question");
cy.findByTestId("save-question-modal").within(modal => {
cy.findByLabelText("Name").clear().should("be.empty").type("mongo count");
cy.findByText("Save").should("not.be.disabled").click();
});
cy.wait("@createQuestion");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Not now").click();
cy.url().should("match", /\/question\/\d+-[a-z0-9-]*$/);
});
});
function startNativeQuestion() {
cy.visit("/");
cy.findByTestId("app-bar").findByText("New").click();
......
import { USER_GROUPS } from "e2e/support/cypress_data";
import { restore } from "e2e/support/helpers";
const MONGO_DB_NAME = "QA Mongo";
const MONGO_DB_ID = 2;
const { ALL_USERS_GROUP } = USER_GROUPS;
describe("scenarios > question > native > mongo", { tags: "@mongo" }, () => {
before(() => {
cy.intercept("POST", "/api/card").as("createQuestion");
cy.intercept("POST", "/api/dataset").as("dataset");
restore("mongo-5");
cy.signInAsAdmin();
cy.updatePermissionsGraph({
[ALL_USERS_GROUP]: {
[MONGO_DB_ID]: {
"view-data": "unrestricted",
"create-queries": "query-builder-and-native",
},
},
});
cy.signInAsNormalUser();
cy.visit("/");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("New").click();
// Reproduces metabase#20499 issue
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Native query").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(MONGO_DB_NAME).click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Select a table").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders").click();
});
it("can save a native MongoDB query", () => {
cy.get(".ace_content")
.should("be.visible")
.type('[ { $count: "Total" } ]', {
parseSpecialCharSequences: false,
});
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.wait("@dataset");
cy.findByTextEnsureVisible("18,760");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Save").click();
cy.findByTextEnsureVisible("Save new question");
cy.findByTestId("save-question-modal").within(modal => {
cy.findByLabelText("Name").clear().should("be.empty").type("mongo count");
cy.findByText("Save").should("not.be.disabled").click();
});
cy.wait("@createQuestion");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Not now").click();
cy.url().should("match", /\/question\/\d+-[a-z0-9-]*$/);
});
});
import { restore, openNativeEditor } from "e2e/support/helpers";
const MYSQL_DB_NAME = "QA MySQL8";
describe("scenatios > question > native > mysql", { tags: "@external" }, () => {
beforeEach(() => {
cy.intercept("POST", "/api/card").as("createQuestion");
cy.intercept("POST", "/api/dataset").as("dataset");
restore("mysql-8");
cy.signInAsAdmin();
});
it("can write a native MySQL query with a field filter", () => {
// Write Native query that includes a filter
openNativeEditor({ databaseName: MYSQL_DB_NAME }).type(
"SELECT TOTAL, CATEGORY FROM ORDERS LEFT JOIN PRODUCTS ON ORDERS.PRODUCT_ID = PRODUCTS.ID [[WHERE PRODUCTS.ID = {{id}}]];",
{
parseSpecialCharSequences: false,
},
);
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.wait("@dataset");
cy.findByTestId("query-visualization-root").as("queryPreview");
cy.get("@queryPreview").should("be.visible").contains("Widget");
// Filter by Product ID = 1 (its category is Gizmo)
cy.findByPlaceholderText(/Id/i).click().type("1");
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.get("@queryPreview").contains("Widget").should("not.exist");
cy.get("@queryPreview").contains("Gizmo");
});
it("can save a native MySQL query", () => {
openNativeEditor({ databaseName: MYSQL_DB_NAME }).type(
"SELECT * FROM ORDERS",
);
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.wait("@dataset");
cy.findByTextEnsureVisible("SUBTOTAL");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("37.65");
// Save the query
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("Save").click();
cy.findByTestId("save-question-modal").within(() => {
cy.findByLabelText("Name").focus().type("sql count");
cy.findByText("Save").should("not.be.disabled").click();
});
cy.wait("@createQuestion");
cy.findByTextEnsureVisible("Not now").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("Save").should("not.exist");
cy.url().should("match", /\/question\/\d+-[a-z0-9-]*$/);
});
});
This diff is collapsed.
import { restore, openNativeEditor, runNativeQuery } from "e2e/support/helpers";
import {
restore,
withDatabase,
adhocQuestionHash,
runNativeQuery,
openNativeEditor,
} from "e2e/support/helpers";
describe("issue 11727", { tags: "@external" }, () => {
const PG_DB_ID = 2;
const questionDetails = {
dataset_query: {
type: "native",
database: PG_DB_ID,
native: {
query: "SELECT pg_sleep(10)",
},
},
};
beforeEach(() => {
restore("postgres-12");
cy.signInAsAdmin();
cy.intercept("GET", "/api/database").as("getDatabases");
});
it("should cancel the native query via the keyboard shortcut (metabase#11727)", () => {
withDatabase(PG_DB_ID, () => {
cy.visit("/question#" + adhocQuestionHash(questionDetails));
cy.wait("@getDatabases");
runNativeQuery({ wait: false });
cy.findByText("Doing science...").should("be.visible");
cy.get("body").type("{cmd}{enter}");
cy.findByText("Here's where your results will appear").should(
"be.visible",
);
});
});
});
describe("issue 16584", () => {
beforeEach(() => {
......
......@@ -14,6 +14,8 @@ import {
filterField,
visitCollection,
popover,
entityPickerModal,
openQuestionActions,
} from "e2e/support/helpers";
describe("scenarios > question > native", () => {
......@@ -484,6 +486,81 @@ describe("no native access", { tags: ["@external", "@quarantine"] }, () => {
);
});
describe("scenarios > native question > data reference sidebar", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("should show tables", () => {
openNativeEditor();
cy.icon("reference").click();
cy.get("[data-testid='sidebar-header-title']").findByText(
"Sample Database",
);
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("ORDERS").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(
"Confirmed Sample Company orders for a product, from a user.",
);
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("9 columns");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("QUANTITY").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Number of products bought.");
// clicking the title should navigate back
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("QUANTITY").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("ORDERS").click();
cy.get("[data-testid='sidebar-header-title']")
.findByText("Sample Database")
.click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Data Reference");
});
it("should show models", () => {
cy.createNativeQuestion(
{
name: "Native Products Model",
description: "A model of the Products table",
native: { query: "select id as renamed_id from products" },
type: "model",
},
{ visitQuestion: true },
);
// Move question to personal collection
openQuestionActions();
popover().findByTestId("move-button").click();
entityPickerModal().within(() => {
cy.findByRole("tab", { name: /Collections/ }).click();
cy.findByText("Bobby Tables's Personal Collection").click();
cy.button("Move").click();
});
openNativeEditor();
cy.icon("reference").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("2 models");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Native Products Model").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("A model of the Products table"); // description
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Bobby Tables's Personal Collection"); // collection
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("1 column");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("RENAMED_ID").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("No description");
});
});
const runQuery = () => {
cy.findByTestId("native-query-editor-container").within(() => {
cy.button("Get Answer").click();
......
import {
restore,
withDatabase,
adhocQuestionHash,
runNativeQuery,
} from "e2e/support/helpers";
const PG_DB_ID = 2;
const questionDetails = {
dataset_query: {
type: "native",
database: PG_DB_ID,
native: {
query: "SELECT pg_sleep(10)",
},
},
};
describe("issue 11727", { tags: "@external" }, () => {
beforeEach(() => {
restore("postgres-12");
cy.signInAsAdmin();
cy.intercept("GET", "/api/database").as("getDatabases");
});
it("should cancel the native query via the keyboard shortcut (metabase#11727)", () => {
withDatabase(PG_DB_ID, () => {
cy.visit("/question#" + adhocQuestionHash(questionDetails));
cy.wait("@getDatabases");
runNativeQuery({ wait: false });
cy.findByText("Doing science...").should("be.visible");
cy.get("body").type("{cmd}{enter}");
cy.findByText("Here's where your results will appear").should(
"be.visible",
);
});
});
});
import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import {
restore,
visitQuestionAdhoc,
sidebar,
cartesianChartCircle,
} from "e2e/support/helpers";
const nativeQuery = `
SELECT "PRODUCTS__via__PRODUCT_ID"."CATEGORY" AS "CATEGORY",
date_trunc('month', "ORDERS"."CREATED_AT") AS "CREATED_AT",
count(*) AS "count"
FROM "ORDERS"
LEFT JOIN "PRODUCTS" "PRODUCTS__via__PRODUCT_ID"
ON "ORDERS"."PRODUCT_ID" = "PRODUCTS__via__PRODUCT_ID"."ID"
GROUP BY "PRODUCTS__via__PRODUCT_ID"."CATEGORY",
date_trunc('month', "ORDERS"."CREATED_AT")
ORDER BY "PRODUCTS__via__PRODUCT_ID"."CATEGORY" ASC,
date_trunc('month', "ORDERS"."CREATED_AT") ASC
`;
const questionDetails = {
dataset_query: {
database: SAMPLE_DB_ID,
native: {
query: nativeQuery,
},
type: "native",
},
display: "line",
};
describe("issue 12439", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
visitQuestionAdhoc(questionDetails);
});
it("should allow clicking on a legend in a native question without breaking the UI (metabase#12439)", () => {
cy.findByTestId("query-visualization-root").within(() => {
cy.findByText("Gizmo").click();
// Make sure the legends and the graph are still there
cy.findByText("Gizmo").should("be.visible");
cy.findByText("Doohickey").should("be.visible");
cartesianChartCircle();
});
// Make sure buttons are clickable
cy.findByTestId("viz-settings-button").click();
sidebar().contains("X-axis");
sidebar().contains("Y-axis");
});
});
import { restore, openNativeEditor } from "e2e/support/helpers";
describe("issue 15029", () => {
beforeEach(() => {
restore();
cy.signInAsNormalUser();
});
it("should allow dots in the variable reference (metabase#15029)", () => {
openNativeEditor().type(
"select * from products where RATING = {{number.of.stars}}",
{
parseSpecialCharSequences: false,
},
);
cy.findAllByText("Variable name").parent().findByText("number.of.stars");
});
});
import { restore, openNativeEditor } from "e2e/support/helpers";
const ORIGINAL_QUERY = "select 1 from orders";
const SELECTED_TEXT = "select 1";
const moveCursorToBeginning = "{selectall}{leftarrow}";
const highlightSelectedText = "{shift}{rightarrow}".repeat(
SELECTED_TEXT.length,
);
describe("issue 16886", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("shouldn't remove parts of the query when choosing 'Run selected text' (metabase#16886)", () => {
openNativeEditor().type(
ORIGINAL_QUERY + moveCursorToBeginning + highlightSelectedText,
{ delay: 50 },
);
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.findByTestId("scalar-value").invoke("text").should("eq", "1");
cy.get("@editor").contains(ORIGINAL_QUERY);
});
});
import { restore, openNativeEditor, runNativeQuery } from "e2e/support/helpers";
describe("issue 16914", () => {
beforeEach(() => {
restore();
cy.intercept("POST", "api/dataset").as("dataset");
cy.signInAsAdmin();
});
it("should recover visualization settings after a failed query (metabase#16914)", () => {
const FAILING_PIECE = " foo";
const highlightSelectedText = "{shift}{leftarrow}".repeat(
FAILING_PIECE.length,
);
openNativeEditor().type("SELECT 'a' as hidden, 'b' as visible");
runNativeQuery();
cy.findByTestId("viz-settings-button").click();
cy.findByTestId("sidebar-left")
.contains(/hidden/i)
.siblings("[data-testid$=hide-button]")
.click();
cy.button("Done").click();
cy.get("@editor").type(FAILING_PIECE);
runNativeQuery();
cy.get("@editor").type(
"{movetoend}" + highlightSelectedText + "{backspace}",
);
runNativeQuery();
cy.findByTestId("query-visualization-root").within(() => {
cy.findByText("Every field is hidden right now").should("not.exist");
cy.findByText("VISIBLE");
cy.findByText("HIDDEN").should("not.exist");
});
});
});
import { restore, openNativeEditor } from "e2e/support/helpers";
import { runQuery } from "../../native-filters/helpers/e2e-sql-filter-helpers";
const ORIGINAL_QUERY =
'select ID as "num", CATEGORY as "text" from PRODUCTS limit 1';
const SECTION = "select ";
const SELECTED_TEXT = "ID";
const moveCursorToBeginning = "{selectall}{leftarrow}";
const highlightSelectedText = "{shift}{rightarrow}".repeat(
SELECTED_TEXT.length,
);
const moveCursorAfterSection = "{rightarrow}".repeat(SECTION.length);
describe("issue 17060", () => {
beforeEach(() => {
cy.intercept("POST", "/api/dataset").as("dataset");
restore();
cy.signInAsAdmin();
openNativeEditor().type(ORIGINAL_QUERY);
runQuery();
cy.findByTestId("viz-settings-button").click();
cy.findByTestId("sidebar-left").within(() => {
rearrangeColumns();
});
});
it("should not render duplicated columns (metabase#17060)", () => {
cy.get("@editor").type(
moveCursorToBeginning +
moveCursorAfterSection +
highlightSelectedText +
"RATING",
{ delay: 50 },
);
runQuery();
cy.findByTestId("query-visualization-root").within(() => {
cy.findByText("num");
});
});
});
function rearrangeColumns() {
cy.findAllByTestId(/draggable-item/)
.first()
.trigger("mousedown", 0, 0, { force: true })
.trigger("mousemove", 5, 5, { force: true })
.trigger("mousemove", 0, 100, { force: true })
.trigger("mouseup", 0, 100, { force: true });
}
import { restore, openNativeEditor } from "e2e/support/helpers";
const dbName = "sqlite";
describe("issue 18148", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.addSQLiteDatabase({
name: dbName,
});
openNativeEditor();
});
it("should not offer to save the question before it is actually possible to save it (metabase#18148)", () => {
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Save").should("have.attr", "aria-disabled", "true");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Select a database").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(dbName).click();
cy.get(".ace_content").should("be.visible").type("select foo");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Save").click();
cy.findByTestId("save-question-modal").findByText("Save").should("exist");
});
});
import {
restore,
POPOVER_ELEMENT,
openNativeEditor,
} from "e2e/support/helpers";
const questionDetails = {
name: "REVIEWS SQL",
native: { query: "select REVIEWER from REVIEWS LIMIT 1" },
};
describe("issue 18418", () => {
beforeEach(() => {
cy.intercept("POST", "/api/card").as("cardCreated");
restore();
cy.signInAsAdmin();
});
it("should not show saved questions DB in native question's DB picker (metabase#18418)", () => {
cy.createNativeQuestion(questionDetails, { visitQuestion: true });
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Explore results").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Save").click();
cy.findByTestId("save-question-modal").within(modal => {
cy.findByText("Save").click();
});
cy.button("Not now").click();
openNativeEditor({ fromCurrentPage: true });
// Clicking native question's database picker usually opens a popover with a list of databases
// As default Cypress environment has only the sample database available, we expect no popup to appear
cy.get(POPOVER_ELEMENT).should("not.exist");
});
});
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { restore } from "e2e/support/helpers";
const { PRODUCTS } = SAMPLE_DATABASE;
const question = {
name: "19451",
native: {
query: "select count(*) from products where {{filter}}",
"template-tags": {
filter: {
id: "1b33304a-18ea-cc77-083a-b5225954f200",
name: "filter",
"display-name": "Filter",
type: "dimension",
dimension: ["field", PRODUCTS.ID, null],
"widget-type": "id",
default: null,
},
},
},
display: "scalar",
};
describe("issue 19451", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.createNativeQuestion(question, { visitQuestion: true });
});
it("question field filter shows all tables from a selected database (metabase#19451)", () => {
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Open Editor").click();
cy.icon("variable").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Products").click();
cy.icon("chevronleft").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Products");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("People");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Reviews");
});
});
import { restore, visitQuestion } from "e2e/support/helpers";
const questionDetails = {
name: "20044",
native: {
query: "select 1",
},
};
describe("issue 20044", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("nodata user should not see 'Explore results' (metabase#20044)", () => {
cy.createNativeQuestion(questionDetails).then(({ body: { id } }) => {
cy.signIn("nodata");
visitQuestion(id);
cy.get("[data-testid=cell-data]").contains("1");
cy.findByText("Explore results").should("not.exist");
});
});
});
import { restore, openNativeEditor } from "e2e/support/helpers";
describe("issue 20625", { tags: "@quarantine" }, () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.request("PUT", "/api/setting/native-query-autocomplete-match-style", {
value: "prefix",
});
cy.signInAsNormalUser();
cy.intercept("GET", "/api/database/*/autocomplete_suggestions**").as(
"autocomplete",
);
});
// realpress messes with cypress 13
it("should continue to request more prefix matches (metabase#20625)", () => {
openNativeEditor().type("s");
// autocomplete_suggestions?prefix=s
cy.wait("@autocomplete");
// can't use cy.type because it does not simulate the bug
cy.realPress("o");
// autocomplete_suggestions?prefix=so
cy.wait("@autocomplete");
});
});
import { restore, openNativeEditor } from "e2e/support/helpers";
describe("issue 21034", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
openNativeEditor();
cy.intercept(
"GET",
"/api/database/**/autocomplete_suggestions?**",
cy.spy().as("suggestions"),
);
});
it("should not invoke API calls for autocomplete twice in a row (metabase#18148)", () => {
cy.get(".ace_content").should("be.visible").type("p");
// Wait until another explicit autocomplete is triggered
// (slightly longer than AUTOCOMPLETE_DEBOUNCE_DURATION)
// See https://github.com/metabase/metabase/pull/20970
cy.wait(1000);
cy.get("@suggestions").its("callCount").should("equal", 1);
});
});
import { restore, modal, openNativeEditor } from "e2e/support/helpers";
describe("issue 21550", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.intercept("GET", "/api/collection/root/items?**").as("rootCollection");
cy.intercept("GET", "/api/native-query-snippet/**").as("snippet");
});
it("should not show scrollbars for very short snippet (metabase#21550)", () => {
openNativeEditor();
cy.icon("snippet").click();
cy.wait("@rootCollection");
cy.findByTestId("sidebar-content").findByText("Create a snippet").click();
modal().within(() => {
cy.findByLabelText("Enter some SQL here so you can reuse it later").type(
"select * from people",
);
cy.findByLabelText("Give your snippet a name").type("people");
cy.findByText("Save").click();
cy.wait("@rootCollection");
});
cy.findByTestId("sidebar-content").within(() => {
cy.findByText("people").realHover();
cy.icon("chevrondown").click({ force: true });
});
cy.get("pre").then($pre => {
const preWidth = $pre[0].getBoundingClientRect().width;
const clientWidth = $pre[0].clientWidth;
const BORDERS = 2; // 1px left and right
expect(clientWidth).to.be.gte(preWidth - BORDERS);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment