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
Always show the Metabot illustrations toggle (#82946)
Andrei Simionescuf2e185369ffb
diff --git a/docs/ai/customization.md b/docs/ai/customization.mdindex 53617039c83..dea356ddb18 100644--- a/docs/ai/customization.md+++ b/docs/ai/customization.md@@ -32,7 +32,7 @@ Upload a custom icon. SVG or PNG with a transparent background gives the cleanes-Once you've uploaded a custom icon, this toggle appears and controls whether the default decorative illustrations show in the Metabot chat sidebar and on the AI exploration page.+This toggle controls whether the default decorative illustrations show in the Metabot chat sidebar.## Further readingdiff --git a/e2e/test/scenarios/metabot/ai-controls.cy.spec.ts b/e2e/test/scenarios/metabot/ai-controls.cy.spec.tsindex 536840cb020..125db2c132f 100644--- a/e2e/test/scenarios/metabot/ai-controls.cy.spec.ts+++ b/e2e/test/scenarios/metabot/ai-controls.cy.spec.ts@@ -137,7 +137,7 @@ describe("AI Controls > Metabot access and customization", () => {cy.findByLabelText("AI agent's name").should("have.value", "HAL 9000");});- it("should upload a custom Metabot icon and show the illustrations section", () => {+ it("should upload a custom Metabot icon", () => {cy.intercept("PUT", "/api/setting/metabot-icon").as("saveIcon");cy.visit("/admin/metabot/customization");@@ -147,9 +147,6 @@ describe("AI Controls > Metabot access and customization", () => {"be.visible",);- // The illustrations section is hidden until a custom icon is set- H.main().findByText("Metabot illustrations").should("not.exist");-// Upload a tiny PNG via the hidden file inputcy.get('input[type="file"]').selectFile({@@ -165,20 +162,12 @@ describe("AI Controls > Metabot access and customization", () => {cy.wait("@saveIcon").its("response.statusCode").should("eq", 204);- // The illustrations section should now appear- H.main().findByText("Metabot illustrations").should("be.visible");- cy.findByRole("switch", { name: /Show Metabot illustrations/ })- .parent()- .should("be.visible");-// The "Remove custom icon" button should be visiblecy.findByLabelText("Remove custom icon").should("be.visible");});it("should hide Metabot illustrations when the toggle is switched off", () => {- // Set a custom icon via API so the illustrations toggle is visibleH.updateEnterpriseSettings({- "metabot-icon": TINY_PNG_DATA_URI,"metabot-show-illustrations": true,});H.updateSetting("metabot-enabled?", true);@@ -209,10 +198,7 @@ describe("AI Controls > Metabot access and customization", () => {// Navigate to the home page and open Metabot chat to verify illustrations are hiddency.visit("/");- // Can't use H.openMetabotViaSearchButton() because custom icon replaces .Icon-metabot- H.appBar()- .findByRole("button", { name: /Chat with/ })- .click();+ H.openMetabotViaSearchButton();cy.findByTestId("metabot-empty-chat-info").should("be.visible");// The SVG illustration should NOT be rendered when showIllustrations=falsediff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotCustomizationPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotCustomizationPage.unit.spec.tsxindex 2e4fc7f102c..459037e56d0 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotCustomizationPage.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotCustomizationPage.unit.spec.tsx@@ -2,12 +2,11 @@ import userEvent from "@testing-library/user-event";import fetchMock from "fetch-mock";import {- setupPropertiesEndpoints,setupSettingsEndpoints,- setupUpdateSettingEndpoint,+ setupStatefulSettingsEndpoints,} from "__support__/server-mocks";import { mockSettings } from "__support__/settings";-import { renderWithProviders, screen } from "__support__/ui";+import { renderWithProviders, screen, waitFor } from "__support__/ui";import { createMockSettings } from "metabase-types/api/mocks";import { MetabotCustomizationPage } from "./MetabotCustomizationPage";@@ -27,9 +26,8 @@ function setup({"metabot-show-illustrations": showIllustrations,});- setupPropertiesEndpoints(settings);+ setupStatefulSettingsEndpoints(settings);setupSettingsEndpoints([]);- setupUpdateSettingEndpoint();// Seed the store state too: without it, the render harness seeds the// settings bootstrap with *defaults*, and assertions can run against the@@ -54,10 +52,9 @@ describe("MetabotCustomizationPage", () => {expect(screen.queryByRole("button", { name: /Remove custom icon/ }),).not.toBeInTheDocument();- expect(screen.queryByText("Metabot illustrations")).not.toBeInTheDocument();expect(- screen.queryByAltText("Metabot illustration preview"),- ).not.toBeInTheDocument();+ screen.getByRole("switch", { name: /Show Metabot illustrations/ }),+ ).toBeChecked();});it("shows the remove button and illustrations toggle when a custom icon is set", async () => {@@ -80,7 +77,7 @@ describe("MetabotCustomizationPage", () => {expect(preview).toHaveAttribute("src", "data:image/png;base64,abc123");});- it("shows the illustrations toggle when illustrations are off, even with the default icon", async () => {+ it("keeps the illustrations toggle after turning illustrations on with the default icon", async () => {setup({ showIllustrations: false });const toggle = await screen.findByRole("switch", {@@ -93,5 +90,10 @@ describe("MetabotCustomizationPage", () => {{ method: "PUT" },);expect(await call?.request?.json()).toEqual({ value: true });+ await waitFor(() =>+ expect(+ screen.getByRole("switch", { name: /Show Metabot illustrations/ }),+ ).toBeChecked(),+ );});});diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotIconField.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotIconField.tsxindex 6158815b524..455ac9aa840 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotIconField.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotIconField.tsx@@ -34,7 +34,6 @@ export function MetabotIconField() {const [iconError, setIconError] = useState("");const isDefaultIcon = !metabotIcon || metabotIcon === "metabot";- const isIllustrationsSectionVisible = !isDefaultIcon || !showIllustrations;const iconPreviewSrc =!isDefaultIcon && typeof metabotIcon === "string" ? metabotIcon : null;@@ -162,40 +161,38 @@ export function MetabotIconField() {</Flex>)}</Flex>- {isIllustrationsSectionVisible && (- <Stack mt="xl" gap="sm">- <Text fz="md" fw="bold">- {t`Metabot illustrations`}- </Text>- <Group gap="xl" align="center" wrap="nowrap">- <Flex align="center" gap="sm" flex="1" miw={0}>- <Box- component="img"- src={EmptyDashboardBot}- alt={t`Metabot illustration preview`}- w="3rem"- h="3rem"- flex="0 0 auto"- />- <Text fz="md" c="text-secondary" flex="1">- {t`Show Metabot illustrations in chat sidebar and AI exploration page`}- </Text>- </Flex>- <Switch- aria-label={t`Show Metabot illustrations`}- checked={!!showIllustrations}- onChange={(e) =>- updateShowIllustrations({- key: "metabot-show-illustrations",- value: e.currentTarget.checked,- toast: false,- })- }- disabled={isLoadingIllustrations}+ <Stack mt="xl" gap="sm">+ <Text fz="md" fw="bold">+ {t`Metabot illustrations`}+ </Text>+ <Group gap="xl" align="center" wrap="nowrap">+ <Flex align="center" gap="sm" flex="1" miw={0}>+ <Box+ component="img"+ src={EmptyDashboardBot}+ alt={t`Metabot illustration preview`}+ w="3rem"+ h="3rem"+ flex="0 0 auto"/>- </Group>- </Stack>- )}+ <Text fz="md" c="text-secondary" flex="1">+ {t`Show Metabot illustrations in the chat sidebar`}+ </Text>+ </Flex>+ <Switch+ aria-label={t`Show Metabot illustrations`}+ checked={!!showIllustrations}+ onChange={(e) =>+ updateShowIllustrations({+ key: "metabot-show-illustrations",+ value: e.currentTarget.checked,+ toast: false,+ })+ }+ disabled={isLoadingIllustrations}+ />+ </Group>+ </Stack></Stack>);}