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
Consolidate dashboard core e2e spec and delete emptied reproductions (#84244)
Nemanja Glumac89348bc8627f
diff --git a/e2e/test/scenarios/dashboard/dashboard-back-navigation.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard-back-navigation.cy.spec.jsindex 4cd01484fba..b6eac2691df 100644--- a/e2e/test/scenarios/dashboard/dashboard-back-navigation.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashboard-back-navigation.cy.spec.js@@ -7,7 +7,7 @@ import {ORDERS_QUESTION_ID,} from "e2e/support/cypress_sample_instance_data";-const { ORDERS_ID } = SAMPLE_DATABASE;+const { ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;const PG_DB_ID = 2;const PERMISSION_ERROR = "Sorry, you don't have permission to see this card.";const MAX_CARDS = 5;@@ -492,3 +492,187 @@ const createDashboardWithPermissionError = () => {});});};++describe("issue 31766", () => {+ function saveUpdatedQuestion() {+ cy.intercept("PUT", "/api/card/*").as("updateQuestion");++ cy.findByText("Save").click();+ cy.findByTestId("save-question-modal").within((modal) => {+ cy.findByText("Save").click();+ });+ }++ function assertQuestionIsUpdatedWithoutError() {+ cy.wait("@updateQuestion");+ H.modal().should("not.exist");+ }++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should not corrupt dashboard data (metabase#31766)", () => {+ const questionDetails = {+ name: "Orders",+ query: { "source-table": ORDERS_ID, limit: 5 },+ };++ const dashboardDetails = { name: "Orders in a dashboard" };++ H.createQuestionAndDashboard({+ questionDetails,+ dashboardDetails,+ cardDetails: { size_x: 16, size_y: 8 },+ }).then(({ body: { dashboard_id, question_id, id: dashcard_id } }) => {+ const textCard = H.getTextCardDetails({+ row: 0,+ size_x: 24,+ size_y: 1,+ text: "top",+ });+ const questionCard = {+ row: 2,+ size_x: 16,+ size_y: 6,+ id: dashcard_id,+ card_id: question_id,+ };++ H.updateDashboardCards({ dashboard_id, cards: [textCard, questionCard] });++ H.visitDashboard(dashboard_id);+ H.editDashboard();+ });++ // update text card+ cy.findByTestId("editing-dashboard-text-preview").type(1);++ H.saveDashboard();++ // visit question+ cy.findAllByTestId("dashcard").eq(1).findByText("Orders").click();++ cy.log("Update viz settings");++ cy.findByTestId("view-footer")+ .findByRole("button", { name: "Visualization" })+ .click();+ cy.findByTestId("Detail-button").click();++ saveUpdatedQuestion();++ assertQuestionIsUpdatedWithoutError();+ });+});++describe("issue 34382", () => {+ const createDashboardWithCards = () => {+ const getParameterMapping = ({ card_id }, parameters) => ({+ parameter_mappings: parameters.map((parameter) => ({+ card_id,+ parameter_id: parameter.id,+ target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],+ })),+ });++ const questionDetails = {+ name: "Products",+ query: { "source-table": PRODUCTS_ID },+ };++ const questionDashcardDetails = {+ row: 0,+ col: 0,+ size_x: 8,+ size_y: 8,+ visualization_settings: {},+ };+ const filterDetails = {+ name: "Product Category",+ slug: "category",+ id: "96917421",+ type: "category",+ };++ const dashboardDetails = {+ name: "Products in a dashboard",+ auto_apply_filters: false,+ parameters: [filterDetails],+ };++ H.createDashboard(dashboardDetails).then(+ ({ body: { id: dashboard_id } }) => {+ H.createQuestion(questionDetails).then(+ ({ body: { id: question_id } }) => {+ cy.request("PUT", `/api/dashboard/${dashboard_id}`, {+ dashcards: [+ {+ id: -1,+ card_id: question_id,+ ...questionDashcardDetails,+ ...getParameterMapping({ card_id: question_id }, [+ filterDetails,+ ]),+ },+ ],+ });+ },+ );++ cy.wrap(dashboard_id).as("dashboardId");+ },+ );+ };++ function addFilterValue(value) {+ H.filterWidget().click();+ H.popover().within(() => {+ cy.findByText(value).click();+ cy.findByRole("button", { name: "Add filter" }).click();+ });+ }++ function applyFilter() {+ cy.findByRole("button", { name: "Apply" }).click();+ cy.wait("@dashcardQuery");+ }++ beforeEach(() => {+ H.restore();+ cy.signInAsNormalUser();++ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(+ "dashcardQuery",+ );+ });++ it("should preserve filter value when navigating between the dashboard and the query builder with auto-apply disabled (metabase#34382)", () => {+ createDashboardWithCards();+ H.visitDashboard("@dashboardId");++ addFilterValue("Gizmo");+ applyFilter();++ cy.log("Navigate to Products question");+ H.getDashboardCard().findByText("Products").click();++ cy.log("Navigate back to dashboard");+ H.queryBuilderHeader()+ .findByLabelText("Back to Products in a dashboard")+ .click();++ cy.location("search").should("eq", "?category=Gizmo");+ H.filterWidget().contains("Gizmo");++ H.getDashboardCard().within(() => {+ // only products with category "Gizmo" are filtered+ cy.findByTestId("table-body")+ .findAllByRole("gridcell")+ .eq(3)+ .should("contain", "Gizmo");+ cy.findByTestId("table-body").should("not.contain", "Doohickey");+ });+ });+});diff --git a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.jsdeleted file mode 100644index 13d7c889f59..00000000000--- a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js+++ /dev/null@@ -1,1352 +0,0 @@-import { assoc } from "icepick";-import _ from "underscore";--const { H } = cy;-import {- ORDERS_DASHBOARD_ID,- ORDERS_QUESTION_ID,-} from "e2e/support/cypress_sample_instance_data";-import { DASHBOARD_SLOW_TIMEOUT } from "metabase/dashboard/constants";-import {- createMockDashboardCard,- createMockParameter,-} from "metabase-types/api/mocks";--const { SAMPLE_DATABASE } = require("e2e/support/cypress_sample_database");--const { ORDERS_ID, ORDERS, PRODUCTS_ID, PRODUCTS, PEOPLE, PEOPLE_ID } =- SAMPLE_DATABASE;--const ORDERS_QUESTION = {- name: "Orders question",- query: {- "source-table": ORDERS_ID,- },-};--describe("issue 12578", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not fetch cards that are still loading when refreshing", () => {- cy.clock(Date.now());- H.createQuestionAndDashboard({ questionDetails: ORDERS_QUESTION }).then(- ({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);- },- );-- // Without tick the dashboard header will not load- cy.tick();- H.openDashboardMenu("Auto-refresh");- H.popover().findByText("1 minute").click();-- // Mock slow card request- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query", (req) => {- req.on("response", (res) => {- res.setDelay(99999);- });- }).as("dashcardQuery");- cy.tick(61 * 1000);- cy.tick(61 * 1000);-- cy.get("@dashcardQuery.all").should("have.length", 1);- });-});--describe("issue 12926", () => {- const filterDisplayName = "F";- const queryResult = 42;- const parameterValue = 10;- const questionDetails = {- name: "Question 1",- native: {- query: `SELECT ${queryResult} [[+{{F}}]] as ANSWER`,- "template-tags": {- F: {- type: "number",- name: "F",- id: "b22a5ce2-fe1d-44e3-8df4-f8951f7921bc",- "display-name": filterDisplayName,- },- },- },- };-- function slowDownDashcardQuery() {- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query", (req) => {- req.on("response", (res) => {- res.setDelay(5000);- });- }).as("dashcardQuerySlowed");- }-- function restoreDashcardQuery() {- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query", (req) => {- // calling req.continue() will make cypress skip all previously added intercepts- req.continue();- }).as("dashcardQueryRestored");- }-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should stop the ongoing query when removing a card, re-fetch it on undo, and undo a virtual card removal (metabase#35545)", () => {- slowDownDashcardQuery();-- H.createNativeQuestionAndDashboard({- questionDetails,- }).then(({ body: { dashboard_id } }) => {- cy.visit(`/dashboard/${dashboard_id}`);- });-- // The API client uses fetch, so cancelling the query aborts its- // AbortController rather than calling XMLHttpRequest.abort().- cy.window().then((win) => {- cy.spy(win.AbortController.prototype, "abort").as("queryAbort");- });-- H.editDashboard();- H.showDashboardCardActions();- H.getDashboardCard().findByTestId("loading-indicator").should("exist");- cy.get("@queryAbort").invoke("resetHistory");- cy.findByTestId("dashboardcard-actions-panel")- .findByLabelText("close icon")- .click();- cy.get("@queryAbort").should("have.been.called");-- restoreDashcardQuery();- H.undo();- cy.wait("@dashcardQueryRestored");- H.getDashboardCard().findByText(queryResult);-- H.addTextBoxWhileEditing("Text card content");- H.getDashboardCards().should("have.length", 2);- H.removeDashboardCard(1);- H.getDashboardCards().should("have.length", 1);- H.undo();- H.getDashboardCard(1).findByText("Text card content");- });-- describe("saving a dashboard that retriggers a non saved query (negative id)", () => {- it("should load the card with correct parameters after save", () => {- H.createNativeQuestion(questionDetails);-- H.createDashboard().then(({ body: { id: dashboardId } }) => {- H.visitDashboard(dashboardId);- });-- H.editDashboard();-- H.openQuestionsSidebar();- H.sidebar().findByText(questionDetails.name).click();-- H.setFilter("Number", "Equal to");- H.sidebar().findByText("No default").click();- H.popover().findByPlaceholderText("Enter a number").type(parameterValue);- H.popover().findByText("Add filter").click();-- H.getDashboardCard().findByText("Select…").click();- H.popover().contains(filterDisplayName).eq(0).click();-- H.saveDashboard();-- H.getDashboardCard().findByText(queryResult + parameterValue);- });- });-});--describe("issue 13736", () => {- const questionDetails = {- name: "Orders count",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should work even if some cards are broken (metabase#13736)", () => {- H.createQuestion(questionDetails, {- wrapId: true,- idAlias: "failingQuestionId",- });- H.createQuestion(questionDetails, {- wrapId: true,- idAlias: "successfulQuestionId",- });- H.createDashboard({ name: "13736 Dashboard" }).then(- ({ body: { id: dashboardId } }) => {- cy.wrap(dashboardId).as("dashboardId");- },- );-- cy.then(function () {- const dashboardId = this.dashboardId;- const failingQuestionId = this.failingQuestionId;- const successfulQuestionId = this.successfulQuestionId;-- cy.intercept(- "POST",- `/api/dashboard/*/dashcard/*/card/${failingQuestionId}/query`,- {- statusCode: 500,- body: {- cause: "some error",- data: {},- message: "some error",- },- },- );-- H.updateDashboardCards({- dashboard_id: dashboardId,- cards: [- {- card_id: failingQuestionId,- },- {- card_id: successfulQuestionId,- col: 11,- },- ],- });- H.visitDashboard(dashboardId);- });-- H.getDashboardCards()- .eq(0)- .findByText("There was a problem displaying this chart.");-- H.getDashboardCards().eq(1).findByText("18,760").should("be.visible");- });-});--describe("issue 16559", () => {- const dashboardDetails = {- name: "16559 Dashboard",- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createDashboard(dashboardDetails).then((response) => {- H.visitDashboard(response.body.id);- });-- cy.intercept("PUT", "/api/dashboard/*").as("saveDashboard");- cy.intercept("POST", "/api/card/*/query").as("cardQuery");- cy.intercept("GET", "/api/dashboard/*?dashboard_load_id=*").as(- "loadDashboard",- );- });-- it("should always show the most recent revision (metabase#16559)", () => {- H.openDashboardInfoSidebar().within(() => {- cy.contains("button", "History").click();- cy.findByRole("tab", { name: "History" }).click();- cy.log("Dashboard creation");- cy.findByTestId("dashboard-history-list")- .findAllByTestId("revision-history-event")- .eq(0)- .findByText("You created this.")- .should("be.visible");- });- H.closeDashboardInfoSidebar();-- cy.log("Edit dashboard");- H.editDashboard();- H.openQuestionsSidebar();- H.sidebar().findByText("Orders, Count").click();- cy.wait("@cardQuery");- // Use the canonical save helper so we deterministically wait for the whole- // save-and-settle sequence (PUT + query_metadata reload, edit-bar gone, all- // dashcards loaded). The previous ad-hoc `Save` click only awaited the PUT,- // so the "More info" click below raced the trailing re-render and was- // dropped, leaving the sidesheet closed.- H.saveDashboard();-- H.openDashboardInfoSidebar().within(() => {- cy.contains("button", "History").click();- cy.findByTestId("dashboard-history-list")- .findAllByTestId("revision-history-event")- .eq(0)- .findByText("You added a card.")- .should("be.visible");- });- H.closeDashboardInfoSidebar();-- cy.log("Change dashboard name");- cy.findByTestId("dashboard-name-heading").click().type(" modified").blur();- cy.wait("@saveDashboard");-- H.openDashboardInfoSidebar().within(() => {- cy.contains("button", "History").click();-- cy.findByTestId("dashboard-history-list")- .findAllByTestId("revision-history-event")- .eq(0)- .findByText(- 'You renamed this Dashboard from "16559 Dashboard" to "16559 Dashboard modified".',- )- .should("be.visible");-- cy.log("Add description");- cy.findByRole("tab", { name: "Overview" }).click();-- cy.findByPlaceholderText("Add description")- .click()- .type("16559 description")- .blur();- cy.wait("@saveDashboard");-- cy.contains("button", "History").click();-- cy.findByTestId("dashboard-history-list")- .findAllByTestId("revision-history-event")- .eq(0)- .findByText("You added a description.")- .should("be.visible");-- cy.log("Toggle auto-apply filters");- });- H.closeDashboardInfoSidebar();-- H.openDashboardSettingsSidebar();- H.sidesheet().findByLabelText("Auto-apply filters").click();- cy.wait("@saveDashboard");- H.closeDashboardSettingsSidebar();-- H.openDashboardInfoSidebar().within(() => {- cy.contains("button", "History").click();-- cy.findByTestId("dashboard-history-list")- .findAllByTestId("revision-history-event")- .eq(0)- .findByText("You set auto apply filters to false.")- .should("be.visible");- });- H.closeDashboardInfoSidebar();-- cy.log("Move dashboard to another collection");- H.dashboardHeader().icon("ellipsis").click();- H.popover().findByText("Move").click();- H.entityPickerModal().within(() => {- cy.findByText("First collection").click();- cy.button("Move").click();- cy.wait(["@saveDashboard"]);- });-- H.openDashboardInfoSidebar().within(() => {- cy.contains("button", "History").click();- cy.findByTestId("dashboard-history-list")- .findAllByTestId("revision-history-event")- .eq(0)- .findByText("You moved this Dashboard to First collection.")- .should("be.visible");- });- });-});--describe("issue 28756", () => {- const UNRESTRICTED_COLLECTION_NAME = "Unrestricted collection";- const RESTRICTED_COLLECTION_NAME = "Restricted collection";-- const ADMIN_GROUP_ID = "2";-- const TOAST_TIMEOUT_SAFETY_MARGIN = 1000;- const TOAST_TIMEOUT = DASHBOARD_SLOW_TIMEOUT + TOAST_TIMEOUT_SAFETY_MARGIN;- const TOAST_MESSAGE = "Want to get notified when this dashboard loads?";-- function restrictCollectionForNonAdmins(collectionId) {- cy.request("GET", "/api/collection/graph").then(- ({ body: { revision, groups } }) => {- cy.request("PUT", "/api/collection/graph", {- revision,- groups: _.mapObject(groups, (groupPermissions, groupId) => {- const permission = groupId === ADMIN_GROUP_ID ? "write" : "none";- return assoc(groupPermissions, collectionId, permission);- }),- });- },- );- }-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createCollection({ name: RESTRICTED_COLLECTION_NAME }).then(- ({ body: restrictedCollection }) => {- restrictCollectionForNonAdmins(restrictedCollection.id);-- H.createCollection({ name: UNRESTRICTED_COLLECTION_NAME }).then(- ({ body: unrestrictedCollection }) => {- H.createQuestionAndDashboard({- dashboardDetails: {- collection_id: unrestrictedCollection.id,- },- questionDetails: {- name: "28756 Question",- query: {- "source-table": PRODUCTS_ID,- },- collection_id: restrictedCollection.id,- },- }).then(({ body: { dashboard_id } }) => {- cy.wrap(dashboard_id).as("dashboardId");- });- },- );- },- );- });-- it("should not show a toast to enable notifications to user with no permissions to see the card (metabase#28756)", () => {- cy.signInAsNormalUser();- cy.clock();-- cy.get("@dashboardId").then((dashboardId) => {- H.visitDashboard(dashboardId);- cy.tick(TOAST_TIMEOUT);-- H.undoToast().should("not.exist");- cy.findByText(TOAST_MESSAGE).should("not.exist");- });- });-});--describe("issue 31274", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not clip dashcard actions (metabase#31274)", () => {- H.createDashboard().then(({ body: { id: dashboard_id } }) => {- // The top card is created last, so it would come last in the DOM and- // cover the actions of the card below if dashcards render in creation order- H.updateDashboardCards({- dashboard_id,- cards: [H.getTextCardDetails({ row: 6, text: "Bottom card" })],- }).then(({ body: { dashcards } }) => {- H.updateDashboardCards({- dashboard_id,- cards: [- ...dashcards,- H.getTextCardDetails({ row: 0, text: "Top card" }),- ],- });- });- H.visitDashboard(dashboard_id);- });-- H.editDashboard();- H.getDashboardCards().should("have.length", 2);-- cy.log(- "Make sure cypress can click the element, which means it is not covered by the card above",- );- H.getDashboardCards()- .filter(":contains('Bottom card')")- .realHover({ scrollBehavior: false })- .findByTestId("dashboardcard-actions-panel")- .icon("close")- .click({ position: "top", scrollBehavior: false });-- H.getDashboardCards().should("have.length", 1);- });-});--describe("issue 31766", () => {- function saveUpdatedQuestion() {- cy.intercept("PUT", "/api/card/*").as("updateQuestion");-- cy.findByText("Save").click();- cy.findByTestId("save-question-modal").within((modal) => {- cy.findByText("Save").click();- });- }-- function assertQuestionIsUpdatedWithoutError() {- cy.wait("@updateQuestion");- H.modal().should("not.exist");- }-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not corrupt dashboard data (metabase#31766)", () => {- const questionDetails = {- name: "Orders",- query: { "source-table": ORDERS_ID, limit: 5 },- };-- const dashboardDetails = { name: "Orders in a dashboard" };-- H.createQuestionAndDashboard({- questionDetails,- dashboardDetails,- cardDetails: { size_x: 16, size_y: 8 },- }).then(({ body: { dashboard_id, question_id, id: dashcard_id } }) => {- const textCard = H.getTextCardDetails({- row: 0,- size_x: 24,- size_y: 1,- text: "top",- });- const questionCard = {- row: 2,- size_x: 16,- size_y: 6,- id: dashcard_id,- card_id: question_id,- };-- H.updateDashboardCards({ dashboard_id, cards: [textCard, questionCard] });-- H.visitDashboard(dashboard_id);- H.editDashboard(dashboard_id);- });-- // update text card- cy.findByTestId("editing-dashboard-text-preview").type(1);-- H.saveDashboard();-- // visit question- cy.findAllByTestId("dashcard").eq(1).findByText("Orders").click();-- cy.log("Update viz settings");-- cy.findByTestId("view-footer")- .findByRole("button", { name: "Visualization" })- .click();- cy.findByTestId("Detail-button").click();-- saveUpdatedQuestion();-- assertQuestionIsUpdatedWithoutError();- });-});--describe("issue 34382", () => {- const createDashboardWithCards = () => {- const getParameterMapping = ({ card_id }, parameters) => ({- parameter_mappings: parameters.map((parameter) => ({- card_id,- parameter_id: parameter.id,- target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],- })),- });-- const questionDetails = {- name: "Products",- query: { "source-table": PRODUCTS_ID },- };-- const questionDashcardDetails = {- row: 0,- col: 0,- size_x: 8,- size_y: 8,- visualization_settings: {},- };- const filterDetails = {- name: "Product Category",- slug: "category",- id: "96917421",- type: "category",- };-- const dashboardDetails = {- name: "Products in a dashboard",- auto_apply_filters: false,- parameters: [filterDetails],- };-- H.createDashboard(dashboardDetails).then(- ({ body: { id: dashboard_id } }) => {- H.createQuestion(questionDetails).then(- ({ body: { id: question_id } }) => {- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {- dashcards: [- {- id: -1,- card_id: question_id,- ...questionDashcardDetails,- ...getParameterMapping({ card_id: question_id }, [- filterDetails,- ]),- },- ],- });- },- );-- cy.wrap(dashboard_id).as("dashboardId");- },- );- };-- function addFilterValue(value) {- H.filterWidget().click();- H.popover().within(() => {- cy.findByText(value).click();- cy.findByRole("button", { name: "Add filter" }).click();- });- }-- function applyFilter() {- cy.findByRole("button", { name: "Apply" }).click();- cy.wait("@dashcardQuery");- }-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();-- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(- "dashcardQuery",- );- });-- it("should preserve filter value when navigating between the dashboard and the query builder with auto-apply disabled (metabase#34382)", () => {- createDashboardWithCards();- H.visitDashboard("@dashboardId");-- addFilterValue("Gizmo");- applyFilter();-- cy.log("Navigate to Products question");- H.getDashboardCard().findByText("Products").click();-- cy.log("Navigate back to dashboard");- H.queryBuilderHeader()- .findByLabelText("Back to Products in a dashboard")- .click();-- cy.location("search").should("eq", "?category=Gizmo");- H.filterWidget().contains("Gizmo");-- H.getDashboardCard().within(() => {- // only products with category "Gizmo" are filtered- cy.findByTestId("table-body")- .findAllByRole("gridcell")- .eq(3)- .should("contain", "Gizmo");- cy.findByTestId("table-body").should("not.contain", "Doohickey");- });- });-});--describe("should not redirect users to other pages when linking an entity (metabase#35037)", () => {- const TEST_DASHBOARD_NAME = "Orders in a dashboard";- const TEST_QUESTION_NAME = "Question#35037";-- beforeEach(() => {- H.resetSnowplow();- H.restore();- cy.signInAsAdmin();- H.enableTracking();- cy.intercept("GET", "/api/activity/recents?*").as("recentViews");- });-- 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.location("pathname").then((originPath) => {- cy.wrap(originPath).as("originPath");- });-- cy.log("link a recent item");- cy.findByLabelText("Add a link or iframe").click();- H.popover().findByText("Link").click();- cy.wait("@recentViews");-- cy.findByTestId("recents-list-container").within(() => {- cy.findByText(TEST_DASHBOARD_NAME).click();- });-- 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.log("link a search item");- cy.icon("link").click();- H.popover().findByText("Link").click();- cy.findByTestId("custom-edit-text-link")- .findByPlaceholderText("https://example.com")- .type(TEST_QUESTION_NAME);- cy.findByTestId("search-results-list").within(() => {- cy.findByText(TEST_QUESTION_NAME).click();- });-- cy.findAllByTestId("entity-edit-display-link")- .should("have.length", 2)- .and("contain", TEST_QUESTION_NAME);- cy.findByTestId("search-results-list").should("not.exist");- assertOriginPath();-- // 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 47170", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- cy.request("POST", `/api/bookmark/dashboard/${ORDERS_DASHBOARD_ID}`);-- H.createDashboard({ name: "Dashboard A" }, { wrapId: true }).then(- (dashboardId) => {- cy.request("POST", `/api/bookmark/dashboard/${dashboardId}`);- },- );-- // Keep the first dashboard loading so that navigating away cancels its fetch- cy.intercept(- { method: "GET", pathname: `/api/dashboard/${ORDERS_DASHBOARD_ID}` },- (req) => {- req.on("response", (res) => {- res.setDelay(10_000);- });- },- );- });-- it("should not show error when dashboard fetch request is cancelled (metabase#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("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();- H.popover().findByText("Enter fullscreen").click();-- const primaryTextColor = "rgba(255, 255, 255, 0.95)";-- cy.findByTestId("dashboard-name-heading").should(- "have.css",- "color",- primaryTextColor,- );-- H.getDashboardCard(0)- .findByText("37.65")- .should("have.css", "color", primaryTextColor);-- cy.findByTestId("sharing-menu-button").should(- "have.css",- "color",- primaryTextColor,- );- });-});--describe("issue 49556", () => {- const TAB = { id: 1, name: "Tab" };-- const PEOPLE_NAME_FIELD_REF = [- "field",- PEOPLE.NAME,- { "base-type": "type/Text" },- ];-- const TARGET_PARAMETER = {- id: "d7988e02",- name: "Target",- slug: "target",- type: "category",- filteringParameters: ["d7988e03"],- };-- const SOURCE_PARAMETER = {- id: "d7988e03",- name: "Source",- slug: "source",- type: "category",- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createDashboardWithTabs({- tabs: [TAB],- parameters: [TARGET_PARAMETER, SOURCE_PARAMETER],- dashcards: [- createMockDashboardCard({- id: -1,- dashboard_tab_id: TAB.id,- size_x: 10,- size_y: 4,- card_id: ORDERS_QUESTION_ID,- parameter_mappings: [- {- parameter_id: TARGET_PARAMETER.id,- card_id: ORDERS_QUESTION_ID,- target: [- "dimension",- PEOPLE_NAME_FIELD_REF,- { "stage-number": 0 },- ],- },- {- parameter_id: SOURCE_PARAMETER.id,- card_id: ORDERS_QUESTION_ID,- target: [- "dimension",- PEOPLE_NAME_FIELD_REF,- { "stage-number": 0 },- ],- },- ],- }),- ],- }).then((dashboard) => H.visitDashboard(dashboard.id));- });-- it("unlinks the filter when it is removed (metabase#49556)", () => {- H.editDashboard();-- cy.findByTestId("fixed-width-filters").findByText("Source").click();- H.dashboardParameterSidebar().findByText("Remove").click();-- cy.findByTestId("fixed-width-filters").findByText("Target").click();- H.dashboardParameterSidebar().button("Edit").should("be.enabled");- });-});--describe("issue 54353", () => {- const peopleSourceFieldRef = [- "field",- PEOPLE.SOURCE,- { "base-type": "type/Text", "source-field": ORDERS.USER_ID },- ];- const ordersCreatedAtFieldRef = [- "field",- ORDERS.CREATED_AT,- { "base-type": "type/DateTime", "temporal-unit": "month" },- ];-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should close date filter on esc (metabase#54353)", () => {- H.createDashboardWithQuestions({- dashboardDetails: {- parameters: [- createMockParameter({- id: "param-1",- name: "Date",- slug: "date",- type: "date/all-options",- }),- ],- },- questions: [- {- name: "fooBarQuestion",- display: "bar",- query: {- aggregation: [["count"]],- breakout: [peopleSourceFieldRef, ordersCreatedAtFieldRef],- "source-table": ORDERS_ID,- },- },- ],- }).then(({ dashboard }) => {- cy.request("GET", `/api/dashboard/${dashboard.id}`).then(- ({ body: dashboard }) => {- const [dashcard] = dashboard.dashcards;- const [parameter] = dashboard.parameters;- cy.request("PUT", `/api/dashboard/${dashboard.id}`, {- dashcards: [- {- ...dashcard,- parameter_mappings: [- {- card_id: dashcard.card_id,- parameter_id: parameter.id,- target: ["dimension", ordersCreatedAtFieldRef],- },- ],- },- ],- }).then(() => {- cy.wrap(dashboard.id).as("dashboardId");- });- },- );- });- H.visitDashboard("@dashboardId");-- cy.log("set dashboard filter value");- cy.findByLabelText("Date").click();- H.popover()- .findByText(/Previous 12 months/i)- .click();-- cy.findByLabelText("Date").click();-- cy.realPress("Escape");-- cy.log("make sure popover is not open");- cy.findByRole("dialog").should("not.exist");- });-});--describe("issue 44937", () => {- beforeEach(() => {- H.restore();- cy.signIn("readonly");- });-- it("dashboard empty state should not suggest creating a new question when users have no creation permission (metabase#44937)", () => {- cy.visit("/");- H.newButton().click();- H.popover().findByText("Dashboard").click();- H.modal().within(() => {- cy.findByPlaceholderText("What is the name of your dashboard?").type(- "my dashboard",- );- cy.button("Create").click();- });-- H.main().findByText(- "Browse your collections to find and add existing questions.",- );-- cy.button("Add a chart").click();- H.sidebar().within(() => {- cy.findByText("Our analytics").click();- cy.findByText("Orders").click();- });- H.getDashboardCards().should("have.length", 1);-- H.createNewTab();-- H.main().findByText(- "Browse your collections to find and add existing questions.",- );- });-});-describe("issue 62170", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should only refresh card data, not reload entire dashboard when auto-refresh is enabled", () => {- const REFRESH_PERIOD = 3;-- H.createQuestionAndDashboard({- questionDetails: {- name: "Orders Count",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- },- },- }).then(({ body: { dashboard_id } }) => {- 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- cy.wait("@dashboardLoad");- cy.wait("@cardDataRefresh");-- // Verify dashboard is loaded- H.getDashboardCard().within(() => {- cy.findByText("Orders Count").should("be.visible");- });-- // Verify card data was refreshed- cy.wait("@cardDataRefresh");-- // Verify dashboard itself was NOT reloaded- cy.get("@dashboardLoad.all").should("have.length", 1);- });-});--describe("issue 52674", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should be possible to open a parameter widget using the keyboard shortcut (metabase#52674)", () => {- H.createDashboardWithQuestions({- questions: [- {- query: {- "source-table": ORDERS_ID,- },- },- ],- dashboardDetails: {- parameters: [- createMockParameter({- id: "param-1",- name: "Number",- slug: "number",- type: "number/between",- }),- ],- },- }).then(({ dashboard }) => {- cy.request("GET", `/api/dashboard/${dashboard.id}`).then(- ({ body: dashboard }) => {- const [dashcard] = dashboard.dashcards;- const [parameter] = dashboard.parameters;- cy.request("PUT", `/api/dashboard/${dashboard.id}`, {- dashcards: [- {- ...dashcard,- parameter_mappings: [- {- card_id: dashcard.card_id,- parameter_id: parameter.id,- target: [- "dimension",- [- "field",- ORDERS.TOTAL,- {- "base-type": "type/Number",- },- ],- ],- },- ],- },- ],- }).then(() => {- cy.wrap(dashboard.id).as("dashboardId");- });- },- );- });- H.visitDashboard("@dashboardId");-- cy.log("Opening with Enter should work");- H.main().button("Number").focus();- cy.realPress("Enter");- H.popover().should("be.visible");-- cy.log("Close the popover");- H.main().button("Number").click();-- cy.log("Opening with Space should work");- H.main().button("Number").focus();- cy.realPress("Space");- H.popover().should("be.visible");- });-});--describe("issue 53370", () => {- const LONG_NAME = "a".repeat(254);-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();-- H.createDashboard({- name: LONG_NAME,- }).then(({ body: dashboard }) => {- H.visitDashboard(dashboard.id);- });- });-- it("should wrap long dashboard named (metabase#53370)", () => {- cy.findByDisplayValue(LONG_NAME)- .should("be.visible")- .then(($el) => {- cy.window().then((win) => {- cy.wrap($el[0].offsetWidth).should("be.lt", win.innerWidth);- });- });- //- });-});--describe("issue 63176", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should not be possible to save a dashboard with an empty name and the correct error should be displayed (metabase#63176)", () => {- cy.visit("/");- H.newButton().click();- H.popover().findByText("Dashboard").click();- H.modal().within(() => {- cy.findByPlaceholderText("What is the name of your dashboard?").type(" ");- cy.button("Create").click();-- cy.findByText("value must be a non-blank string.").should("be.visible");- cy.findByPlaceholderText("What is the name of your dashboard?").should(- "have.attr",- "aria-invalid",- "true",- );- cy.button("Failed").should("be.visible");- });- });-});--describe("issue 64138", () => {- const MAP_QUESTION = {- query: {- "source-table": PEOPLE_ID,- },-- display: "map",- displayIsLocked: true,- visualization_settings: {- "map.type": "pin",- "map.pin_type": "markers",- },- };-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();-- H.createQuestionAndDashboard({- questionDetails: MAP_QUESTION,- }).then(({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);- });- });-- it("should hide map controls when editing dashboard (metabase#64138)", () => {- H.editDashboard();-- cy.log("hovering the map should not show the zoom controls");- H.getDashboardCard(0)- .realHover({- position: "center",- })- .within(() => {- cy.findByLabelText("Zoom in").should("not.exist");- // the update button is disabled until the map is panned, so only- // assert that it is shown while the zoom controls are hidden- cy.findByText("Set as default view").should("be.visible");- });-- cy.log("hovering marker icons should not open their tooltips");- getMarkerIcon(0).trigger("mousemove", { force: true });- H.tooltip().should("not.exist");-- cy.log("clicking marker icons should not navigate to the question");- getMarkerIcon(0).click({ force: true });- cy.location("pathname").should("match", /^\/dashboard\/[0-9]+$/);- H.modal().should("not.exist");-- cy.log(- "outside of edit mode, the map shows its controls and handles markers",- );- cy.findByTestId("edit-bar").button("Cancel").click();- H.getDashboardCard(0).findByLabelText("Zoom in").should("exist");- getMarkerIcon(0).trigger("mousemove", { force: true });- H.tooltip().should("be.visible");- getMarkerIcon(0).click({ force: true });- cy.location("pathname").should("match", /^\/question/);- cy.location("search").should("match", /objectId=\d+/);- });-- function getMarkerIcon(index) {- // pick the last one so it will be on top- return H.getDashboardCard(index)- .find(".leaflet-marker-icon")- .should("have.length.gt", 0)- .last();- }-});--describe("issue 65908", () => {- const dateParameters = {- default: "2030-01-01~",- id: "d3b78b27",- name: "Date Filter",- slug: "date_filter",- type: "date/all-options",- };-- function createDashcard({- index,- questionId,- hideEmptyResults,- withParameterMappings,- }) {- const cardHeightInRows = 10;-- return {- col: 0,- row: cardHeightInRows * index,- size_x: 24,- size_y: cardHeightInRows,- card_id: questionId,- visualization_settings: {- "card.hide_empty": hideEmptyResults,- },- parameter_mappings: withParameterMappings- ? [- {- parameter_id: dateParameters.id,- card_id: questionId,- target: ["dimension", ["field", ORDERS.CREATED_AT, null]],- },- ]- : undefined,- };- }-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- const dashboardDetails = {- name: "Dashboard with empty result cards",- parameters: [dateParameters],- };-- const questionDetails = {- name: "Orders question",- query: {- "source-table": ORDERS_ID,- limit: 5,- },- };-- H.createDashboardWithQuestions({- dashboardDetails,- questions: [questionDetails],- }).then(({ dashboard, questions }) => {- const [question] = questions;- H.updateDashboardCards({- dashboard_id: dashboard.id,- cards: [- createDashcard({- index: 0,- questionId: question.id,- hideEmptyResults: true,- withParameterMappings: true,- }),- createDashcard({- index: 1,- questionId: question.id,- hideEmptyResults: true,- withParameterMappings: true,- }),- createDashcard({- index: 2,- questionId: question.id,- hideEmptyResults: true,- withParameterMappings: true,- }),- createDashcard({- index: 3,- questionId: question.id,- hideEmptyResults: false,- withParameterMappings: false,- }),- ],- });- cy.wrap(dashboard.id).as("dashboardId");- });- });-- it("should not take into account the height of cards with no results when calculating dashboard height (metabase#65908)", () => {- cy.get("@dashboardId").then((dashboardId) => {- H.visitDashboard(dashboardId);-- cy.findByDisplayValue("Dashboard with empty result cards").should(- "be.visible",- );-- H.getDashboardCard().within(() => {- cy.findByText("Orders question").should("be.visible");- cy.log("Checks for the subtotal value from the first row");- cy.findByText("37.65").should("be.visible");- });-- cy.findByRole("main").should(($main) => {- // 4 cards take about 2000px in height, so only 1 card should definitely take less than 1000px- expect($main[0].scrollHeight).to.be.lessThan(1000);- });- });- });-});diff --git a/e2e/test/scenarios/dashboard/dashboard.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard.cy.spec.jsindex 3e8d0826ebb..a9453527ae8 100644--- a/e2e/test/scenarios/dashboard/dashboard.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashboard.cy.spec.js@@ -11,18 +11,15 @@ import {} from "e2e/support/cypress_sample_instance_data";import { GRID_WIDTH } from "metabase/utils/dashboard_grid";import {+ createMockDashboardCard,+ createMockParameter,createMockVirtualCard,createMockVirtualDashCard,} from "metabase-types/api/mocks";const { H } = cy;-const { ORDERS, ORDERS_ID, PRODUCTS } = SAMPLE_DATABASE;--// There's a race condition when saving a dashboard-// and then immediately editing it again. After saving,-// we exit the edit mode and that can happen after-// `H.editDashboard` is called for some reason+const { ORDERS, ORDERS_ID, PRODUCTS, PEOPLE } = SAMPLE_DATABASE;describe("scenarios > dashboard", () => {beforeEach(() => {@@ -113,6 +110,24 @@ describe("scenarios > dashboard", () => {.and("not.contain", newQuestionName);});+ it("should not create a dashboard with a blank name (metabase#63176)", () => {+ cy.visit("/");+ H.newButton().click();+ H.popover().findByText("Dashboard").click();+ H.modal().within(() => {+ cy.findByPlaceholderText(/name of your dashboard/i).type(" ");+ cy.button("Create").click();++ cy.findByText("value must be a non-blank string.").should("be.visible");+ cy.findByPlaceholderText(/name of your dashboard/i).should(+ "have.attr",+ "aria-invalid",+ "true",+ );+ cy.button("Failed").should("be.visible");+ });+ });+it("adding question to one dashboard shouldn't affect previously visited unrelated dashboards (metabase#26826)", () => {cy.intercept("POST", "/api/card").as("saveQuestion");@@ -400,7 +415,25 @@ describe("scenarios > dashboard", () => {cy.get("@updateDashboardSpy").should("have.callCount", 2);});- it("should not have markdown content overflow the description area (metabase#31326)", () => {+ it("should keep a long title and a markdown description within their areas (metabase#31326, metabase#53370)", () => {+ cy.log("The title is limited to 254 characters");+ const longTitle = "A".repeat(256);+ cy.findByTestId("dashboard-name-heading")+ .as("dashboardInput")+ .clear()+ .type(longTitle, { delay: 0 })+ .blur();+ cy.get("@dashboardInput").invoke("text").should("have.length", 254);+ cy.wait("@updateDashboard");++ cy.log("A long title wraps within the window (metabase#53370)");+ cy.reload();+ cy.findByDisplayValue("A".repeat(254))+ .should("be.visible")+ .then(($el) => {+ cy.window().its("innerWidth").should("be.gt", $el[0].offsetWidth);+ });+H.openDashboardInfoSidebar();const testMarkdownContent =@@ -449,64 +482,8 @@ describe("scenarios > dashboard", () => {});});});-- it("should prevent entering a title longer than 254 chars", () => {- const longTitle = "A".repeat(256);- cy.findByTestId("dashboard-name-heading")- .as("dashboardInput")- .clear()- .type(longTitle, { delay: 0 })- .blur();- cy.get("@dashboardInput").invoke("text").should("have.length", 254);- });});- it(- "should not allow dashboard editing on small screens",- { viewportWidth: 480, viewportHeight: 800 },- () => {- cy.findByLabelText("Edit dashboard").should("not.be.visible");-- cy.viewport(660, 800);-- cy.findByLabelText("Edit dashboard").should("be.visible").click();- cy.findByTestId("edit-bar").findByText(- "You're editing this dashboard.",- );- },- );-- it(- "shows sorted cards on mobile screens",- { viewportWidth: 400, viewportHeight: 800 },- () => {- H.createDashboard().then(({ body: { id: dashboard_id } }) => {- const cards = [- // the bottom card intentionally goes first to have unsorted cards coming from the BE- H.getTextCardDetails({- row: 1,- size_x: 24,- size_y: 1,- text: "bottom",- }),- H.getTextCardDetails({- row: 0,- size_x: 24,- size_y: 1,- text: "top",- }),- ];-- H.updateDashboardCards({ dashboard_id, cards });-- H.visitDashboard(dashboard_id);- });-- H.getDashboardCard(0).contains("top");- H.getDashboardCard(1).contains("bottom");- },- );-it("should not save the dashboard when the user clicks 'Discard changes'", () => {// Navigate to the dashboard via client-side navigation (to trigger the client-side "Discard changes" prompt)cy.visit("/");@@ -535,6 +512,45 @@ describe("scenarios > dashboard", () => {});});+ it(+ "should sort cards and not allow dashboard editing on small screens",+ { viewportWidth: 400, viewportHeight: 800 },+ () => {+ H.createDashboard().then(({ body: { id: dashboard_id } }) => {+ const cards = [+ // the bottom card intentionally goes first to have unsorted cards coming from the BE+ H.getTextCardDetails({+ row: 1,+ size_x: 24,+ size_y: 1,+ text: "bottom",+ }),+ H.getTextCardDetails({+ row: 0,+ size_x: 24,+ size_y: 1,+ text: "top",+ }),+ ];++ H.updateDashboardCards({ dashboard_id, cards });++ H.visitDashboard(dashboard_id);+ });++ H.getDashboardCard(0).contains("top");+ H.getDashboardCard(1).contains("bottom");++ cy.viewport(480, 800);+ cy.findByLabelText("Edit dashboard").should("not.be.visible");++ cy.viewport(660, 800);++ cy.findByLabelText("Edit dashboard").should("be.visible").click();+ cy.findByTestId("edit-bar").findByText("You're editing this dashboard.");+ },+ );+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);@@ -595,49 +611,23 @@ describe("scenarios > dashboard", () => {});});- it("should add a filter", () => {- H.visitDashboard(ORDERS_DASHBOARD_ID);- H.editDashboard();-- // Adding location/state doesn't make much sense for this case,- // but we're testing just that the filter is added to the dashboard- H.setFilter("Location", "Is");-- H.getDashboardCard().findByText("Select…").click();-- H.popover().findByText("State").click();-- cy.icon("close");- cy.button("Done").click();-- H.saveDashboard();-- cy.log("Assert that the selected filter is present in the dashboard");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Location", { exact: false }).should("be.visible");- });-it("should link filters to custom question with filtered aggregate data (metabase#11007)", () => {- // programmatically create and save a question as per repro instructions in #11007- cy.request("POST", "/api/card", {+ // The filter on the aggregated column puts the aggregation in a nested stage+ H.createQuestion({name: "11007",- dataset_query: {- database: SAMPLE_DB_ID,- filter: [">", ["field", "sum", { "base-type": "type/Float" }], 100],- query: {+ query: {+ "source-query": {"source-table": ORDERS_ID,+ filter: ["=", ["field", ORDERS.USER_ID, null], 1],aggregation: [["sum", ["field", ORDERS.TOTAL, null]]],breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "day" }],["field", PRODUCTS.ID, { "source-field": ORDERS.PRODUCT_ID }],["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],],- filter: ["=", ["field", ORDERS.USER_ID, null], 1],},- type: "query",+ filter: [">", ["field", "sum", { "base-type": "type/Float" }], 100],},- display: "table",- visualization_settings: {},});H.createDashboard({ name: "dash:11007" });@@ -676,10 +666,11 @@ describe("scenarios > dashboard", () => {// and connect it to the cardH.selectDashboardFilter(cy.findByTestId("dashcard-container"), "Category");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Save").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("You're editing this dashboard.").should("not.exist");+ cy.intercept("PUT", "/api/dashboard/*").as("updateDashboard");+ H.saveDashboard();+ cy.wait("@updateDashboard")+ .its("request.body.dashcards.0.parameter_mappings")+ .should("have.length", 3);});it("should not get the parameter values from the field API", () => {@@ -750,42 +741,7 @@ describe("scenarios > dashboard", () => {cy.get("@fetchFieldValues").should("not.have.been.called");});- it("should be possible to scroll vertically after fullscreen layer is closed (metabase#15596)", () => {- // Make this dashboard card extremely tall so that it spans outside of visible viewport- cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {- dashcards: [- {- id: ORDERS_DASHBOARD_DASHCARD_ID,- card_id: ORDERS_QUESTION_ID,- row: 0,- col: 0,- size_x: 16,- size_y: 20,- series: [],- visualization_settings: {},- parameter_mappings: [],- },- ],- });-- H.visitDashboard(ORDERS_DASHBOARD_ID);- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("37.65");- assertScrollBarExists();-- H.openLegacyStaticEmbeddingModal({- resource: "dashboard",- resourceId: ORDERS_DASHBOARD_ID,- });-- H.modal().within(() => {- cy.icon("close").click();- });- H.modal().should("not.exist");- assertScrollBarExists();- });-- it("should support auto-scrolling to a dashcard via a url hash param", () => {+ it("should support auto-scrolling to a dashcard via a url hash param and keep the page scrollable after a modal closes (metabase#15596)", () => {const questionCard = {id: ORDERS_DASHBOARD_DASHCARD_ID,card_id: ORDERS_QUESTION_ID,@@ -812,6 +768,20 @@ describe("scenarios > dashboard", () => {cy.visit(`/dashboard/${dashboard.id}`);cy.findByText(TARGET_TEXT).should("not.be.visible");+ cy.log("closing a modal should unlock scrolling (metabase#15596)");+ H.openLegacyStaticEmbeddingModal({+ resource: "dashboard",+ resourceId: dashboard.id,+ });+ cy.get("body").should("have.attr", "data-scroll-locked");++ H.modal().within(() => {+ cy.icon("close").click();+ });+ H.modal().should("not.exist");+ cy.get("body").should("not.have.attr", "data-scroll-locked");+ cy.get("body").should("not.have.css", "overflow", "hidden");+cy.log("should scroll into view w/ scrollTo hash param");cy.visit(`/dashboard/${dashboard.id}#scrollTo=${targetCard.id}`);// wait for scroll to complete (hash cleared) then verify visibility@@ -821,90 +791,13 @@ describe("scenarios > dashboard", () => {);});- it("should allow making card hide when it is empty", () => {- const FILTER_ID = "d7988e02";-- cy.log("Add filter to the dashboard");- cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {- parameters: [- {- id: FILTER_ID,- name: "ID",- slug: "id",- type: "id",- },- ],- });-- cy.log("Connect filter to the existing card");- cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {- dashcards: [- {- id: ORDERS_DASHBOARD_DASHCARD_ID,- card_id: ORDERS_QUESTION_ID,- row: 0,- col: 0,- size_x: 16,- size_y: 8,- parameter_mappings: [- {- parameter_id: FILTER_ID,- card_id: ORDERS_QUESTION_ID,- target: ["dimension", ["field", ORDERS.ID]],- },- ],- visualization_settings: {},- },- ],- });-- H.visitDashboard(ORDERS_DASHBOARD_ID);- H.editDashboard();-- cy.findByTestId("dashboardcard-actions-panel").within(() => {- cy.icon("palette").click({ force: true });- });-- cy.findByRole("dialog").within(() => {- cy.findByRole("switch", {- name: "Hide this card if there are no results",- }).click({ force: true });- cy.button("Done").click();- });-- H.saveDashboard();-- // Verify the card is hidden when the value is correct but produces empty results- H.filterWidget().click();- H.dashboardParametersPopover().within(() => {- cy.findByPlaceholderText("Enter an ID").type("-1{enter}");- cy.button("Add filter").click();- });-- cy.findByTestId("dashcard").should("not.exist");-- // Verify it becomes visible once the filter is cleared- H.filterWidget().within(() => {- cy.icon("close").click();- });-- cy.findByTestId("dashcard").findByText("Orders");- });-describe("warn before leave", () => {beforeEach(() => {cy.intercept("GET", "/api/card/*/query_metadata").as("queryMetadata");});- it("should warn a user before leaving after adding, editing, or removing a card on a dashboard", () => {+ it("should warn a user before leaving after changing cards or tabs on a dashboard", () => {cy.visit("/");- cy.findByTestId("loading-indicator").should("not.exist");-- cy.findByTestId("home-page").should(- "contain",- "Try out these sample x-rays to see what Metabase can do.",- );-// addcreateNewDashboard();cy.findByTestId("dashboard-header").icon("add").click();@@ -927,14 +820,10 @@ describe("scenarios > dashboard", () => {H.editDashboard();H.removeDashboardCard();assertPreventLeave();- });-- it("should warn a user before leaving after adding, removing, moving, or duplicating a tab", () => {- cy.visit("/");- cy.findByTestId("loading-indicator").should("not.exist");+ H.saveDashboard();// add tab- createNewDashboard();+ H.editDashboard();H.createNewTab();assertPreventLeave();H.saveDashboard();@@ -975,6 +864,14 @@ describe("scenarios > dashboard", () => {H.editDashboard();H.renameTab("Tab 2", "Foo tab");assertPreventLeave();+ H.saveDashboard();++ cy.log("No warning without changes");+ H.editDashboard();+ H.openQuestionsSidebar();+ cy.findByTestId("new-button-bar").findByText("New Question").click();+ cy.location("pathname").should("not.match", /^\/dashboard\//);+ cy.get("body").should("not.contain", "Save your changes?");});function createNewDashboard() {@@ -1008,7 +905,7 @@ describe("scenarios > dashboard", () => {});});-describe("scenarios > dashboard", () => {+describe("scenarios > dashboard > tracking", () => {beforeEach(() => {H.resetSnowplow();H.restore();@@ -1122,10 +1019,6 @@ describe("scenarios > dashboard", () => {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 domainsH.editIFrameWhileEditing(0, "player.videos.com/video/123456789");cy.button("Done").click();@@ -1161,7 +1054,43 @@ describe("scenarios > dashboard", () => {});});- it("should track enabling the hide empty cards setting", () => {+ it("should allow making card hide when it is empty and track enabling it", () => {+ const FILTER_ID = "d7988e02";++ cy.log("Add filter to the dashboard");+ cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {+ parameters: [+ {+ id: FILTER_ID,+ name: "ID",+ slug: "id",+ type: "id",+ },+ ],+ });++ cy.log("Connect filter to the existing card");+ cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {+ dashcards: [+ {+ id: ORDERS_DASHBOARD_DASHCARD_ID,+ card_id: ORDERS_QUESTION_ID,+ row: 0,+ col: 0,+ size_x: 16,+ size_y: 8,+ parameter_mappings: [+ {+ parameter_id: FILTER_ID,+ card_id: ORDERS_QUESTION_ID,+ target: ["dimension", ["field", ORDERS.ID]],+ },+ ],+ visualization_settings: {},+ },+ ],+ });+H.visitDashboard(ORDERS_DASHBOARD_ID);H.editDashboard();@@ -1184,7 +1113,26 @@ describe("scenarios > dashboard", () => {},2,);+ cy.button("Done").click();+ });++ H.saveDashboard();++ // Verify the card is hidden when the value is correct but produces empty results+ H.filterWidget().click();+ H.dashboardParametersPopover().within(() => {+ cy.findByPlaceholderText("Enter an ID").type("-1{enter}");+ cy.button("Add filter").click();+ });++ cy.findByTestId("dashcard").should("not.exist");++ // Verify it becomes visible once the filter is cleared+ H.filterWidget().within(() => {+ cy.icon("close").click();});++ cy.findByTestId("dashcard").findByText("Orders");});it("should allow the creator to change the dashboard width to 'fixed' or 'full'", () => {@@ -1247,6 +1195,10 @@ describe("scenarios > dashboard", () => {// confirm it saves the state after saving and refreshingH.saveDashboard();cy.reload();+ H.getDashboardCard(0)+ .findByText("Top: contains Example Input")+ .should("be.visible");+ H.getDashboardCard(1).findByText("Bottom").should("be.visible");H.assertDashboardFullWidth();// toggle back to fixed@@ -1301,13 +1253,6 @@ describe("scenarios > dashboard", () => {});});-function assertScrollBarExists() {- cy.get("body").then(($body) => {- const bodyWidth = $body[0].getBoundingClientRect().width;- cy.window().its("innerWidth").should("be.gte", bodyWidth);- });-}-describe("scenarios > dashboard > permissions", () => {let dashboardId;@@ -1379,35 +1324,57 @@ describe("scenarios > dashboard > permissions", () => {});});- it("should let admins view all cards in a dashboard", () => {+ it("should show each user the cards and dashboards they have permission to see", () => {+ cy.log("Admins can see all cards");H.visitDashboard(dashboardId);- // Admin can see both questions- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("First Question");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("foo");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Second Question");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("bar");- });-- it("should display dashboards with some cards locked down", () => {+ H.getDashboardCards()+ .should("have.length", 2)+ .and("contain", "First Question")+ .and("contain", "foo")+ .and("contain", "Second Question")+ .and("contain", "bar");++ cy.log("Users without collection access see the other cards");cy.signIn("nodata");H.visitDashboard(dashboardId);- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Sorry, you don't have permission to see this card.");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Second Question");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("bar");- });+ H.getDashboardCards()+ .should("have.length", 2)+ .and("contain", "Sorry, you don't have permission to see this card.")+ .and("contain", "Second Question")+ .and("contain", "bar");- it("should display an error if they don't have perms for the dashboard", () => {+ cy.log("Users without dashboard access see an error");cy.signIn("nocollection");- H.visitDashboard(dashboardId);- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Sorry, you don’t have permission to see that.");+ cy.visit(`/dashboard/${dashboardId}`);+ H.main()+ .findByText("Sorry, you don’t have permission to see that.")+ .should("be.visible");+ });++ it("should not count cards the user cannot see as loading (metabase#28756)", () => {+ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query", (req) => {+ req.on("response", (res) => {+ res.setDelay(60_000);+ });+ });++ cy.log("The tab title shows the loading progress");+ cy.visit(`/dashboard/${dashboardId}`);+ cy.title().should("contain", "0/2 loaded");++ cy.log(+ "A card the user has no permission to see does not count as loading",+ );+ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query", (req) => {+ // req.continue() skips the intercepts that were added before this one+ req.continue();+ });+ cy.signInAsNormalUser();+ cy.visit(`/dashboard/${dashboardId}`);+ H.getDashboardCards()+ .should("contain", "Sorry, you don't have permission to see this card.")+ .and("contain", "bar");+ cy.title().should("match", /^Test Dashboard · /);});});@@ -1417,16 +1384,19 @@ describe("scenarios > dashboard > entity id support", () => {cy.signInAsAdmin();});- it("when loading `/dashboard/entity/${entity_id}`, it should redirect to `/dashboard/${id}` and display the dashboard correctly", () => {+ it("should redirect entity id paths to the dashboard, its tabs and its modals, and keep the search params", () => {+ cy.log("Dashboard entity id");cy.visit(`/dashboard/entity/${ORDERS_DASHBOARD_ENTITY_ID}`);-cy.url().should("contain", `/dashboard/${ORDERS_DASHBOARD_ID}`);+ H.main().findByText("Orders in a dashboard").should("be.visible");- // Making sure the dashboard loads+ cy.log("Dashboard entity id with the move modal path");+ cy.visit(`/dashboard/entity/${ORDERS_DASHBOARD_ENTITY_ID}/move`);+ cy.url().should("contain", `/dashboard/${ORDERS_DASHBOARD_ID}/move`);H.main().findByText("Orders in a dashboard").should("be.visible");- });+ H.modal().findByText("Move dashboard to…").should("be.visible");- it("when loading `/dashboard/entity/${entity_id}?tab=${tab_entity_id}`, it should redirect to `/dashboard/${id}?tab=${tab_id}` and select the correct tab", () => {+ cy.log("Dashboard and tab entity ids");H.createDashboardWithTabs({tabs: [{ name: "Tab 1", id: -1 },@@ -1447,10 +1417,8 @@ describe("scenarios > dashboard > entity id support", () => {.findByRole("tab", { name: "Tab 2" }).should("have.attr", "aria-selected", "true");});- });- it("it should preserve search params such as filters when redirecting", () => {- // Add filter to the dashboard+ cy.log("Search params such as filters are kept");cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {parameters: [{@@ -1460,10 +1428,6 @@ describe("scenarios > dashboard > entity id support", () => {type: "string/=",},],- });-- // Connect filter to the existing card- cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {dashcards: [{id: ORDERS_DASHBOARD_DASHCARD_ID,@@ -1483,46 +1447,30 @@ describe("scenarios > dashboard > entity id support", () => {},],});-- // Visit the dashboard via the entity id path and verify that the filter is preservedcy.visit(`/dashboard/entity/${ORDERS_DASHBOARD_ENTITY_ID}?text=123`);-cy.url().should("contain", `/dashboard/${ORDERS_DASHBOARD_ID}`).and("contain", "text=123");-H.filterWidget().should("contain", "Text").and("contain", "123");});- it("when loading `/dashboard/entity/${entity_id}/move`, it should redirect to `/dashboard/${id}/move` and show the move modal", () => {- cy.visit(`/dashboard/entity/${ORDERS_DASHBOARD_ENTITY_ID}/move`);- cy.url().should("contain", `/dashboard/${ORDERS_DASHBOARD_ID}/move`);-- H.main().findByText("Orders in a dashboard").should("be.visible");- H.modal().findByText("Move dashboard to…").should("be.visible");- });-- it("when loading `/dashboard/entity/${non existing entity id}`, it should show a 404 page", () => {- const nonExistingEntityId = "x".repeat(21);- cy.visit(`/dashboard/entity/${nonExistingEntityId}`);+ it("should show a 404 page for entity ids that do not exist", () => {+ const assertNotFound = () =>+ H.main().findByText("We're a little lost...").should("be.visible");- H.main().findByText("We're a little lost...").should("be.visible");- });-- it("when loading `/dashboard/entity/${non existing entity id}`, it should show a 404 page even if the entity id starts with a number", () => {- const nonExistingEntityId = "12".padEnd(21, "x");- cy.visit(`/dashboard/entity/${nonExistingEntityId}`);+ cy.log("non existing dashboard entity id");+ cy.visit(`/dashboard/entity/${"x".repeat(21)}`);+ assertNotFound();- H.main().findByText("We're a little lost...").should("be.visible");- });+ cy.log("non existing dashboard entity id that starts with a number");+ cy.visit(`/dashboard/entity/${"12".padEnd(21, "x")}`);+ assertNotFound();- it("when loading `/dashboard/entity/${entity id}?tab=${non existing tab entity id}`, it should show a 404 page even if the entity id starts with a number", () => {- const nonExistingEntityId = "12".padEnd(21, "x");+ cy.log("non existing tab entity id that starts with a number");cy.visit(- `/dashboard/entity/${ORDERS_DASHBOARD_ENTITY_ID}?tab=${nonExistingEntityId}`,+ `/dashboard/entity/${ORDERS_DASHBOARD_ENTITY_ID}?tab=${"12".padEnd(21, "x")}`,);-- H.main().findByText("We're a little lost...").should("be.visible");+ assertNotFound();});});@@ -1530,11 +1478,783 @@ 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)+ H.getDashboardCard(index)+ .find("iframe").should("have.attr", "src", src).and("have.attr", "sandbox", IFRAME_SANDBOX).and("not.have.attr", "onload");}++describe("issue 43219", () => {+ const questionDetails = {+ display: "line",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ [+ "field",+ ORDERS.CREATED_AT,+ {+ "base-type": "type/DateTime",+ "temporal-unit": "month",+ },+ ],+ ],+ },+ };++ const textFilter = createMockParameter({+ name: "Text",+ slug: "string",+ id: "5aefc726",+ type: "string/=",+ sectionId: "string",+ });++ const cardsCount = 10;++ const getQuestionAlias = (index) => `question-${index}`;++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ H.cypressWaitAll(+ Array.from({ length: cardsCount }, (_value, index) => {+ const name = `Series ${index + 1}`;+ return H.createQuestion({ ...questionDetails, name }).then(+ ({ body: question }) => {+ cy.wrap(question).as(getQuestionAlias(index));+ },+ );+ }),+ );++ cy.then(function () {+ H.createDashboardWithQuestions({+ dashboardDetails: {+ parameters: [textFilter],+ },+ questions: [+ {+ ...questionDetails,+ name: "Base series",+ },+ ],+ cards: [+ {+ size_x: 4,+ size_y: 3,+ series: Array.from(+ { length: cardsCount },+ (_value, index) => this[getQuestionAlias(index)],+ ),+ },+ ],+ }).then(({ dashboard }) => {+ H.visitDashboard(dashboard.id);+ });+ });+ });++ it("is possible to map parameters to dashcards with lots of series (metabase#43219)", () => {+ H.editDashboard();+ cy.findByTestId("edit-dashboard-parameters-widget-container")+ .findByText("Text")+ .click();++ H.getDashboardCard(0).within(() => {+ cy.findByText("Series 10").should("exist").and("not.be.visible");++ cy.findByTestId("visualization-root").scrollTo("bottom");+ cy.findByTestId("parameter-mapper-container").scrollTo("right");++ cy.findByText("Series 10").should("be.visible");+ });+ });+});++describe("issue 16559", () => {+ const dashboardDetails = {+ name: "16559 Dashboard",+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ H.createDashboard(dashboardDetails).then((response) => {+ H.visitDashboard(response.body.id);+ });++ cy.intercept("PUT", "/api/dashboard/*").as("saveDashboard");+ cy.intercept("POST", "/api/card/*/query").as("cardQuery");+ });++ it("should always show the most recent revision (metabase#16559)", () => {+ H.openDashboardInfoSidebar().within(() => {+ cy.contains("button", "History").click();+ cy.findByRole("tab", { name: "History" }).click();+ cy.log("Dashboard creation");+ cy.findByTestId("dashboard-history-list")+ .findAllByTestId("revision-history-event")+ .eq(0)+ .findByText("You created this.")+ .should("be.visible");+ });+ H.closeDashboardInfoSidebar();++ cy.log("Edit dashboard");+ H.editDashboard();+ H.openQuestionsSidebar();+ H.sidebar().findByText("Orders, Count").click();+ cy.wait("@cardQuery");+ // Use the canonical save helper so we deterministically wait for the whole+ // save-and-settle sequence (PUT + query_metadata reload, edit-bar gone, all+ // dashcards loaded). The previous ad-hoc `Save` click only awaited the PUT,+ // so the "More info" click below raced the trailing re-render and was+ // dropped, leaving the sidesheet closed.+ H.saveDashboard();++ H.openDashboardInfoSidebar().within(() => {+ cy.contains("button", "History").click();+ cy.findByTestId("dashboard-history-list")+ .findAllByTestId("revision-history-event")+ .eq(0)+ .findByText("You added a card.")+ .should("be.visible");+ });+ H.closeDashboardInfoSidebar();++ cy.log("Change dashboard name");+ cy.findByTestId("dashboard-name-heading").click().type(" modified").blur();+ cy.wait("@saveDashboard");++ H.openDashboardInfoSidebar().within(() => {+ cy.contains("button", "History").click();++ cy.findByTestId("dashboard-history-list")+ .findAllByTestId("revision-history-event")+ .eq(0)+ .findByText(+ 'You renamed this Dashboard from "16559 Dashboard" to "16559 Dashboard modified".',+ )+ .should("be.visible");++ cy.log("Add description");+ cy.findByRole("tab", { name: "Overview" }).click();++ cy.findByPlaceholderText("Add description")+ .click()+ .type("16559 description")+ .blur();+ cy.wait("@saveDashboard");++ cy.contains("button", "History").click();++ cy.findByTestId("dashboard-history-list")+ .findAllByTestId("revision-history-event")+ .eq(0)+ .findByText("You added a description.")+ .should("be.visible");++ cy.log("Toggle auto-apply filters");+ });+ H.closeDashboardInfoSidebar();++ H.openDashboardSettingsSidebar();+ H.sidesheet().findByLabelText("Auto-apply filters").click();+ cy.wait("@saveDashboard");+ H.closeDashboardSettingsSidebar();++ H.openDashboardInfoSidebar().within(() => {+ cy.contains("button", "History").click();++ cy.findByTestId("dashboard-history-list")+ .findAllByTestId("revision-history-event")+ .eq(0)+ .findByText("You set auto apply filters to false.")+ .should("be.visible");+ });+ H.closeDashboardInfoSidebar();++ cy.log("Move dashboard to another collection");+ H.dashboardHeader().icon("ellipsis").click();+ H.popover().findByText("Move").click();+ H.entityPickerModal().within(() => {+ cy.findByText("First collection").click();+ cy.button("Move").click();+ cy.wait(["@saveDashboard"]);+ });++ H.openDashboardInfoSidebar().within(() => {+ cy.contains("button", "History").click();+ cy.findByTestId("dashboard-history-list")+ .findAllByTestId("revision-history-event")+ .eq(0)+ .findByText("You moved this Dashboard to First collection.")+ .should("be.visible");+ });+ });+});++describe("should not redirect users to other pages when linking an entity (metabase#35037)", () => {+ const TEST_DASHBOARD_NAME = "Orders in a dashboard";+ const TEST_QUESTION_NAME = "Question#35037";++ beforeEach(() => {+ H.resetSnowplow();+ H.restore();+ cy.signInAsAdmin();+ H.enableTracking();+ cy.intercept("GET", "/api/activity/recents?*").as("recentViews");+ });++ 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.location("pathname").then((originPath) => {+ cy.wrap(originPath).as("originPath");+ });++ cy.log("link a recent item");+ cy.findByLabelText("Add a link or iframe").click();+ H.popover().findByText("Link").click();+ cy.wait("@recentViews");++ cy.findByTestId("recents-list-container").within(() => {+ cy.findByText(TEST_DASHBOARD_NAME).click();+ });++ 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.log("link a search item");+ cy.icon("link").click();+ H.popover().findByText("Link").click();+ cy.findByTestId("custom-edit-text-link")+ .findByPlaceholderText("https://example.com")+ .type(TEST_QUESTION_NAME);+ cy.findByTestId("search-results-list").within(() => {+ cy.findByText(TEST_QUESTION_NAME).click();+ });++ cy.findAllByTestId("entity-edit-display-link")+ .should("have.length", 2)+ .and("contain", TEST_QUESTION_NAME);+ cy.findByTestId("search-results-list").should("not.exist");+ assertOriginPath();++ // 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 47170", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ cy.request("POST", `/api/bookmark/dashboard/${ORDERS_DASHBOARD_ID}`);++ H.createDashboard({ name: "Dashboard A" }, { wrapId: true }).then(+ (dashboardId) => {+ cy.request("POST", `/api/bookmark/dashboard/${dashboardId}`);+ },+ );++ // Keep the first dashboard loading so that navigating away cancels its fetch+ cy.intercept(+ { method: "GET", pathname: `/api/dashboard/${ORDERS_DASHBOARD_ID}` },+ (req) => {+ req.on("response", (res) => {+ res.setDelay(10_000);+ });+ },+ );+ });++ it("should not show error when dashboard fetch request is cancelled (metabase#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("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();+ H.popover().findByText("Enter fullscreen").click();++ const primaryTextColor = "rgba(255, 255, 255, 0.95)";++ cy.findByTestId("dashboard-name-heading").should(+ "have.css",+ "color",+ primaryTextColor,+ );++ H.getDashboardCard(0)+ .findByText("37.65")+ .should("have.css", "color", primaryTextColor);++ cy.findByTestId("sharing-menu-button").should(+ "have.css",+ "color",+ primaryTextColor,+ );+ });+});++describe("issue 49556", () => {+ const TAB = { id: 1, name: "Tab" };++ const PEOPLE_NAME_FIELD_REF = [+ "field",+ PEOPLE.NAME,+ { "base-type": "type/Text" },+ ];++ const TARGET_PARAMETER = {+ id: "d7988e02",+ name: "Target",+ slug: "target",+ type: "category",+ filteringParameters: ["d7988e03"],+ };++ const SOURCE_PARAMETER = {+ id: "d7988e03",+ name: "Source",+ slug: "source",+ type: "category",+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ H.createDashboardWithTabs({+ tabs: [TAB],+ parameters: [TARGET_PARAMETER, SOURCE_PARAMETER],+ dashcards: [+ createMockDashboardCard({+ id: -1,+ dashboard_tab_id: TAB.id,+ size_x: 10,+ size_y: 4,+ card_id: ORDERS_QUESTION_ID,+ parameter_mappings: [+ {+ parameter_id: TARGET_PARAMETER.id,+ card_id: ORDERS_QUESTION_ID,+ target: [+ "dimension",+ PEOPLE_NAME_FIELD_REF,+ { "stage-number": 0 },+ ],+ },+ {+ parameter_id: SOURCE_PARAMETER.id,+ card_id: ORDERS_QUESTION_ID,+ target: [+ "dimension",+ PEOPLE_NAME_FIELD_REF,+ { "stage-number": 0 },+ ],+ },+ ],+ }),+ ],+ }).then((dashboard) => H.visitDashboard(dashboard.id));+ });++ it("unlinks the filter when it is removed (metabase#49556)", () => {+ H.editDashboard();++ cy.log("Values of a linked filter cannot be edited");+ cy.findByTestId("fixed-width-filters").findByText("Target").click();+ H.dashboardParameterSidebar().button("Edit").should("be.disabled");++ cy.findByTestId("fixed-width-filters").findByText("Source").click();+ H.dashboardParameterSidebar().findByText("Remove").click();+ cy.findByTestId("fixed-width-filters")+ .findByText("Source")+ .should("not.exist");++ cy.findByTestId("fixed-width-filters").findByText("Target").click();+ H.dashboardParameterSidebar().button("Edit").should("be.enabled");+ });+});++describe("issues 54353 and 52674", () => {+ const peopleSourceFieldRef = [+ "field",+ PEOPLE.SOURCE,+ { "base-type": "type/Text", "source-field": ORDERS.USER_ID },+ ];+ const ordersCreatedAtFieldRef = [+ "field",+ ORDERS.CREATED_AT,+ { "base-type": "type/DateTime", "temporal-unit": "month" },+ ];+ const ordersTotalFieldRef = [+ "field",+ ORDERS.TOTAL,+ { "base-type": "type/Number" },+ ];++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should open and close filter widgets with the keyboard (metabase#54353, metabase#52674)", () => {+ H.createDashboardWithQuestions({+ dashboardDetails: {+ parameters: [+ createMockParameter({+ id: "param-1",+ name: "Date",+ slug: "date",+ type: "date/all-options",+ }),+ createMockParameter({+ id: "param-2",+ name: "Number",+ slug: "number",+ type: "number/between",+ }),+ ],+ },+ questions: [+ {+ name: "fooBarQuestion",+ display: "bar",+ query: {+ aggregation: [["count"]],+ breakout: [peopleSourceFieldRef, ordersCreatedAtFieldRef],+ "source-table": ORDERS_ID,+ },+ },+ {+ query: {+ "source-table": ORDERS_ID,+ },+ },+ ],+ }).then(({ dashboard, questions: [barQuestion, tableQuestion] }) => {+ cy.request("GET", `/api/dashboard/${dashboard.id}`).then(+ ({ body: dashboard }) => {+ const findDashcard = (question) =>+ dashboard.dashcards.find(+ (dashcard) => dashcard.card_id === question.id,+ );+ const barDashcard = findDashcard(barQuestion);+ const tableDashcard = findDashcard(tableQuestion);+ cy.request("PUT", `/api/dashboard/${dashboard.id}`, {+ dashcards: [+ {+ ...barDashcard,+ parameter_mappings: [+ {+ card_id: barDashcard.card_id,+ parameter_id: "param-1",+ target: ["dimension", ordersCreatedAtFieldRef],+ },+ ],+ },+ {+ ...tableDashcard,+ parameter_mappings: [+ {+ card_id: tableDashcard.card_id,+ parameter_id: "param-2",+ target: ["dimension", ordersTotalFieldRef],+ },+ ],+ },+ ],+ }).then(() => {+ cy.wrap(dashboard.id).as("dashboardId");+ });+ },+ );+ });+ H.visitDashboard("@dashboardId");++ cy.log("Escape should close the date filter (metabase#54353)");+ cy.findByLabelText("Date").click();+ H.popover()+ .findByText(/Previous 12 months/i)+ .click();++ cy.findByLabelText("Date").click();+ H.popover().should("be.visible");++ cy.realPress("Escape");+ cy.findByRole("dialog").should("not.exist");++ cy.log("Enter should open a filter widget (metabase#52674)");+ H.main().button("Number").focus();+ cy.realPress("Enter");+ H.popover().should("be.visible");++ cy.log("Close the popover");+ H.main().button("Number").click();+ cy.findByRole("dialog").should("not.exist");++ cy.log("Space should open a filter widget (metabase#52674)");+ H.main().button("Number").focus();+ cy.realPress("Space");+ H.popover().should("be.visible");+ });+});++describe("issue 44937", () => {+ beforeEach(() => {+ H.restore();+ cy.signIn("readonly");+ });++ it("dashboard empty state should not suggest creating a new question when users have no creation permission (metabase#44937)", () => {+ cy.visit("/");+ H.newButton().click();+ H.popover().findByText("Dashboard").click();+ H.modal().within(() => {+ cy.findByPlaceholderText("What is the name of your dashboard?").type(+ "my dashboard",+ );+ cy.button("Create").click();+ });++ H.main().findByText(+ "Browse your collections to find and add existing questions.",+ );++ cy.button("Add a chart").click();+ H.sidebar().within(() => {+ cy.findByText("Our analytics").click();+ cy.findByText("Orders").click();+ });+ H.getDashboardCards().should("have.length", 1);++ H.createNewTab();++ H.main().findByText(+ "Browse your collections to find and add existing questions.",+ );+ });+});++describe("issue 65908", () => {+ const dateParameters = {+ default: "2030-01-01~",+ id: "d3b78b27",+ name: "Date Filter",+ slug: "date_filter",+ type: "date/all-options",+ };++ function createDashcard({+ index,+ questionId,+ hideEmptyResults,+ withParameterMappings,+ }) {+ const cardHeightInRows = 10;++ return {+ col: 0,+ row: cardHeightInRows * index,+ size_x: 24,+ size_y: cardHeightInRows,+ card_id: questionId,+ visualization_settings: {+ "card.hide_empty": hideEmptyResults,+ },+ parameter_mappings: withParameterMappings+ ? [+ {+ parameter_id: dateParameters.id,+ card_id: questionId,+ target: ["dimension", ["field", ORDERS.CREATED_AT, null]],+ },+ ]+ : undefined,+ };+ }++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ const dashboardDetails = {+ name: "Dashboard with empty result cards",+ parameters: [dateParameters],+ };++ const questionDetails = {+ name: "Orders question",+ query: {+ "source-table": ORDERS_ID,+ limit: 5,+ },+ };++ H.createDashboardWithQuestions({+ dashboardDetails,+ questions: [questionDetails],+ }).then(({ dashboard, questions }) => {+ const [question] = questions;+ H.updateDashboardCards({+ dashboard_id: dashboard.id,+ cards: [+ createDashcard({+ index: 0,+ questionId: question.id,+ hideEmptyResults: true,+ withParameterMappings: true,+ }),+ createDashcard({+ index: 1,+ questionId: question.id,+ hideEmptyResults: true,+ withParameterMappings: true,+ }),+ createDashcard({+ index: 2,+ questionId: question.id,+ hideEmptyResults: true,+ withParameterMappings: true,+ }),+ createDashcard({+ index: 3,+ questionId: question.id,+ hideEmptyResults: false,+ withParameterMappings: false,+ }),+ ],+ });+ cy.wrap(dashboard.id).as("dashboardId");+ });+ });++ it("should not take into account the height of cards with no results when calculating dashboard height (metabase#65908)", () => {+ cy.get("@dashboardId").then((dashboardId) => {+ H.visitDashboard(dashboardId);++ cy.findByDisplayValue("Dashboard with empty result cards").should(+ "be.visible",+ );++ H.getDashboardCard().within(() => {+ cy.findByText("Orders question").should("be.visible");+ cy.log("Checks for the subtotal value from the first row");+ cy.findByText("37.65").should("be.visible");+ });++ cy.findByRole("main").should(($main) => {+ // 4 cards take about 2000px in height, so only 1 card should definitely take less than 1000px+ expect($main[0].scrollHeight).to.be.lessThan(1000);+ });+ });+ });+});++describe("issue 12926", () => {+ const filterDisplayName = "F";+ const queryResult = 42;+ const parameterValue = 10;+ const questionDetails = {+ name: "Question 1",+ native: {+ query: `SELECT ${queryResult} [[+{{F}}]] as ANSWER`,+ "template-tags": {+ F: {+ type: "number",+ name: "F",+ id: "b22a5ce2-fe1d-44e3-8df4-f8951f7921bc",+ "display-name": filterDisplayName,+ },+ },+ },+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should load a card with correct parameters after a save retriggers a non saved query with a negative id (metabase#12926)", () => {+ H.createNativeQuestion(questionDetails);++ H.createDashboard().then(({ body: { id: dashboardId } }) => {+ H.visitDashboard(dashboardId);+ });++ H.editDashboard();++ H.openQuestionsSidebar();+ H.sidebar().findByText(questionDetails.name).click();++ H.setFilter("Number", "Equal to");+ H.sidebar().findByText("No default").click();+ H.popover().findByPlaceholderText("Enter a number").type(parameterValue);+ H.popover().findByText("Add filter").click();++ H.getDashboardCard().findByText("Select…").click();+ H.popover().contains(filterDisplayName).eq(0).click();++ H.saveDashboard();++ H.getDashboardCard().findByText(queryResult + parameterValue);+ });+});diff --git a/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.jsindex 399de794db4..f31935b2a18 100644--- a/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashcard-drill.cy.spec.js@@ -1132,153 +1132,146 @@ describe("scenarios > dashboard > title drill", () => {cy.findByText(/Created At/).should("not.exist");});});- });-});-describe("issue 29076", () => {- beforeEach(() => {- H.restore();+ it("should use the card name instead of series names when navigating to the query builder from the dashcard title (metabase#42165)", () => {+ const peopleSourceFieldRef = [+ "field",+ PEOPLE.SOURCE,+ { "base-type": "type/Text", "source-field": ORDERS.USER_ID },+ ];+ const ordersCreatedAtFieldRef = [+ "field",+ ORDERS.CREATED_AT,+ { "base-type": "type/DateTime", "temporal-unit": "month" },+ ];- cy.intercept("/api/dashboard/*/dashcard/*/card/*/query").as("cardQuery");+ cy.intercept("POST", "/api/dataset").as("dataset");- cy.signInAsAdmin();- H.activateToken("pro-self-hosted");-- cy.updatePermissionsGraph({- [ALL_USERS_GROUP]: {- [SAMPLE_DB_ID]: {- "view-data": "blocked",- "create-queries": "no",- },- },- [COLLECTION_GROUP]: {- [SAMPLE_DB_ID]: {- "view-data": "unrestricted",- "create-queries": "query-builder",+ H.createDashboardWithQuestions({+ dashboardDetails: {+ parameters: [+ createMockParameter({+ id: "param-1",+ name: "Date",+ slug: "date",+ type: "date/all-options",+ }),+ ],},- },- });- cy.sandboxTable({- table_id: ORDERS_ID,- attribute_remappings: {- attr_uid: ["dimension", ["field", ORDERS.ID, null]],- },- });- cy.signInAsSandboxedUser();- });+ questions: [+ {+ name: "fooBarQuestion",+ display: "bar",+ query: {+ aggregation: [["count"]],+ breakout: [peopleSourceFieldRef, ordersCreatedAtFieldRef],+ "source-table": ORDERS_ID,+ },+ },+ ],+ }).then(({ dashboard: _dashboard }) => {+ cy.request("GET", `/api/dashboard/${_dashboard.id}`).then(+ ({ body: dashboard }) => {+ const [dashcard] = dashboard.dashcards;+ const [parameter] = dashboard.parameters;+ cy.request("PUT", `/api/dashboard/${dashboard.id}`, {+ dashcards: [+ {+ ...dashcard,+ parameter_mappings: [+ {+ card_id: dashcard.card_id,+ parameter_id: parameter.id,+ target: ["dimension", ordersCreatedAtFieldRef],+ },+ ],+ },+ ],+ }).then(() => {+ cy.wrap(_dashboard.id).as("dashboardId");+ });+ },+ );+ });- it("should be able to drilldown to a saved question in a dashboard with sandboxing (metabase#29076)", () => {- H.visitDashboard(ORDERS_DASHBOARD_ID);- cy.wait("@cardQuery");- // test that user is sandboxed - normal users has over 2000 rows- H.getDashboardCard()- .findByTestId("table-body")- .findAllByRole("row")- .should("have.length", 1);- H.assertDatasetReqIsSandboxed({- requestAlias: "@cardQuery",- columnId: ORDERS.ID,- columnAssertion: Number(USERS.sandboxed.login_attributes.attr_uid),- });+ cy.get("@dashboardId").then((dashboardId) => {+ H.visitDashboard(dashboardId, { params: { date: "2027-01" } });+ H.filterWidget().should("contain", "2027");- cy.intercept("POST", "/api/card/*/query").as("questionQuery");- H.getDashboardCard().findByRole("link", { name: "Orders" }).click();- cy.wait("@questionQuery");+ H.getDashboardCard(0).within(() => {+ cy.findAllByTestId("legend-item").should("have.length", 5);+ cy.findAllByTestId("legend-item")+ .first()+ .should("contain.text", "Affiliate");+ cy.findByText("fooBarQuestion").click();+ });- cy.location("pathname").should(- "eq",- `/question/${ORDERS_QUESTION_ID}-orders`,- );- H.assertQueryBuilderRowCount(1); // test that user is sandboxed - normal users has over 2000 rows- H.assertDatasetReqIsSandboxed({- requestAlias: "@questionQuery",- columnId: ORDERS.ID,- columnAssertion: Number(USERS.sandboxed.login_attributes.attr_uid),+ cy.wait("@dataset");+ cy.title().should("eq", "fooBarQuestion · Metabase");+ });});});-});-describe("issue 42165", () => {- const peopleSourceFieldRef = [- "field",- PEOPLE.SOURCE,- { "base-type": "type/Text", "source-field": ORDERS.USER_ID },- ];- const ordersCreatedAtFieldRef = [- "field",- ORDERS.CREATED_AT,- { "base-type": "type/DateTime", "temporal-unit": "month" },- ];+ describe("with sandboxing", () => {+ beforeEach(() => {+ H.restore();- beforeEach(() => {- H.restore();- cy.signInAsAdmin();+ cy.intercept("/api/dashboard/*/dashcard/*/card/*/query").as("cardQuery");- cy.intercept("POST", "/api/dataset").as("dataset");+ cy.signInAsAdmin();+ H.activateToken("pro-self-hosted");- H.createDashboardWithQuestions({- dashboardDetails: {- parameters: [- createMockParameter({- id: "param-1",- name: "Date",- slug: "date",- type: "date/all-options",- }),- ],- },- questions: [- {- name: "fooBarQuestion",- display: "bar",- query: {- aggregation: [["count"]],- breakout: [peopleSourceFieldRef, ordersCreatedAtFieldRef],- "source-table": ORDERS_ID,+ cy.updatePermissionsGraph({+ [ALL_USERS_GROUP]: {+ [SAMPLE_DB_ID]: {+ "view-data": "blocked",+ "create-queries": "no",},},- ],- }).then(({ dashboard: _dashboard }) => {- cy.request("GET", `/api/dashboard/${_dashboard.id}`).then(- ({ body: dashboard }) => {- const [dashcard] = dashboard.dashcards;- const [parameter] = dashboard.parameters;- cy.request("PUT", `/api/dashboard/${dashboard.id}`, {- dashcards: [- {- ...dashcard,- parameter_mappings: [- {- card_id: dashcard.card_id,- parameter_id: parameter.id,- target: ["dimension", ordersCreatedAtFieldRef],- },- ],- },- ],- }).then(() => {- cy.wrap(_dashboard.id).as("dashboardId");- });+ [COLLECTION_GROUP]: {+ [SAMPLE_DB_ID]: {+ "view-data": "unrestricted",+ "create-queries": "query-builder",+ },},- );+ });+ cy.sandboxTable({+ table_id: ORDERS_ID,+ attribute_remappings: {+ attr_uid: ["dimension", ["field", ORDERS.ID, null]],+ },+ });+ cy.signInAsSandboxedUser();});- });- it("should use card name instead of series names when navigating to QB from dashcard title", () => {- cy.get("@dashboardId").then((dashboardId) => {- H.visitDashboard(dashboardId, { params: { date: "2027-01" } });- H.filterWidget().should("contain", "2027");-- H.getDashboardCard(0).within(() => {- cy.findAllByTestId("legend-item").should("have.length", 5);- cy.findAllByTestId("legend-item")- .first()- .should("contain.text", "Affiliate");- cy.findByText("fooBarQuestion").click();+ it("should be able to drilldown to a saved question in a dashboard with sandboxing (metabase#29076)", () => {+ H.visitDashboard(ORDERS_DASHBOARD_ID);+ cy.wait("@cardQuery");+ // test that user is sandboxed - normal users has over 2000 rows+ H.getDashboardCard()+ .findByTestId("table-body")+ .findAllByRole("row")+ .should("have.length", 1);+ H.assertDatasetReqIsSandboxed({+ requestAlias: "@cardQuery",+ columnId: ORDERS.ID,+ columnAssertion: Number(USERS.sandboxed.login_attributes.attr_uid),});- cy.wait("@dataset");- cy.title().should("eq", "fooBarQuestion · Metabase");+ cy.intercept("POST", "/api/card/*/query").as("questionQuery");+ H.getDashboardCard().findByRole("link", { name: "Orders" }).click();+ cy.wait("@questionQuery");++ cy.location("pathname").should(+ "eq",+ `/question/${ORDERS_QUESTION_ID}-orders`,+ );+ H.assertQueryBuilderRowCount(1); // test that user is sandboxed - normal users has over 2000 rows+ H.assertDatasetReqIsSandboxed({+ requestAlias: "@questionQuery",+ columnId: ORDERS.ID,+ columnAssertion: Number(USERS.sandboxed.login_attributes.attr_uid),+ });});});});@@ -1296,3 +1289,100 @@ function checkFilterLabelAndValue(label, value) {function checkScalarResult(result) {cy.findByTestId("scalar-value").invoke("text").should("eq", result);}++describe("issue 67432", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should copy sorted table data in correct sorted order (metabase#67432)", () => {+ H.grantClipboardPermissions();++ const ROWS_LIMIT = 5;+ const questionDetails = {+ name: "67432 Question",+ query: {+ "source-table": PRODUCTS_ID,+ fields: [+ ["field", PRODUCTS.ID, null],+ ["field", PRODUCTS.TITLE, null],+ ["field", PRODUCTS.CATEGORY, null],+ ],+ limit: ROWS_LIMIT,+ },+ };++ H.createQuestionAndDashboard({+ questionDetails,+ cardDetails: {+ size_x: 16,+ size_y: 10,+ },+ }).then(({ body: { dashboard_id } }) => {+ H.visitDashboard(dashboard_id);+ });++ // Wait for table to load+ H.tableInteractiveBody().should("be.visible");++ // Sort by Category column (descending first click)+ H.tableHeaderClick("Category");++ // Wait for sort to apply - the sort icon should appear+ H.tableHeaderColumn("Category")+ .closest("[data-testid=header-cell]")+ .icon("chevrondown")+ .should("exist");++ // Products 1-5 sorted by Category descending; equal categories keep their row order+ const EXPECTED_ROWS = [+ ["Rustic Paper Wallet", "Gizmo"],+ ["Enormous Marble Wallet", "Gadget"],+ ["Small Marble Shoes", "Doohickey"],+ ["Synergistic Granite Chair", "Doohickey"],+ ["Enormous Aluminum Shirt", "Doohickey"],+ ];++ H.tableInteractiveBody()+ .find('[data-column-id="CATEGORY"]')+ .should(($cells) => {+ expect($cells.toArray().map((cell) => cell.textContent)).to.deep.equal(+ EXPECTED_ROWS.map(([, category]) => category),+ );+ });++ // Select multiple cells across rows by dragging+ const getNonPKCells = () =>+ H.tableInteractiveBody().find(+ '[data-selectable-cell]:not([data-column-id="ID"])',+ );++ // Select Title and Category cells in every row+ getNonPKCells()+ .eq(0)+ .trigger("mousedown", { which: 1 })+ .then(() => {+ const lastCellIndex = ROWS_LIMIT * 2 - 1;+ getNonPKCells()+ .should("have.length", ROWS_LIMIT * 2)+ .eq(lastCellIndex)+ .trigger("mouseover", { buttons: 1 });+ getNonPKCells()+ .should("have.length", ROWS_LIMIT * 2)+ .eq(lastCellIndex)+ .trigger("mouseup");+ });++ // Copy to clipboard+ cy.realPress(["Meta", "c"]);++ // The clipboard holds tab-separated rows in the sorted order+ H.readClipboard().should(+ "equal",+ [["Title", "Category"], ...EXPECTED_ROWS]+ .map((cells) => cells.join("\t"))+ .join("\n"),+ );+ });+});diff --git a/e2e/test/scenarios/dashboard/dashcard-fetching.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-fetching.cy.spec.jsindex c0939fb0f55..9b7d8cb5045 100644--- a/e2e/test/scenarios/dashboard/dashcard-fetching.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashcard-fetching.cy.spec.js@@ -1,9 +1,13 @@const { H } = cy;+import { SAMPLE_DB_ID } from "e2e/support/cypress_data";+import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";import {ORDERS_BY_YEAR_QUESTION_ID,ORDERS_COUNT_QUESTION_ID,} from "e2e/support/cypress_sample_instance_data";+const { ORDERS_ID } = SAMPLE_DATABASE;+const cards = [{card_id: ORDERS_COUNT_QUESTION_ID,@@ -57,3 +61,232 @@ function createDashboardWithCards({cy.wrap(id).as("dashboardId");});}++describe("issue 48878", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ H.setActionsEnabledForDB(SAMPLE_DB_ID);++ cy.signInAsNormalUser();+ cy.intercept("POST", "/api/dataset").as("dataset");+ cy.intercept("POST", "/api/card").as("saveQuestion");+ cy.intercept("POST", "/api/action").as("createAction");+ cy.intercept("GET", "/api/dashboard/*").as("getDashboard");+ cy.intercept("PUT", "/api/dashboard/*").as("updateDashboard");++ cy.intercept("GET", "/api/card/*").as("fetchCard");+ setup();+ });++ // I could only reproduce this issue in Cypress when I didn't use any helpers like createQuestion, etc.+ it("does not crash the action button viz (metabase#48878)", () => {+ cy.reload();+ cy.wait("@fetchCard");+ H.getDashboardCard(0).findByText("Click Me").should("be.visible");+ });++ function setup() {+ cy.log("create model");++ createModel({+ name: "SQL Model",+ query: "select * from orders limit 5",+ });++ cy.log("create model action");++ cy.findByTestId("qb-header-info-button").click();+ H.sidesheet().findByText("Actions").click();++ cy.findByTestId("model-actions-header").findByText("New action").click();++ H.modal().within(() => {+ H.NativeEditor.focus().type("UPDATE orders SET plan = {{ plan ", {+ parseSpecialCharSequences: false,+ });+ cy.button("Save").click();+ });++ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ H.modal()+ .last()+ .within(() => {+ cy.findByPlaceholderText("My new fantastic action").type("Test action");+ cy.button("Create").click();+ cy.wait("@createAction");+ });++ cy.visit("/");++ cy.log("create dashoard");++ cy.button("New").click();+ H.popover().findByText("Dashboard").click();++ H.modal().within(() => {+ cy.findByPlaceholderText("What is the name of your dashboard?").type(+ "Dash",+ );+ cy.button("Create").click();+ cy.wait("@getDashboard");+ });++ cy.button("Add action").click();+ cy.button("Pick an action").click();+ H.modal().within(() => {+ cy.findByText("SQL Model").click();+ cy.findByText("Test action").click();+ cy.button("Done").click();+ });+ cy.button("Save").click();+ cy.wait("@updateDashboard");+ cy.wait("@fetchCard");+ }++ function createModel({ name, query }) {+ cy.visit("/model/new");+ cy.findByTestId("new-model-options")+ .findByText("Use a native query")+ .click();++ H.NativeEditor.focus().type(query);+ cy.findByTestId("native-query-editor-container")+ .findByTestId("run-button")+ .click();+ cy.wait("@dataset");+ cy.button("Save").click();++ H.modal().within(() => {+ cy.findByPlaceholderText("What is the name of your model?").type(name);+ cy.button("Save").click();+ cy.wait("@saveQuestion");+ });+ cy.wait("@fetchCard");+ }+});++describe("dashboard auto-refresh", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should refresh only the card data and not fetch cards that are still loading (metabase#12578, metabase#62170)", () => {+ let releaseQueries;+ const queriesReleased = new Promise((resolve) => {+ releaseQueries = resolve;+ });++ cy.clock(Date.now());+ H.createQuestionAndDashboard({+ questionDetails: {+ name: "Orders Count",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ },+ },+ }).then(({ body: { dashboard_id } }) => {+ cy.intercept("GET", `/api/dashboard/${dashboard_id}*`).as(+ "dashboardLoad",+ );+ H.visitDashboard(dashboard_id);+ });++ // Without tick the dashboard header will not load+ cy.tick();+ H.openDashboardMenu("Auto-refresh");+ H.popover().findByText("1 minute").click();++ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query", (req) =>+ queriesReleased.then(() => req.continue()),+ ).as("dashcardQuery");++ cy.tick(61 * 1000);+ cy.get("@dashcardQuery.all").should("have.length", 1);++ cy.log("refresh while the card query is still loading");+ cy.tick(61 * 1000);+ cy.then(() => releaseQueries());+ cy.wait("@dashcardQuery");+ cy.get("@dashcardQuery.all").should("have.length", 1);++ cy.log("refresh after the card query has loaded");+ cy.tick(61 * 1000);+ cy.get("@dashcardQuery.all").should("have.length", 2);+ cy.wait("@dashcardQuery");+ H.getDashboardCard().findByText("18,760").should("be.visible");+ cy.get("@dashboardLoad.all").should("have.length", 1);+ });+});++describe("issue 13736", () => {+ const questionDetails = {+ name: "Orders count",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ },+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should work even if some cards are broken (metabase#13736)", () => {+ H.createQuestion(questionDetails, {+ wrapId: true,+ idAlias: "failingQuestionId",+ });+ H.createQuestion(questionDetails, {+ wrapId: true,+ idAlias: "successfulQuestionId",+ });+ H.createDashboard({ name: "13736 Dashboard" }).then(+ ({ body: { id: dashboardId } }) => {+ cy.wrap(dashboardId).as("dashboardId");+ },+ );++ cy.then(function () {+ const dashboardId = this.dashboardId;+ const failingQuestionId = this.failingQuestionId;+ const successfulQuestionId = this.successfulQuestionId;++ cy.intercept(+ "POST",+ `/api/dashboard/*/dashcard/*/card/${failingQuestionId}/query`,+ {+ statusCode: 500,+ body: {+ cause: "some error",+ data: {},+ message: "some error",+ },+ },+ );++ H.updateDashboardCards({+ dashboard_id: dashboardId,+ cards: [+ {+ card_id: failingQuestionId,+ },+ {+ card_id: successfulQuestionId,+ col: 11,+ },+ ],+ });+ H.visitDashboard(dashboardId);+ });++ H.getDashboardCards()+ .eq(0)+ .findByText("There was a problem displaying this chart.");++ H.getDashboardCards().eq(1).findByText("18,760").should("be.visible");+ });+});diff --git a/e2e/test/scenarios/dashboard/dashcard-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-reproductions.cy.spec.jsdeleted file mode 100644index a6c226a412b..00000000000--- a/e2e/test/scenarios/dashboard/dashcard-reproductions.cy.spec.js+++ /dev/null@@ -1,902 +0,0 @@-const { H } = cy;-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";-import { createMockParameter } from "metabase-types/api/mocks";--const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;--describe("issue 18454", () => {- const CARD_DESCRIPTION = "CARD_DESCRIPTION";-- const questionDetails = {- name: "18454 Question",- description: CARD_DESCRIPTION,- query: {- "source-table": PRODUCTS_ID,- aggregation: [["count"]],- breakout: [["field", PRODUCTS.CATEGORY, null]],- },- display: "line",- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createQuestionAndDashboard({ questionDetails }).then(- ({ body: { id, card_id, dashboard_id } }) => {- H.visitDashboard(dashboard_id);- },- );- });-- it("should show card descriptions (metabase#18454)", () => {- cy.findByTestId("dashcard-container").realHover();- cy.findByTestId("dashcard-container").within(() => {- cy.icon("info").trigger("mouseenter", { force: true });- });- H.tooltip().should("contain", CARD_DESCRIPTION);- });-});--// Tests for issues 27020 and 27105 (static-viz rendering with date formatting options)-// have been moved to backend tests in metabase.channel.render.card-test--describe("issue 29304", () => {- // Couldn't import from `metabase/common/components/ExplicitSize` because dependency issue.- // It will fail Cypress tests.- const WAIT_TIME = 300;-- const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;-- const SCALAR_QUESTION = {- name: "Scalar question",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- },- display: "scalar",- };-- const SCALAR_QUESTION_CARD = { size_x: 4, size_y: 3, row: 0, col: 0 };-- const SMART_SCALAR_QUESTION = {- name: "Smart scalar question",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- [- "field",- ORDERS.CREATED_AT,- {- "base-type": "type/DateTime",- "temporal-unit": "month",- },- ],- ],- },- display: "smartscalar",- };-- const SMART_SCALAR_QUESTION_CARD = { ...SCALAR_QUESTION_CARD, col: 4 };-- // Use full-app embedding to test because `ExplicitSize` checks for `isCypressActive`,- // which checks `window.Cypress`, and will disable the refresh mode on Cypress test.- // If we test by simply visiting the dashboard, the refresh mode will be disabled,- // and we won't be able to reproduce the problem.- const visitFullAppEmbeddingUrl = ({ url }) => {- cy.visit({- url,- onBeforeLoad(window) {- // cypress runs all tests in an iframe and the app uses this property to avoid embedding mode for all tests- // by removing the property the app would work in embedding mode- window.Cypress = undefined;- },- });- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- cy.intercept("api/dashboard/*/dashcard/*/card/*/query").as(- "getDashcardQuery",- );- cy.intercept("api/dashboard/*").as("getDashboard");- cy.clock();- });-- it("should render scalar and smart scalar with correct size on the first render (metabase#29304)", () => {- H.createDashboard().then(({ body: dashboard }) => {- H.createQuestionAndAddToDashboard(- SCALAR_QUESTION,- dashboard.id,- SCALAR_QUESTION_CARD,- );- H.createQuestionAndAddToDashboard(- SMART_SCALAR_QUESTION,- dashboard.id,- SMART_SCALAR_QUESTION_CARD,- );-- visitFullAppEmbeddingUrl({ url: `/dashboard/${dashboard.id}` });-- cy.wait("@getDashboard");- cy.wait(["@getDashcardQuery", "@getDashcardQuery"]);- // This extra 1ms is crucial, without this the test would fail.- cy.tick(WAIT_TIME + 1);-- [- { index: 0, expectedWidth: 100 },- { index: 1, expectedWidth: 47 },- ].forEach(({ index, expectedWidth }) => {- H.getDashboardCard(index)- .findByTestId("scalar-value")- .should(([$scalarValue]) => {- expect($scalarValue.offsetWidth).to.be.closeTo(- expectedWidth,- expectedWidth * 0.2, // 20% tolerance for font rendering differences across Chrome versions- );- });- });- });- });-});--describe("issue 31628", () => {- const SCALAR_QUESTION = {- name: "31628 Question - This is a rather lengthy question name",- description: "This is a rather lengthy question description",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- },- display: "scalar",- };-- const SMART_SCALAR_QUESTION = {- ...SCALAR_QUESTION,- query: {- ...SCALAR_QUESTION.query,- breakout: [- [- "field",- ORDERS.CREATED_AT,- {- "base-type": "type/DateTime",- "temporal-unit": "month",- },- ],- ],- },- display: "smartscalar",- };-- const TREND_QUESTION = {- display: "smartscalar",- query: {- "source-table": ORDERS_ID,- aggregation: [- ["count"],- ["sum", ["field", ORDERS.TOTAL, null]],- [- "aggregation-options",- ["*", ["count"], 10000],- { name: "Mega Count", "display-name": "Mega Count" },- ],- ],- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],- },- visualization_settings: {- "scalar.comparisons": [- {- id: "fecd2c69-4d43-57d0-6d60-6781a54beceb",- type: "previousPeriod",- },- {- id: "e8b8d831-d2a9-9fd7-17a7-db8b4834ac5a",- type: "periodsAgo",- value: 2,- },- {- id: "9712f309-6849-20ba-7cef-54ae899a0e41",- type: "anotherColumn",- label: "Sum of Total",- column: "sum",- },- ],- },- };-- const OVERFLOW_CHECKED_TEST_IDS = {- scalar: ["scalar-container", "scalar-title"],- smartscalar: ["scalar-container", "scalar-title", "scalar-previous-value"],- };-- const ROW_WIDTHS = [6, 5, 4, 3, 2];-- const OVERFLOW_ROWS = [- { display: "scalar", size_y: 2, row: 0 },- { display: "scalar", size_y: 3, row: 2 },- { display: "scalar", size_y: 4, row: 5 },- { display: "smartscalar", size_y: 2, row: 9 },- ];-- const OVERFLOW_CARDS = OVERFLOW_ROWS.flatMap(({ display, size_y, row }) =>- ROW_WIDTHS.map((size_x, index) => ({- display,- size_x,- size_y,- row,- col: ROW_WIDTHS.slice(0, index).reduce((sum, width) => sum + width, 0),- })),- );-- const TRUNCATION_CARDS = {- scalar1x2: { display: "scalar", size_x: 1, size_y: 2, row: 0, col: 0 },- scalar2x2: { display: "scalar", size_x: 2, size_y: 2, row: 0, col: 1 },- scalar6x3: { display: "scalar", size_x: 6, size_y: 3, row: 0, col: 3 },- smart2x2: { display: "smartscalar", size_x: 2, size_y: 2, row: 0, col: 9 },- smart7x3: { display: "smartscalar", size_x: 7, size_y: 3, row: 0, col: 11 },- smart7x4: { display: "smartscalar", size_x: 7, size_y: 4, row: 4, col: 0 },- trend4x3: { display: "trend", size_x: 4, size_y: 3, row: 4, col: 7 },- };-- const setupDashboard = (cards) => {- H.createDashboardWithQuestions({- questions: [SCALAR_QUESTION, SMART_SCALAR_QUESTION, TREND_QUESTION],- }).then(({ dashboard, questions: [scalar, smartScalar, trend] }) => {- const cardIds = {- scalar: scalar.id,- smartscalar: smartScalar.id,- trend: trend.id,- };- H.updateDashboardCards({- dashboard_id: dashboard.id,- cards: cards.map(({ display, ...layout }) => ({- card_id: cardIds[display],- ...layout,- })),- }).then(({ body: { dashcards } }) => {- cy.wrap(- cards.map(- ({ row, col }) =>- dashcards.find(- (dashcard) => dashcard.row === row && dashcard.col === col,- ).id,- ),- ).as("dashcardIds");- });- H.visitDashboard(dashboard.id);- });- };-- const getCard = (index) =>- cy- .get("@dashcardIds")- .then((ids) => cy.get(`[data-dashcard-key="${ids[index]}"]`));-- const scalarContainer = (card) => card.findByTestId("scalar-container");- const previousValue = (card) => card.findByTestId("scalar-previous-value");-- const moveMouseAway = () => {- H.dashboardHeader().realHover({ position: "left" });- cy.findByRole("tooltip").should("not.exist");- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should render descendants of scalar and smart scalar cards without overflowing them (metabase#31628)", () => {- cy.viewport(1440, 800);- setupDashboard(OVERFLOW_CARDS);- H.getDashboardCards().should("have.length", OVERFLOW_CARDS.length);-- cy.wait(100);- H.openNavigationSidebar();-- cy.log("The dashboard fits the viewport, so no scrollbar narrows the grid");- cy.get("main").should(([main]) => {- expect(main.scrollHeight).to.be.at.most(main.clientHeight);- });-- cy.get("@dashcardIds").then((ids) => {- cy.findAllByTestId("dashcard").should((dashcards) => {- OVERFLOW_CARDS.forEach(({ display, size_x, size_y }, index) => {- const dashcard = dashcards.filter(- `[data-dashcard-key="${ids[index]}"]`,- )[0];- const label = `${display} ${size_x}x${size_y}`;-- expect(- dashcard.querySelectorAll("[data-testid='scalar-container']"),- `${label} scalar-container`,- ).to.have.length(1);- if (display === "smartscalar") {- expect(- dashcard.querySelectorAll(- "[data-testid='scalar-previous-value']",- ),- `${label} scalar-previous-value`,- ).to.have.length(1);- }-- OVERFLOW_CHECKED_TEST_IDS[display].forEach((testId) => {- dashcard- .querySelectorAll(`[data-testid='${testId}']`)- .forEach((descendant) => {- H.assertDescendantNotOverflowsContainer(- descendant,- dashcard,- `${label} [data-testid="${testId}"]`,- );- });- });- });- });- });- });-- it("should follow truncation rules for scalar, smart scalar and trend cards (metabase#31628)", () => {- const cards = Object.values(TRUNCATION_CARDS);- const card = (key) => getCard(cards.indexOf(TRUNCATION_CARDS[key]));-- setupDashboard(cards);- H.getDashboardCards().should("have.length", cards.length);-- cy.log("scalar 1x2: should truncate value and show value tooltip on hover");- scalarContainer(card("scalar1x2")).then(($element) =>- H.assertIsEllipsified($element[0]),- );- //TODO: Need to hover on the actual text, not just the container. This is a weird one- scalarContainer(card("scalar1x2")).realHover({ position: "bottom" });- cy.findByRole("tooltip").findByText("18,760").should("exist");- moveMouseAway();-- cy.log("scalar 2x2: should not truncate value");- scalarContainer(card("scalar2x2")).then(($element) =>- H.assertIsNotEllipsified($element[0]),- );- cy.log(- "scalar 2x2: should show the title tooltip on hover because the smallest cards hide the inline title",- );- scalarContainer(card("scalar2x2")).realHover();- cy.findByRole("tooltip").findByText(SCALAR_QUESTION.name).should("exist");- moveMouseAway();-- cy.log(- "scalar 6x3: should not truncate value and should not show value tooltip on hover",- );- scalarContainer(card("scalar6x3")).then(($element) =>- H.assertIsNotEllipsified($element[0]),- );- scalarContainer(card("scalar6x3")).realHover();- cy.findByRole("tooltip").should("not.exist");- moveMouseAway();-- cy.log("smart scalar 2x2: should not truncate value");- scalarContainer(card("smart2x2")).then(($element) =>- H.assertIsNotEllipsified($element[0]),- );- cy.log(- "smart scalar 2x2: should show the title tooltip on hover because the smallest cards hide the inline title",- );- scalarContainer(card("smart2x2")).realHover();- cy.findByRole("tooltip")- .findByText(SMART_SCALAR_QUESTION.name)- .should("exist");- moveMouseAway();-- cy.log(- "smart scalar 2x2: should not display the period, which wider cards show",- );- card("smart7x3")- .findByTestId("scalar-period")- .should("have.text", "Apr 2029");- card("smart2x2").findByTestId("scalar-period").should("not.exist");-- cy.log(- "smart scalar 2x2: should show the previous value as a percentage only (without truncation)",- );- previousValue(card("smart2x2"))- .should("contain", "-34.72%")- .and("not.contain", "527");- previousValue(card("smart2x2")).then(($element) =>- H.assertIsNotEllipsified($element[0]),- );-- cy.log(- "smart scalar 2x2: should show the full comparison in a panel on hover",- );- previousValue(card("smart2x2")).realHover();- cy.findByRole("tooltip").within(() => {- cy.contains("34.72%").should("exist");- cy.contains("vs. previous month").should("exist");- cy.contains("527").should("exist");- });- moveMouseAway();-- ["smart7x3", "smart7x4"].forEach((key) => {- cy.log(`${key}: should truncate the inline title and show it on hover`);- card(key).findByTestId("scalar-title").realHover();- cy.findByRole("tooltip")- .findByText(SMART_SCALAR_QUESTION.name)- .should("exist");- moveMouseAway();-- cy.log(`${key}: should show description tooltip on hover`);- card(key).findByTestId("scalar-title").icon("info").realHover();- cy.findByRole("tooltip")- .findByText(SMART_SCALAR_QUESTION.description)- .should("exist");- moveMouseAway();-- cy.log(- `${key}: should not truncate value and should not show value tooltip on hover`,- );- scalarContainer(card(key)).then(($element) =>- H.assertIsNotEllipsified($element[0]),- );- scalarContainer(card(key)).realHover();- cy.findByRole("tooltip").should("not.exist");- moveMouseAway();-- cy.log(`${key}: should display the period as part of the comparison`);- previousValue(card(key)).should("contain", "Apr 2029");-- cy.log(`${key}: should show previous value in full`);- previousValue(card(key))- .should("contain", "-34.72% MoM")- .and("contain", "(527)");- previousValue(card(key)).then(($element) =>- H.assertIsNotEllipsified($element[0]),- );-- cy.log(- `${key}: should not show a panel for a single fully-displayed comparison`,- );- previousValue(card(key)).realHover();- cy.findByRole("tooltip").should("not.exist");- moveMouseAway();- });-- cy.log(- "trend 4x3: extra comparisons should only be shown in the hover panel",- );- previousValue(card("trend4x3"))- .should("contain", "-34.72%")- .and("not.contain", "36.65%")- .and("not.contain", "98.88%");- previousValue(card("trend4x3")).realHover();- H.tooltip().within(() => {- cy.findByText("34.72%").should("be.visible");- cy.findByText("36.65%").should("be.visible");- cy.findByText("98.88%").should("be.visible");- });- });-});--describe("issue 43219", () => {- const questionDetails = {- display: "line",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- [- "field",- ORDERS.CREATED_AT,- {- "base-type": "type/DateTime",- "temporal-unit": "month",- },- ],- ],- },- };-- const textFilter = createMockParameter({- name: "Text",- slug: "string",- id: "5aefc726",- type: "string/=",- sectionId: "string",- });-- const cardsCount = 10;-- const getQuestionAlias = (index) => `question-${index}`;-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.cypressWaitAll(- Array.from({ length: cardsCount }, (_value, index) => {- const name = `Series ${index + 1}`;- return H.createQuestion({ ...questionDetails, name }).then(- ({ body: question }) => {- cy.wrap(question).as(getQuestionAlias(index));- },- );- }),- );-- cy.then(function () {- H.createDashboardWithQuestions({- dashboardDetails: {- parameters: [textFilter],- },- questions: [- {- ...questionDetails,- name: "Base series",- },- ],- cards: [- {- size_x: 4,- size_y: 3,- series: Array.from(- { length: cardsCount },- (_value, index) => this[getQuestionAlias(index)],- ),- },- ],- }).then(({ dashboard }) => {- H.visitDashboard(dashboard.id);- });- });- });-- it("is possible to map parameters to dashcards with lots of series (metabase#43219)", () => {- H.editDashboard();- cy.findByTestId("edit-dashboard-parameters-widget-container")- .findByText("Text")- .click();-- H.getDashboardCard(0).within(() => {- cy.findByText("Series 10").should("exist").and("not.be.visible");-- cy.findByTestId("visualization-root").scrollTo("bottom");- cy.findByTestId("parameter-mapper-container").scrollTo("right");-- cy.findByText("Series 10").should("be.visible");- });- });-});--describe("issue 48878", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- H.setActionsEnabledForDB(SAMPLE_DB_ID);-- cy.signInAsNormalUser();- cy.intercept("POST", "/api/dataset").as("dataset");- cy.intercept("POST", "/api/card").as("saveQuestion");- cy.intercept("POST", "/api/action").as("createAction");- cy.intercept("GET", "/api/dashboard/*").as("getDashboard");- cy.intercept("PUT", "/api/dashboard/*").as("updateDashboard");-- cy.intercept("GET", "/api/card/*").as("fetchCard");- setup();- });-- // I could only reproduce this issue in Cypress when I didn't use any helpers like createQuestion, etc.- it("does not crash the action button viz (metabase#48878)", () => {- cy.reload();- cy.wait("@fetchCard");- H.getDashboardCard(0).findByText("Click Me").should("be.visible");- });-- function setup() {- cy.log("create model");-- createModel({- name: "SQL Model",- query: "select * from orders limit 5",- });-- cy.log("create model action");-- cy.findByTestId("qb-header-info-button").click();- H.sidesheet().findByText("Actions").click();-- cy.findByTestId("model-actions-header").findByText("New action").click();-- H.modal().within(() => {- H.NativeEditor.focus().type("UPDATE orders SET plan = {{ plan ", {- parseSpecialCharSequences: false,- });- cy.button("Save").click();- });-- // eslint-disable-next-line metabase/no-unsafe-element-filtering- H.modal()- .last()- .within(() => {- cy.findByPlaceholderText("My new fantastic action").type("Test action");- cy.button("Create").click();- cy.wait("@createAction");- });-- cy.visit("/");-- cy.log("create dashoard");-- cy.button("New").click();- H.popover().findByText("Dashboard").click();-- H.modal().within(() => {- cy.findByPlaceholderText("What is the name of your dashboard?").type(- "Dash",- );- cy.button("Create").click();- cy.wait("@getDashboard");- });-- cy.button("Add action").click();- cy.button("Pick an action").click();- H.modal().within(() => {- cy.findByText("SQL Model").click();- cy.findByText("Test action").click();- cy.button("Done").click();- });- cy.button("Save").click();- cy.wait("@updateDashboard");- cy.wait("@fetchCard");- }-- function createModel({ name, query }) {- cy.visit("/model/new");- cy.findByTestId("new-model-options")- .findByText("Use a native query")- .click();-- H.NativeEditor.focus().type(query);- cy.findByTestId("native-query-editor-container")- .findByTestId("run-button")- .click();- cy.wait("@dataset");- cy.button("Save").click();-- H.modal().within(() => {- cy.findByPlaceholderText("What is the name of your model?").type(name);- cy.button("Save").click();- cy.wait("@saveQuestion");- });- cy.wait("@fetchCard");- }-});--describe("issue 67432", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should copy sorted table data in correct sorted order (metabase#67432)", () => {- H.grantClipboardPermissions();-- const ROWS_LIMIT = 5;- const questionDetails = {- name: "67432 Question",- query: {- "source-table": PRODUCTS_ID,- fields: [- ["field", PRODUCTS.ID, null],- ["field", PRODUCTS.TITLE, null],- ["field", PRODUCTS.CATEGORY, null],- ],- limit: ROWS_LIMIT,- },- };-- H.createQuestionAndDashboard({- questionDetails,- cardDetails: {- size_x: 16,- size_y: 10,- },- }).then(({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);- });-- // Wait for table to load- H.tableInteractiveBody().should("be.visible");-- // Sort by Category column (descending first click)- H.tableHeaderClick("Category");-- // Wait for sort to apply - the sort icon should appear- H.tableHeaderColumn("Category")- .closest("[data-testid=header-cell]")- .icon("chevrondown")- .should("exist");-- // Products 1-5 sorted by Category descending; equal categories keep their row order- const EXPECTED_ROWS = [- ["Rustic Paper Wallet", "Gizmo"],- ["Enormous Marble Wallet", "Gadget"],- ["Small Marble Shoes", "Doohickey"],- ["Synergistic Granite Chair", "Doohickey"],- ["Enormous Aluminum Shirt", "Doohickey"],- ];-- H.tableInteractiveBody()- .find('[data-column-id="CATEGORY"]')- .should(($cells) => {- expect($cells.toArray().map((cell) => cell.textContent)).to.deep.equal(- EXPECTED_ROWS.map(([, category]) => category),- );- });-- // Select multiple cells across rows by dragging- const getNonPKCells = () =>- H.tableInteractiveBody().find(- '[data-selectable-cell]:not([data-column-id="ID"])',- );-- // Select Title and Category cells in every row- getNonPKCells()- .eq(0)- .trigger("mousedown", { which: 1 })- .then(() => {- const lastCellIndex = ROWS_LIMIT * 2 - 1;- getNonPKCells()- .should("have.length", ROWS_LIMIT * 2)- .eq(lastCellIndex)- .trigger("mouseover", { buttons: 1 });- getNonPKCells()- .should("have.length", ROWS_LIMIT * 2)- .eq(lastCellIndex)- .trigger("mouseup");- });-- // Copy to clipboard- cy.realPress(["Meta", "c"]);-- // The clipboard holds tab-separated rows in the sorted order- H.readClipboard().should(- "equal",- [["Title", "Category"], ...EXPECTED_ROWS]- .map((cells) => cells.join("\t"))- .join("\n"),- );- });-});--describe("issue 63416", () => {- const questionDetails = {- name: "63416 Question",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- [- "field",- ORDERS.CREATED_AT,- {- "base-type": "type/DateTime",- "temporal-unit": "month",- },- ],- ],- filter: [">=", ["field", ORDERS.CREATED_AT, null], "2027-01-01"],- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- const textFilter = createMockParameter({- name: "Text",- slug: "string",- id: "5aefc726",- type: "string/=",- sectionId: "string",- });-- H.createDashboardWithQuestions({- dashboardDetails: {- parameters: [textFilter],- },- questions: [questionDetails],- }).then(({ dashboard, questions }) => {- H.updateDashboardCards({- dashboard_id: dashboard.id,- cards: [- {- card_id: questions[0].id,- parameter_mappings: [- {- parameter_id: textFilter.id,- card_id: questions[0].id,- target: [- "dimension",- [- "field",- PRODUCTS.CATEGORY,- {- "base-type": "type/Text",- "source-field": ORDERS.PRODUCT_ID,- },- ],- { "stage-number": 0 },- ],- },- ],- },- ],- });-- cy.wrap(dashboard.id).as("dashboardId");-- H.visitDashboard(dashboard.id);- });- });-- it("should download visualizer dashboard card without additional dataset with proper parameter values (metabase#63416)", function () {- H.editDashboard();-- H.showDashcardVisualizerModalSettings(0, {- isVisualizerCard: false,- });-- cy.log("Make this a visualizer card");- H.saveDashcardVisualizerModal();-- H.showDashboardCardActions(0);- H.getDashboardCard(0).findByLabelText("Edit visualization").should("exist");-- H.saveDashboard();-- H.toggleFilterWidgetValues(["Doohickey"]);-- H.downloadAndAssert({- fileType: "csv",- isDashboard: true,- downloadMethod: "POST",- downloadUrl: `/api/dashboard/${this.dashboardId}/dashcard/*/card/*/query/csv`,- assertParameters: [{ type: "string/=", value: ["Doohickey"] }],- });- });-});--describe("issue 76056", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- H.setActionsEnabledForDB(SAMPLE_DB_ID);-- H.createDashboard().then(({ body: dashboard }) => {- H.visitDashboard(dashboard.id);- });- });-- it("the dashcard actions panel should not have redundant horizontal space (metabase#76056)", () => {- H.editDashboard();- cy.button("Add action").click();- cy.button("Close").click();-- H.showDashboardCardActions();-- cy.findByTestId("dashboardcard-actions-panel")- .should("be.visible")- .then(($panel) => {- const panelRect = $panel[0].getBoundingClientRect();- const buttonRects = Array.from($panel[0].querySelectorAll("a")).map(- (button) => button.getBoundingClientRect(),- );- const maxRight = Math.max(...buttonRects.map((rect) => rect.right));- const minLeft = Math.min(...buttonRects.map((rect) => rect.left));- const contentWidth = maxRight - minLeft;-- expect(panelRect.width).to.be.closeTo(contentWidth, 10);- });- });-});diff --git a/e2e/test/scenarios/dashboard/dashcard-resizing.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-resizing.cy.spec.jsindex 9dfe8848ec4..fa8f2de4af7 100644--- a/e2e/test/scenarios/dashboard/dashcard-resizing.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashcard-resizing.cy.spec.js@@ -375,7 +375,7 @@ describe("issue 31701", () => {});});- it("should prevent link dashboard card overflows and not clip the link card cross icon (metabase#31701, metabase#31274)", () => {+ it("should prevent link dashboard card overflows (metabase#31701)", () => {H.createDashboard({name: TEST_DASHBOARD_NAME,}).then(({ body: { id: dashId } }) => {@@ -384,19 +384,6 @@ describe("issue 31701", () => {H.editDashboard();- cy.log("Remove an empty link card through its cross icon (metabase#31274)");- cy.findByLabelText("Add a link or iframe").click();- H.popover().findByText("Link").click();- cy.findByPlaceholderText("https://example.com").realHover();- H.getDashboardCards().should("have.length", 1);- cy.log(- "Make sure cypress can click the element, which means it is not covered by another",- );- cy.findByTestId("dashboardcard-actions-panel").within(() => {- cy.icon("close").closest("a").click({ position: "bottom" });- });- cy.findByTestId("dashcard").should("not.exist");-cy.log("Add first link card (connected to an entity");cy.findByLabelText("Add a link or iframe").click();H.popover().findByText("Link").click();@@ -446,3 +433,520 @@ const assertLinkCardOverflow = (link, card) => {);});};++describe("issue 29304", () => {+ // Couldn't import from `metabase/common/components/ExplicitSize` because dependency issue.+ // It will fail Cypress tests.+ const WAIT_TIME = 300;++ const SCALAR_QUESTION = {+ name: "Scalar question",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ },+ display: "scalar",+ };++ const SCALAR_QUESTION_CARD = { size_x: 4, size_y: 3, row: 0, col: 0 };++ const SMART_SCALAR_QUESTION = {+ name: "Smart scalar question",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ [+ "field",+ ORDERS.CREATED_AT,+ {+ "base-type": "type/DateTime",+ "temporal-unit": "month",+ },+ ],+ ],+ },+ display: "smartscalar",+ };++ const SMART_SCALAR_QUESTION_CARD = { ...SCALAR_QUESTION_CARD, col: 4 };++ // Use full-app embedding to test because `ExplicitSize` checks for `isCypressActive`,+ // which checks `window.Cypress`, and will disable the refresh mode on Cypress test.+ // If we test by simply visiting the dashboard, the refresh mode will be disabled,+ // and we won't be able to reproduce the problem.+ const visitFullAppEmbeddingUrl = ({ url }) => {+ cy.visit({+ url,+ onBeforeLoad(window) {+ // cypress runs all tests in an iframe and the app uses this property to avoid embedding mode for all tests+ // by removing the property the app would work in embedding mode+ window.Cypress = undefined;+ },+ });+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ cy.intercept("api/dashboard/*/dashcard/*/card/*/query").as(+ "getDashcardQuery",+ );+ cy.intercept("api/dashboard/*").as("getDashboard");+ cy.clock();+ });++ it("should render scalar and smart scalar with correct size on the first render (metabase#29304)", () => {+ H.createDashboard().then(({ body: dashboard }) => {+ H.createQuestionAndAddToDashboard(+ SCALAR_QUESTION,+ dashboard.id,+ SCALAR_QUESTION_CARD,+ );+ H.createQuestionAndAddToDashboard(+ SMART_SCALAR_QUESTION,+ dashboard.id,+ SMART_SCALAR_QUESTION_CARD,+ );++ visitFullAppEmbeddingUrl({ url: `/dashboard/${dashboard.id}` });++ cy.wait("@getDashboard");+ cy.wait(["@getDashcardQuery", "@getDashcardQuery"]);+ // This extra 1ms is crucial, without this the test would fail.+ cy.tick(WAIT_TIME + 1);++ [+ { index: 0, expectedWidth: 100 },+ { index: 1, expectedWidth: 47 },+ ].forEach(({ index, expectedWidth }) => {+ H.getDashboardCard(index)+ .findByTestId("scalar-value")+ .should(([$scalarValue]) => {+ expect($scalarValue.offsetWidth).to.be.closeTo(+ expectedWidth,+ expectedWidth * 0.2, // 20% tolerance for font rendering differences across Chrome versions+ );+ });+ });+ });+ });+});++describe("issue 31628", () => {+ const SCALAR_QUESTION = {+ name: "31628 Question - This is a rather lengthy question name",+ description: "This is a rather lengthy question description",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ },+ display: "scalar",+ };++ const SMART_SCALAR_QUESTION = {+ ...SCALAR_QUESTION,+ query: {+ ...SCALAR_QUESTION.query,+ breakout: [+ [+ "field",+ ORDERS.CREATED_AT,+ {+ "base-type": "type/DateTime",+ "temporal-unit": "month",+ },+ ],+ ],+ },+ display: "smartscalar",+ };++ const TREND_QUESTION = {+ display: "smartscalar",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [+ ["count"],+ ["sum", ["field", ORDERS.TOTAL, null]],+ [+ "aggregation-options",+ ["*", ["count"], 10000],+ { name: "Mega Count", "display-name": "Mega Count" },+ ],+ ],+ breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],+ },+ visualization_settings: {+ "scalar.comparisons": [+ {+ id: "fecd2c69-4d43-57d0-6d60-6781a54beceb",+ type: "previousPeriod",+ },+ {+ id: "e8b8d831-d2a9-9fd7-17a7-db8b4834ac5a",+ type: "periodsAgo",+ value: 2,+ },+ {+ id: "9712f309-6849-20ba-7cef-54ae899a0e41",+ type: "anotherColumn",+ label: "Sum of Total",+ column: "sum",+ },+ ],+ },+ };++ const OVERFLOW_CHECKED_TEST_IDS = {+ scalar: ["scalar-container", "scalar-title"],+ smartscalar: ["scalar-container", "scalar-title", "scalar-previous-value"],+ };++ const ROW_WIDTHS = [6, 5, 4, 3, 2];++ const OVERFLOW_ROWS = [+ { display: "scalar", size_y: 2, row: 0 },+ { display: "scalar", size_y: 3, row: 2 },+ { display: "scalar", size_y: 4, row: 5 },+ { display: "smartscalar", size_y: 2, row: 9 },+ ];++ const OVERFLOW_CARDS = OVERFLOW_ROWS.flatMap(({ display, size_y, row }) =>+ ROW_WIDTHS.map((size_x, index) => ({+ display,+ size_x,+ size_y,+ row,+ col: ROW_WIDTHS.slice(0, index).reduce((sum, width) => sum + width, 0),+ })),+ );++ const TRUNCATION_CARDS = {+ scalar1x2: { display: "scalar", size_x: 1, size_y: 2, row: 0, col: 0 },+ scalar2x2: { display: "scalar", size_x: 2, size_y: 2, row: 0, col: 1 },+ scalar6x3: { display: "scalar", size_x: 6, size_y: 3, row: 0, col: 3 },+ smart2x2: { display: "smartscalar", size_x: 2, size_y: 2, row: 0, col: 9 },+ smart7x3: { display: "smartscalar", size_x: 7, size_y: 3, row: 0, col: 11 },+ smart7x4: { display: "smartscalar", size_x: 7, size_y: 4, row: 4, col: 0 },+ trend4x3: { display: "trend", size_x: 4, size_y: 3, row: 4, col: 7 },+ };++ const setupDashboard = (cards) => {+ H.createDashboardWithQuestions({+ questions: [SCALAR_QUESTION, SMART_SCALAR_QUESTION, TREND_QUESTION],+ }).then(({ dashboard, questions: [scalar, smartScalar, trend] }) => {+ const cardIds = {+ scalar: scalar.id,+ smartscalar: smartScalar.id,+ trend: trend.id,+ };+ H.updateDashboardCards({+ dashboard_id: dashboard.id,+ cards: cards.map(({ display, ...layout }) => ({+ card_id: cardIds[display],+ ...layout,+ })),+ }).then(({ body: { dashcards } }) => {+ cy.wrap(+ cards.map(+ ({ row, col }) =>+ dashcards.find(+ (dashcard) => dashcard.row === row && dashcard.col === col,+ ).id,+ ),+ ).as("dashcardIds");+ });+ H.visitDashboard(dashboard.id);+ });+ };++ const getCard = (index) =>+ cy+ .get("@dashcardIds")+ .then((ids) => cy.get(`[data-dashcard-key="${ids[index]}"]`));++ const scalarContainer = (card) => card.findByTestId("scalar-container");+ const previousValue = (card) => card.findByTestId("scalar-previous-value");++ const moveMouseAway = () => {+ H.dashboardHeader().realHover({ position: "left" });+ cy.findByRole("tooltip").should("not.exist");+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should render descendants of scalar and smart scalar cards without overflowing them (metabase#31628)", () => {+ cy.viewport(1440, 800);+ setupDashboard(OVERFLOW_CARDS);+ H.getDashboardCards().should("have.length", OVERFLOW_CARDS.length);++ cy.wait(100);+ H.openNavigationSidebar();++ cy.log("The dashboard fits the viewport, so no scrollbar narrows the grid");+ cy.get("main").should(([main]) => {+ expect(main.scrollHeight).to.be.at.most(main.clientHeight);+ });++ cy.get("@dashcardIds").then((ids) => {+ cy.findAllByTestId("dashcard").should((dashcards) => {+ OVERFLOW_CARDS.forEach(({ display, size_x, size_y }, index) => {+ const dashcard = dashcards.filter(+ `[data-dashcard-key="${ids[index]}"]`,+ )[0];+ const label = `${display} ${size_x}x${size_y}`;++ expect(+ dashcard.querySelectorAll("[data-testid='scalar-container']"),+ `${label} scalar-container`,+ ).to.have.length(1);+ if (display === "smartscalar") {+ expect(+ dashcard.querySelectorAll(+ "[data-testid='scalar-previous-value']",+ ),+ `${label} scalar-previous-value`,+ ).to.have.length(1);+ }++ OVERFLOW_CHECKED_TEST_IDS[display].forEach((testId) => {+ dashcard+ .querySelectorAll(`[data-testid='${testId}']`)+ .forEach((descendant) => {+ H.assertDescendantNotOverflowsContainer(+ descendant,+ dashcard,+ `${label} [data-testid="${testId}"]`,+ );+ });+ });+ });+ });+ });+ });++ it("should follow truncation rules for scalar, smart scalar and trend cards (metabase#31628)", () => {+ const cards = Object.values(TRUNCATION_CARDS);+ const card = (key) => getCard(cards.indexOf(TRUNCATION_CARDS[key]));++ setupDashboard(cards);+ H.getDashboardCards().should("have.length", cards.length);++ cy.log("scalar 1x2: should truncate value and show value tooltip on hover");+ scalarContainer(card("scalar1x2")).then(($element) =>+ H.assertIsEllipsified($element[0]),+ );+ //TODO: Need to hover on the actual text, not just the container. This is a weird one+ scalarContainer(card("scalar1x2")).realHover({ position: "bottom" });+ cy.findByRole("tooltip").findByText("18,760").should("exist");+ moveMouseAway();++ cy.log("scalar 2x2: should not truncate value");+ scalarContainer(card("scalar2x2")).then(($element) =>+ H.assertIsNotEllipsified($element[0]),+ );+ cy.log(+ "scalar 2x2: should show the title tooltip on hover because the smallest cards hide the inline title",+ );+ scalarContainer(card("scalar2x2")).realHover();+ cy.findByRole("tooltip").findByText(SCALAR_QUESTION.name).should("exist");+ moveMouseAway();++ cy.log(+ "scalar 6x3: should not truncate value and should not show value tooltip on hover",+ );+ scalarContainer(card("scalar6x3")).then(($element) =>+ H.assertIsNotEllipsified($element[0]),+ );+ scalarContainer(card("scalar6x3")).realHover();+ cy.findByRole("tooltip").should("not.exist");+ moveMouseAway();++ cy.log("smart scalar 2x2: should not truncate value");+ scalarContainer(card("smart2x2")).then(($element) =>+ H.assertIsNotEllipsified($element[0]),+ );+ cy.log(+ "smart scalar 2x2: should show the title tooltip on hover because the smallest cards hide the inline title",+ );+ scalarContainer(card("smart2x2")).realHover();+ cy.findByRole("tooltip")+ .findByText(SMART_SCALAR_QUESTION.name)+ .should("exist");+ moveMouseAway();++ cy.log(+ "smart scalar 2x2: should not display the period, which wider cards show",+ );+ card("smart7x3")+ .findByTestId("scalar-period")+ .should("have.text", "Apr 2029");+ card("smart2x2").findByTestId("scalar-period").should("not.exist");++ cy.log(+ "smart scalar 2x2: should show the previous value as a percentage only (without truncation)",+ );+ previousValue(card("smart2x2"))+ .should("contain", "-34.72%")+ .and("not.contain", "527");+ previousValue(card("smart2x2")).then(($element) =>+ H.assertIsNotEllipsified($element[0]),+ );++ cy.log(+ "smart scalar 2x2: should show the full comparison in a panel on hover",+ );+ previousValue(card("smart2x2")).realHover();+ cy.findByRole("tooltip").within(() => {+ cy.contains("34.72%").should("exist");+ cy.contains("vs. previous month").should("exist");+ cy.contains("527").should("exist");+ });+ moveMouseAway();++ ["smart7x3", "smart7x4"].forEach((key) => {+ cy.log(`${key}: should truncate the inline title and show it on hover`);+ card(key).findByTestId("scalar-title").realHover();+ cy.findByRole("tooltip")+ .findByText(SMART_SCALAR_QUESTION.name)+ .should("exist");+ moveMouseAway();++ cy.log(`${key}: should show description tooltip on hover`);+ card(key).findByTestId("scalar-title").icon("info").realHover();+ cy.findByRole("tooltip")+ .findByText(SMART_SCALAR_QUESTION.description)+ .should("exist");+ moveMouseAway();++ cy.log(+ `${key}: should not truncate value and should not show value tooltip on hover`,+ );+ scalarContainer(card(key)).then(($element) =>+ H.assertIsNotEllipsified($element[0]),+ );+ scalarContainer(card(key)).realHover();+ cy.findByRole("tooltip").should("not.exist");+ moveMouseAway();++ cy.log(`${key}: should display the period as part of the comparison`);+ previousValue(card(key)).should("contain", "Apr 2029");++ cy.log(`${key}: should show previous value in full`);+ previousValue(card(key))+ .should("contain", "-34.72% MoM")+ .and("contain", "(527)");+ previousValue(card(key)).then(($element) =>+ H.assertIsNotEllipsified($element[0]),+ );++ cy.log(+ `${key}: should not show a panel for a single fully-displayed comparison`,+ );+ previousValue(card(key)).realHover();+ cy.findByRole("tooltip").should("not.exist");+ moveMouseAway();+ });++ cy.log(+ "trend 4x3: extra comparisons should only be shown in the hover panel",+ );+ previousValue(card("trend4x3"))+ .should("contain", "-34.72%")+ .and("not.contain", "36.65%")+ .and("not.contain", "98.88%");+ previousValue(card("trend4x3")).realHover();+ H.tooltip().within(() => {+ cy.findByText("34.72%").should("be.visible");+ cy.findByText("36.65%").should("be.visible");+ cy.findByText("98.88%").should("be.visible");+ });+ });+});++describe("dashcard actions panel", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ H.setActionsEnabledForDB(SAMPLE_DB_ID);+ });++ it("should not clip dashcard actions and should not have redundant horizontal space (metabase#31274, metabase#76056)", () => {+ H.createDashboard().then(({ body: { id: dashboard_id } }) => {+ // The top card is created last, so it would come last in the DOM and+ // cover the actions of the card below if dashcards render in creation order+ H.updateDashboardCards({+ dashboard_id,+ cards: [H.getTextCardDetails({ row: 6, text: "Bottom card" })],+ }).then(({ body: { dashcards } }) => {+ H.updateDashboardCards({+ dashboard_id,+ cards: [+ ...dashcards,+ H.getTextCardDetails({ row: 0, text: "Top card" }),+ ],+ });+ });+ H.visitDashboard(dashboard_id);+ });++ H.editDashboard();+ H.getDashboardCards().should("have.length", 2);++ cy.log(+ "Make sure cypress can click the element, which means it is not covered by the card above",+ );+ H.getDashboardCards()+ .filter(":contains('Bottom card')")+ .realHover({ scrollBehavior: false })+ .findByTestId("dashboardcard-actions-panel")+ .icon("close")+ .click({ position: "top", scrollBehavior: false });++ H.getDashboardCards().should("have.length", 1);+ H.removeDashboardCard(0);+ cy.findByTestId("dashcard").should("not.exist");++ cy.log(+ "The actions panel should not have redundant horizontal space (metabase#76056)",+ );+ cy.button("Add action").click();+ cy.button("Close").click();++ H.showDashboardCardActions();++ cy.findByTestId("dashboardcard-actions-panel")+ .should("be.visible")+ .should(($panel) => {+ const panelRect = $panel[0].getBoundingClientRect();+ const buttonRects = Array.from($panel[0].querySelectorAll("a")).map(+ (button) => button.getBoundingClientRect(),+ );+ const maxRight = Math.max(...buttonRects.map((rect) => rect.right));+ const minLeft = Math.min(...buttonRects.map((rect) => rect.left));+ const contentWidth = maxRight - minLeft;++ expect(panelRect.width).to.be.closeTo(contentWidth, 10);+ });++ H.removeDashboardCard(0);+ cy.findByTestId("dashcard").should("not.exist");++ cy.log("Remove an empty link card through its cross icon (metabase#31274)");+ cy.findByLabelText("Add a link or iframe").click();+ H.popover().findByText("Link").click();+ cy.findByPlaceholderText("https://example.com").realHover();+ H.getDashboardCards().should("have.length", 1);+ cy.log(+ "Make sure cypress can click the element, which means it is not covered by another",+ );+ cy.findByTestId("dashboardcard-actions-panel").within(() => {+ cy.icon("close").closest("a").click({ position: "bottom" });+ });+ cy.findByTestId("dashcard").should("not.exist");+ });+});diff --git a/e2e/test/scenarios/dashboard/dashcard-undo.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-undo.cy.spec.jsindex f507d7cccab..ae7b6c4b204 100644--- a/e2e/test/scenarios/dashboard/dashcard-undo.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashcard-undo.cy.spec.js@@ -109,4 +109,65 @@ describe("scenarios > dashboard cards > undo", () => {}},);++ it("should stop the ongoing query when removing a card, re-fetch it on undo, and undo a virtual card removal (metabase#12926, metabase#35545)", () => {+ const filterDisplayName = "F";+ const queryResult = 42;+ const questionDetails = {+ name: "Question 1",+ native: {+ query: `SELECT ${queryResult} [[+{{F}}]] as ANSWER`,+ "template-tags": {+ F: {+ type: "number",+ name: "F",+ id: "b22a5ce2-fe1d-44e3-8df4-f8951f7921bc",+ "display-name": filterDisplayName,+ },+ },+ },+ };++ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query", (req) => {+ req.on("response", (res) => {+ res.setDelay(5000);+ });+ });++ H.createNativeQuestionAndDashboard({+ questionDetails,+ }).then(({ body: { dashboard_id } }) => {+ cy.visit(`/dashboard/${dashboard_id}`);+ });++ // The API client uses fetch, so cancelling the query aborts its+ // AbortController rather than calling XMLHttpRequest.abort().+ cy.window().then((win) => {+ cy.spy(win.AbortController.prototype, "abort").as("queryAbort");+ });++ H.editDashboard();+ H.showDashboardCardActions();+ H.getDashboardCard().findByTestId("loading-indicator").should("exist");+ cy.get("@queryAbort").invoke("resetHistory");+ cy.findByTestId("dashboardcard-actions-panel")+ .findByLabelText("close icon")+ .click();+ cy.get("@queryAbort").should("have.been.called");++ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query", (req) => {+ // calling req.continue() will make cypress skip all previously added intercepts+ req.continue();+ }).as("dashcardQueryRestored");+ H.undo();+ cy.wait("@dashcardQueryRestored");+ H.getDashboardCard().findByText(queryResult);++ H.addTextBoxWhileEditing("Text card content");+ H.getDashboardCards().should("have.length", 2);+ H.removeDashboardCard(1);+ H.getDashboardCards().should("have.length", 1);+ H.undo();+ H.getDashboardCard(1).findByText("Text card content");+ });});diff --git a/e2e/test/scenarios/dashboard/dashcard-visualization-options.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-visualization-options.cy.spec.jsindex 454237feed3..420bac9e531 100644--- a/e2e/test/scenarios/dashboard/dashcard-visualization-options.cy.spec.js+++ b/e2e/test/scenarios/dashboard/dashcard-visualization-options.cy.spec.js@@ -1,6 +1,9 @@const { H } = cy;import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";import { ORDERS_DASHBOARD_ID } from "e2e/support/cypress_sample_instance_data";+import { createMockParameter } from "metabase-types/api/mocks";++const { ORDERS, ORDERS_ID, PRODUCTS, PEOPLE_ID } = SAMPLE_DATABASE;describe("scenarios > dashboard cards > visualization options", () => {beforeEach(() => {@@ -9,8 +12,6 @@ describe("scenarios > dashboard cards > visualization options", () => {});it("should show the ellipsis even with an empty card title on visualizations with noHeader (metabase#46897)", () => {- const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;-const QUESTION_LINE = {name: "The lineest of all lines",display: "line",@@ -144,3 +145,173 @@ describe("scenarios > dashboard cards > visualization options", () => {.and("contain", "Download results");});});++describe("issue 63416", () => {+ const questionDetails = {+ name: "63416 Question",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ [+ "field",+ ORDERS.CREATED_AT,+ {+ "base-type": "type/DateTime",+ "temporal-unit": "month",+ },+ ],+ ],+ filter: [">=", ["field", ORDERS.CREATED_AT, null], "2027-01-01"],+ },+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ const textFilter = createMockParameter({+ name: "Text",+ slug: "string",+ id: "5aefc726",+ type: "string/=",+ sectionId: "string",+ });++ H.createDashboardWithQuestions({+ dashboardDetails: {+ parameters: [textFilter],+ },+ questions: [questionDetails],+ }).then(({ dashboard, questions }) => {+ H.updateDashboardCards({+ dashboard_id: dashboard.id,+ cards: [+ {+ card_id: questions[0].id,+ parameter_mappings: [+ {+ parameter_id: textFilter.id,+ card_id: questions[0].id,+ target: [+ "dimension",+ [+ "field",+ PRODUCTS.CATEGORY,+ {+ "base-type": "type/Text",+ "source-field": ORDERS.PRODUCT_ID,+ },+ ],+ { "stage-number": 0 },+ ],+ },+ ],+ },+ ],+ });++ cy.wrap(dashboard.id).as("dashboardId");++ H.visitDashboard(dashboard.id);+ });+ });++ it("should download visualizer dashboard card without additional dataset with proper parameter values (metabase#63416)", function () {+ H.editDashboard();++ H.showDashcardVisualizerModalSettings(0, {+ isVisualizerCard: false,+ });++ cy.log("Make this a visualizer card");+ H.saveDashcardVisualizerModal();++ H.showDashboardCardActions(0);+ H.getDashboardCard(0).findByLabelText("Edit visualization").should("exist");++ H.saveDashboard();++ H.toggleFilterWidgetValues(["Doohickey"]);++ H.downloadAndAssert({+ fileType: "csv",+ isDashboard: true,+ downloadMethod: "POST",+ downloadUrl: `/api/dashboard/${this.dashboardId}/dashcard/*/card/*/query/csv`,+ assertParameters: [{ type: "string/=", value: ["Doohickey"] }],+ });+ });+});++describe("issue 64138", () => {+ const MAP_QUESTION = {+ query: {+ "source-table": PEOPLE_ID,+ },++ display: "map",+ displayIsLocked: true,+ visualization_settings: {+ "map.type": "pin",+ "map.pin_type": "markers",+ },+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsNormalUser();++ H.createQuestionAndDashboard({+ questionDetails: MAP_QUESTION,+ }).then(({ body: { dashboard_id } }) => {+ H.visitDashboard(dashboard_id);+ });+ });++ it("should hide map controls when editing dashboard (metabase#64138)", () => {+ H.editDashboard();++ cy.log("hovering the map should not show the zoom controls");+ H.getDashboardCard(0)+ .realHover({+ position: "center",+ })+ .within(() => {+ cy.findByLabelText("Zoom in").should("not.exist");+ // the update button is disabled until the map is panned, so only+ // assert that it is shown while the zoom controls are hidden+ cy.findByText("Set as default view").should("be.visible");+ });++ cy.log("hovering marker icons should not open their tooltips");+ getMarkerIcon(0).trigger("mousemove", { force: true });+ H.tooltip().should("not.exist");++ cy.log("clicking marker icons should not navigate to the question");+ getMarkerIcon(0).click({ force: true });+ cy.findByTestId("edit-bar").should("be.visible");+ getMarkerIcon(0).should("exist");+ cy.location("pathname").should("match", /^\/dashboard\/[0-9]+$/);+ H.modal().should("not.exist");++ cy.log(+ "outside of edit mode, the map shows its controls and handles markers",+ );+ cy.findByTestId("edit-bar").button("Cancel").click();+ H.getDashboardCard(0).findByLabelText("Zoom in").should("exist");+ getMarkerIcon(0).trigger("mousemove", { force: true });+ H.tooltip().should("be.visible");+ getMarkerIcon(0).click({ force: true });+ cy.location("pathname").should("match", /^\/question/);+ cy.location("search").should("match", /objectId=\d+/);+ });++ function getMarkerIcon(index) {+ // pick the last one so it will be on top+ return H.getDashboardCard(index)+ .find(".leaflet-marker-icon")+ .should("have.length.gt", 0)+ .last();+ }+});