Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Consolidate dashboard virtual cards loading and question (#83852)

Nemanja Glumac8c9c7d900872
diff --git a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js
index 8e86e4be7c1..79e3e2118fb 100644
--- a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js
@@ -995,21 +995,31 @@ describe("should not redirect users to other pages when linking an entity (metab
const TEST_QUESTION_NAME = "Question#35037";
beforeEach(() => {
+ H.resetSnowplow();
H.restore();
cy.signInAsAdmin();
- cy.intercept("GET", "/api/search?q=*").as("search");
+ H.enableTracking();
cy.intercept("GET", "/api/activity/recents?*").as("recentViews");
});
- it("should not redirect users to recent item", () => {
+ afterEach(() => {
+ H.expectNoBadSnowplowEvents();
+ });
+
+ it("should add link cards without redirecting users to recent or search items", () => {
+ H.createNativeQuestion({
+ name: TEST_QUESTION_NAME,
+ native: { query: "SELECT 1" },
+ });
H.visitDashboard(ORDERS_DASHBOARD_ID);
H.editDashboard();
- cy.url().then((url) => {
- cy.wrap(url).as("originUrl");
+ cy.location("pathname").then((originPath) => {
+ cy.wrap(originPath).as("originPath");
});
- cy.icon("link").click();
+ cy.log("link a recent item");
+ cy.findByLabelText("Add a link or iframe").click();
H.popover().findByText("Link").click();
cy.wait("@recentViews");
@@ -1017,29 +1027,13 @@ describe("should not redirect users to other pages when linking an entity (metab
cy.findByText(TEST_DASHBOARD_NAME).click();
});
- cy.url().then((currentURL) => {
- cy.get("@originUrl").should("eq", currentURL);
- });
-
+ cy.findAllByTestId("entity-edit-display-link")
+ .should("have.length", 1)
+ .and("contain", TEST_DASHBOARD_NAME);
cy.findByTestId("recents-list-container").should("not.exist");
+ assertOriginPath();
- cy.findByTestId("entity-edit-display-link")
- .findByText(TEST_DASHBOARD_NAME)
- .should("exist");
- });
-
- it("should not redirect users to search item", () => {
- H.createNativeQuestion({
- name: TEST_QUESTION_NAME,
- native: { query: "SELECT 1" },
- });
- H.visitDashboard(ORDERS_DASHBOARD_ID);
- H.editDashboard();
-
- cy.url().then((url) => {
- cy.wrap(url).as("originUrl");
- });
-
+ cy.log("link a search item");
cy.icon("link").click();
H.popover().findByText("Link").click();
cy.findByTestId("custom-edit-text-link")
@@ -1049,16 +1043,29 @@ describe("should not redirect users to other pages when linking an entity (metab
cy.findByText(TEST_QUESTION_NAME).click();
});
- cy.url().then((currentURL) => {
- cy.get("@originUrl").should("eq", currentURL);
- });
-
+ cy.findAllByTestId("entity-edit-display-link")
+ .should("have.length", 2)
+ .and("contain", TEST_QUESTION_NAME);
cy.findByTestId("search-results-list").should("not.exist");
+ assertOriginPath();
- cy.findByTestId("entity-edit-display-link")
- .findByText(TEST_QUESTION_NAME)
- .should("exist");
+ // A blocked in-app navigation opens a leave confirmation modal, which
+ // prevents the save
+ H.saveDashboard();
+ cy.findAllByTestId("entity-view-display-link")
+ .should("have.length", 2)
+ .and("contain", TEST_DASHBOARD_NAME)
+ .and("contain", TEST_QUESTION_NAME);
+ assertOriginPath();
+
+ H.expectUnstructuredSnowplowEvent({ event: "new_link_card_created" }, 2);
});
+
+ function assertOriginPath() {
+ cy.get("@originPath").then((originPath) => {
+ cy.location("pathname").should("eq", originPath);
+ });
+ }
});
describe("issue 42165", () => {
@@ -1159,16 +1166,13 @@ describe("issue 47170", () => {
},
);
+ // Keep the first dashboard loading so that navigating away cancels its fetch
cy.intercept(
- {
- method: "GET",
- url: "/api/dashboard/*",
- middleware: true,
- },
+ { method: "GET", pathname: `/api/dashboard/${ORDERS_DASHBOARD_ID}` },
(req) => {
- req.continue(
- (res) => new Promise((resolve) => setTimeout(resolve, 1000)),
- );
+ req.on("response", (res) => {
+ res.setDelay(10_000);
+ });
},
);
});
@@ -1177,18 +1181,29 @@ describe("issue 47170", () => {
cy.visit(`/dashboard/${ORDERS_DASHBOARD_ID}`);
H.appBar().button("Toggle sidebar").click();
+ H.navigationSidebar().findByText("Dashboard A").should("be.visible");
+ H.main().findByTestId("dashboard-header-skeleton").should("be.visible");
H.navigationSidebar().findByText("Dashboard A").click();
H.main().within(() => {
- cy.findByText("Something’s gone wrong").should("not.exist");
cy.findByText("Dashboard A").should("be.visible");
+ cy.findByText("Something’s gone wrong").should("not.exist");
});
});
+});
+
+describe("issue 51524", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
it("should show legible dark mode colors in fullscreen mode (metabase#51524)", () => {
+ cy.intercept("PUT", "/api/setting/color-scheme").as("saveColorScheme");
cy.visit("/account/profile");
cy.findByDisplayValue("Use system default").click();
H.popover().findByText("Dark").click();
+ cy.wait("@saveColorScheme");
cy.visit(`/dashboard/${ORDERS_DASHBOARD_ID}`);
H.dashboardHeader().findByLabelText("Move, trash, and more…").click();
@@ -1395,6 +1410,7 @@ describe("issue 44937", () => {
cy.findByText("Our analytics").click();
cy.findByText("Orders").click();
});
+ H.getDashboardCards().should("have.length", 1);
H.createNewTab();
@@ -1504,14 +1520,14 @@ describe("issue 62170", () => {
},
},
}).then(({ body: { dashboard_id } }) => {
- cy.visit(`/dashboard/${dashboard_id}#refresh=${REFRESH_PERIOD}`);
-
cy.intercept("GET", `/api/dashboard/${dashboard_id}*`).as(
"dashboardLoad",
);
cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
"cardDataRefresh",
);
+
+ cy.visit(`/dashboard/${dashboard_id}#refresh=${REFRESH_PERIOD}`);
});
// Wait for initial dashboard load
@@ -1523,8 +1539,6 @@ describe("issue 62170", () => {
cy.findByText("Orders Count").should("be.visible");
});
- cy.wait(REFRESH_PERIOD * 1000);
-
// Verify card data was refreshed
cy.wait("@cardDataRefresh");
diff --git a/e2e/test/scenarios/dashboard/dashboard-tenant-question-picker.cy.spec.ts b/e2e/test/scenarios/dashboard/dashboard-tenant-question-picker.cy.spec.ts
new file mode 100644
index 00000000000..8031d05d64c
--- /dev/null
+++ b/e2e/test/scenarios/dashboard/dashboard-tenant-question-picker.cy.spec.ts
@@ -0,0 +1,225 @@
+const { H } = cy;
+
+import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
+import { JWT_SHARED_SECRET } from "e2e/support/helpers/e2e-jwt-helpers";
+import type { Collection, Dashboard, Tenant, User } from "metabase-types/api";
+
+const { ORDERS_ID } = SAMPLE_DATABASE;
+
+const TENANT_USER = {
+ first_name: "acme",
+ last_name: "user",
+ email: "[email protected]",
+ "@tenant": "acme",
+};
+
+const loginAsTenantUser = (returnTo: string) => {
+ cy.task<string>("signJwt", {
+ payload: TENANT_USER,
+ secret: JWT_SHARED_SECRET,
+ }).then((key) =>
+ cy.visit(`/auth/sso?return_to=${encodeURIComponent(returnTo)}&jwt=${key}`),
+ );
+};
+
+describe("scenarios > dashboard > tenant question picker", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ H.activateToken("pro-self-hosted");
+
+ cy.request("PUT", "/api/setting", {
+ "jwt-attribute-email": "email",
+ "jwt-attribute-firstname": "first_name",
+ "jwt-attribute-lastname": "last_name",
+ "jwt-enabled": true,
+ "jwt-identity-provider-uri": "localhost:4000",
+ "jwt-shared-secret": JWT_SHARED_SECRET,
+ "jwt-user-provisioning-enabled?": true,
+ "use-tenants": true,
+ });
+
+ cy.request("POST", "/api/ee/tenant", {
+ name: "Acme",
+ slug: "acme",
+ })
+ .its("body")
+ .as("tenant");
+
+ H.createSharedTenantCollection("Finance");
+ H.createSharedTenantCollection("Marketing");
+
+ cy.get<Tenant>("@tenant")
+ .then(({ tenant_collection_id }) =>
+ H.createCollection({
+ name: "Tenant questions",
+ parent_id: tenant_collection_id,
+ }),
+ )
+ .its("body")
+ .as("tenantCollection");
+
+ cy.get<Collection>("@tenantCollection").then((tenantCollection) =>
+ H.createQuestion({
+ name: "Tenant orders",
+ collection_id: tenantCollection.id,
+ query: { "source-table": ORDERS_ID },
+ }),
+ );
+ });
+
+ it("lets admins add questions from tenant-specific collections (EMB-2312)", () => {
+ cy.get<Tenant>("@tenant")
+ .then(({ tenant_collection_id }) =>
+ H.createDashboard({
+ name: "Tenant dashboard",
+ collection_id: tenant_collection_id,
+ }),
+ )
+ .its("body")
+ .as("tenantDashboard");
+
+ H.createDashboard({ name: "Our analytics dashboard" })
+ .its("body")
+ .as("rootDashboard");
+
+ cy.log("from the dashboard's tenant-specific collection");
+ cy.get<Dashboard>("@tenantDashboard").then(({ id }) => {
+ H.visitDashboard(id);
+ });
+ H.editDashboard();
+ H.openQuestionsSidebar();
+
+ H.sidebar()
+ .findByTestId("breadcrumbs")
+ .should("contain", "Acme")
+ .and("not.contain", "Unknown");
+
+ H.sidebar().findByText("Tenant questions").click();
+ H.sidebar().findByText("Tenant orders").click();
+
+ H.getDashboardCards()
+ .should("have.length", 1)
+ .and("contain", "Tenant orders");
+ H.saveDashboard();
+
+ // Tenant collections and Our analytics are separate top-level entries
+ cy.log("by browsing from Our analytics");
+ cy.get<Dashboard>("@rootDashboard").then(({ id }) => {
+ H.visitDashboard(id);
+ });
+ H.editDashboard();
+ H.openQuestionsSidebar();
+
+ H.sidebar()
+ .findByTestId("breadcrumbs")
+ .should("contain", "Collections")
+ .and("contain", "Our analytics");
+
+ H.sidebar().findByTestId("breadcrumbs").findByText("Collections").click();
+
+ H.sidebar().findByText("Our analytics").should("be.visible");
+ H.sidebar().findByText("Shared collections").should("be.visible");
+ H.sidebar().findByText("Tenant collections").click();
+ H.sidebar().findByText("Acme").click();
+ H.sidebar().findByText("Tenant questions").click();
+ H.sidebar().findByText("Tenant orders").click();
+
+ H.getDashboardCards()
+ .should("have.length", 1)
+ .and("contain", "Tenant orders");
+ });
+
+ it("shows tenant users a flattened collection tree (EMB-2312)", () => {
+ cy.get<Collection>("@tenantCollection")
+ .then(({ id }) =>
+ H.createDashboard({
+ name: "Tenant dashboard",
+ collection_id: id,
+ }),
+ )
+ .its("body")
+ .as("tenantDashboard");
+
+ // Tenant users do not know what is a 'Tenant-specific collection' or 'Shared collection'.
+ // Only show a flattened structure for them, with "Our data" being their tenant collection.
+ cy.log("from a dashboard in the tenant collection");
+ cy.get<Dashboard>("@tenantDashboard").then(({ id }) => {
+ loginAsTenantUser(`/dashboard/${id}`);
+ });
+ H.editDashboard();
+ H.openQuestionsSidebar();
+
+ H.sidebar()
+ .findByTestId("breadcrumbs")
+ .should("contain", "Collections")
+ .and("contain", "Our data");
+
+ H.sidebar().findByTestId("breadcrumbs").findByText("Collections").click();
+
+ H.sidebar().findByText("Our data").should("be.visible");
+ H.sidebar().findByText("Finance").should("be.visible");
+ H.sidebar().findByText("Marketing").should("be.visible");
+ H.sidebar().findByText("Our analytics").should("not.exist");
+ H.sidebar().findByText("Shared collections").should("not.exist");
+ H.sidebar().findByText("Tenant collections").should("not.exist");
+
+ // The API omits 'Our analytics' when tenant users cannot read it, but it still
+ // returns their personal collection. Show that collection directly under the
+ // synthetic collections level instead of adding another 'collections' folder.
+ cy.log("from a dashboard in the personal collection");
+ cy.request<User>("GET", "/api/user/current").its("body").as("tenantUser");
+
+ cy.get<User>("@tenantUser")
+ .then(({ personal_collection_id }) => {
+ if (personal_collection_id == null) {
+ throw new Error("Tenant user has no personal collection");
+ }
+
+ return H.createDashboard({
+ name: "Personal dashboard",
+ collection_id: personal_collection_id,
+ });
+ })
+ .its("body")
+ .as("personalDashboard");
+
+ cy.intercept({
+ method: "GET",
+ pathname: "/api/collection/tree",
+ query: {
+ namespace: "shared-tenant-collection",
+ "exclude-archived": "true",
+ },
+ }).as("sharedTenantCollections");
+
+ cy.get<Dashboard>("@personalDashboard").then(({ id }) => {
+ H.visitDashboard(id);
+ });
+ H.editDashboard();
+ H.openQuestionsSidebar();
+
+ cy.wait("@sharedTenantCollections");
+
+ H.sidebar()
+ .findByTestId("breadcrumbs")
+ .should("contain", "Collections")
+ .and("contain", "My personal collection");
+
+ H.sidebar().findByTestId("breadcrumbs").findByText("Collections").click();
+
+ H.sidebar()
+ .findByRole("menuitem", { name: "My personal collection" })
+ .should("be.visible");
+
+ // There should not be a second nested "Collections" folder.
+ H.sidebar()
+ .findByTestId("breadcrumbs")
+ .findAllByText("Collections")
+ .should("have.length", 1);
+
+ H.sidebar()
+ .findByRole("menuitem", { name: "Collections" })
+ .should("not.exist");
+ });
+});
diff --git a/e2e/test/scenarios/dashboard/dashboard-tenant-specific-question-picker.cy.spec.ts b/e2e/test/scenarios/dashboard/dashboard-tenant-specific-question-picker.cy.spec.ts
deleted file mode 100644
index e143beee72c..00000000000
--- a/e2e/test/scenarios/dashboard/dashboard-tenant-specific-question-picker.cy.spec.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-const { H } = cy;
-
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-import type { Collection, Dashboard, Tenant } from "metabase-types/api";
-
-const { ORDERS_ID } = SAMPLE_DATABASE;
-
-describe("scenarios > dashboard > admins using tenant-specific question picker", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.activateToken("pro-self-hosted");
- H.updateSetting("use-tenants", true);
-
- cy.request("POST", "/api/ee/tenant", {
- name: "Acme",
- slug: "acme",
- })
- .its("body")
- .as("tenant");
-
- cy.get<Tenant>("@tenant")
- .then(({ tenant_collection_id }) =>
- H.createCollection({
- name: "Tenant questions",
- parent_id: tenant_collection_id,
- }),
- )
- .its("body")
- .as("tenantCollection");
-
- cy.get<Collection>("@tenantCollection").then((tenantCollection) =>
- H.createQuestion({
- name: "Tenant orders",
- collection_id: tenantCollection.id,
- query: { "source-table": ORDERS_ID },
- }),
- );
- });
-
- it("allows adding questions from the dashboard's tenant-specific collection (EMB-2312)", () => {
- cy.get<Tenant>("@tenant")
- .then(({ tenant_collection_id }) =>
- H.createDashboard({
- name: "Tenant dashboard",
- collection_id: tenant_collection_id,
- }),
- )
- .its("body")
- .as("dashboard");
-
- cy.get<Dashboard>("@dashboard").then(({ id }) => {
- H.visitDashboard(id);
- H.editDashboard();
- H.openQuestionsSidebar();
-
- H.sidebar()
- .findByTestId("breadcrumbs")
- .should("contain", "Acme")
- .and("not.contain", "Unknown");
-
- H.sidebar().findByText("Tenant questions").click();
- H.sidebar().findByText("Tenant orders").click();
-
- H.getDashboardCards()
- .should("have.length", 1)
- .and("contain", "Tenant orders");
- });
- });
-
- // Verify that Tenant collections and Our analytics are separate top-level entries.
- it("allows browsing into a tenant-specific collection from Our Analytics (EMB-2312)", () => {
- H.createDashboard({ name: "Our analytics dashboard" })
- .its("body")
- .as("dashboard");
-
- cy.get<Dashboard>("@dashboard").then(({ id }) => {
- H.visitDashboard(id);
- H.editDashboard();
- H.openQuestionsSidebar();
-
- H.sidebar()
- .findByTestId("breadcrumbs")
- .should("contain", "Collections")
- .and("contain", "Our analytics");
-
- H.sidebar().findByTestId("breadcrumbs").findByText("Collections").click();
-
- H.sidebar().findByText("Tenant collections").click();
- H.sidebar().findByText("Acme").click();
- H.sidebar().findByText("Tenant questions").click();
- H.sidebar().findByText("Tenant orders").click();
-
- H.getDashboardCards()
- .should("have.length", 1)
- .and("contain", "Tenant orders");
- });
- });
-});
diff --git a/e2e/test/scenarios/dashboard/dashboard-tenant-user-question-picker.cy.spec.ts b/e2e/test/scenarios/dashboard/dashboard-tenant-user-question-picker.cy.spec.ts
deleted file mode 100644
index ca48af76fa2..00000000000
--- a/e2e/test/scenarios/dashboard/dashboard-tenant-user-question-picker.cy.spec.ts
+++ /dev/null
@@ -1,159 +0,0 @@
-const { H } = cy;
-
-import { JWT_SHARED_SECRET } from "e2e/support/helpers/e2e-jwt-helpers";
-import type { Collection, Dashboard, Tenant, User } from "metabase-types/api";
-
-const TENANT_USER = {
- first_name: "acme",
- last_name: "user",
- email: "[email protected]",
- "@tenant": "acme",
-};
-
-const loginAsTenantUser = (returnTo: string) => {
- cy.task<string>("signJwt", {
- payload: TENANT_USER,
- secret: JWT_SHARED_SECRET,
- }).then((key) =>
- cy.visit(`/auth/sso?return_to=${encodeURIComponent(returnTo)}&jwt=${key}`),
- );
-};
-
-describe("scenarios > dashboard > tenant users using question picker", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.activateToken("pro-self-hosted");
-
- cy.request("PUT", "/api/setting", {
- "jwt-attribute-email": "email",
- "jwt-attribute-firstname": "first_name",
- "jwt-attribute-lastname": "last_name",
- "jwt-enabled": true,
- "jwt-identity-provider-uri": "localhost:4000",
- "jwt-shared-secret": JWT_SHARED_SECRET,
- "jwt-user-provisioning-enabled?": true,
- "use-tenants": true,
- });
-
- cy.request("POST", "/api/ee/tenant", {
- name: "Acme",
- slug: "acme",
- })
- .its("body")
- .as("tenant");
-
- H.createSharedTenantCollection("Finance")
- .its("body")
- .as("financeCollection");
-
- H.createSharedTenantCollection("Marketing")
- .its("body")
- .as("marketingCollection");
-
- cy.get<Tenant>("@tenant")
- .then(({ tenant_collection_id }) =>
- H.createCollection({
- name: "Tenant questions",
- parent_id: tenant_collection_id,
- }),
- )
- .its("body")
- .as("tenantCollection");
- });
-
- // Tenant users do not know what is a 'Tenant-specific collection' or 'Shared collection'.
- // Only show a flattened structure for them, with "Our data" being their tenant collection.
- it("shows flattened tenant collections without grouping by namespaces (EMB-2312)", () => {
- cy.get<Collection>("@tenantCollection")
- .then(({ id }) =>
- H.createDashboard({
- name: "Tenant dashboard",
- collection_id: id,
- }),
- )
- .its("body")
- .as("dashboard");
-
- cy.get<Dashboard>("@dashboard").then(({ id }) => {
- loginAsTenantUser(`/dashboard/${id}`);
- H.editDashboard();
- H.openQuestionsSidebar();
-
- H.sidebar()
- .findByTestId("breadcrumbs")
- .should("contain", "Collections")
- .and("contain", "Our data");
-
- H.sidebar().findByTestId("breadcrumbs").findByText("Collections").click();
-
- H.sidebar().findByText("Our data").should("be.visible");
- H.sidebar().findByText("Finance").should("be.visible");
- H.sidebar().findByText("Marketing").should("be.visible");
- H.sidebar().findByText("Our analytics").should("not.exist");
- H.sidebar().findByText("Shared collections").should("not.exist");
- H.sidebar().findByText("Tenant collections").should("not.exist");
- });
- });
-
- // The API omits 'Our analytics' when tenant users cannot read it, but it still
- // returns their personal collection. Show that collection directly under the
- // synthetic collections level instead of adding another 'collections' folder.
- it("shows the personal collection under top-level collections (EMB-2312)", () => {
- loginAsTenantUser("/");
-
- cy.request<User>("GET", "/api/user/current").its("body").as("tenantUser");
-
- cy.get<User>("@tenantUser")
- .then(({ personal_collection_id }) => {
- if (personal_collection_id == null) {
- throw new Error("Tenant user has no personal collection");
- }
-
- return H.createDashboard({
- name: "Personal dashboard",
- collection_id: personal_collection_id,
- });
- })
- .its("body")
- .as("personalDashboard");
-
- cy.get<Dashboard>("@personalDashboard").then(({ id }) => {
- cy.intercept({
- method: "GET",
- pathname: "/api/collection/tree",
- query: {
- namespace: "shared-tenant-collection",
- "exclude-archived": "true",
- },
- }).as("sharedTenantCollections");
-
- H.visitDashboard(id);
- H.editDashboard();
- H.openQuestionsSidebar();
-
- cy.wait("@sharedTenantCollections");
-
- H.sidebar()
- .findByTestId("breadcrumbs")
- .should("contain", "Collections")
- .and("contain", "My personal collection");
-
- H.sidebar().findByTestId("breadcrumbs").findByText("Collections").click();
-
- H.sidebar()
- .findByRole("menuitem", { name: "My personal collection" })
- .should("be.visible");
-
- // There should not be a second nested "Collections" folder.
- H.sidebar()
- .findByTestId("breadcrumbs")
- .findAllByText("Collections")
- .should("have.length", 1);
-
- H.sidebar()
- .findByRole("menuitem", { name: "Collections" })
- .should("not.exist");
- });
- });
-});
diff --git a/e2e/test/scenarios/dashboard/dashboard.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard.cy.spec.js
index b88093bada1..05146d0934c 100644
--- a/e2e/test/scenarios/dashboard/dashboard.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashboard.cy.spec.js
@@ -182,9 +182,11 @@ describe("scenarios > dashboard", () => {
});
context("add a question (dashboard card)", () => {
- it("should be possible via questions sidebar", () => {
- H.editDashboard();
- H.openQuestionsSidebar();
+ it("should be possible via questions sidebar from an empty state (metabase#29450)", () => {
+ cy.findByTestId("dashboard-empty-state").within(() => {
+ cy.findByText("This dashboard is empty").should("be.visible");
+ cy.findByText("Add a chart").click();
+ });
cy.log("The list of saved questions");
H.sidebar().findByText("Orders, Count").click();
@@ -228,19 +230,14 @@ describe("scenarios > dashboard", () => {
};
H.createCollection(collectionInRoot);
const myPersonalCollection = "My personal collection";
- H.createDashboard({
- name: "dashboard in root collection",
- }).then(({ body: { id: dashboardId } }) => {
- H.visitDashboard(dashboardId);
- });
cy.log("assert that personal collections are not visible");
H.editDashboard();
H.openQuestionsSidebar();
H.sidebar().within(() => {
cy.findByText("Our analytics").should("be.visible");
- cy.findByText(myPersonalCollection).should("not.exist");
cy.findByText(collectionInRoot.name).should("be.visible");
+ cy.findByText(myPersonalCollection).should("not.exist");
});
cy.log("Move dashboard to a personal collection");
@@ -274,27 +271,11 @@ describe("scenarios > dashboard", () => {
H.openQuestionsSidebar();
H.sidebar().within(() => {
cy.findByText("Our analytics").should("be.visible");
- cy.findByText(myPersonalCollection).should("not.exist");
cy.findByText(collectionInRoot.name).should("be.visible");
+ cy.findByText(myPersonalCollection).should("not.exist");
});
});
- it("should save a dashboard after adding a saved question from an empty state (metabase#29450)", () => {
- cy.findByTestId("dashboard-empty-state").within(() => {
- cy.findByText("This dashboard is empty");
- cy.findByText("Add a chart").click();
- });
-
- H.sidebar().findByText("Orders, Count").click();
-
- H.saveDashboard();
-
- H.getDashboardCards()
- .should("have.length", 1)
- .and("contain", "Orders, Count")
- .and("contain", "18,760");
- });
-
it("should save changes to a dashboard after using the 'Add a chart' button from an empty tab (metabase#53132)", () => {
cy.log("add an existing card");
H.editDashboard();
@@ -322,65 +303,6 @@ describe("scenarios > dashboard", () => {
cy.findAllByRole("tab", { name: /Tab \d/ }).should("have.length", 2);
H.getDashboardCards().should("have.length", 2);
});
-
- it("should allow navigating to the notebook editor directly from a dashboard card", () => {
- H.visitDashboard(ORDERS_DASHBOARD_ID);
- H.showDashboardCardActions();
- H.getDashboardCardMenu().click();
- H.popover().findByText("Edit question").should("be.visible").click();
- cy.findByRole("button", { name: "Visualize" }).should("be.visible");
- });
-
- it("should allow navigating to the model editor directly from a dashboard card", () => {
- H.createQuestionAndDashboard({
- questionDetails: {
- name: "orders",
- type: "model",
- query: {
- "source-table": ORDERS_ID,
- },
- },
- dashboardDetails: {
- name: "Dashboard",
- },
- }).then(({ body: { dashboard_id, card } }) => {
- cy.wrap(`${card.id}-${card.name}`).as("slug");
- H.visitDashboard(dashboard_id);
- });
-
- H.showDashboardCardActions();
- H.getDashboardCardMenu().click();
- H.popover().findByText("Edit model").should("be.visible").click();
- cy.get("@slug").then((slug) => {
- cy.location("pathname").should("eq", `/model/${slug}/query`);
- });
- });
-
- it("should allow navigating to the metric editor directly from a dashboard card", () => {
- H.createQuestionAndDashboard({
- questionDetails: {
- name: "orders",
- type: "metric",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- },
- },
- dashboardDetails: {
- name: "Dashboard",
- },
- }).then(({ body: { dashboard_id, card } }) => {
- cy.wrap(`${card.id}-${card.name}`).as("slug");
- H.visitDashboard(dashboard_id);
- });
-
- H.showDashboardCardActions();
- H.getDashboardCardMenu().click();
- H.popover().findByText("Edit metric").should("be.visible").click();
- cy.get("@slug").then((slug) => {
- cy.location("pathname").should("eq", `/metric/${slug}/query`);
- });
- });
});
describe("title and description", () => {
@@ -613,111 +535,63 @@ describe("scenarios > dashboard", () => {
});
});
- describe("iframe cards", () => {
- it("should handle various iframe and URL inputs", () => {
- const testCases = [
- {
- input: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
- expected: "https://www.youtube.com/embed/dQw4w9WgXcQ",
- },
- {
- input: "https://youtu.be/dQw4w9WgXcQ",
- expected: "https://www.youtube.com/embed/dQw4w9WgXcQ",
- },
- {
- input: "https://www.loom.com/share/1234567890abcdef",
- expected: "https://www.loom.com/embed/1234567890abcdef",
- },
- {
- input: "https://vimeo.com/123456789",
- expected: "https://player.vimeo.com/video/123456789",
- },
- {
- input: "example.com",
- expected: "https://example.com",
- },
- {
- input: "https://example.com",
- expected: "https://example.com",
- },
- {
- input:
- '<iframe src="https://example.com" onload="alert(\'XSS\')"></iframe>',
- expected: "https://example.com",
+ it("should allow navigating to the notebook, model and metric editors directly from a dashboard card", () => {
+ cy.log("notebook editor");
+ H.visitDashboard(ORDERS_DASHBOARD_ID);
+ H.showDashboardCardActions();
+ H.getDashboardCardMenu().click();
+ H.popover().findByText("Edit question").should("be.visible").click();
+ cy.findByRole("button", { name: "Visualize" }).should("be.visible");
+
+ cy.log("model editor");
+ H.createQuestionAndDashboard({
+ questionDetails: {
+ name: "orders",
+ type: "model",
+ query: {
+ "source-table": ORDERS_ID,
},
- ];
-
- H.updateSetting("allowed-iframe-hosts", "*");
-
- H.createDashboard().then(({ body: { id } }) => {
- H.visitDashboard(id);
- });
-
- H.editDashboard();
-
- testCases.forEach(({ input, expected }, index) => {
- H.addIFrameWhileEditing(input);
- cy.button("Done").click();
- validateIFrame(expected, index);
- });
+ },
+ dashboardDetails: {
+ name: "Model dashboard",
+ },
+ }).then(({ body: { dashboard_id, card } }) => {
+ cy.wrap(`${card.id}-${card.name}`).as("modelSlug");
+ H.visitDashboard(dashboard_id);
});
- it("should respect allowed-iframe-hosts setting", () => {
- const errorMessage = /can not be embedded in iframe cards/;
-
- H.updateSetting(
- "allowed-iframe-hosts",
- ["youtube.com", "player.videos.com"].join("\n"),
- );
-
- H.createDashboard().then(({ body: { id } }) => H.visitDashboard(id));
- H.editDashboard();
-
- // Test allowed domain with subdomains
- H.addIFrameWhileEditing("https://youtube.com/watch?v=dQw4w9WgXcQ");
- cy.button("Done").click();
- validateIFrame("https://www.youtube.com/embed/dQw4w9WgXcQ");
-
- H.editIFrameWhileEditing(
- 0,
- "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
- );
- cy.button("Done").click();
- validateIFrame("https://www.youtube.com/embed/dQw4w9WgXcQ");
-
- // Test allowed subdomain, but no other domains
- H.editIFrameWhileEditing(0, "player.videos.com/video/123456789");
- cy.button("Done").click();
- validateIFrame("https://player.videos.com/video/123456789");
-
- H.editIFrameWhileEditing(0, "videos.com/video/123456789");
- cy.button("Done").click();
- H.getDashboardCard().within(() => {
- cy.findByText(errorMessage).should("be.visible");
- cy.get("iframe").should("not.exist");
- });
-
- H.editIFrameWhileEditing(0, "www.videos.com/video");
- cy.button("Done").click();
- H.getDashboardCard().within(() => {
- cy.findByText(errorMessage).should("be.visible");
- cy.get("iframe").should("not.exist");
- });
+ H.showDashboardCardActions();
+ H.getDashboardCardMenu().click();
+ H.popover().findByText("Edit model").should("be.visible").click();
+ H.datasetEditBar().should("be.visible");
+ cy.get("@modelSlug").then((slug) => {
+ cy.location("pathname").should("eq", `/model/${slug}/query`);
+ });
- // Test forbidden domain and subdomains
- H.editIFrameWhileEditing(0, "https://example.com");
- cy.button("Done").click();
- H.getDashboardCard().within(() => {
- cy.findByText(errorMessage).should("be.visible");
- cy.get("iframe").should("not.exist");
- });
+ cy.log("metric editor");
+ H.createQuestionAndDashboard({
+ questionDetails: {
+ name: "orders",
+ type: "metric",
+ query: {
+ "source-table": ORDERS_ID,
+ aggregation: [["count"]],
+ },
+ },
+ dashboardDetails: {
+ name: "Metric dashboard",
+ },
+ }).then(({ body: { dashboard_id, card } }) => {
+ cy.wrap(`${card.id}-${card.name}`).as("metricSlug");
+ H.visitDashboard(dashboard_id);
+ });
- H.editIFrameWhileEditing(0, "www.example.com");
- cy.button("Done").click();
- H.getDashboardCard().within(() => {
- cy.findByText(errorMessage).should("be.visible");
- cy.get("iframe").should("not.exist");
- });
+ H.showDashboardCardActions();
+ H.getDashboardCardMenu().click();
+ H.popover().findByText("Edit metric").should("be.visible").click();
+ H.MetricPage.queryEditor().should("be.visible");
+ cy.get("@metricSlug").then((slug) => {
+ cy.location("pathname").should("eq", `/metric/${slug}/query`);
});
});
@@ -1299,7 +1173,6 @@ describe("scenarios > dashboard", () => {
describe("scenarios > dashboard", () => {
beforeEach(() => {
- cy.intercept("GET", "/api/activity/recents?*").as("recentViews");
H.resetSnowplow();
H.restore();
cy.signInAsAdmin();
@@ -1310,69 +1183,144 @@ describe("scenarios > dashboard", () => {
H.expectNoBadSnowplowEvents();
});
- it("should be possible to add an iframe card", () => {
+ it("should be possible to add iframe cards from various iframe and URL inputs and allowed hosts", () => {
+ const testCases = [
+ {
+ input: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
+ expected: "https://www.youtube.com/embed/dQw4w9WgXcQ",
+ },
+ {
+ input: "https://youtu.be/dQw4w9WgXcQ",
+ expected: "https://www.youtube.com/embed/dQw4w9WgXcQ",
+ },
+ {
+ input: "https://www.loom.com/share/1234567890abcdef",
+ expected: "https://www.loom.com/embed/1234567890abcdef",
+ },
+ {
+ input: "https://vimeo.com/123456789",
+ expected: "https://player.vimeo.com/video/123456789",
+ },
+ {
+ input: "example.com",
+ expected: "https://example.com",
+ },
+ {
+ input: "https://example.com",
+ expected: "https://example.com",
+ },
+ {
+ input:
+ '<iframe src="https://example.com" onload="alert(\'XSS\')"></iframe>',
+ expected: "https://example.com",
+ },
+ ];
+
H.updateSetting("allowed-iframe-hosts", "*");
H.createDashboard({ name: "iframe card" }).then(({ body: { id } }) => {
H.visitDashboard(id);
H.editDashboard();
- H.addIFrameWhileEditing("https://example.com");
- cy.findByTestId("dashboardcard-actions-panel").should("not.exist");
- cy.button("Done").click();
- H.getDashboardCard(0).realHover();
- cy.findByTestId("dashboardcard-actions-panel").should("be.visible");
- validateIFrame("https://example.com");
+ testCases.forEach(({ input, expected }, index) => {
+ H.addIFrameWhileEditing(input);
+ H.getDashboardCard(index)
+ .findByTestId("dashboardcard-actions-panel")
+ .should("not.exist");
+ cy.button("Done").click();
+ H.getDashboardCard(index).realHover();
+ H.getDashboardCard(index)
+ .findByTestId("dashboardcard-actions-panel")
+ .should("be.visible");
+ validateIFrame(expected, index);
+ });
+
H.saveDashboard();
- validateIFrame("https://example.com");
+ H.expectUnstructuredSnowplowEvent({ event: "dashboard_saved" });
+
+ // The saved dashcard order is not guaranteed, so compare sorted sources
+ H.getDashboardCards()
+ .find("iframe")
+ .should(($iframes) => {
+ const iframes = $iframes.toArray();
+ expect(
+ iframes.map((el) => el.getAttribute("src")).sort(),
+ ).to.deep.equal(testCases.map(({ expected }) => expected).sort());
+ iframes.forEach((el) => {
+ expect(el.getAttribute("sandbox")).to.equal(IFRAME_SANDBOX);
+ expect(el.hasAttribute("onload")).to.equal(false);
+ });
+ });
- H.expectUnstructuredSnowplowEvent({
- event: "new_iframe_card_created",
- target_id: id,
- event_detail: "example.com",
- });
+ H.expectUnstructuredSnowplowEvent(
+ {
+ event: "new_iframe_card_created",
+ target_id: id,
+ event_detail: "example.com",
+ },
+ 3,
+ );
+ ["www.youtube.com", "youtu.be", "www.loom.com", "vimeo.com"].forEach(
+ (domain) =>
+ H.expectUnstructuredSnowplowEvent({
+ event: "new_iframe_card_created",
+ target_id: id,
+ event_detail: domain,
+ }),
+ );
});
- });
- it("saving a dashboard should track a 'dashboard_saved' snowplow event", () => {
- H.visitDashboard(ORDERS_DASHBOARD_ID);
- H.editDashboard();
- const newTitle = "New title";
- cy.findByTestId("dashboard-name-heading").clear().type(newTitle).blur();
- H.saveDashboard();
- H.expectUnstructuredSnowplowEvent({
- event: "dashboard_saved",
- });
- });
+ cy.log("allowed-iframe-hosts setting");
+ const errorMessage = /can not be embedded in iframe cards/;
- it("should allow users to add link cards to dashboards", () => {
- H.visitDashboard(ORDERS_DASHBOARD_ID);
+ H.updateSetting(
+ "allowed-iframe-hosts",
+ ["youtube.com", "player.videos.com"].join("\n"),
+ );
+
+ H.createDashboard().then(({ body: { id } }) => H.visitDashboard(id));
H.editDashboard();
- cy.findByLabelText("Add a link or iframe").click();
- H.popover().findByText("Link").click();
- cy.wait("@recentViews");
+ // Test allowed domain with subdomains
+ H.addIFrameWhileEditing("https://youtube.com/watch?v=dQw4w9WgXcQ");
+ cy.button("Done").click();
+ validateIFrame("https://www.youtube.com/embed/dQw4w9WgXcQ");
- cy.findByTestId("custom-edit-text-link")
- .findByPlaceholderText("https://example.com")
- .type("Orders");
+ H.editIFrameWhileEditing(0, "https://www.youtube.com/watch?v=dQw4w9WgXcQ");
+ cy.button("Done").click();
+ validateIFrame("https://www.youtube.com/embed/dQw4w9WgXcQ");
- H.popover().within(() => {
- cy.findByText(/Loading/i).should("not.exist");
- cy.findByText("Orders in a dashboard").click();
- });
+ // Test allowed subdomain, but no other domains
+ H.editIFrameWhileEditing(0, "player.videos.com/video/123456789");
+ cy.button("Done").click();
+ validateIFrame("https://player.videos.com/video/123456789");
- cy.findByTestId("entity-edit-display-link").findByText(
- /orders in a dashboard/i,
- );
+ H.editIFrameWhileEditing(0, "videos.com/video/123456789");
+ cy.button("Done").click();
+ H.getDashboardCard().within(() => {
+ cy.findByText(errorMessage).should("be.visible");
+ cy.get("iframe").should("not.exist");
+ });
- H.saveDashboard();
+ H.editIFrameWhileEditing(0, "www.videos.com/video");
+ cy.button("Done").click();
+ H.getDashboardCard().within(() => {
+ cy.findByText(errorMessage).should("be.visible");
+ cy.get("iframe").should("not.exist");
+ });
- cy.findByTestId("entity-view-display-link").findByText(
- /orders in a dashboard/i,
- );
+ // Test forbidden domain and subdomains
+ H.editIFrameWhileEditing(0, "https://example.com");
+ cy.button("Done").click();
+ H.getDashboardCard().within(() => {
+ cy.findByText(errorMessage).should("be.visible");
+ cy.get("iframe").should("not.exist");
+ });
- H.expectUnstructuredSnowplowEvent({
- event: "new_link_card_created",
+ H.editIFrameWhileEditing(0, "www.example.com");
+ cy.button("Done").click();
+ H.getDashboardCard().within(() => {
+ cy.findByText(errorMessage).should("be.visible");
+ cy.get("iframe").should("not.exist");
});
});
@@ -1753,16 +1701,15 @@ describe("scenarios > dashboard > entity id support", () => {
});
});
+const IFRAME_SANDBOX =
+ "allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts";
+
function validateIFrame(src, index = 0) {
// eslint-disable-next-line metabase/no-unsafe-element-filtering
H.getDashboardCards()
.get("iframe")
.eq(index)
.should("have.attr", "src", src)
- .and(
- "have.attr",
- "sandbox",
- "allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",
- )
+ .and("have.attr", "sandbox", IFRAME_SANDBOX)
.and("not.have.attr", "onload");
}
diff --git a/e2e/test/scenarios/dashboard/text-cards.cy.spec.js b/e2e/test/scenarios/dashboard/text-cards.cy.spec.js
index ef6c9c3fad3..f5bf901bd7f 100644
--- a/e2e/test/scenarios/dashboard/text-cards.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/text-cards.cy.spec.js
@@ -22,7 +22,7 @@ describe("scenarios > dashboard > text and headings", () => {
H.expectNoBadSnowplowEvents();
});
- it("should allow creation, editing, and saving of text boxes", () => {
+ it("should allow creation, editing, and saving of text boxes and headings", () => {
// should be able to create new text box
H.editDashboard();
cy.findByLabelText("Add a heading or text box").click();
@@ -53,13 +53,13 @@ describe("scenarios > dashboard > text and headings", () => {
.click(); // un-focus text
H.getDashboardCard(1).within(() => {
- // preview should have no textarea element
- cy.get("textarea").should("not.exist");
-
// if no content has been entered, preview should have placeholder content
cy.findByText(
"You can use Markdown here, and include variables {{like_this}}",
).should("be.visible");
+
+ // preview should have no textarea element
+ cy.get("textarea").should("not.exist");
});
// should focus textarea editor on click
@@ -78,18 +78,14 @@ describe("scenarios > dashboard > text and headings", () => {
.click(); // un-focus text
H.getDashboardCard(1).contains("Text text text").should("be.visible");
- // should render visualization options
- H.getDashboardCard(1)
- .realHover()
- .within(() => {
- cy.findByLabelText("Show visualization options").click();
- });
-
- // should not render visualizer option
+ // should render visualization options, but no visualizer or edit actions
H.getDashboardCard(1)
.realHover()
.within(() => {
+ cy.findByLabelText("Show visualization options").should("be.visible");
cy.findByLabelText("Visualize another way").should("not.exist");
+ cy.findByLabelText("Edit card").should("not.exist");
+ cy.findByLabelText("Show visualization options").click();
});
cy.findByRole("dialog").within(() => {
@@ -102,68 +98,7 @@ describe("scenarios > dashboard > text and headings", () => {
cy.findByText("Cancel").click(); // dismiss modal
});
- // should not render edit and preview actions
- H.getDashboardCard(1)
- .realHover()
- .within(() => {
- cy.findByLabelText("Edit card").should("not.exist");
- cy.findByLabelText("Preview card").should("not.exist");
- });
-
- // should allow saving and show up after refresh
- H.saveDashboard();
-
- H.getDashboardCard(1).contains("Text text text").should("be.visible");
- });
-
- it("should have a scroll bar for long text (metabase#8333)", () => {
- H.addTextBox(
- "Lorem ipsum dolor sit amet,\n\nfoo\n\nbar\n\nbaz\n\nboo\n\nDonec quis enim porta.",
- { delay: 0.5 },
- );
-
- H.expectUnstructuredSnowplowEvent({
- event: "new_text_card_created",
- });
-
- cy.findByTestId("edit-bar").findByText("Save").click();
-
- // The test fails if there is no scroll bar
- H.getDashboardCard(1)
- .get(".text-card-markdown")
- .should("have.css", "overflow-x", "hidden")
- .should("have.css", "overflow-y", "auto")
- .scrollTo("bottom");
- });
-
- it("should let you add a parameter to a dashboard with a text box (metabase#11927)", () => {
- H.addTextBox("text text text");
-
- H.setFilter("Text or Category", "Is");
-
- H.selectDashboardFilter(cy.findAllByTestId("dashcard").first(), "Name");
- cy.findByTestId("edit-bar").findByText("Save").click();
-
- // confirm text box and filter are still there
- H.getDashboardCard(1).contains("text text text").should("be.visible");
- cy.findByTestId("dashboard-parameters-widget-container")
- .findByText("Text")
- .should("be.visible");
- });
- });
-
- describe("heading", () => {
- beforeEach(() => {
- H.visitDashboard(ORDERS_DASHBOARD_ID);
- });
-
- afterEach(() => {
- H.expectNoBadSnowplowEvents();
- });
-
- it("should allow creation, editing, and saving of heading component", () => {
// should be able to create new heading
- H.editDashboard();
cy.findByLabelText("Add a heading or text box").click();
H.popover().findByText("Heading").click();
@@ -171,7 +106,7 @@ describe("scenarios > dashboard > text and headings", () => {
event: "new_heading_card_created",
});
- H.getDashboardCard(1).within(() => {
+ H.getDashboardCard(2).within(() => {
cy.get("input")
.should("have.focus")
.should("have.value", "")
@@ -186,19 +121,19 @@ describe("scenarios > dashboard > text and headings", () => {
cy.findByTestId("edit-bar")
.findByText("You're editing this dashboard.")
.click(); // un-focus heading
- H.getDashboardCard(1).within(() => {
- // preview mode should have no input
- cy.get("input").should("not.exist");
-
+ H.getDashboardCard(2).within(() => {
cy.get("h2")
.findByText(
"You can connect widgets to {{variables}} in heading cards.",
)
.should("be.visible");
+
+ // preview mode should have no input
+ cy.get("input").should("not.exist");
});
// should focus input editor on click
- H.getDashboardCard(1)
+ H.getDashboardCard(2)
.click()
.within(() => {
cy.get("input").should("have.focus");
@@ -211,34 +146,56 @@ describe("scenarios > dashboard > text and headings", () => {
cy.findByTestId("edit-bar")
.findByText("You're editing this dashboard.")
.click(); // un-focus heading
- H.getDashboardCard(1)
- .get("h2")
+ H.getDashboardCard(2)
+ .find("h2")
.findByText("Example Heading")
.should("be.visible");
- // should have no visualization options
- H.getDashboardCard(1)
+ // should have no visualization options or edit actions
+ H.getDashboardCard(2)
.realHover()
.within(() => {
+ cy.findByLabelText("Add a filter").should("be.visible");
cy.findByLabelText("Show visualization options").should("not.exist");
- });
-
- // should not render edit and preview actions
- H.getDashboardCard(1)
- .realHover()
- .within(() => {
cy.findByLabelText("Edit card").should("not.exist");
- cy.findByLabelText("Preview card").should("not.exist");
});
// should allow saving and show up after refresh
H.saveDashboard();
- H.getDashboardCard(1)
- .get("h2")
+ H.getDashboardCard(1).contains("Text text text").should("be.visible");
+ H.getDashboardCard(2)
+ .find("h2")
.findByText("Example Heading")
.should("be.visible");
});
+
+ it("should let you add a parameter to a dashboard with a long text box (metabase#8333, metabase#11927)", () => {
+ H.addTextBox(
+ "Lorem ipsum dolor sit amet,\n\nfoo\n\nbar\n\nbaz\n\nboo\n\nDonec quis enim porta.",
+ { delay: 0.5 },
+ );
+
+ H.setFilter("Text or Category", "Is");
+
+ H.selectDashboardFilter(cy.findAllByTestId("dashcard").first(), "Name");
+ cy.findByTestId("edit-bar").findByText("Save").click();
+
+ // confirm text box and filter are still there
+ H.getDashboardCard(1)
+ .contains("Lorem ipsum dolor sit amet,")
+ .should("be.visible");
+ cy.findByTestId("dashboard-parameters-widget-container")
+ .findByText("Text")
+ .should("be.visible");
+
+ // scrollTo fails if the text card has no scroll bar
+ H.getDashboardCard(1)
+ .find(".text-card-markdown")
+ .should("have.css", "overflow-x", "hidden")
+ .should("have.css", "overflow-y", "auto")
+ .scrollTo("bottom");
+ });
});
});
@@ -276,8 +233,8 @@ describe("scenarios > dashboard > parameters in text and heading cards", () => {
H.fieldValuesCombobox().type("1"),
);
cy.button("Add filter").click();
- H.getDashboardCard(0).findByText("Variable: 1").should("exist");
- H.getDashboardCard(1).findByText("Variable: 1").should("exist");
+ H.getDashboardCard(0).findByText("Variable: 1").should("be.visible");
+ H.getDashboardCard(1).findByText("Variable: 1").should("be.visible");
cy.findByTestId("dashboard-parameters-widget-container")
.findByText("1")
@@ -291,6 +248,10 @@ describe("scenarios > dashboard > parameters in text and heading cards", () => {
H.editDashboard();
+ // Edit mode shows the raw template (metabase#31626)
+ H.getDashboardCard(0).findByText("Variable: {{foo}}").should("be.visible");
+ H.getDashboardCard(1).findByText("Variable: {{foo}}").should("be.visible");
+
cy.findByTestId("edit-dashboard-parameters-widget-container")
.findByText("Equal to")
.click();
@@ -298,38 +259,7 @@ describe("scenarios > dashboard > parameters in text and heading cards", () => {
H.getDashboardCard(1).findByText("foo").should("exist");
});
- it("should not transform text variables to plain text (metabase#31626)", () => {
- H.editDashboard();
-
- const textContent = "Variable: {{foo}}";
- H.addTextBoxWhileEditing(textContent, { parseSpecialCharSequences: false });
- H.addHeadingWhileEditing(textContent, { parseSpecialCharSequences: false });
-
- H.setFilter("Number", "Equal to");
-
- H.getDashboardCard(0).findByText("Select…").click();
- H.popover().findByText("foo").click();
-
- H.getDashboardCard(1).findByText("Select…").click();
- H.popover().findByText("foo").click();
-
- H.saveDashboard();
-
- H.filterWidget().click();
- cy.findByPlaceholderText("Enter a number").type("1{enter}");
- cy.button("Add filter").click();
-
- // view mode
- H.getDashboardCard(0).findByText("Variable: 1").should("be.visible");
- H.getDashboardCard(1).findByText("Variable: 1").should("be.visible");
-
- H.editDashboard();
-
- H.getDashboardCard(0).findByText(textContent).should("be.visible");
- H.getDashboardCard(1).findByText(textContent).should("be.visible");
- });
-
- it("should translate parameter values into the instance language", () => {
+ it("should translate and localize parameter values into the instance language", () => {
// Set user locale to English explicitly so that we can change the site locale separately, without the user
// locale following it (by default, user locale matches site locale)
cy.request("GET", "/api/user/current").then(({ body: { id: USER_ID } }) => {
@@ -376,12 +306,8 @@ describe("scenarios > dashboard > parameters in text and heading cards", () => {
cy.findByText("Pick up where you left off").should("be.visible");
cy.findByText("[zz] Pick up where you left off").should("not.exist");
});
- });
- it("should localize date parameters in the instance locale", () => {
- cy.request("GET", "/api/user/current").then(({ body: { id: USER_ID } }) => {
- cy.request("PUT", `/api/user/${USER_ID}`, { locale: "en" });
- });
+ cy.log("date parameters use the instance locale");
H.updateSetting("site-locale", "fr");
// Create dashboard with a single date parameter, and a single question