From cf30638e4077f6edee07fb1f71ccf378d504f46a Mon Sep 17 00:00:00 2001 From: github-automation-metabase <166700802+github-automation-metabase@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:05:06 -0400 Subject: [PATCH] E2E test for "Custom click behavior on a pivot table will go always to tab 1 on a destination dashboard with several tabs" (#49187) (#49235) * Add tests * Add tests * Add tests Co-authored-by: Alexander Polyankin <alexander.polyankin@metabase.com> --- e2e/support/helpers/e2e-dashboard-helpers.ts | 8 ++ ...dashboard-filters-reproductions.cy.spec.js | 82 +++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/e2e/support/helpers/e2e-dashboard-helpers.ts b/e2e/support/helpers/e2e-dashboard-helpers.ts index d16c24b6efc..baf0b34866e 100644 --- a/e2e/support/helpers/e2e-dashboard-helpers.ts +++ b/e2e/support/helpers/e2e-dashboard-helpers.ts @@ -234,6 +234,14 @@ export function goToTab(tabName: string) { cy.findByRole("tab", { name: tabName }).click(); } +export function assertTabSelected(tabName: string) { + cy.findByRole("tab", { name: tabName }).should( + "have.attr", + "aria-selected", + "true", + ); +} + export function moveDashCardToTab({ dashcardIndex = 0, tabName, diff --git a/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions.cy.spec.js b/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions.cy.spec.js index 08eb0c84d3f..49b1e9c9f14 100644 --- a/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions.cy.spec.js +++ b/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions.cy.spec.js @@ -12,6 +12,7 @@ import { addOrUpdateDashboardCard, appBar, assertQueryBuilderRowCount, + assertTabSelected, changeSynchronousBatchUpdateSetting, commandPalette, commandPaletteSearch, @@ -3976,3 +3977,84 @@ describe("issue 45670", { tags: ["@external"] }, () => { }); }); }); + +describe("issue 48351", () => { + beforeEach(() => { + restore(); + cy.signInAsNormalUser(); + }); + + it("should navigate to the specified tab with click behaviors (metabase#48351)", () => { + createDashboardWithTabs({ + name: "Dashboard 1", + tabs: [ + { id: 1, name: "Tab 1" }, + { id: 2, name: "Tab 2" }, + ], + dashcards: [ + createMockDashboardCard({ + id: -1, + card_id: ORDERS_QUESTION_ID, + dashboard_tab_id: 1, + size_x: 8, + size_y: 8, + }), + createMockDashboardCard({ + id: -2, + card_id: ORDERS_QUESTION_ID, + dashboard_tab_id: 2, + col: 8, + size_x: 8, + size_y: 8, + }), + ], + }).then(dashboard1 => { + createDashboardWithTabs({ + name: "Dashboard 2", + tabs: [ + { id: 3, name: "Tab 3" }, + { id: 4, name: "Tab 4" }, + ], + dashcards: [ + createMockDashboardCard({ + id: -1, + card_id: ORDERS_QUESTION_ID, + dashboard_tab_id: 3, + size_x: 8, + size_y: 8, + }), + createMockDashboardCard({ + id: -2, + card_id: ORDERS_QUESTION_ID, + dashboard_tab_id: 4, + visualization_settings: { + column_settings: { + '["name","ID"]': { + click_behavior: { + type: "link", + linkType: "dashboard", + targetId: dashboard1.id, + tabId: dashboard1.tabs[1].id, + parameterMapping: {}, + }, + }, + }, + }, + col: 8, + size_x: 8, + size_y: 8, + }), + ], + }).then(dashboard2 => visitDashboard(dashboard2.id)); + }); + goToTab("Tab 4"); + getDashboardCard().within(() => + cy.findAllByTestId("cell-data").eq(0).click(), + ); + cy.findByTestId("dashboard-name-heading").should( + "have.value", + "Dashboard 1", + ); + assertTabSelected("Tab 2"); + }); +}); -- GitLab