The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Metakey helper (#68987)
Romeo Van Snick0f7e8983ca67
diff --git a/e2e/support/helpers/e2e-browser-helpers.ts b/e2e/support/helpers/e2e-browser-helpers.tsindex 24753f41ab4..ea0e98e66ef 100644--- a/e2e/support/helpers/e2e-browser-helpers.ts+++ b/e2e/support/helpers/e2e-browser-helpers.ts@@ -29,4 +29,6 @@ export function readClipboard() {}const isMac = Cypress.platform === "darwin";+export const metaKey = isMac ? "Meta" : "Control";+export const holdMetaKey = isMac ? { metaKey: true } : { ctrlKey: true };diff --git a/e2e/support/helpers/e2e-codemirror-helpers.ts b/e2e/support/helpers/e2e-codemirror-helpers.tsindex 91f0342b5bd..ffcfc814001 100644--- a/e2e/support/helpers/e2e-codemirror-helpers.ts+++ b/e2e/support/helpers/e2e-codemirror-helpers.ts@@ -1,3 +1,5 @@+import { metaKey } from "./e2e-browser-helpers";+type TypeOptions = {delay?: number;focus?: boolean;@@ -30,8 +32,6 @@ export function codeMirrorHelpers<T extends object>(testId: string, extra: T) {return helpers;},selectAll() {- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";helpers.focus();cy.realPress([metaKey, "A"]);return helpers;@@ -63,9 +63,6 @@ export function codeMirrorHelpers<T extends object>(testId: string, extra: T) {return helpers;}- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";-const parts = text.replaceAll("{{", "{{}{{}").split(/(\{[^}]+\})/);function insert(text: string) {diff --git a/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.jsindex 67cd556e3c8..0b563634556 100644--- a/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js+++ b/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js@@ -702,13 +702,10 @@ describe("scenarios > question > custom column", () => {// `1+1` (3 chars) is reformatted to `1 + 1` (5 chars)H.CustomExpressionEditor.focus();- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";-H.CustomExpressionEditor.formatButton().should("be.visible");H.CustomExpressionEditor.get().get(".cm-editor")- .realPress(["Shift", metaKey, "f"]);+ .realPress(["Shift", H.metaKey, "f"]);H.CustomExpressionEditor.value().should("equal", "1 + 1");// Make sure the cursor is at the end of the expression@@ -723,10 +720,7 @@ describe("scenarios > question > custom column", () => {H.enterCustomColumnDetails({ formula: "1+" });H.CustomExpressionEditor.focus();- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";-- cy.realPress(["Shift", metaKey, "f"]);+ cy.realPress(["Shift", H.metaKey, "f"]);H.CustomExpressionEditor.value().should("equal", "1+");// Make sure the cursor is at the end of the expressiondiff --git a/e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.ts b/e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.tsindex 9cf3b4b39fc..118dab4e687 100644--- a/e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.ts+++ b/e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.ts@@ -2260,9 +2260,7 @@ LIMIT});cy.button("Create a transform").click();H.popover().findByText("Python script").click();- cy.get(".cm-clickable-token")- .should("be.visible")- .click({ metaKey: true });+ cy.get(".cm-clickable-token").should("be.visible").click(H.holdMetaKey);cy.get("@windowOpen").should("have.been.calledWithMatch",diff --git a/e2e/test/scenarios/documents/card-embed-node.cy.spec.ts b/e2e/test/scenarios/documents/card-embed-node.cy.spec.tsindex 04e9ca8f527..a0bd7201027 100644--- a/e2e/test/scenarios/documents/card-embed-node.cy.spec.ts+++ b/e2e/test/scenarios/documents/card-embed-node.cy.spec.ts@@ -544,8 +544,6 @@ describe("documents card embed node custom logic", () => {describe("navigating from cardEmbed", () => {it("should open a question in a new tab when clicking title with ctrl/meta key", () => {- const macOSX = Cypress.platform === "darwin";-H.createDocument({name: "Test Document",document: DOCUMENT_WITH_TWO_CARDS,@@ -577,15 +575,12 @@ describe("documents card embed node custom logic", () => {});// Click on the card title with ctrl/meta key- H.getDocumentCard("Orders").findByTestId("card-embed-title").click({- metaKey: macOSX,- ctrlKey: !macOSX,- });+ H.getDocumentCard("Orders")+ .findByTestId("card-embed-title")+ .click(H.holdMetaKey);});it("should open drill-through action in a new tab when clicking with ctrl/meta key", () => {- const macOSX = Cypress.platform === "darwin";-H.createDocument({name: "Test Document",document: DOCUMENT_WITH_TWO_CARDS,@@ -624,12 +619,10 @@ describe("documents card embed node custom logic", () => {});// Wait for the popover to appear and click the first action with ctrl/meta key- H.popover().within(() => {- cy.findByText("See these Orders").should("be.visible").click({- metaKey: macOSX,- ctrlKey: !macOSX,- });- });+ H.popover()+ .findByText("See these Orders")+ .should("be.visible")+ .click(H.holdMetaKey);});});diff --git a/e2e/test/scenarios/documents/documents.cy.spec.ts b/e2e/test/scenarios/documents/documents.cy.spec.tsindex 44cb1f41aed..562b8d70de6 100644--- a/e2e/test/scenarios/documents/documents.cy.spec.ts+++ b/e2e/test/scenarios/documents/documents.cy.spec.ts@@ -519,37 +519,32 @@ describe("documents", () => {});it("should handle undo/redo properly, resetting the history whenever a different document is viewed", () => {- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";H.visitDocument("@documentId");H.getDocumentCard("Orders").should("exist");H.documentContent().within(() => {const originalText = "Lorem Ipsum and some more words";const originalExact = new RegExp(`^${originalText}$`);cy.contains(originalExact).click();- cy.realPress([metaKey, "z"]);+ cy.realPress([H.metaKey, "z"]);cy.contains(originalExact);const modification = " etc.";const modifiedExact = new RegExp(`^${originalText}${modification}$`);H.addToDocument(modification, false);cy.contains(modifiedExact);- cy.realPress([metaKey, "z"]);+ cy.realPress([H.metaKey, "z"]);cy.contains(originalExact);- cy.realPress(["Shift", metaKey, "z"]);+ cy.realPress(["Shift", H.metaKey, "z"]);cy.contains(modifiedExact);- cy.realPress([metaKey, "z"]); // revert to prevent "unsaved changes" dialog+ cy.realPress([H.metaKey, "z"]); // revert to prevent "unsaved changes" dialog});H.newButton("Document").click();H.documentContent().should("have.text", "");- cy.realPress([metaKey, "z"]);+ cy.realPress([H.metaKey, "z"]);H.documentContent().should("have.text", "");});it("should not clear undo history on save", () => {- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";-const originalText = "Lorem Ipsum and some more words";const originalExact = new RegExp(`^${originalText}$`);H.visitDocument("@documentId");@@ -561,13 +556,13 @@ describe("documents", () => {H.addToDocument(modification, false);H.documentContent().contains(modifiedExact);- cy.realPress([metaKey, "s"]);+ cy.realPress([H.metaKey, "s"]);cy.findByTestId("toast-undo").findByText("Document saved").should("be.visible");- cy.realPress([metaKey, "z"]);- cy.realPress([metaKey, "z"]);+ cy.realPress([H.metaKey, "z"]);+ cy.realPress([H.metaKey, "z"]);H.documentContent().contains(originalExact);});});diff --git a/e2e/test/scenarios/metabot/native-sql-generation.cy.spec.ts b/e2e/test/scenarios/metabot/native-sql-generation.cy.spec.tsindex 7a912c4348d..a591726f827 100644--- a/e2e/test/scenarios/metabot/native-sql-generation.cy.spec.ts+++ b/e2e/test/scenarios/metabot/native-sql-generation.cy.spec.ts@@ -2,16 +2,12 @@ import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";const { H } = cy;-// Helper functions-const isMac = Cypress.platform === "darwin";-const metaKey = isMac ? "Meta" : "Control";-const { ORDERS_ID, PEOPLE_ID } = SAMPLE_DATABASE;const toggleInlineSQLPrompt = () => {H.NativeEditor.get().focus();cy.wait(250);- H.NativeEditor.get().realPress([metaKey, "Shift", "I"]);+ H.NativeEditor.get().realPress([H.metaKey, "Shift", "I"]);};const inlinePrompt = () => cy.findByTestId("metabot-inline-sql-prompt");@@ -149,7 +145,7 @@ describe("Native SQL generation", () => {cy.log("manually editing query to add reviews extracts reviews table");H.NativeEditor.get().click();- H.NativeEditor.get().realPress([metaKey, "a"]);+ H.NativeEditor.get().realPress([H.metaKey, "a"]);H.NativeEditor.get().realPress("Backspace");H.NativeEditor.type("SELECT * FROM ORDERS JOIN REVIEWS ON ORDERS.PRODUCT_ID = REVIEWS.PRODUCT_ID",@@ -348,7 +344,7 @@ describe("Native SQL generation", () => {// manually editing the editor should dismiss suggestion buttonsH.NativeEditor.get().click();- H.NativeEditor.get().realPress([metaKey, "a"]);+ H.NativeEditor.get().realPress([H.metaKey, "a"]);H.NativeEditor.get().realPress("Backspace");acceptButton().should("not.exist");rejectButton().should("not.exist");diff --git a/e2e/test/scenarios/metrics/browse.cy.spec.ts b/e2e/test/scenarios/metrics/browse.cy.spec.tsindex 7cf448e228a..b315ad7c749 100644--- a/e2e/test/scenarios/metrics/browse.cy.spec.ts+++ b/e2e/test/scenarios/metrics/browse.cy.spec.ts@@ -191,11 +191,9 @@ describe("scenarios > browse > metrics", () => {createMetrics([ORDERS_SCALAR_METRIC]);cy.visit("/browse/metrics");- const macOSX = Cypress.platform === "darwin";- findMetric(ORDERS_SCALAR_METRIC.name).should("be.visible").click({- metaKey: macOSX,- ctrlKey: !macOSX,- });+ findMetric(ORDERS_SCALAR_METRIC.name)+ .should("be.visible")+ .click(H.holdMetaKey);cy.get("@open").should("have.been.calledOnce");cy.get("@open").should(diff --git a/e2e/test/scenarios/native/native-reproductions.cy.spec.ts b/e2e/test/scenarios/native/native-reproductions.cy.spec.tsindex dca03cff175..96aaea2b970 100644--- a/e2e/test/scenarios/native/native-reproductions.cy.spec.ts+++ b/e2e/test/scenarios/native/native-reproductions.cy.spec.ts@@ -478,11 +478,7 @@ describe("issue 54799", () => {});function select(el: Cypress.Chainable, pos: Cypress.PositionType = "center") {- const macOSX = Cypress.platform === "darwin";- el.dblclick(pos, {- metaKey: macOSX,- ctrlKey: !macOSX,- });+ el.dblclick(pos, H.holdMetaKey);}it("it should be possible to select multiple ranges and run those (metabase#54799)", () => {@@ -576,9 +572,7 @@ describe("issue 56905", () => {H.NativeEditor.type("select {{ foo }}");cy.findByPlaceholderText("Foo").type("foobar", { delay: 0 });- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";- cy.realPress([metaKey, "Enter"]);+ cy.realPress([H.metaKey, "Enter"]);cy.findByTestId("query-visualization-root").findByText("foobar")@@ -760,9 +754,7 @@ describe("issue 60719", () => {describe("issue 59356", () => {function typeRunShortcut() {- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";- cy.realPress([metaKey, "Enter"]);+ cy.realPress([H.metaKey, "Enter"]);}function getLoader() {diff --git a/e2e/test/scenarios/native/native.cy.spec.js b/e2e/test/scenarios/native/native.cy.spec.jsindex 9e13d6817e7..9d29c1aaabc 100644--- a/e2e/test/scenarios/native/native.cy.spec.js+++ b/e2e/test/scenarios/native/native.cy.spec.js@@ -595,9 +595,7 @@ describe("scenarios > question > native", () => {});H.NativeEditor.focus();- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";- cy.realPress([metaKey, "Enter"]);+ cy.realPress([H.metaKey, "Enter"]);cy.wait("@dataset");@@ -615,9 +613,7 @@ describe("scenarios > question > native", () => {});H.NativeEditor.focus();- const isMac = Cypress.platform === "darwin";- const metaKey = isMac ? "Meta" : "Control";- cy.realPress(["Shift", metaKey, "f"]);+ cy.realPress(["Shift", H.metaKey, "f"]);H.NativeEditor.value().should("contain",diff --git a/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts b/e2e/test/scenarios/onboarding/home/browse.cy.spec.tsindex 0319f292afd..12cb73c458d 100644--- a/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts+++ b/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts@@ -52,11 +52,7 @@ describe("browse > models", () => {cy.stub(win, "open").as("open");});cy.visit("/browse/models");- const macOSX = Cypress.platform === "darwin";- cy.findByRole("heading", { name: "Orders Model" }).click({- metaKey: macOSX,- ctrlKey: !macOSX,- });+ cy.findByRole("heading", { name: "Orders Model" }).click(H.holdMetaKey);cy.get("@open").should("have.been.calledOnce");cy.get("@open").should(diff --git a/e2e/test/scenarios/question/notebook-link-to-data-source.cy.spec.ts b/e2e/test/scenarios/question/notebook-link-to-data-source.cy.spec.tsindex 7849d511443..ebc2bc0b25d 100644--- a/e2e/test/scenarios/question/notebook-link-to-data-source.cy.spec.ts+++ b/e2e/test/scenarios/question/notebook-link-to-data-source.cy.spec.ts@@ -24,14 +24,6 @@ const {PRODUCTS,} = SAMPLE_DATABASE;-// https://docs.cypress.io/api/cypress-api/platform-const macOSX = Cypress.platform === "darwin";--const clickConfig = {- metaKey: macOSX,- ctrlKey: !macOSX,-};-describe("scenarios > notebook > link to data source", () => {beforeEach(() => {H.restore();@@ -56,7 +48,9 @@ describe("scenarios > notebook > link to data source", () => {H.miniPicker().findByText("Reviews").click(); // close miniPickercy.log("Meta/Ctrl click on the fields picker behaves as a regular click");- H.getNotebookStep("data").findByTestId("fields-picker").click(clickConfig);+ H.getNotebookStep("data")+ .findByTestId("fields-picker")+ .click(H.holdMetaKey);H.popover().within(() => {cy.findByText("Select all").click();});@@ -83,7 +77,7 @@ describe("scenarios > notebook > link to data source", () => {`${METAKEY}+click to open in new tab`,);- H.getNotebookStep("data").findByText("Reviews").click(clickConfig);+ H.getNotebookStep("data").findByText("Reviews").click(H.holdMetaKey);cy.wait("@dataset"); // already intercepted in `visualize()`cy.log("Make sure Reviews table is rendered in a simple mode");@@ -101,7 +95,7 @@ describe("scenarios > notebook > link to data source", () => {it("should open the source table from a simple question", () => {H.visitQuestion(ORDERS_COUNT_QUESTION_ID);H.openNotebook();- H.getNotebookStep("data").findByText("Orders").click(clickConfig);+ H.getNotebookStep("data").findByText("Orders").click(H.holdMetaKey);cy.log("Make sure Orders table is rendered in a simple mode");cy.findAllByTestId("header-cell").should("contain", "Subtotal");@@ -124,7 +118,9 @@ describe("scenarios > notebook > link to data source", () => {);H.openNotebook();- H.getNotebookStep("data").findByText("Orders, Count").click(clickConfig);+ H.getNotebookStep("data")+ .findByText("Orders, Count")+ .click(H.holdMetaKey);cy.log("Make sure the source question rendered in a simple mode");cy.location("pathname").should(@@ -163,7 +159,7 @@ describe("scenarios > notebook > link to data source", () => {);H.openNotebook();- H.getNotebookStep("data").findByText(source.name).click(clickConfig);+ H.getNotebookStep("data").findByText(source.name).click(H.holdMetaKey);cy.log("Make sure the source question rendered in a simple mode");cy.location("pathname").should(@@ -197,7 +193,7 @@ describe("scenarios > notebook > link to data source", () => {);H.openNotebook();- H.getNotebookStep("data").findByText("Orders Model").click(clickConfig);+ H.getNotebookStep("data").findByText("Orders Model").click(H.holdMetaKey);cy.log("Make sure the source model is rendered in a simple mode");cy.location("pathname").should(@@ -237,7 +233,7 @@ describe("scenarios > notebook > link to data source", () => {H.openNotebook();H.getNotebookStep("data").findByText(sourceQuestion.name)- .click(clickConfig);+ .click(H.holdMetaKey);cy.log("Make sure the source model rendered in a simple mode");cy.location("pathname").should(@@ -270,7 +266,9 @@ describe("scenarios > notebook > link to data source", () => {});H.openNotebook();- H.getNotebookStep("data").findByText("Orders, Count").click(clickConfig);+ H.getNotebookStep("data")+ .findByText("Orders, Count")+ .click(H.holdMetaKey);cy.log('Make sure the source question opens in the "trash"');cy.location("pathname").should(@@ -288,7 +286,7 @@ describe("scenarios > notebook > link to data source", () => {it("should open the underlying model", () => {H.visitModel(ORDERS_MODEL_ID);H.openNotebook();- H.getNotebookStep("data").findByText("Orders Model").click(clickConfig);+ H.getNotebookStep("data").findByText("Orders Model").click(H.holdMetaKey);cy.log("Make sure the source model is rendered in a simple mode");cy.location("pathname").should(@@ -320,7 +318,7 @@ describe("scenarios > notebook > link to data source", () => {H.visitModel(id);H.openNotebook();- H.getNotebookStep("data").findByText(name).click(clickConfig);+ H.getNotebookStep("data").findByText(name).click(H.holdMetaKey);cy.log("Make sure the source model rendered in a simple mode");cy.location("pathname").should("eq", `/model/${id}-native-model`);@@ -349,7 +347,7 @@ describe("scenarios > notebook > link to data source", () => {H.openNotebook();H.getNotebookStep("data").findByText("Nested model based on a question")- .click(clickConfig);+ .click(H.holdMetaKey);cy.log("Make sure the source model is rendered in a simple mode");cy.get("@nestedModelId").then((id) => {@@ -381,7 +379,7 @@ describe("scenarios > notebook > link to data source", () => {H.openNotebook();H.getNotebookStep("data").findByText("Nested model based on a model")- .click(clickConfig);+ .click(H.holdMetaKey);cy.log("Make sure the source model is rendered in a simple mode");cy.get("@nestedModelId").then((id) => {@@ -498,7 +496,9 @@ describe("scenarios > notebook > link to data source", () => {"Showing 11 rows",);H.openNotebook();- H.getNotebookStep("data").findByText("Orders Model").click(clickConfig);+ H.getNotebookStep("data")+ .findByText("Orders Model")+ .click(H.holdMetaKey);cy.findByTestId("question-row-count").should("have.text","Showing 11 rows",@@ -521,7 +521,7 @@ describe("scenarios > notebook > link to data source", () => {H.getNotebookStep("join").findByLabelText("Right table").should("have.text", "Orders")- .click(clickConfig);+ .click(H.holdMetaKey);cy.findByTestId("question-row-count").should("have.text",@@ -625,7 +625,7 @@ describe("scenarios > notebook > link to data source", () => {H.getNotebookStep("join", { stage: 0, index: 0 }).within(() => {cy.findByLabelText("Right table").should("have.text", "Orders Model")- .click(clickConfig);+ .click(H.holdMetaKey);});cy.location("pathname").should(@@ -650,7 +650,7 @@ describe("scenarios > notebook > link to data source", () => {H.getNotebookStep("join", { stage: 0, index: 1 }).within(() => {cy.findByLabelText("Right table").should("have.text", savedQuestion.name)- .click(clickConfig);+ .click(H.holdMetaKey);});cy.location("pathname").should(@@ -674,7 +674,7 @@ describe("scenarios > notebook > link to data source", () => {H.getNotebookStep("join", { stage: 0, index: 2 }).within(() => {cy.findByLabelText("Right table").should("have.text", "Reviews")- .click(clickConfig);+ .click(H.holdMetaKey);});cy.findAllByTestId("header-cell").should("contain", "Reviewer");@@ -695,7 +695,7 @@ describe("scenarios > notebook > link to data source", () => {);H.getNotebookStep("join").findByLabelText("Change join type")- .click(clickConfig);+ .click(H.holdMetaKey);H.popover().should("contain", "Inner join");cy.log(@@ -703,7 +703,7 @@ describe("scenarios > notebook > link to data source", () => {);H.getNotebookStep("join").findByLabelText("Pick columns")- .click(clickConfig);+ .click(H.holdMetaKey);H.popover().should("contain", "Discount");cy.log(@@ -711,7 +711,7 @@ describe("scenarios > notebook > link to data source", () => {);H.getNotebookStep("join").findByLabelText("Left column")- .click(clickConfig);+ .click(H.holdMetaKey);H.popover().should("contain", "Vendor");cy.log(@@ -719,7 +719,7 @@ describe("scenarios > notebook > link to data source", () => {);H.getNotebookStep("join").findByLabelText("Change operator")- .click(clickConfig);+ .click(H.holdMetaKey);H.popover().should("contain", ">=");cy.log(@@ -727,7 +727,7 @@ describe("scenarios > notebook > link to data source", () => {);H.getNotebookStep("join").findByLabelText("Right column")- .click(clickConfig);+ .click(H.holdMetaKey);H.popover().should("contain", "Discount");cy.log(@@ -735,7 +735,7 @@ describe("scenarios > notebook > link to data source", () => {);H.getNotebookStep("join").findByLabelText("Add condition")- .click(clickConfig);+ .click(H.holdMetaKey);cy.findByTestId("new-join-condition").should("be.visible");})();});diff --git a/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/table.cy.spec.jsindex df8bb906ee1..09a0ddcc7eb 100644--- a/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js+++ b/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js@@ -114,7 +114,7 @@ describe("scenarios > visualizations > table", () => {// Cmd+click to add cells to selectiongetNonPKCells().eq(5).as("cmdClickCell");- cy.get("@cmdClickCell").click({ metaKey: true });+ cy.get("@cmdClickCell").click(H.holdMetaKey);assertSelectedCells(5);// Shift+click for range selection