Skip to content
Snippets Groups Projects
Unverified Commit 9be96da9 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Prevent custom expressions from being removed from the query (#39518)

parent 48caf35d
No related branches found
No related tags found
No related merge requests found
......@@ -496,8 +496,6 @@ describe("scenarios > visualizations > table column settings", () => {
_hideColumn(testData);
_showColumn(testData);
_removeColumn(testData);
_addColumn(testData);
});
it("should be able to show and hide custom expressions for a table with selected fields", () => {
......@@ -515,8 +513,6 @@ describe("scenarios > visualizations > table column settings", () => {
_hideColumn(testData);
_showColumn(testData);
_removeColumn(testData);
_addColumn(testData);
});
it("should be able to show and hide columns from aggregations", () => {
......
......@@ -2,7 +2,7 @@ import userEvent from "@testing-library/user-event";
import { useState } from "react";
import { renderWithProviders, screen } from "__support__/ui";
import type * as Lib from "metabase-lib";
import * as Lib from "metabase-lib";
import { createQuery } from "metabase-lib/test-helpers";
import { FieldPanel } from "./FieldPanel";
......@@ -116,6 +116,22 @@ describe("QueryColumnPicker", () => {
expect(firstColumn).toBeEnabled();
});
it("should not allow to remove custom columns", () => {
const query = Lib.expression(
createQuery(),
-1,
"Custom",
Lib.expressionClause("+", [1, 2]),
);
setup({ query });
const [orderGroup] = screen.getAllByRole("checkbox");
const customColumn = screen.getByRole("checkbox", { name: "Custom" });
expect(orderGroup).toBeChecked();
expect(orderGroup).toBeDisabled();
expect(customColumn).toBeChecked();
expect(customColumn).toBeDisabled();
});
it("should allow to search for columns", () => {
setup();
userEvent.type(screen.getByPlaceholderText("Search for a column…"), "a");
......
......@@ -24,7 +24,10 @@ function getColumnItems(
column,
displayName: columnInfo.displayName,
isSelected: columnInfo.selected ?? false,
isDisabled: columnInfo.isAggregation || columnInfo.isBreakout,
isDisabled:
columnInfo.isAggregation ||
columnInfo.isBreakout ||
columnInfo.isCalculated,
};
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment