Skip to content

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

Replace flaky e2e repro no. 55637 with predicate unit test (#73556)

Nemanja Glumac0b2c1965f955
diff --git a/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js
index 540c3deca47..0a06d30789d 100644
--- a/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js
@@ -1465,27 +1465,6 @@ describe("issue 55673", () => {
});
});
-describe("issue 55637", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should not show column metadata popovers when header cell is clicked (metabase#55637)", () => {
- H.openOrdersTable();
- H.tableHeaderColumn("ID").realHover();
- cy.findByTestId("column-info").should("exist");
-
- H.tableHeaderColumn("ID").click();
-
- H.tableHeaderColumn("ID").realHover();
- cy.findByTestId("column-info").should("not.exist");
-
- H.tableHeaderColumn("Tax").realHover();
- cy.findByTestId("column-info").should("not.exist");
- });
-});
-
describe("issue 63745", () => {
beforeEach(() => {
H.restore();
diff --git a/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx
index df030a49305..31f38b18bd5 100644
--- a/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx
+++ b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx
@@ -79,6 +79,7 @@ import {
import { MiniBarCell } from "./cells/MiniBarCell";
import { useObjectDetail } from "./hooks/use-object-detail";
import { useResetWidthsOnColumnsChange } from "./hooks/use-reset-widths-on-columns-change";
+import { getInfoPopoversDisabled } from "./utils/get-info-popovers-disabled";
import { tableThemeToDataGridTheme } from "./utils/table-theme-to-data-grid-theme";
const shouldWrap = (
@@ -744,11 +745,12 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(
enableSelection: true,
});
const { getCenterColumns, scrollTo, columnsReordering } = tableProps;
- const infoPopoversDisabled =
- clicked !== null ||
- !hasMetadataPopovers ||
- isDashboard ||
- columnsReordering.isDragging;
+ const infoPopoversDisabled = getInfoPopoversDisabled({
+ clicked,
+ hasMetadataPopovers,
+ isDashboard,
+ isReorderingColumns: columnsReordering.isDragging,
+ });
const tableInteractiveContextValue = useMemo(
() => ({ infoPopoversDisabled }),
[infoPopoversDisabled],
diff --git a/frontend/src/metabase/visualizations/components/TableInteractive/utils/get-info-popovers-disabled.ts b/frontend/src/metabase/visualizations/components/TableInteractive/utils/get-info-popovers-disabled.ts
new file mode 100644
index 00000000000..f40b2106bc4
--- /dev/null
+++ b/frontend/src/metabase/visualizations/components/TableInteractive/utils/get-info-popovers-disabled.ts
@@ -0,0 +1,22 @@
+import type { ClickObject } from "metabase-lib";
+
+type Args = {
+ clicked: ClickObject | null | undefined;
+ hasMetadataPopovers: boolean;
+ isDashboard: boolean;
+ isReorderingColumns: boolean;
+};
+
+export function getInfoPopoversDisabled({
+ clicked,
+ hasMetadataPopovers,
+ isDashboard,
+ isReorderingColumns,
+}: Args) {
+ return (
+ clicked !== null ||
+ !hasMetadataPopovers ||
+ isDashboard ||
+ isReorderingColumns
+ );
+}
diff --git a/frontend/src/metabase/visualizations/components/TableInteractive/utils/get-info-popovers-disabled.unit.spec.ts b/frontend/src/metabase/visualizations/components/TableInteractive/utils/get-info-popovers-disabled.unit.spec.ts
new file mode 100644
index 00000000000..86112d99ced
--- /dev/null
+++ b/frontend/src/metabase/visualizations/components/TableInteractive/utils/get-info-popovers-disabled.unit.spec.ts
@@ -0,0 +1,41 @@
+import type { ClickObject } from "metabase-lib";
+
+import { getInfoPopoversDisabled } from "./get-info-popovers-disabled";
+
+const baseArgs = {
+ clicked: null,
+ hasMetadataPopovers: true,
+ isDashboard: false,
+ isReorderingColumns: false,
+};
+
+describe("getInfoPopoversDisabled", () => {
+ it("returns false when nothing is suppressing the popovers", () => {
+ expect(getInfoPopoversDisabled(baseArgs)).toBe(false);
+ });
+
+ // metabase#55637: clicking a header cell sets `clicked` and the
+ // header-info popover must stop appearing on subsequent hovers.
+ it("returns true when a click action is open", () => {
+ const clicked = { element: document.createElement("div") } as ClickObject;
+ expect(getInfoPopoversDisabled({ ...baseArgs, clicked })).toBe(true);
+ });
+
+ it("returns true when the caller has opted out of metadata popovers", () => {
+ expect(
+ getInfoPopoversDisabled({ ...baseArgs, hasMetadataPopovers: false }),
+ ).toBe(true);
+ });
+
+ it("returns true when rendered inside a dashboard", () => {
+ expect(getInfoPopoversDisabled({ ...baseArgs, isDashboard: true })).toBe(
+ true,
+ );
+ });
+
+ it("returns true while a column drag-reorder is in progress", () => {
+ expect(
+ getInfoPopoversDisabled({ ...baseArgs, isReorderingColumns: true }),
+ ).toBe(true);
+ });
+});