diff --git a/e2e/support/helpers/e2e-dashboard-helpers.ts b/e2e/support/helpers/e2e-dashboard-helpers.ts index b2ea448a783d9716096bd78e0ab817d50f6d4b77..54a2de215c55fed311019d7278a0e94450315aec 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 1d8b7b88c593472f4d254a35e1d373c3c11d5c40..a217b9e8a18144d35c214a37d86b8f0c9bf36141 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, @@ -3986,3 +3987,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"); + }); +});