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
Disable explorations (#82230)
Kevin Kelleherc505a9a785a6
diff --git a/.clj-kondo/config/modules/config.edn b/.clj-kondo/config/modules/config.ednindex 7aca2f922eb..82de9f2531a 100644--- a/.clj-kondo/config/modules/config.edn+++ b/.clj-kondo/config/modules/config.edn@@ -970,7 +970,7 @@explorations{:team "UX West"- :api #{metabase.explorations.api metabase.explorations.core metabase.explorations.init}+ :api #{metabase.explorations.core metabase.explorations.init}:uses #{analyticsanalytics.interfaceapidiff --git a/e2e/test/scenarios/collections/collections.cy.spec.js b/e2e/test/scenarios/collections/collections.cy.spec.jsindex 4fe2d20562d..1ca47c72469 100644--- a/e2e/test/scenarios/collections/collections.cy.spec.js+++ b/e2e/test/scenarios/collections/collections.cy.spec.js@@ -1337,7 +1337,7 @@ describe("scenarios > collection items listing", () => {cy.findByRole("button", { name: "Filter" }).click();H.popover().within(() => {- cy.findAllByRole("checkbox").should("have.length", 8);+ cy.findAllByRole("checkbox").should("have.length", 7);cy.findByLabelText("Collection").should("not.be.checked");cy.findByLabelText("Dashboard").should("not.be.checked");cy.findByLabelText("Question").should("not.be.checked");diff --git a/e2e/test/scenarios/explorations/explorations.cy.spec.ts b/e2e/test/scenarios/explorations/explorations.cy.spec.tsdeleted file mode 100644index 720335f65c0..00000000000--- a/e2e/test/scenarios/explorations/explorations.cy.spec.ts+++ /dev/null@@ -1,1418 +0,0 @@-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";-import type { StructuredQuestionDetails } from "e2e/support/helpers";-import type {- Exploration,- GetExplorationDataResponse,-} from "metabase-types/api";--const { H } = cy;-const { ORDERS_ID, ORDERS, PRODUCTS } = SAMPLE_DATABASE;--type StructuredQuestionDetailsWithName = StructuredQuestionDetails & {- name: string;-};--const ORDERS_COUNT_METRIC_NAME = "Count of orders";-const ORDERS_COUNT_METRIC: StructuredQuestionDetailsWithName = {- name: ORDERS_COUNT_METRIC_NAME,- type: "metric" as const,- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- },- display: "scalar" as const,-};--const ORDERS_TIMESERIES_METRIC_NAME = "Count of orders over time";-const ORDERS_TIMESERIES_METRIC: StructuredQuestionDetailsWithName = {- name: ORDERS_TIMESERIES_METRIC_NAME,- type: "metric" as const,- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- [- "field",- ORDERS.CREATED_AT,- { "base-type": "type/DateTime", "temporal-unit": "month" },- ],- ],- },- display: "line" as const,-};--function seedMetrics() {- for (const metric of [ORDERS_COUNT_METRIC, ORDERS_TIMESERIES_METRIC]) {- H.createQuestion(metric).then(({ body }) => {- // The response is unused, but `GET /api/metric/:id` calls- // `sync-dimensions!` server-side, persisting the metric's dimensions- // and dimension_mappings — which `/api/exploration/dimensions` needs.- cy.request("GET", `/api/metric/${body.id}`);- });- }-}--/**- * Create a timeline + one sentinel event in a single chain. The- * Exploration timeline picker (`useGetExplorationTimelinesQuery`) hides- * timelines without events, so test fixtures that want to surface the- * timeline in the picker — or attach it to an exploration — need at- * least one event hanging off it.- *- * Returns the new `timeline_id` so callers that need it (e.g. to assert- * a request body's `timeline_ids` field) can chain off it; call sites- * that just need the timeline to exist can ignore the return value.- */-function createTimelineWithSentinelEvent(- name: string,- icon: string,-): Cypress.Chainable<number> {- return cy- .request("POST", "/api/timeline", {- name,- collection_id: null,- icon,- default: false,- })- .then(({ body }: { body: { id: number } }) => {- const timelineId = body.id;- return cy- .request("POST", "/api/timeline-event", {- timeline_id: timelineId,- name: `${name} event`,- icon,- timestamp: "2026-01-01T00:00:00Z",- time_matters: false,- timezone: "UTC",- })- .then(() => timelineId);- });-}--describe("scenarios > explorations > new research > manual flow", () => {- beforeEach(() => {- cy.task("stopMockLlmServer");- H.restore();- cy.signInAsAdmin();- H.enableExplorations();- seedMetrics();- H.resetSnowplow();- H.enableTracking();- });-- afterEach(() => {- H.expectNoBadSnowplowEvents();- });-- it("picks Our analytics + metrics + timelines, creates an exploration, and lands on the detail page", () => {- createTimelineWithSentinelEvent("Releases", "star").then((releasesId) => {- createTimelineWithSentinelEvent("Marketing campaigns", "bell").then(- (marketingId) => {- H.visitNewExploration();-- // Root is a FE-only id (`"root"`); the create POST must send- // `collection_id: null` or the BE schema rejects it.- cy.findByRole("button", { name: /Personal collection/i }).click();- H.pickEntity({ path: ["Our analytics"], select: true });- cy.findByRole("button", { name: /Our analytics/i }).should(- "be.visible",- );-- H.startManualExploration();-- // Manual setup is its own location, so browser back returns here- // instead of leaving the research flow (UXW-4832).- cy.location("pathname").should("eq", "/question/research/plan");-- H.addMetricsToExploration({- metrics: [ORDERS_COUNT_METRIC_NAME],- });-- cy.findByTestId("research-content")- .should("be.visible")- .and("contain", ORDERS_COUNT_METRIC_NAME);-- // Pick two timelines via the "+ Events" modal.- H.addTimelinesToExploration(["Marketing campaigns", "Releases"]);-- // The first picked timeline shows as a pill next to the Events- // button; the rest collapse into a "+N" overflow pill.- cy.findByTestId("selected-timelines-container").within(() => {- cy.findByText("Marketing campaigns").should("be.visible");- cy.findByText("+1").should("be.visible");- });-- H.beginResearch().then((id) => {- // `beginResearch` consumed the create request; re-read it off its- // alias to assert timeline ids + root collection were forwarded.- cy.get("@createExploration")- .its("request.body")- .should((body) => {- expect(body.timeline_ids).to.deep.eq([marketingId, releasesId]);- expect(body.collection_id).to.eq(null);- });-- H.expectUnstructuredSnowplowEvent({- event: "exploration_plan_edited",- triggered_from: "manual",- event_detail: "metrics",- });- H.expectUnstructuredSnowplowEvent({- event: "exploration_plan_edited",- triggered_from: "manual",- event_detail: "timelines",- });- H.expectUnstructuredSnowplowEvent({- event: "exploration_created",- target_id: id,- });-- // `beginResearch` already asserted the detail-page URL.- // No new-exploration CTA on the detail page.- cy.findByRole("button", { name: /Start research/i }).should(- "not.exist",- );- });- },- );- });- });-- it("filters Exploration data pickers by typing into their search inputs", () => {- // Both timelines need an event so the picker surfaces them — the- // empty-state case is still exercised by the "no match" search at- // the bottom of this test.- createTimelineWithSentinelEvent("Releases", "star");- createTimelineWithSentinelEvent("Marketing campaigns", "bell");-- H.visitNewExploration();- H.startManualExploration();-- // --- "+ Metrics" modal search ---- cy.findByRole("button", { name: /Metrics/ }).click();- // Seeded names are "Count of orders" + "Count of orders over time".- cy.wait("@getDimensions");- // Seeded metrics aren't in the library; switch off the default Library tab.- H.selectAllMetricsTab();- cy.findByRole("checkbox", { name: ORDERS_COUNT_METRIC_NAME }).should(- "exist",- );- cy.findByRole("checkbox", { name: ORDERS_TIMESERIES_METRIC_NAME }).should(- "exist",- );-- // Type a substring that only matches the timeseries metric.- cy.findByPlaceholderText("Search for a metric").type("over time");- cy.wait("@getDimensions");- cy.findByRole("checkbox", { name: ORDERS_TIMESERIES_METRIC_NAME }).should(- "exist",- );- cy.findByRole("checkbox", { name: ORDERS_COUNT_METRIC_NAME }).should(- "not.exist",- );-- // Clear the input → both rows return.- cy.findByPlaceholderText("Search for a metric").clear();- cy.findByRole("checkbox", { name: ORDERS_COUNT_METRIC_NAME }).should(- "exist",- );- cy.findByRole("checkbox", { name: ORDERS_TIMESERIES_METRIC_NAME }).should(- "exist",- );-- // Search for something that matches no metric → empty-state copy.- cy.findByPlaceholderText("Search for a metric").type("zzz");- cy.wait("@getDimensions");- cy.findByRole("dialog").should("contain", "No results");-- // Close the metrics modal before opening the events one.- cy.get("body").type("{esc}");-- // --- "+ Events" modal search ---- cy.findByRole("button", { name: /Events/ }).click();- cy.findByRole("checkbox", { name: "Releases" }).should("exist");- cy.findByRole("checkbox", { name: "Marketing campaigns" }).should("exist");-- // Filter to just one timeline by name fragment.- cy.findByPlaceholderText("Search for a timeline").type("release");- cy.findByRole("checkbox", { name: "Releases" }).should("exist");- cy.findByRole("checkbox", { name: "Marketing campaigns" }).should(- "not.exist",- );-- // Clear → both return.- cy.findByPlaceholderText("Search for a timeline").clear();- cy.findByRole("checkbox", { name: "Releases" }).should("exist");- cy.findByRole("checkbox", { name: "Marketing campaigns" }).should("exist");- });-});--describe("scenarios > explorations > new research > metabot flow", () => {- beforeEach(() => {- cy.task("stopMockLlmServer");- H.restore();- cy.signInAsAdmin();- H.enableExplorations();- seedMetrics();- H.resetSnowplow();- H.enableTracking();- });-- afterEach(() => {- H.expectNoBadSnowplowEvents();- });-- it("auto-populates metrics + dimensions + name from agent tool calls, then Start research succeeds", () => {- cy.request("GET", "/api/exploration/dimensions").then(({ body }) => {- // Unjustified type cast. FIXME- const data = body as {- metrics: Array<{ id: number; name: string; dimension_ids: string[] }>;- dimension_groups: Array<{- name: string;- dimension_interestingness: number | null;- dimensions: Array<{- id: string;- name: string;- display_name: string;- dimension_interestingness: number | null;- }>;- }>;- };-- const firstMetric = data.metrics[0];- const interestingGroup =- data.dimension_groups.find((g) =>- g.dimensions.some((d) => (d.dimension_interestingness ?? 0) >= 0.7),- ) ?? data.dimension_groups[0];- expect(- firstMetric,- "seeded metric is exposed by /api/exploration/dimensions",- ).to.exist;- expect(interestingGroup, "at least one dimension group is exposed").to- .exist;-- const agentName = "New exploration";- H.mockExplorationsAgentToolCalls([- {- toolCallId: "groups-1",- toolName: "add_research_groups",- // The tool result is only the LLM's summary of the edit; the picker- // hydration rides a `research_plan_update` data part.- result: `Added 1 group(s) to the research plan:\n- ${firstMetric.name}, by the automatically-selected dimensions`,- dataParts: [- {- dataType: "research_plan_update",- data: {- metrics: [firstMetric],- dimension_groups: [interestingGroup],- groups: [{ metric_id: firstMetric.id }],- },- },- ],- },- {- toolCallId: "name-1",- toolName: "set_research_name",- result: { name: agentName },- },- ]);-- H.visitNewExploration();-- H.explorationsMetabotPromptInput().type("Why are signups down?");- cy.findByRole("button", { name: /Create plan/i }).click();-- // The chat dispatch went through with the `explorations`- // profile, confirming we wired the new-exploration page to- // the right agent.- cy.wait("@metabotAgent")- .its("request.body.profile_id")- .should("eq", "explorations");-- // Right panel hydrated from the tool-call result — the agent's- // metric now heads a research-plan block.- cy.findByRole("main").findByText(firstMetric.name).should("be.visible");-- // Click Start research; the create-exploration POST body- // should carry the name the agent picked.- cy.intercept("POST", "/api/exploration").as("createExploration");- cy.findByRole("button", { name: /Start research/i }).click();- cy.wait("@createExploration").then(({ request, response }) => {- expect(request.body.name).to.eq(agentName);- // Unjustified type cast. FIXME- const id = response?.body?.id as number;- H.expectUnstructuredSnowplowEvent({- event: "exploration_agent_message_sent",- });- H.expectUnstructuredSnowplowEvent({- event: "exploration_plan_edited",- triggered_from: "agent",- event_detail: "metrics",- });- H.expectUnstructuredSnowplowEvent({- event: "exploration_created",- target_id: id,- });- });- });- });-});--describe("scenarios > explorations > detail page", () => {- beforeEach(() => {- cy.task("stopMockLlmServer");- H.restore();- cy.signInAsAdmin();- H.enableExplorations();- seedMetrics();- H.resetSnowplow();- H.enableTracking();- });-- afterEach(() => {- H.expectNoBadSnowplowEvents();- });-- it("changes sidebar selection on click and shows the corresponding visualization area", () => {- H.createExplorationViaApi({ name: "Click selection fixture" }).then(- (id) => {- visitExplorationUntilSettled(id, 2);-- // The page auto-selects a row on load, so clicking the first (already- // selected) row would pass even with click-to-select broken. Click a- // row that is NOT selected and assert the selection moves to it.- cy.findAllByRole("treeitem")- .filter('[aria-selected="false"]')- .eq(1) // first treeitem is the summary document- .invoke("attr", "href")- .then((href) => {- cy.get(`[role="treeitem"][href="${href}"]`).click();- cy.get(`[role="treeitem"][href="${href}"]`).should(- "have.attr",- "aria-selected",- "true",- );- });-- // The clicked page's chart renders in the main area — assert a real- // visualization anchor, not just "main is not empty" (a spinner- // satisfies that).- cy.location("pathname").should("match", /\/page\/\d+$/);- cy.findByRole("main")- .findByTestId("visualization-root", { timeout: 15000 })- .should("be.visible");- },- );- });-- it("preserves the URL `timeline` param across navigation and reload", () => {- createTimelineWithSentinelEvent("Releases", "star").then((timelineId) => {- cy.request("GET", "/api/exploration/dimensions").then(({ body }) => {- // Unjustified type cast. FIXME- const data = body as GetExplorationDataResponse;- const temporalDimension = data.dimension_groups- .flatMap((group) => group.dimensions)- .find((dim) => dim.effective_type.includes("Date"));- expect(temporalDimension, "sample DB exposes a temporal dimension").to- .exist;-- H.createExplorationViaApi({- name: "Timeline persistence fixture",- timelineIds: [timelineId],- dimensionIds: [temporalDimension!.id],- }).then((id) => {- cy.visit(`/question/research/${id}?timeline=${timelineId}`);- // Sidebar treeitems appear once the BE returns query rows.- cy.findAllByRole("treeitem", { timeout: 15000 })- .first()- .should("be.visible");-- cy.findByRole("treeitem", {- name: new RegExp(`${temporalDimension!.display_name}$`), // anchor at end so we don't match day of week or hour of day- }).click();-- cy.findByTestId("exploration-chart-grid").within(() => {- H.timelineEventChip("Releases event").should("be.visible");- });-- cy.location("search").should("include", `timeline=${timelineId}`);-- // Reload — the URL param is the source of truth and the- // router shouldn't rewrite it away on hydration.- cy.reload();- cy.findAllByRole("treeitem", { timeout: 15000 })- .first()- .should("be.visible");- cy.location("search").should("include", `timeline=${timelineId}`);-- cy.findByTestId("exploration-chart-grid").within(() => {- H.timelineEventChip("Releases event").should("be.visible");- });- });- });- });- });-});--/**- * Resolve the "Count of orders" metric plus its first two dimensions and- * create an exploration with them — yielding one metric-group heading with- * exactly two dimension-named pages, the smallest deterministic tree for- * sidebar-triage assertions.- */-function createTwoPageExploration(name: string): Cypress.Chainable<{- explorationId: number;- metricName: string;- pageNames: string[];-}> {- return cy.request("GET", "/api/exploration/dimensions").then(({ body }) => {- // Unjustified type cast. FIXME- const data = body as GetExplorationDataResponse;- const ordersMetric = data.metrics.find(- (metric) => metric.name === ORDERS_COUNT_METRIC_NAME,- );- expect(- ordersMetric,- `"${ORDERS_COUNT_METRIC_NAME}" metric is exposed by /api/exploration/dimensions`,- ).to.exist;- const dimsById = new Map(- data.dimension_groups.flatMap((group) =>- group.dimensions.map((dim) => [dim.id, dim] as const),- ),- );- const pickedDimensions = ordersMetric!.dimension_ids- .map((id) => dimsById.get(id))- .filter((dim) => dim != null)- .slice(0, 2);- expect(- pickedDimensions.length,- "metric exposes at least two dimensions",- ).to.eq(2);-- return H.createExplorationViaApi({- name,- metricCardIds: [ordersMetric!.id],- dimensionIds: pickedDimensions.map((dim) => dim!.id),- }).then((explorationId) => ({- explorationId,- metricName: ordersMetric!.name,- pageNames: pickedDimensions.map((dim) => dim!.display_name),- }));- });-}--/**- * Visit an exploration and wait until it has fully settled. The "Ready" icons- * only say every page's queries finished; the page keeps polling- * `GET /api/exploration/:id` (rebuilding the sidebar tree on each response)- * until the BE also stamps the thread's `completed_at` after its post-query- * handling. Interact with the tree only after that final response, or clicks- * can land on nodes a re-render just replaced.- */-function visitExplorationUntilSettled(- explorationId: number,- minReadyCount: number,-): void {- cy.intercept("GET", `/api/exploration/${explorationId}`).as("getExploration");- H.visitExploration(explorationId);- cy.findAllByLabelText("Ready", { timeout: 30000 }).should(- "have.length.at.least",- minReadyCount,- );- const awaitThreadCompletion = (attempt: number) => {- cy.wait("@getExploration", { timeout: 30000 }).then(({ response }) => {- // Unjustified type cast. FIXME- const threads = (response?.body as Exploration).threads ?? [];- if (!threads.every((thread) => thread.completed_at != null)) {- expect(- attempt,- "exploration completes within the poll budget",- ).to.be.lessThan(30);- awaitThreadCompletion(attempt + 1);- }- });- };- awaitThreadCompletion(0);-}--/**- * The FE polls every 2s while the new thread's queries are in flight, then- * toasts once its first page lands. Timing is covered by- * ExplorationPage.unit.spec.tsx — here we just wait for the real BE.- * Scoped to the toast container so we don't match the thread name in the- * sidebar.- */-function openExploreFurtherToast(threadName: string): void {- H.undoToastListContainer().within(() => {- cy.findByText(`Added ${threadName}`, { timeout: 60000 }).should(- "be.visible",- );- cy.findByRole("button", { name: "View" }).click();- });-}--describe("scenarios > explorations > sidebar triage", () => {- const sidebar = () => cy.findByTestId("exploration-page-sidebar");- const filterToggle = () => cy.findByTestId("exploration-show-hidden-toggle");- const selectedRows = () =>- cy.findAllByRole("treeitem").filter('[aria-selected="true"]');- const toggleShowHiddenItems = () => {- filterToggle().click();- H.menu().findByText("Show hidden items").click();- cy.get("body").type("{esc}");- };-- beforeEach(() => {- cy.task("stopMockLlmServer");- H.restore();- cy.signInAsAdmin();- H.enableExplorations();- seedMetrics();- H.resetSnowplow();- H.enableTracking();- });-- afterEach(() => {- H.expectNoBadSnowplowEvents();- });-- it("filters pages with the Stars and Discussions tabs and persists the sort preference across reloads", () => {- createTwoPageExploration("Sidebar tabs fixture").then(- ({ explorationId, pageNames }) => {- visitExplorationUntilSettled(explorationId, 2);-- cy.log("Stars tab is empty until something is starred");- cy.findByRole("radio", { name: "Stars" }).click({ force: true });- cy.location("search").should("include", "tab=stars");- H.main().findByText("Nothing's been starred yet.").should("be.visible");- cy.findAllByRole("treeitem").should("not.exist");-- cy.log("Discussions tab shows its own empty message");- cy.findByRole("radio", { name: "Discussions" }).click({ force: true });- H.main().findByText("No discussions yet.").should("be.visible");- cy.findAllByRole("treeitem").should("not.exist");-- cy.log("Star the selected page with the s shortcut");- cy.findByRole("radio", { name: "All" }).click({ force: true });- cy.findAllByRole("treeitem").should("have.length", 3); // summary document + 2 pages- sidebar().findByText(pageNames[0]).click();- selectedRows().should("contain.text", pageNames[0]);- cy.intercept("PUT", "/api/exploration/page/*/starred").as("setStarred");- cy.get("body").type("s");- cy.wait("@setStarred").its("request.body.starred").should("eq", true);- H.main()- .findByRole("button", { name: "Remove star" })- .should("be.visible");-- cy.log("The c shortcut opens the comment editor");- cy.get("body").type("c");- // The editor's placeholder is CSS-rendered by TipTap (not real text),- // so anchor on the editor's Send button instead. The popover is- // portaled outside <main>.- H.popover().findByRole("button", { name: "Send" }).should("be.visible");- H.main().findByRole("button", { name: "Add comment" }).click();- cy.findByRole("button", { name: "Send" }).should("not.exist");-- cy.log("The l shortcut copies a link to the selected page");- // Headless Chrome denies real clipboard access here (NotAllowedError),- // so stub the write and assert the call instead of reading it back.- cy.window().then((win) => {- cy.stub(win.navigator.clipboard, "writeText")- .as("copyToClipboard")- .resolves();- });- cy.get("body").type("l");- H.undoToastListContainer()- .findByText("Copied link")- .should("be.visible");- cy.location("href").then((href) => {- cy.get("@copyToClipboard").should("have.been.calledWith", href);- });-- cy.log("Stars tab now shows only the starred page");- cy.findByRole("radio", { name: "Stars" }).click({ force: true });- cy.findAllByRole("treeitem")- .should("have.length", 1)- .first()- .should("contain.text", pageNames[0]);-- cy.log("Alphabetical sort is remembered per exploration");- cy.findByRole("radio", { name: "All" }).click({ force: true });- // Assert and click through separate queries — chaining `.click()` off- // the assertion can act on a node a poll-driven re-render detached.- filterToggle().should("have.attr", "aria-pressed", "false");- filterToggle().click();- H.menu().findByText("Alphabetical").click();- H.menu()- .findByRole("menuitem", { name: /Alphabetical/ })- .should("have.attr", "data-checked", "true");- cy.get("body").type("{esc}");- cy.log("Sorting is not a filter, so the toggle stays unfilled");- filterToggle().should("have.attr", "aria-pressed", "false");-- cy.reload();- cy.findAllByRole("treeitem", { timeout: 15000 })- .first()- .should("be.visible");- filterToggle().should("have.attr", "aria-pressed", "false");- filterToggle().click();- H.menu()- .findByRole("menuitem", { name: /Alphabetical/ })- .should("have.attr", "data-checked", "true");- },- );- });-- it("hides pages from the toolbar and group menus and reveals them via Show hidden items", () => {- createTwoPageExploration("Sidebar hide fixture").then(- ({ explorationId, metricName, pageNames }) => {- cy.intercept("PUT", "/api/exploration/pages/hidden").as(- "setPagesHidden",- );- visitExplorationUntilSettled(explorationId, 2);-- // The page auto-selects the tree's first page on load, and the tree- // orders pages by interestingness — so which of the two- // dimension-named pages is selected is data-dependent; derive it- // from the DOM instead of assuming.- cy.findAllByRole("treeitem").should("have.length", 3); // summary document + 2 pages- selectedRows().should("have.length", 1);- selectedRows()- .first()- .invoke("text")- .then((text) => {- const firstPageName = text.trim();- const secondPageName = pageNames.find(- (name) => name !== firstPageName,- )!;-- cy.log("Triage arrows step between pages");- cy.findByRole("button", { name: "Next" }).click();- selectedRows().should("contain.text", secondPageName);- cy.findByRole("button", { name: "Previous" }).click();- selectedRows().should("contain.text", firstPageName);-- cy.log("Hide the selected page with the h shortcut");- cy.get("body").type("h");- cy.wait("@setPagesHidden").then(({ request }) => {- expect(request.body.hidden).to.eq(true);- expect(request.body.page_ids).to.have.length(1);- });- H.undoToastListContainer()- .findByText(`"${firstPageName}" hidden`)- .should("be.visible");-- cy.log("Auto-advance moves the selection to the remaining page");- selectedRows().should("contain.text", secondPageName);- cy.findAllByRole("treeitem").should("have.length", 2); // summary document + 1 non-hidden page- sidebar().findByText(firstPageName).should("not.exist");-- cy.log("Show hidden items reveals the page with a Hidden marker");- toggleShowHiddenItems();- filterToggle().should("have.attr", "aria-pressed", "true");- sidebar().findByText(firstPageName).should("be.visible");- sidebar().findAllByLabelText("Hidden").should("have.length", 1);- toggleShowHiddenItems();- cy.findAllByRole("treeitem").should("have.length", 2);- sidebar().findByText(firstPageName).should("not.exist");- });-- cy.log("Hide the whole group from its actions menu");- sidebar()- .findByRole("group", { name: metricName })- .findByRole("button", { name: "Group actions" })- .click({ force: true });- H.menu().findByText("Hide").click();- cy.wait("@setPagesHidden")- .its("request.body.hidden")- .should("eq", true);- H.undoToastListContainer()- .findByText(`${metricName} hidden`)- .should("be.visible");-- cy.log("Everything but the summary document is hidden");- cy.findAllByRole("treeitem").should("have.length", 1);-- cy.log("Hidden state is persisted server-side across a reload");- cy.reload();- cy.findAllByRole("treeitem").should("have.length", 1);-- cy.log("Show hidden items + the group Show action restore the pages");- toggleShowHiddenItems();- cy.findAllByRole("treeitem").should("have.length", 3);- sidebar().findAllByLabelText("Hidden").should("have.length", 2);- sidebar()- .findByRole("group", { name: metricName })- .findByRole("button", { name: "Group actions" })- .click({ force: true });- H.menu().findByText("Show").click();- cy.wait("@setPagesHidden")- .its("request.body.hidden")- .should("eq", false);- cy.findAllByRole("treeitem").should("have.length", 3);- sidebar().findAllByLabelText("Hidden").should("not.exist");-- cy.log("Hiding the group with every page visible sends both page ids");- toggleShowHiddenItems();- cy.findAllByRole("treeitem").should("have.length", 3);- sidebar()- .findByRole("group", { name: metricName })- .findByRole("button", { name: "Group actions" })- .click({ force: true });- H.menu().findByText("Hide").click();- cy.wait("@setPagesHidden").then(({ request }) => {- expect(request.body.hidden).to.eq(true);- expect(request.body.page_ids).to.have.length(2);- });- cy.findAllByRole("treeitem").should("have.length", 1);-- cy.log("Undo on the group-hidden toast restores the whole group");- H.undoToastListContainer()- .findByText(`${metricName} hidden`)- .should("be.visible");- H.undoToastListContainer()- .findByRole("button", { name: "Undo" })- .click();- cy.wait("@setPagesHidden")- .its("request.body.hidden")- .should("eq", false);- cy.findAllByRole("treeitem").should("have.length", 3);- },- );- });-});--describe("scenarios > explorations > chart click-through", () => {- beforeEach(() => {- cy.task("stopMockLlmServer");- H.restore();- cy.signInAsAdmin();- H.enableExplorations();- seedMetrics();- H.resetSnowplow();- H.enableTracking();- });-- afterEach(() => {- H.expectNoBadSnowplowEvents();- });-- it("clicking a cartesian point opens Explore further + Add comment, posts explore-further filters, and navigates from the new-thread toast", () => {- createTimelineWithSentinelEvent("Releases", "star").then((timelineId) => {- cy.request("GET", "/api/exploration/dimensions").then(({ body }) => {- // manual typecast for BE data- const seeded = body as GetExplorationDataResponse;- const seededMetric = seeded.metrics.find(- (metric) => metric.name === ORDERS_COUNT_METRIC_NAME,- );- expect(- seededMetric,- `"${ORDERS_COUNT_METRIC_NAME}" metric is exposed by /api/exploration/dimensions`,- ).to.exist;- cy.request("POST", `/api/metric/${seededMetric!.id}/dimension/add`, {- dimensions: [- {- id: "e2e00000-cafe-4bb8-9d8a-0123456789ab",- mapping_target: [- "field",- { "source-field": ORDERS.PRODUCT_ID },- PRODUCTS.CATEGORY,- ],- },- ],- });- });-- cy.request("GET", "/api/exploration/dimensions").then(({ body }) => {- // Unjustified type cast. FIXME- const data = body as GetExplorationDataResponse;- const ordersMetric = data.metrics.find(- (metric) => metric.name === ORDERS_COUNT_METRIC_NAME,- );- expect(- ordersMetric,- `"${ORDERS_COUNT_METRIC_NAME}" metric is exposed by /api/exploration/dimensions`,- ).to.exist;- const dimsById = new Map(- data.dimension_groups.flatMap((group) =>- group.dimensions.map((dim) => [dim.id, dim] as const),- ),- );- const dimension = ordersMetric!.dimension_ids- .map((id) => dimsById.get(id))- .find((dim) => dim != null && dim.display_name === "Category");- expect(- dimension,- 'orders metric exposes the curated "Category" dimension',- ).to.exist;-- H.createExplorationViaApi({- name: "Chart click-through fixture",- metricCardIds: [ordersMetric!.id],- dimensionIds: [dimension!.id],- timelineIds: [timelineId],- }).then((explorationId) => {- let initialThreadIds: number[] = [];-- cy.intercept(- "POST",- `/api/exploration/${explorationId}/explore-further`,- ).as("exploreFurther");-- cy.visit(- `/question/research/${explorationId}?timeline=${timelineId}`,- );- cy.findAllByRole("treeitem", { timeout: 30000 })- .first()- .should("be.visible");-- cy.request("GET", `/api/exploration/${explorationId}`).then(- ({ body }) => {- // Unjustified type cast. FIXME- const exploration = body as Exploration;- initialThreadIds = (exploration.threads ?? []).map(- (thread) => thread.id,- );- // Navigate straight to the dimension's page. Driving the- // sidebar here would depend on which group happens to be- // auto-expanded — a state this test doesn't control.- const pages = (exploration.threads ?? []).flatMap((thread) =>- (thread.blocks ?? []).flatMap((block) => block.pages ?? []),- );- const page = pages.find((p) =>- (p.name ?? "").includes(dimension!.display_name),- );- expect(page, "the dimension's page exists on the exploration").to- .exist;- cy.wrap(page!.id).as("pageId");- cy.visit(- `/question/research/${explorationId}/page/${page!.id}?timeline=${timelineId}`,- );- },- );-- cy.location("pathname").should("include", "/page/");-- // Wait for the selected page's queries to settle before clicking- // the chart — `Ready` is the settled-state icon label.- cy.findAllByLabelText("Ready", { timeout: 30000 })- .first()- .should("be.visible");-- H.chartPathWithFillColor("#509EE3").first().click({ force: true });-- cy.findByTestId("click-actions-view").within(() => {- cy.findByRole("button", { name: /Explore further/i }).should(- "be.visible",- );- cy.findByRole("button", { name: /Add comment/i }).should(- "be.visible",- );- });-- cy.findByTestId("click-actions-view")- .findByRole("button", { name: /Explore further/i })- .click();-- cy.wait("@exploreFurther").then(({ request, response }) => {- cy.get("@pageId").then((pageId) => {- expect(request.body.page_id).to.eq(pageId);- });- expect(request.body.explore_filters).to.be.an("array").and.not.be- .empty;- expect(request.body.explore_filters[0]).to.include.keys(- "operator",- "field_ref",- "value",- "display_value",- );- expect(request.body.explore_filters[0].operator).to.eq("=");-- // Unjustified type cast. FIXME- const threads = (response?.body as Exploration).threads ?? [];- const newThread = threads.find(- (thread) => !initialThreadIds.includes(thread.id),- );- expect(newThread, "explore-further adds a new thread").to.exist;- cy.wrap(newThread!.name).as("newThreadName");- });-- cy.get<string>("@newThreadName").then((name) => {- openExploreFurtherToast(name);- });-- cy.location("pathname").should(- "include",- `/question/research/${explorationId}/page/`,- );- cy.location("search").should("include", "tab=all");- cy.location("search").should("include", `timeline=${timelineId}`);-- cy.get("@newThreadName").then((name) => {- cy.findByRole("group", { name: String(name) }).should(- "have.attr",- "aria-expanded",- "true",- );- });-- cy.findByRole("main")- .findByTestId("exploration-chart-grid")- .should("exist");- });- });- });- });-- it("brushing a timeseries cartesian chart opens Explore further only, posts between explore_filters, navigates from the new-thread toast, and Add to Summary preserves filter pills", () => {- cy.request<GetExplorationDataResponse>(- "GET",- "/api/exploration/dimensions",- ).then(({ body: data }) => {- const ordersMetric = data.metrics.find(- (metric) => metric.name === ORDERS_COUNT_METRIC_NAME,- );- expect(- ordersMetric,- `"${ORDERS_COUNT_METRIC_NAME}" metric is exposed by /api/exploration/dimensions`,- ).to.exist;- const dimsById = new Map(- data.dimension_groups.flatMap((group) =>- group.dimensions.map((dim) => [dim.id, dim] as const),- ),- );- const temporalDimension = ordersMetric!.dimension_ids- .map((id) => dimsById.get(id))- .find((dim) => dim != null && dim.effective_type.includes("Date"));- expect(- temporalDimension,- "orders metric exposes at least one temporal dimension",- ).to.exist;-- H.createExplorationViaApi({- name: "Chart brush explore-further fixture",- metricCardIds: [ordersMetric!.id],- dimensionIds: [temporalDimension!.id],- }).then((explorationId) => {- let initialThreadIds: number[] = [];-- cy.intercept(- "POST",- `/api/exploration/${explorationId}/explore-further`,- ).as("exploreFurther");-- visitExplorationUntilSettled(explorationId, 1);-- cy.request<Exploration>(- "GET",- `/api/exploration/${explorationId}`,- ).then(({ body: exploration }) => {- initialThreadIds = (exploration.threads ?? []).map(- (thread) => thread.id,- );- });-- cy.findByTestId("exploration-page-sidebar").within(() => {- cy.findByRole("group", { name: ordersMetric!.name }).then(- ($group) => {- if ($group.attr("aria-expanded") !== "true") {- cy.wrap($group).click();- }- },- );- cy.findByRole("treeitem", {- // Anchor on end so we don't match e.g. "Hour of day".- name: new RegExp(`${temporalDimension!.display_name}$`),- }).click();- });-- H.ensureEchartsContainerHasSvg();- H.applyBrush(120, 280);-- cy.findByTestId("click-actions-view").within(() => {- cy.findByRole("button", { name: /Explore further/i }).should(- "be.visible",- );- cy.findByRole("button", { name: /Add comment/i }).should("not.exist");- });-- cy.findByTestId("click-actions-view")- .findByRole("button", { name: /Explore further/i })- .click();-- cy.wait("@exploreFurther").then(({ request, response }) => {- expect(request.body.explore_filters)- .to.be.an("array")- .and.have.length(1);- expect(request.body.explore_filters[0]).to.include.keys(- "operator",- "field_ref",- "values",- "display_value",- );- expect(request.body.explore_filters[0].operator).to.eq("between");- expect(request.body.explore_filters[0].values)- .to.be.an("array")- .and.have.length(2);-- // Cypress does not type intercept response bodies.- const threads = (response?.body as Exploration).threads ?? [];- const newThread = threads.find(- (thread) => !initialThreadIds.includes(thread.id),- );- expect(newThread, "explore-further adds a new thread").to.exist;- cy.wrap(newThread!.name).as("newThreadName");- });-- cy.get<string>("@newThreadName").then((name) => {- openExploreFurtherToast(name);- });-- cy.location("pathname").should(- "include",- `/question/research/${explorationId}/page/`,- );-- // Temporal ranges use an en-dash (e.g. "Feb 2020 – Mar 2020"); exact- // bounds depend on brush pixel coords, so just assert range formatting.- cy.findByTestId("filter-pill")- .should("be.visible")- .invoke("text")- .should("match", /–/)- .as("exploreFilterPillText");-- cy.intercept(- "POST",- `/api/exploration/${explorationId}/summary/append`,- ).as("appendSummary");-- cy.findByRole("button", { name: "Add to Summary" }).click();- cy.wait("@appendSummary");-- H.undoToastListContainer().within(() => {- cy.findByText(/Added to/).should("be.visible");- cy.findByRole("button", { name: "View" }).click();- });-- cy.location("pathname").should(- "eq",- `/question/research/${explorationId}/summary`,- );- cy.findByTestId("document-card-embed", { timeout: 15000 })- .should("be.visible")- .findByTestId("filter-pill")- .should("be.visible")- .invoke("text")- .then((text) => {- cy.get("@exploreFilterPillText").should("eq", text);- });- });- });- });-});--describe("scenarios > explorations > Summary document", () => {- beforeEach(() => {- cy.task("stopMockLlmServer");- H.restore();- cy.signInAsAdmin();- H.enableExplorations();- seedMetrics();- });-- it("auto-creates Summary at the top of the tree, keeps pages selected initially, supports Add to Summary, and mirrors comments both ways", () => {- H.createExplorationViaApi({ name: "Summary fixture" }).then(- (explorationId) => {- cy.request("GET", `/api/exploration/${explorationId}`).then(- ({ body }) => {- // api returns an Exploration- const exploration = body as Exploration;- expect(exploration.document, "BE auto-creates a Summary document")- .to.exist;- expect(exploration.document?.name).to.eq("Summary");- expect(exploration.document?.is_placeholder).to.eq(true);- },- );-- visitExplorationUntilSettled(explorationId, 1);-- // Summary is pinned at the top of the tree but not initially selected- // while it is still a placeholder.- cy.findAllByRole("treeitem")- .first()- .should("contain.text", "Summary")- .and("have.attr", "aria-selected", "false");-- // Capture the settled page id from the auto-selected sidebar row- // (pages only exist after settlement), then click through- cy.findAllByRole("treeitem")- .filter('[aria-selected="true"]')- .should("have.length", 1)- .and("not.contain.text", "Summary")- .invoke("attr", "href")- .should("match", /\/page\/\d+/)- .then((href) => {- const pageId = Number(/\/page\/(\d+)/.exec(href!)![1]);- cy.wrap(pageId).as("pageId");- cy.get(`[role="treeitem"][href="${href}"]`).click();- });-- cy.location("pathname").should("match", /\/page\/\d+$/);- cy.findByTestId("exploration-chart-grid").should("be.visible");-- cy.intercept(- "POST",- `/api/exploration/${explorationId}/summary/append`,- ).as("appendSummary");-- cy.findByRole("button", { name: "Add to Summary" }).click();- cy.wait("@appendSummary").then(({ response }) => {- expect(response?.statusCode).to.eq(200);- expect(response?.body?.is_placeholder).to.eq(false);- });-- H.undoToastListContainer()- .findByText(/Added to/)- .should("be.visible");- H.undoToast().findByRole("button", { name: "View" }).click();-- cy.location("pathname").should(- "eq",- `/question/research/${explorationId}/summary`,- );- cy.findByTestId("document-card-embed", { timeout: 15000 }).should(- "be.visible",- );-- // Seed a page comment via API- cy.get<number>("@pageId").then((pageId) => {- H.createComment({- target_type: "exploration",- target_id: explorationId,- child_target_id: String(pageId),- parent_comment_id: null,- content: {- type: "doc",- content: [- {- type: "paragraph",- content: [{ type: "text", text: "Shared comment" }],- },- ],- },- });- });-- // Cold-load the Summary with the comments query param — the panel- // must open without a prior click (the deep-link regression).- cy.get<number>("@pageId").then((pageId) => {- cy.visit(- `/question/research/${explorationId}/summary?comments=${pageId}`,- );- cy.findByTestId("exploration-summary-comments", {- timeout: 15000,- })- .should("be.visible")- .and("contain.text", "Shared comment");- });-- cy.get<number>("@pageId").then((pageId) => {- cy.visit(- `/question/research/${explorationId}/page/${pageId}?comments=${pageId}`,- );- });-- cy.findByTestId("exploration-comments", { timeout: 15000 }).should(- "contain.text",- "Shared comment",- );- },- );- });-});--describe("scenarios > explorations > collection placement + archive", () => {- beforeEach(() => {- cy.task("stopMockLlmServer");- H.restore();- cy.signInAsAdmin();- H.enableExplorations();- seedMetrics();- H.resetSnowplow();- H.enableTracking();- });-- afterEach(() => {- H.expectNoBadSnowplowEvents();- });-- it("places a newly-created exploration in the creator's personal collection and lets the user move it to trash from there", () => {- const explorationName = "Personal-collection archive fixture";-- H.createExplorationViaApi({ name: explorationName }).then(- (explorationId) => {- cy.request("GET", "/api/user/current").then(({ body: user }) => {- // Unjustified type cast. FIXME- const personalCollectionId = user.personal_collection_id as number;- expect(- personalCollectionId,- "/api/user/current returns a personal collection id",- ).to.be.a("number");-- cy.request("GET", `/api/exploration/${explorationId}`).then(- ({ body }) => {- expect(- body.collection_id,- "exploration lives in the creator's personal collection",- ).to.eq(personalCollectionId);- },- );-- // Visit the personal collection and confirm the row- // renders.- H.visitCollection(personalCollectionId);- cy.findByTestId("collection-table")- .findByText(explorationName)- .should("be.visible");-- // Open the row's overflow menu and click `Move to trash`.- // Archiving an exploration goes through the centralized- // `useSetArchive` hook → `PUT /api/exploration/:id- // { archived: true }`.- cy.intercept("PUT", `/api/exploration/${explorationId}`).as(- "archiveExploration",- );- H.openCollectionItemMenu(explorationName);- // The EntityItem dropdown renders each action as a- // `<li aria-labelledby="...">`, not `role="menuitem"`,- // so match the visible text — scoped to the open popover.- H.popover().findByText("Move to trash").click();-- cy.wait("@archiveExploration").then(({ request, response }) => {- expect(request.body).to.deep.eq({ archived: true });- expect(response?.statusCode).to.eq(200);- });-- // After archive, the collection shows its empty state and- // the exploration row is gone from the page.- cy.findByText("This collection is empty").should("be.visible");- cy.findByText(explorationName).should("not.exist");-- // BE state agrees: a subsequent GET reports- // `archived: true`.- cy.request("GET", `/api/exploration/${explorationId}`).then(- ({ body }) => {- expect(body.archived, "exploration is archived").to.eq(true);- },- );-- H.undoToast().findByText("Trashed research").should("exist");- H.undo();-- cy.findByTestId("collection-table")- .findByText(explorationName)- .should("be.visible");- });- },- );- });-- it("permanently deletes an archived exploration via the Delete permanently action on the /trash page", () => {- // `ActionMenu`'s `handleDeletePermanently` previously routed- // every non-collection model through the legacy entity factory- // (`entityForObject`), which has no `explorations` entry — so- // the delete crashed. The fix dispatches the RTKQ- // `deleteExploration` mutation, which calls- // `DELETE /api/exploration/:id` (a new BE endpoint that cascades- // through threads/queries/documents via the FK tree).- const explorationName = "Trash-page delete-permanently fixture";-- H.createExplorationViaApi({ name: explorationName }).then(- (explorationId) => {- cy.request("PUT", `/api/exploration/${explorationId}`, {- archived: true,- });-- cy.visit("/trash");- cy.findByTestId("collection-table")- .findByText(explorationName)- .should("be.visible");-- cy.intercept("DELETE", `/api/exploration/${explorationId}`).as(- "deleteExploration",- );- H.openCollectionItemMenu(explorationName);- H.popover().findByText("Delete permanently").click();- // The confirmation modal owns the final destructive button.- H.modal()- .findByRole("button", { name: /Delete permanently/i })- .click();-- cy.wait("@deleteExploration")- .its("response.statusCode")- .should("eq", 204);-- // The row is gone from the trash listing…- cy.findByText(explorationName).should("not.exist");-- // …and the BE returns 404 for the now-hard-deleted exploration.- cy.request({- method: "GET",- url: `/api/exploration/${explorationId}`,- failOnStatusCode: false,- })- .its("status")- .should("eq", 404);- },- );- });-- it("restores an archived exploration via the Restore action on the /trash page", () => {- // `useSetArchive`'s undo toast is one path back, but the trash- // page exposes a separate `Restore` action that runs through- // `ActionMenu.tsx`'s `handleRestore`. Without an explicit- // `exploration` branch in that handler it falls through to the- // legacy `entityForObject(...)`, which has no `explorations`- // entry — so the restore would silently throw. This test- // exercises the dedicated branch end-to-end.- const explorationName = "Trash-page restore fixture";-- H.createExplorationViaApi({ name: explorationName }).then(- (explorationId) => {- // Archive directly via the BE so we land on /trash with the- // exploration already in it.- cy.request("PUT", `/api/exploration/${explorationId}`, {- archived: true,- });-- cy.visit("/trash");- cy.findByTestId("collection-table")- .findByText(explorationName)- .should("be.visible");-- cy.intercept("PUT", `/api/exploration/${explorationId}`).as(- "restoreExploration",- );- H.openCollectionItemMenu(explorationName);- H.popover().findByText("Restore").click();-- cy.wait("@restoreExploration").then(({ request, response }) => {- expect(request.body).to.deep.eq({ archived: false });- expect(response?.statusCode).to.eq(200);- });-- // The trash listing no longer shows the exploration.- cy.findByText(explorationName).should("not.exist");-- // And the BE reports the exploration as un-archived again.- cy.request("GET", `/api/exploration/${explorationId}`).then(- ({ body }) => {- expect(body.archived, "exploration is no longer archived").to.eq(- false,- );- },- );- },- );- });-});diff --git a/e2e/test/scenarios/onboarding/command-palette.cy.spec.js b/e2e/test/scenarios/onboarding/command-palette.cy.spec.jsindex 6812da2d663..b8ebdc119d2 100644--- a/e2e/test/scenarios/onboarding/command-palette.cy.spec.js+++ b/e2e/test/scenarios/onboarding/command-palette.cy.spec.js@@ -171,7 +171,7 @@ describe("command palette", () => {cy.wait(100); // pressing page down too fast does nothingH.pressPageDown();H.commandPalette()- .findByRole("option", { name: "New collection" })+ .findByRole("option", { name: "New model" }).should("have.attr", "aria-selected", "true");H.pressPageDown();@@ -181,7 +181,7 @@ describe("command palette", () => {H.pressPageUp();H.commandPalette()- .findByRole("option", { name: "New collection" })+ .findByRole("option", { name: "New model" }).should("have.attr", "aria-selected", "true");H.pressPageUp();diff --git a/enterprise/backend/test/metabase_enterprise/sandbox/explorations_test.clj b/enterprise/backend/test/metabase_enterprise/sandbox/explorations_test.cljindex db48ce5a238..0f5ba356992 100644--- a/enterprise/backend/test/metabase_enterprise/sandbox/explorations_test.clj+++ b/enterprise/backend/test/metabase_enterprise/sandbox/explorations_test.clj@@ -12,6 +12,7 @@[metabase-enterprise.sandbox.test-util :as sandbox.tu][metabase-enterprise.test :as met][metabase.explorations.query-plan.variants :as variants]+ [metabase.explorations.test-util :as explorations.tu][metabase.lib.core :as lib][metabase.lib.metadata :as lib.metadata][metabase.permissions.core :as perms]@@ -28,6 +29,9 @@(use-fixtures :once (fixtures/initialize :db :web-server :test-users))+;; The application does not mount `/api/exploration` while explorations are disabled; serve it for these tests.+(use-fixtures :each explorations.tu/exploration-routes-fixture)+(defn- venues-count-query [](let [mp (mt/metadata-provider)](-> (lib/query mp (lib.metadata/table mp (mt/id :venues)))diff --git a/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.unit.spec.tsx b/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.unit.spec.tsxindex 40bb8addd0e..c67c0d6b4ea 100644--- a/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.unit.spec.tsx+++ b/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.unit.spec.tsx@@ -25,7 +25,7 @@ import {} from "metabase-types/api/mocks";import { CollectionItemsTable } from "./CollectionItemsTable";-import { ALL_MODELS } from "./constants";+import { ALL_MODELS, TYPE_FILTER_MODELS } from "./constants";const collection = createMockCollection({ id: 1, can_write: false });@@ -689,7 +689,9 @@ describe("CollectionItemsTable", () => {);const popover = screen.getByTestId("collection-type-filter-popover");- expect(within(popover).getAllByRole("checkbox")).toHaveLength(8);+ expect(within(popover).getAllByRole("checkbox")).toHaveLength(+ TYPE_FILTER_MODELS.length,+ );for (const label of ["Dashboard", "Model", "Question"]) {expect(within(popover).getByLabelText(label)).not.toBeChecked();expect(within(popover).getByLabelText(label)).toBeEnabled();@@ -777,7 +779,9 @@ describe("CollectionItemsTable", () => {expect(getMetadataCalls()).toHaveLength(1);await user.click(screen.getByTestId("collection-type-filter-button"));const popover = screen.getByTestId("collection-type-filter-popover");- expect(within(popover).getAllByRole("checkbox")).toHaveLength(8);+ expect(within(popover).getAllByRole("checkbox")).toHaveLength(+ TYPE_FILTER_MODELS.length,+ );expect(within(popover).getByLabelText("Dashboard")).not.toBeChecked();expect(within(popover).getByLabelText("Model")).toBeChecked();expect(within(popover).getByLabelText("Question")).toBeChecked();@@ -867,7 +871,9 @@ describe("CollectionItemsTable", () => {await screen.findByTestId("collection-type-filter-button"),);let popover = screen.getByTestId("collection-type-filter-popover");- expect(within(popover).getAllByRole("checkbox")).toHaveLength(8);+ expect(within(popover).getAllByRole("checkbox")).toHaveLength(+ TYPE_FILTER_MODELS.length,+ );within(popover).getByLabelText("Dashboard").focus();await user.keyboard("{Escape}");await waitFor(() => {@@ -887,7 +893,9 @@ describe("CollectionItemsTable", () => {await user.click(screen.getByTestId("collection-type-filter-button"));popover = screen.getByTestId("collection-type-filter-popover");- expect(within(popover).getAllByRole("checkbox")).toHaveLength(8);+ expect(within(popover).getAllByRole("checkbox")).toHaveLength(+ TYPE_FILTER_MODELS.length,+ );expect(within(popover).getByLabelText("Dashboard")).toBeEnabled();expect(within(popover).getByLabelText("Model")).toBeEnabled();expect(within(popover).getByLabelText("Question")).toBeEnabled();diff --git a/frontend/src/metabase/collections/components/CollectionContent/CollectionTypeFilter.unit.spec.tsx b/frontend/src/metabase/collections/components/CollectionContent/CollectionTypeFilter.unit.spec.tsxindex 3edadeba5de..7b26402dbb7 100644--- a/frontend/src/metabase/collections/components/CollectionContent/CollectionTypeFilter.unit.spec.tsx+++ b/frontend/src/metabase/collections/components/CollectionContent/CollectionTypeFilter.unit.spec.tsx@@ -4,6 +4,7 @@ import { renderWithProviders, screen } from "__support__/ui";import type { CollectionItemModel } from "metabase-types/api";import { CollectionTypeFilter } from "./CollectionTypeFilter";+import { TYPE_FILTER_MODELS } from "./constants";type SetupOpts = {availableModels?: string[];@@ -37,14 +38,7 @@ describe("CollectionTypeFilter", () => {it("shows every type in display order, disabling those without items", async () => {setup({- availableModels: [- "metric",- "card",- "collection",- "dataset",- "dashboard",- "exploration",- ],+ availableModels: ["metric", "card", "collection", "dataset", "dashboard"],});const filterButton = screen.getByTestId("collection-type-filter-button");@@ -62,17 +56,16 @@ describe("CollectionTypeFilter", () => {"Question","Metric","Document",- "Research","Table",];- expect(checkboxes).toHaveLength(8);+ expect(checkboxes).toHaveLength(TYPE_FILTER_MODELS.length);expect(checkboxes).toEqual(labels.map((label) => screen.getByLabelText(label)),);for (const label of labels) {expect(screen.getByLabelText(label)).not.toBeChecked();}- for (const label of ["Collection", "Dashboard", "Metric", "Research"]) {+ for (const label of ["Collection", "Dashboard", "Metric"]) {expect(screen.getByLabelText(label)).toBeEnabled();}expect(screen.getByLabelText("Document")).toBeDisabled();diff --git a/frontend/src/metabase/collections/components/CollectionContent/constants.ts b/frontend/src/metabase/collections/components/CollectionContent/constants.tsindex c6700eee0b2..c42f86019ac 100644--- a/frontend/src/metabase/collections/components/CollectionContent/constants.ts+++ b/frontend/src/metabase/collections/components/CollectionContent/constants.ts@@ -20,7 +20,6 @@ export const ALL_MODELS: CollectionItemModel[] = ["collection","document","table",- "exploration",];export const TYPE_FILTER_MODELS = [@@ -30,6 +29,5 @@ export const TYPE_FILTER_MODELS = ["card","metric","document",- "exploration","table",] as const satisfies readonly CollectionItemModel[];diff --git a/frontend/src/metabase/metabot/components/MetabotAsk/MetabotGreeting.tsx b/frontend/src/metabase/metabot/components/MetabotAsk/MetabotGreeting.tsxindex 2fd473e849b..817a7d6217d 100644--- a/frontend/src/metabase/metabot/components/MetabotAsk/MetabotGreeting.tsx+++ b/frontend/src/metabase/metabot/components/MetabotAsk/MetabotGreeting.tsx@@ -3,7 +3,6 @@ import { useState } from "react";import { t } from "ttag";import _ from "underscore";-import { ForwardRefLink } from "metabase/common/components/Link";import { AIProviderConfigurationModal } from "metabase/metabot/components/AIProviderConfigurationModal";import { AIProviderConfigurationNotice } from "metabase/metabot/components/AIProviderConfigurationNotice";import { MetabotPromptInput } from "metabase/metabot/components/MetabotPromptInput";@@ -15,7 +14,6 @@ import type { SuggestionModel } from "metabase/rich_text_editing/tiptap/extensioimport {ActionIcon,Box,- Button,Flex,Icon,Paper,@@ -23,7 +21,6 @@ import {Text,UnstyledButton,} from "metabase/ui";-import * as Urls from "metabase/urls";import { useGetSuggestedMetabotPromptsQuery } from "../../api";@@ -80,14 +77,6 @@ export const MetabotGreeting = ({<Text fz="xl" fw={600} c="text-primary">{title}</Text>- <Button- component={ForwardRefLink}- to={Urls.newExploration()}- bd="none"- leftSection={<Icon name="telescope" c="brand" />}- >- {t`Research`}- </Button></Flex><Paper className={S.inputContainer}><Box className={S.editorWrapper}>diff --git a/frontend/src/metabase/metabot/components/NewMenuItemAIExploration.tsx b/frontend/src/metabase/metabot/components/NewMenuItemAIExploration.tsxindex bafcec1a81c..15a9470747f 100644--- a/frontend/src/metabase/metabot/components/NewMenuItemAIExploration.tsx+++ b/frontend/src/metabase/metabot/components/NewMenuItemAIExploration.tsx@@ -7,20 +7,16 @@ import type { CollectionId } from "metabase-types/api";interface NewMenuItemAIExplorationProps {collectionId?: CollectionId;- hasNlqAccess?: boolean;}export function NewMenuItemAIExploration({collectionId,- hasNlqAccess,}: NewMenuItemAIExplorationProps) {- const url = hasNlqAccess- ? Urls.newQuestion({- mode: "ask",- collectionId,- cardType: "question",- })- : Urls.newExploration();+ const url = Urls.newQuestion({+ mode: "ask",+ collectionId,+ cardType: "question",+ });return (<Menu.Itemdiff --git a/frontend/src/metabase/metabot/components/NewMenuItemAIExploration.unit.spec.tsx b/frontend/src/metabase/metabot/components/NewMenuItemAIExploration.unit.spec.tsxindex 28e381bea14..f25f1c14955 100644--- a/frontend/src/metabase/metabot/components/NewMenuItemAIExploration.unit.spec.tsx+++ b/frontend/src/metabase/metabot/components/NewMenuItemAIExploration.unit.spec.tsx@@ -7,15 +7,11 @@ import { Menu } from "metabase/ui";import { NewMenuItemAIExploration } from "./NewMenuItemAIExploration";-function setup(- { hasNlqAccess } = {- hasNlqAccess: true,- },-) {+function setup() {const TestComponent = () => (<Menu opened><Menu.Dropdown>- <NewMenuItemAIExploration hasNlqAccess={hasNlqAccess} />+ <NewMenuItemAIExploration /></Menu.Dropdown></Menu>);@@ -33,21 +29,11 @@ function setup(}describe("NewMenuItemAIExploration", () => {- it("links to the ask mode question page when hasNlqAccess is true", () => {+ it("links to the ask mode question page", () => {setup();expect(screen.getByRole("menuitem", { name: /AI exploration/ }),).toHaveAttribute("href", "/question/ask");});-- it("should link to the research mode page when hasNlqAccess is false", () => {- setup({- hasNlqAccess: false,- });-- expect(- screen.getByRole("menuitem", { name: /AI exploration/ }),- ).toHaveAttribute("href", "/question/research");- });});diff --git a/frontend/src/metabase/nav/components/NewItemMenu/NewItemMenuView.tsx b/frontend/src/metabase/nav/components/NewItemMenu/NewItemMenuView.tsxindex f3e392d2cc1..035b5867f70 100644--- a/frontend/src/metabase/nav/components/NewItemMenu/NewItemMenuView.tsx+++ b/frontend/src/metabase/nav/components/NewItemMenu/NewItemMenuView.tsx@@ -47,13 +47,9 @@ export const NewItemMenuView = ({const menuItems = useMemo(() => {const items = [];- if (hasDataAccess) {+ if (hasDataAccess && hasNlqAccess) {items.push(- <NewMenuItemAIExploration- key="nlq"- collectionId={collectionId}- hasNlqAccess={hasNlqAccess}- />,+ <NewMenuItemAIExploration key="nlq" collectionId={collectionId} />,);}diff --git a/frontend/src/metabase/palette/hooks/useCommandPaletteBasicActions.tsx b/frontend/src/metabase/palette/hooks/useCommandPaletteBasicActions.tsxindex 64bbbb40693..42c889dddeb 100644--- a/frontend/src/metabase/palette/hooks/useCommandPaletteBasicActions.tsx+++ b/frontend/src/metabase/palette/hooks/useCommandPaletteBasicActions.tsx@@ -41,7 +41,6 @@ import {export const BASIC_ACTION_ORDER = ["create-new-question","create-new-native-query",- "create-new-research","create-new-dashboard","create-new-document","create-new-collection",@@ -158,19 +157,6 @@ export const useCommandPaletteBasicActions = ({});}- if (hasDataAccess) {- actions.push({- id: "create-new-research",- name: t`New research`,- section: "basic",- icon: "telescope",- perform: () => {- dispatch(closeModal());- navigate(Urls.newExploration());- },- });- }-actions.push({id: "create-new-dashboard",name: t`New dashboard`,diff --git a/frontend/src/metabase/palette/shortcuts/global.ts b/frontend/src/metabase/palette/shortcuts/global.tsindex 1ff2d7ef720..3bb8da8c2ab 100644--- a/frontend/src/metabase/palette/shortcuts/global.ts+++ b/frontend/src/metabase/palette/shortcuts/global.ts@@ -21,16 +21,6 @@ export const globalShortcuts = {shortcut: ["c n"],shortcutGroup: "global" as const,},- "create-new-research": {- get name() {- return t`Create a research`;- },- get keywords() {- return t`add research, add exploration, research mode`;- },- shortcut: ["c r"],- shortcutGroup: "global" as const,- },"create-new-dashboard": {get name() {return t`Create a dashboard`;diff --git a/frontend/src/metabase/routes.tsx b/frontend/src/metabase/routes.tsxindex be99f92d14c..719752de4e8 100644--- a/frontend/src/metabase/routes.tsx+++ b/frontend/src/metabase/routes.tsx@@ -20,7 +20,6 @@ import { MoveQuestionsIntoDashboardsModal } from "metabase/common/components/Movimport { NotFoundFallbackPage } from "metabase/common/components/NotFoundFallbackPage";import { UnsubscribePage } from "metabase/common/components/Unsubscribe";import { getDataStudioRoutes } from "metabase/data-studio/routes";-import { getRoutes as getExplorationsRoutes } from "metabase/explorations/routes";import { getMetabotRoutes } from "metabase/metabot/routes";import { getMetricRoutes } from "metabase/metrics/routes";import NewModelOptions from "metabase/models/containers/NewModelOptions";@@ -445,7 +444,8 @@ export const getRoutes = (store: AppStore): RouteObject[] => [{ index: true, lazy: queryBuilder },{ path: "notebook", lazy: queryBuilder },{ path: "ask", lazy: metabotQueryBuilder },- ...toRouteObjects(getExplorationsRoutes()),+ // Explorations are intentionally disabled on the v64 release branch. do not uncomment this+ // ...toRouteObjects(getExplorationsRoutes()),{ path: ":slug", lazy: queryBuilder },{ path: ":slug/notebook", lazy: queryBuilder },{ path: ":slug/metabot", lazy: queryBuilder },diff --git a/src/metabase/api_routes/routes.clj b/src/metabase/api_routes/routes.cljindex 3f79cb98c30..c5e0aa1ab8c 100644--- a/src/metabase/api_routes/routes.clj+++ b/src/metabase/api_routes/routes.clj@@ -28,7 +28,6 @@[metabase.documents.api][metabase.eid-translation.api][metabase.embedding-rest.api]- [metabase.explorations.api][metabase.frontend-errors.api][metabase.geojson.api][metabase.glossary.api]@@ -98,7 +97,6 @@metabase.data-studio.api/keep-memetabase.documents.api/keep-memetabase.eid-translation.api/keep-me- metabase.explorations.api/keep-memetabase.frontend-errors.api/keep-memetabase.geojson.api/keep-memetabase.glossary.api/keep-me@@ -206,7 +204,8 @@"/embed-mcp" (+auth metabase.mcp.callback-api/routes)"/embed-theme" (+auth metabase.embedding-rest.api/theme-routes)"/eval-trace" (metabase.ai-tracing.api/+eval-capture-enabled metabase.ai-tracing.api/routes)- "/exploration" (+auth metabase.explorations.api/routes)+ ;; Explorations are intentionally disabled on the v64 release branch. do not uncomment this+ ;; "/exploration" (+auth metabase.explorations.api/routes)"/field" (+auth metabase.warehouse-schema-rest.api/field-routes)"/frontend-errors" metabase.frontend-errors.api/routes"/geojson" 'metabase.geojson.apidiff --git a/src/metabase/bookmarks/api.clj b/src/metabase/bookmarks/api.cljindex 93e85829840..580335b4138 100644--- a/src/metabase/bookmarks/api.clj+++ b/src/metabase/bookmarks/api.clj@@ -14,7 +14,7 @@(def Models"Schema enumerating bookmarkable models."(into [:enum]- ["card" "dashboard" "collection" "document" "exploration"]))+ ["card" "dashboard" "collection" "document"]))(def BookmarkOrderings"Schema for an ordered of bookmark orderings"diff --git a/src/metabase/bookmarks/db.clj b/src/metabase/bookmarks/db.cljindex 2cbd9a24992..643d1df57e3 100644--- a/src/metabase/bookmarks/db.clj+++ b/src/metabase/bookmarks/db.clj@@ -206,17 +206,9 @@:created_at]:from [:document_bookmark]:where [:= :user_id user-id]}]]- {:union-all (conj base-queries- ^:allow-subquery {:select [[as-null :card_id]- [as-null :dashboard_id]- [as-null :collection_id]- [as-null :document_id]- :exploration_id- [:exploration_id :item_id]- [(h2x/literal "exploration") :type]- :created_at]- :from [:exploration_bookmark]- :where [:= :user_id user-id]})}))+ ;; While explorations are disabled, `exploration_bookmark` is left out of the union so residue rows never reach+ ;; the listing. The `exploration_id` column stays so the joins in [[bookmark-rows-for-user]] resolve.+ {:union-all base-queries}))(mu/defn bookmark-rows-for-user"The bookmarks of the User with `user-id`, joined against the Card, Dashboard, Collection, Document, and Explorationdiff --git a/src/metabase/collections/children.clj b/src/metabase/collections/children.cljindex a52090e4e11..257c18c4d0c 100644--- a/src/metabase/collections/children.clj+++ b/src/metabase/collections/children.clj@@ -159,7 +159,6 @@#{"card" ; SavedQuestion"dataset" ; Model. TODO : update this"document"- "exploration""metric""collection""dashboard"@@ -1115,7 +1114,7 @@(defn- valid-collection-models"Return every item model that can appear in `collection-namespace`."[collection-namespace]- (for [model-kw (cond-> [:collection :dataset :metric :card :dashboard :pulse :snippet :timeline :document :exploration :transform]+ (for [model-kw (cond-> [:collection :dataset :metric :card :dashboard :pulse :snippet :timeline :document :transform];; Tables in collections are an EE feature (library)(premium-features/has-feature? :library) (conj :table)):let [toucan-model (model-name->toucan-model model-kw)@@ -1128,7 +1127,7 @@"Fetch a sequence of 'child' objects belonging to a Collection, filtered using `options`."[{collection-namespace :namespace, :as collection} :- collection/CollectionWithLocationAndIDOrRoot{:keys [models created-by-id], :as options} :- CollectionChildrenOptions]- (let [valid-models (for [model-kw (cond-> [:collection :dataset :metric :card :dashboard :pulse :snippet :timeline :document :exploration :transform]+ (let [valid-models (for [model-kw (cond-> [:collection :dataset :metric :card :dashboard :pulse :snippet :timeline :document :transform];; Tables in collections are an EE feature (library)(premium-features/has-feature? :library) (conj :table));; only fetch models that are specified by the `model` param; or everything if it's emptydiff --git a/src/metabase/comments/api.clj b/src/metabase/comments/api.cljindex 14380916357..62855feb7c1 100644--- a/src/metabase/comments/api.clj+++ b/src/metabase/comments/api.clj@@ -23,8 +23,9 @@[toucan2.core :as t2]))(def ^:private type->model- {"document" :model/Document- "exploration" :model/Exploration})+ ;; While explorations are disabled, leaving the type out rejects exploration targets, since [[TargetType]] derives+ ;; from these keys.+ {"document" :model/Document})(def ^:private TargetType"Malli enum of valid comment target types, derived from [[type->model]]."diff --git a/src/metabase/metabot/agent/profiles.clj b/src/metabase/metabot/agent/profiles.cljindex a3137b480ce..5299425f03b 100644--- a/src/metabase/metabot/agent/profiles.clj+++ b/src/metabase/metabot/agent/profiles.clj@@ -228,23 +228,26 @@#'tools/create-alert-tool#'tools/slackbot-create-dashboard-subscription-tool]})-(register-profile!- {:name :explorations- :prompt-template "explorations.selmer"- :max-iterations 15- :temperature 0.3- :system-prompt-context #'tools.explorations/research-plan-system-context- :skills? false- :tools [#'tools/search-tool- #'tools/read-resource-tool- #'tools/list-research-metrics-tool- #'tools/get-research-candidates-tool- #'tools/add-research-groups-tool- #'tools/remove-from-research-plan-tool- #'tools/set-exploration-name-tool- #'tools/list-timelines-tool- #'tools/get-timeline-details-tool- #'tools/select-exploration-timelines-tool]})+(def explorations-profile+ "The `:explorations` (Research mode) profile. Explorations are intentionally disabled on the v64 release branch,+ so this profile is defined but not registered; do not register it here. Tests that exercise it register it with+ [[metabase.metabot.test-util/do-with-registered-profile!]]."+ {:name :explorations+ :prompt-template "explorations.selmer"+ :max-iterations 15+ :temperature 0.3+ :system-prompt-context #'tools.explorations/research-plan-system-context+ :skills? false+ :tools [#'tools/search-tool+ #'tools/read-resource-tool+ #'tools/list-research-metrics-tool+ #'tools/get-research-candidates-tool+ #'tools/add-research-groups-tool+ #'tools/remove-from-research-plan-tool+ #'tools/set-exploration-name-tool+ #'tools/list-timelines-tool+ #'tools/get-timeline-details-tool+ #'tools/select-exploration-timelines-tool]})(defn- filter-by-capabilities"Filter tool vars by user capabilities.@@ -284,6 +287,11 @@(and (= profile-id :nlq)(not (entity-retrieval/entity-retrieval-available?))))+(defn profile-registered?+ "Whether a profile with `profile-id` is registered."+ [profile-id]+ (contains? @*profiles profile-id))+(defn get-profile"Get profile configuration by profile-id keyword.The `:model` in the returned profile is resolved from the `llm-metabot-provider`diff --git a/src/metabase/metabot/api.clj b/src/metabase/metabot/api.cljindex 763d39d0335..4d4b5b13e2b 100644--- a/src/metabase/metabot/api.clj+++ b/src/metabase/metabot/api.clj@@ -14,6 +14,7 @@[metabase.lib.core :as lib][metabase.metabot.agent.core :as agent][metabase.metabot.agent.memory :as memory]+ [metabase.metabot.agent.profiles :as profiles][metabase.metabot.api.conversations][metabase.metabot.api.document][metabase.metabot.api.metabot]@@ -304,6 +305,9 @@_ (metabot.config/check-metabot-enabled! metabot-id)_ (metabot.usage/check-metabase-managed-free-limit!)profile-id (metabot.config/resolve-dynamic-profile-id profile_id metabot-id)+ ;; reject before `start-turn!` persists anything or the title job calls the LLM+ _ (when-not (profiles/profile-registered? (keyword profile-id))+ (throw (ex-info (tru "Unknown profile") {:status-code 400 :profile-id profile-id})));; Only allow debug mode in dev — never in productiondebug? (and config/is-dev? (boolean debug))hostname (analytics.core/extract-hostname (:origin request-info))diff --git a/src/metabase/search/config.clj b/src/metabase/search/config.cljindex 9da565c665c..f42559f49cb 100644--- a/src/metabase/search/config.clj+++ b/src/metabase/search/config.clj@@ -50,6 +50,9 @@#{"dashboard-card""dashboard-tab""dimension"+ ;; While explorations are disabled. Residue rows (from an instance that was upgraded, used explorations, then+ ;; downgraded) are still ingested, so excluding the model here filters them out at query time.+ "exploration""permissions-group""pulse""pulse-card"@@ -78,7 +81,8 @@(def models-search-order"The order of this list influences the order of the results: items earlier in thelist will be ranked higher."- ["dashboard" "metric" "segment" "measure" "indexed-entity" "card" "dataset" "collection" "table" "action" "document" "exploration" "transform" "database"])+ ["dashboard" "metric" "segment" "measure" "indexed-entity" "card" "dataset" "collection" "table" "action" "document"+ "transform" "database"])(assert (= all-models (set models-search-order)) "The models search order has to include all models")diff --git a/test/metabase/bookmarks/api_test.clj b/test/metabase/bookmarks/api_test.cljindex c80f20da11a..bbfa3c6b341 100644--- a/test/metabase/bookmarks/api_test.clj+++ b/test/metabase/bookmarks/api_test.clj@@ -120,16 +120,13 @@(mt/with-temp [:model/Collection {coll-id :id :as coll} {:name "Readable"}:model/Card {card-id :id} {:name "Secret Card" :collection_id coll-id}:model/Dashboard {dash-id :id} {:name "Secret Dashboard" :collection_id coll-id}- :model/Document {doc-id :id} {:name "Secret Document" :collection_id coll-id}- :model/Exploration {expl-id :id} {:name "Secret Exploration" :collection_id coll-id}]+ :model/Document {doc-id :id} {:name "Secret Document" :collection_id coll-id}](perms/grant-collection-read-permissions! (perms/all-users-group) coll);; rasta bookmarks each item (including the collection itself) while access is granted; POST read-check passes.- (doseq [[model id] [["card" card-id] ["dashboard" dash-id] ["document" doc-id]- ["exploration" expl-id] ["collection" coll-id]]]+ (doseq [[model id] [["card" card-id] ["dashboard" dash-id] ["document" doc-id] ["collection" coll-id]]](mt/user-http-request :rasta :post 200 (format "bookmark/%s/%d" model id)))(testing "happy path: all bookmarks are visible while access is granted"- (is (= #{["card" card-id] ["dashboard" dash-id] ["document" doc-id]- ["exploration" expl-id] ["collection" coll-id]}+ (is (= #{["card" card-id] ["dashboard" dash-id] ["document" doc-id] ["collection" coll-id]}(bookmarked-items :rasta))))(testing "after revoking read access (nothing archived), none of the bookmarks are returned"(perms/revoke-collection-permissions! (perms/all-users-group) coll)@@ -142,19 +139,17 @@:model/Collection {hidden-id :id} {:name "Hidden"}:model/Card {card-id :id} {:name "Secret Card" :collection_id readable-id}:model/Dashboard {dash-id :id} {:name "Secret Dashboard" :collection_id readable-id}- :model/Document {doc-id :id} {:name "Secret Document" :collection_id readable-id}- :model/Exploration {expl-id :id} {:name "Secret Exploration" :collection_id readable-id}]+ :model/Document {doc-id :id} {:name "Secret Document" :collection_id readable-id}](perms/grant-collection-read-permissions! (perms/all-users-group) readable)- (doseq [[model id] [["card" card-id] ["dashboard" dash-id] ["document" doc-id] ["exploration" expl-id]]]+ (doseq [[model id] [["card" card-id] ["dashboard" dash-id] ["document" doc-id]]](mt/user-http-request :rasta :post 200 (format "bookmark/%s/%d" model id)))- (is (= #{["card" card-id] ["dashboard" dash-id] ["document" doc-id] ["exploration" expl-id]}+ (is (= #{["card" card-id] ["dashboard" dash-id] ["document" doc-id]}(bookmarked-items :rasta)))(testing "moving each item into an unreadable collection (admin action; nothing archived) hides its bookmark";; stand in for the admin PUT /api/card|document ... {:collection_id hidden} in the attack(t2/update! :model/Card card-id {:collection_id hidden-id})(t2/update! :model/Dashboard dash-id {:collection_id hidden-id})(t2/update! :model/Document doc-id {:collection_id hidden-id})- (t2/update! :model/Exploration expl-id {:collection_id hidden-id})(is (= #{} (bookmarked-items :rasta))))))))(deftest bookmark-card-type-tracks-current-card-type-test@@ -282,42 +277,3 @@(testing "archived documents don't appear in bookmark list"(is (empty? (filter #(= (:type %) "document")(mt/user-http-request :rasta :get 200 "bookmark"))))))))--(deftest exploration-bookmarks-test- (testing "Exploration bookmarks"- (mt/with-temp [:model/Collection {coll-id :id} {:name "Test Collection"}- :model/Exploration exploration {:name "Test Exploration" :collection_id coll-id}]- (testing "can bookmark an exploration"- (is (= (u/the-id exploration)- (->> (mt/user-http-request :rasta :post 200 (str "bookmark/exploration/" (u/the-id exploration)))- :exploration_id))))- (testing "exploration appears in bookmark list"- (let [result (mt/user-http-request :rasta :get 200 "bookmark")- exploration-bookmark (first (filter #(= (:type %) "exploration") result))]- (is (some? exploration-bookmark))- (is (= "Test Exploration" (:name exploration-bookmark)))- (is (= (u/the-id exploration) (:item_id exploration-bookmark)))))- (testing "can delete exploration bookmark"- (mt/user-http-request :rasta :delete 204 (str "bookmark/exploration/" (u/the-id exploration)))- (is (empty? (filter #(= (:type %) "exploration")- (mt/user-http-request :rasta :get 200 "bookmark")))))- (testing "exploration bookmarks are included in ordering"- (mt/with-temp [:model/Card card {:name "Test Card"}]- (mt/with-model-cleanup [:model/BookmarkOrdering]- (bookmark-models (mt/user->id :rasta) exploration card)- (mt/user-http-request :rasta :put 204 "bookmark/ordering"- {:orderings [{:type "exploration" :item_id (u/the-id exploration)}- {:type "card" :item_id (u/the-id card)}]})- (is (= ["exploration" "card"]- (map :type (mt/user-http-request :rasta :get 200 "bookmark"))))))))))--(deftest exploration-bookmarks-archived-test- (testing "Exploration bookmarks on archived explorations"- (mt/with-temp [:model/Collection {coll-id :id} {:name "Test Collection"}- :model/Exploration archived-exploration {:name "Archived Exploration"- :collection_id coll-id- :archived true}]- (bookmark-models (mt/user->id :rasta) archived-exploration)- (testing "archived explorations don't appear in bookmark list"- (is (empty? (filter #(= (:type %) "exploration")- (mt/user-http-request :rasta :get 200 "bookmark"))))))))diff --git a/test/metabase/collections_rest/api_test.clj b/test/metabase/collections_rest/api_test.cljindex 3d524948dc3..39853ed71a6 100644--- a/test/metabase/collections_rest/api_test.clj+++ b/test/metabase/collections_rest/api_test.clj@@ -1063,20 +1063,6 @@(is (= #{["card" "Question"]}(set (map (juxt :model :name) (:data models-response)))))))))))-(deftest collection-items-available-models-exploration-test- (testing "GET /api/collection/:id/items"- (mt/with-temp [:model/User owner {}- :model/Collection collection {}- :model/Card _ {:name "Question" :collection_id (u/the-id collection)}- :model/Exploration _ {:name "Exploration"- :creator_id (u/the-id owner)- :collection_id (u/the-id collection)}]- (testing "reports explorations so they can be filtered on"- (let [response (mt/user-http-request :crowberto :get 200- (str "collection/" (u/the-id collection) "/items")- :include-available-models true)]- (is (= ["card" "exploration"] (:available_models response))))))))-(deftest collection-items-metadata-test(testing "GET /api/collection/:id/items/metadata"(mt/with-temp [:model/Collection collection {}@@ -4001,162 +3987,3 @@(is (= "You don't have permissions to do that."(mt/user-http-request :rasta :put 403 (str "collection/" (u/the-id archived-collection)){:archived false :parent_id (u/the-id dest-collection)}))))))))--(defn- exploration-items-in [coll-id & {:keys [user] :or {user :crowberto}}]- (->> (:data (mt/user-http-request user :get 200 (str "collection/" coll-id "/items")))- (filter #(= "exploration" (:model %)))))--(deftest explorations-appear-in-collection-items-test- (testing "GET /api/collection/:id/items"- (testing "explorations in a shared collection appear in that collection's items"- (mt/with-temp [:model/User owner {}- :model/Collection coll {}- :model/Exploration e {:name "Shared Expl"- :creator_id (:id owner)- :collection_id (:id coll)}]- (let [items (exploration-items-in (:id coll))]- (is (= [{:id (:id e) :name "Shared Expl" :model "exploration"}]- (map #(select-keys % [:id :name :model]) items))))))- (testing "?model=exploration filters to only explorations"- (mt/with-temp [:model/User owner {}- :model/Collection coll {}- :model/Card _card {:collection_id (:id coll)}- :model/Exploration e {:name "Just me"- :creator_id (:id owner)- :collection_id (:id coll)}]- (let [items (:data (mt/user-http-request :crowberto :get 200- (str "collection/" (:id coll) "/items?models=exploration")))]- (is (= [{:id (:id e) :model "exploration"}]- (map #(select-keys % [:id :model]) items))))))))--(deftest exploration-respects-collection-perms-test- (testing "Users without read on the exploration's collection don't see it in /items"- (mt/with-temp [:model/User owner {}- :model/Collection coll {:name "Locked"}- :model/Exploration e {:name "Hidden"- :creator_id (:id owner)- :collection_id (:id coll)}]- (perms/revoke-collection-permissions! (perms/all-users-group) coll)- (testing "rasta cannot see the exploration"- (let [resp (mt/user-http-request :rasta :get (str "collection/" (:id coll) "/items"))]- ;; Either the collection itself is forbidden (403) or the items list omits the exploration.- (cond- (= 403 (:status-code resp)) (is true)- :else (is (not (some #(= (:id e) (:id %)) (filter #(= "exploration" (:model %)) (:data resp))))))))- (testing "after granting read, the exploration appears"- (perms/grant-collection-read-permissions! (perms/all-users-group) coll)- (let [items (exploration-items-in (:id coll) :user :rasta)]- (is (some #(= (:id e) (:id %)) items)))))))--(deftest exploration-trash-and-archive-directly-test- (testing "Directly-archived exploration appears in /collection/trash/items"- (mt/with-temp [:model/User owner {}- :model/Collection coll {}- :model/Exploration e {:name "Tossed"- :creator_id (:id owner)- :collection_id (:id coll)- :archived true- :archived_directly true}]- (let [items (->> (:data (mt/user-http-request :crowberto :get 200- (format "collection/%d/items" (collection/trash-collection-id))))- (filter #(= "exploration" (:model %))))]- (is (some #(= (:id e) (:id %)) items)))))- (testing "Cascade-archived (archived=true, archived_directly=false) does not appear in trash"- (mt/with-temp [:model/User owner {}- :model/Collection coll {}- :model/Exploration e {:name "Cascade"- :creator_id (:id owner)- :collection_id (:id coll)- :archived true- :archived_directly false}]- (let [items (->> (:data (mt/user-http-request :crowberto :get 200- (format "collection/%d/items" (collection/trash-collection-id))))- (filter #(= "exploration" (:model %))))]- (is (not (some #(= (:id e) (:id %)) items)))))))--(deftest exploration-pinning-test- (testing "explorations with collection_position appear under ?pinned-state=is_pinned"- (mt/with-temp [:model/User owner {}- :model/Collection coll {}- :model/Exploration pinned {:name "Pinned"- :creator_id (:id owner)- :collection_id (:id coll)- :collection_position 1}- :model/Exploration unpinned {:name "Unpinned"- :creator_id (:id owner)- :collection_id (:id coll)}]- (let [pinned-items (->> (:data (mt/user-http-request :crowberto :get 200- (str "collection/" (:id coll) "/items?pinned-state=is_pinned")))- (filter #(= "exploration" (:model %)))- (map :id)- set)]- (is (contains? pinned-items (:id pinned)))- (is (not (contains? pinned-items (:id unpinned))))))))--(defn- find-exploration [items expl-id]- (some #(when (and (= "exploration" (:model %)) (= expl-id (:id %))) %) items))--(deftest exploration-last-edit-info-test- (testing "GET /api/collection/:id/items reports last-edit-info for explorations"- (testing "freshly created exploration with a creation revision -> last-edit-info populated"- (mt/with-temp [:model/Collection coll {}- :model/Exploration e {:name "Created"- :creator_id (mt/user->id :crowberto)- :collection_id (:id coll)}]- (revision/push-revision! {:entity :model/Exploration- :id (:id e)- :object (t2/select-one :model/Exploration :id (:id e))- :user-id (mt/user->id :crowberto)- :is-creation? true})- (let [item (find-exploration (:data (mt/user-http-request :crowberto :get 200- (str "collection/" (:id coll) "/items")))- (:id e))]- (is (some? item))- (is (= (mt/user->id :crowberto)- (-> item :last-edit-info :id))))))- (testing "no Exploration or Document revisions -> last-edit-info absent"- (mt/with-temp [:model/Collection coll {}- :model/Exploration e {:name "Bare"- :creator_id (mt/user->id :crowberto)- :collection_id (:id coll)}]- (let [item (find-exploration (:data (mt/user-http-request :crowberto :get 200- (str "collection/" (:id coll) "/items")))- (:id e))]- (is (some? item))- (is (nil? (:last-edit-info item))))))- (testing "Document attached to an exploration bumps the exploration's last-edit-info"- (mt/with-temp [:model/Collection coll {}- :model/Exploration e {:name "DocBumped"- :creator_id (mt/user->id :crowberto)- :collection_id (:id coll)}- :model/Document doc {:name "notes"- :collection_id (:id coll)- :creator_id (mt/user->id :crowberto)- :exploration_id (:id e)- :document {:type "doc" :content []}}]- ;; Older Exploration revision by :crowberto, newer Document revision by :rasta.- ;; Insert directly so we control timestamps — within a `with-temp` transaction- ;; the DB-side NOW() is frozen, so the standard push-revision! path would emit- ;; identical timestamps and tiebreak non-deterministically.- (let [t (java.time.OffsetDateTime/now)]- (t2/insert! :model/Revision- {:model "Exploration"- :model_id (:id e)- :user_id (mt/user->id :crowberto)- :object (revision/serialize-instance :model/Exploration (:id e)- (t2/select-one :model/Exploration :id (:id e)))- :timestamp (.minusSeconds t 60)- :is_creation true})- (t2/insert! :model/Revision- {:model "Document"- :model_id (:id doc)- :user_id (mt/user->id :rasta)- :object (revision/serialize-instance :model/Document (:id doc)- (t2/select-one :model/Document :id (:id doc)))- :timestamp t}))- (let [item (find-exploration (:data (mt/user-http-request :crowberto :get 200- (str "collection/" (:id coll) "/items")))- (:id e))]- (is (some? item))- (is (= (mt/user->id :rasta)- (-> item :last-edit-info :id))))))))diff --git a/test/metabase/explorations/api_test.clj b/test/metabase/explorations/api_test.cljindex af90898a116..379d4bb53c7 100644--- a/test/metabase/explorations/api_test.clj+++ b/test/metabase/explorations/api_test.clj@@ -14,6 +14,7 @@[metabase.explorations.query-plan.context :as qp.context][metabase.explorations.query-plan.variants :as qp.variants][metabase.explorations.queues :as explorations.queues]+ [metabase.explorations.test-util :as explorations.tu][metabase.lib-be.metadata.jvm :as lib-be][metabase.lib.core :as lib][metabase.lib.metadata :as lib.metadata]@@ -29,6 +30,9 @@(use-fixtures :once (fixtures/initialize :db :web-server :test-users))+;; The application does not mount `/api/exploration` while explorations are disabled; serve it for these tests.+(use-fixtures :each explorations.tu/exploration-routes-fixture)+(deftest gate-threads-derived-data-forbidden-status-test(testing "gate-threads-derived-data stamps forbidden when derived data is not visible"(let [gate #'metabase.explorations.api/gate-threads-derived-datadiff --git a/test/metabase/explorations/derived_perms_test.clj b/test/metabase/explorations/derived_perms_test.cljindex f36aa1b67b5..4464f7ad436 100644--- a/test/metabase/explorations/derived_perms_test.clj+++ b/test/metabase/explorations/derived_perms_test.clj@@ -5,6 +5,8 @@the batching that must not merge snapshots requiring different permissions."(:require[clojure.test :refer :all]+ [metabase.comments.db :as comments.db]+ [metabase.comments.models.comment :as comment][metabase.documents.core :as documents][metabase.explorations.derived-perms :as derived-perms][metabase.lib.core :as lib]@@ -378,12 +380,14 @@:join [[:exploration_block :b] [:= :b.id :p.exploration_block_id]]:where [:= :b.exploration_thread_id thread-id]}))-(defn- comment-contexts [exploration-id user-kw]- (->> (mt/user-http-request user-kw :get 200 "comment/"- :target_type "exploration"- :target_id exploration-id)- :comments- (mapv :context)))+(defn- comment-contexts+ "The contexts of the comments on `exploration-id` as `user-kw` sees them. The comments API rejects exploration+ targets while explorations are disabled, so this runs the registered gate over the rows the way its GET does."+ [exploration-id user-kw]+ (request/with-current-user (mt/user->id user-kw)+ (->> (comments.db/comments-for-target "exploration" exploration-id)+ (comment/apply-context-gate "exploration" exploration-id)+ (mapv :context))))(deftest exploration-comment-context-is-gated-test(testing "a comment anchored to a chart point of an exploration the viewer is gated out of"@@ -395,24 +399,24 @@;; by the data-access gate rather than by collection permissions.(t2/update! :model/Exploration expl-id {:collection_id coll-id})(perms/grant-collection-read-permissions! (perms-group/all-users) coll-id)- (mt/user-http-request :lucky :post 200 "comment/"- {:target_type "exploration"- :target_id expl-id- :child_target_id (str page-id)- :content {:type "doc" :content []}- :context {:highlighted {:columnName "CATEGORY"- :dimensions [{:columnName "CATEGORY"- :value "ACME Corp"}]}- :highlight_label "ACME Corp"}})- (testing "keeps its context for a superuser, who is exempt from the gate"- (is (=? [{:highlighted {:columnName "CATEGORY"}- :highlight_label "ACME Corp"}]- (comment-contexts expl-id :crowberto))))- (testing "is stripped of its context for a viewer whose data-access lens is incompatible —- the comment itself remains readable, only the warehouse values it carries are withheld"- (let [contexts (comment-contexts expl-id :rasta)]- (is (= 1 (count contexts)) "the comment is still listed")- (is (= [nil] contexts) "but carries no context")))))))+ (mt/with-temp [:model/Comment _ {:target_type "exploration"+ :target_id expl-id+ :child_target_id (str page-id)+ :creator_id (mt/user->id :lucky)+ :content {:type "doc" :content []}+ :context {:highlighted {:columnName "CATEGORY"+ :dimensions [{:columnName "CATEGORY"+ :value "ACME Corp"}]}+ :highlight_label "ACME Corp"}}]+ (testing "keeps its context for a superuser, who is exempt from the gate"+ (is (=? [{:highlighted {:columnName "CATEGORY"}+ :highlight_label "ACME Corp"}]+ (comment-contexts expl-id :crowberto))))+ (testing "is stripped of its context for a viewer whose data-access lens is incompatible —+ the comment itself remains readable, only the warehouse values it carries are withheld"+ (let [contexts (comment-contexts expl-id :rasta)]+ (is (= 1 (count contexts)) "the comment is still listed")+ (is (= [nil] contexts) "but carries no context"))))))))(deftest content-gate-verdict-is-memoized-within-a-scope-test(testing "every Card in a Summary document shares one document, and therefore one verdict. Withoutdiff --git a/test/metabase/explorations/disabled_test.clj b/test/metabase/explorations/disabled_test.cljnew file mode 100644index 00000000000..a4500d905ac--- /dev/null+++ b/test/metabase/explorations/disabled_test.clj@@ -0,0 +1,140 @@+(ns metabase.explorations.disabled-test+ "Every test that pins the disabled state of explorations, so the definition of \"disabled\" lives in one place: the+ API routes are unmounted, the Metabot profile is unregistered, and the listing surfaces that could hand a client+ residue exploration rows are closed. Rows can still exist: an instance upgraded to a version with explorations, used+ to create some, then downgraded keeps its exploration tables, since their migrations belong to this version."+ (:require+ [clojure.test :refer :all]+ [metabase.llm.settings :as llm.settings]+ [metabase.llm.test-util :as llm.tu]+ [metabase.metabot.scope :as scope]+ [metabase.metabot.settings :as metabot.settings]+ [metabase.search.appdb.index :as search.index]+ [metabase.search.config :as search.config]+ [metabase.search.core :as search]+ [metabase.search.test-util :as search.tu]+ [metabase.test :as mt]+ [metabase.test.fixtures :as fixtures]+ [toucan2.core :as t2]))++(set! *warn-on-reflection* true)++(use-fixtures :once (fixtures/initialize :db :web-server :test-users))++(deftest exploration-routes-not-mounted-test+ (testing "The application does not serve /api/exploration"+ (mt/user-http-request :crowberto :get 404 "exploration/dimensions")))++(deftest metabot-explorations-profile-unregistered-test+ (testing "Asking the agent for the explorations profile is rejected before a turn starts"+ (mt/with-temporary-setting-values [llm.settings/llm-providers llm.tu/default-connections+ metabot.settings/llm-metabot-provider "openrouter/anthropic/claude-haiku-4-5"]+ (binding [scope/*current-user-metabot-permissions* scope/all-yes-permissions]+ (mt/with-model-cleanup [:model/MetabotMessage [:model/MetabotConversation :created_at]]+ (let [conversation-id (str (random-uuid))]+ (is (=? {:message #"Unknown profile"}+ (mt/user-http-request :rasta :post 400 "metabot/agent-streaming"+ {:message "hello"+ :context {}+ :conversation_id conversation-id+ :state {}+ :profile_id "explorations"})))+ (is (empty? (t2/select :model/MetabotMessage :conversation_id conversation-id))+ "no turn was persisted")))))))++(deftest collection-items-omit-explorations-test+ (testing "GET /api/collection/:id/items"+ (mt/with-temp [:model/Collection coll {}+ :model/Card card {:collection_id (:id coll)}+ :model/Exploration expl {:name "Residue exploration"+ :creator_id (mt/user->id :crowberto)+ :collection_id (:id coll)}]+ (let [url (str "collection/" (:id coll) "/items")]+ (testing "omits a residue exploration"+ (is (= [["card" (:id card)]]+ (map (juxt :model :id) (:data (mt/user-http-request :crowberto :get 200 url))))))+ (testing "does not report exploration as an available model"+ (is (= ["card"]+ (:available_models (mt/user-http-request :crowberto :get 200 url :include-available-models true)))))+ (testing "rejects a models parameter naming exploration"+ (is (=? {:errors {:models some?}}+ (mt/user-http-request :crowberto :get 400 url :models "exploration")))+ (is (=? {:errors {:models some?}}+ (mt/user-http-request :crowberto :get 400 url :models "card" :models "exploration"))))+ (testing "the exploration id is not reachable through the residue row"+ (is (not-any? #(= (:id expl) (:id %))+ (:data (mt/user-http-request :crowberto :get 200 url)))))))))++(deftest bookmarks-omit-explorations-test+ (testing "GET /api/bookmark"+ (mt/with-temp [:model/Collection coll {}+ :model/Card card {:collection_id (:id coll)}+ :model/Exploration expl {:name "Residue exploration"+ :creator_id (mt/user->id :rasta)+ :collection_id (:id coll)}+ :model/CardBookmark _ {:user_id (mt/user->id :rasta) :card_id (:id card)}+ :model/ExplorationBookmark _ {:user_id (mt/user->id :rasta) :exploration_id (:id expl)}]+ (let [bookmarks (set (map (juxt :type :item_id) (mt/user-http-request :rasta :get 200 "bookmark")))]+ (testing "omits a residue exploration bookmark"+ (is (contains? bookmarks ["card" (:id card)]))+ (is (not-any? #(= "exploration" (first %)) bookmarks))))+ (testing "rejects creating or deleting an exploration bookmark"+ ;; the model enum is part of the route match, so an unknown model is a 404 like any other unknown model+ (is (= "API endpoint does not exist."+ (mt/user-http-request :rasta :post 404 (str "bookmark/exploration/" (:id expl)))))+ (is (= "API endpoint does not exist."+ (mt/user-http-request :rasta :delete 404 (str "bookmark/exploration/" (:id expl)))))+ (is (t2/exists? :model/ExplorationBookmark :exploration_id (:id expl) :user_id (mt/user->id :rasta))+ "the rejected delete left the residue row alone"))+ (testing "rejects an exploration in the bookmark ordering"+ (is (=? {:errors {:orderings some?}}+ (mt/user-http-request :rasta :put 400 "bookmark/ordering"+ {:orderings [{:type "exploration" :item_id (:id expl)}]})))))))++(deftest search-omits-explorations-test+ (testing "GET /api/search"+ ;; the index table is only available on app DBs that support it; the in-place engine runs everywhere+ (search.tu/with-temp-index-table-if-supported+ (let [term (mt/random-name)+ search (fn [& args]+ (apply mt/user-http-request :crowberto :get 200 "search" :q term args))+ engines (cond-> ["in-place"]+ (search/supports-index?) (conj "appdb"))]+ (mt/with-temp [:model/Exploration expl {:name (str "Residue " term)+ :creator_id (mt/user->id :crowberto)}]+ (when (search/supports-index?)+ (testing "the residue row is still ingested into the index"+ (is (t2/exists? (search.index/active-table) :model "exploration" :model_id (str (:id expl))))))+ (doseq [engine engines]+ (testing (str "the " engine " engine")+ (testing "omits the row"+ (is (empty? (:data (search :search_engine engine)))))+ (testing "does not list exploration as an available model"+ (is (not (contains? (set (:available_models (search :search_engine engine+ :calculate_available_models true)))+ "exploration"))))))+ (testing "a models filter naming exploration is rejected"+ (is (=? {:errors {:models some?}}+ (mt/user-http-request :crowberto :get 400 "search" :q term :models "exploration")))))))))++(deftest search-config-excludes-explorations-test+ (testing "exploration is not a searchable model"+ (is (not (contains? search.config/all-models "exploration")))+ (is (contains? search.config/excluded-models "exploration")))+ (testing "the models search order still covers exactly the searchable models"+ (is (= search.config/all-models (set search.config/models-search-order)))))++(deftest comments-reject-exploration-targets-test+ (mt/with-temp [:model/Exploration expl {:name "Residue exploration"+ :creator_id (mt/user->id :crowberto)}]+ (testing "GET /api/comment/ rejects an exploration target"+ (is (=? {:errors {:target_type some?}}+ (mt/user-http-request :crowberto :get 400 "comment/"+ :target_type "exploration" :target_id (:id expl)))))+ (testing "POST /api/comment/ rejects an exploration target"+ (is (=? {:errors {:target_type some?}}+ (mt/user-http-request :crowberto :post 400 "comment/"+ {:target_type "exploration"+ :target_id (:id expl)+ :content {:type "doc" :content [{:type "paragraph"+ :content [{:type "text" :text "hi"}]}]}}))))))diff --git a/test/metabase/explorations/models/exploration_test.clj b/test/metabase/explorations/models/exploration_test.cljindex 287b54b77b7..09f59a15726 100644--- a/test/metabase/explorations/models/exploration_test.clj+++ b/test/metabase/explorations/models/exploration_test.clj@@ -7,11 +7,7 @@[metabase.models.interface :as mi][metabase.permissions.core :as perms][metabase.permissions.models.permissions-group :as perms-group]- [metabase.search.config :as search.config]- [metabase.search.core :as search]- [metabase.search.ingestion :as search.ingestion][metabase.search.spec :as search.spec]- [metabase.search.test-util :as search.tu][metabase.test :as mt][metabase.test.fixtures :as fixtures][toucan2.core :as t2]))@@ -164,32 +160,11 @@(is (= "d1" (:dimension_id reread)))(is (= 1 (-> reread :dataset_query :database)))))))-(deftest exploration-is-searchable-test- ;; The wiring assertions run unconditionally so this test can never silently pass- ;; with zero assertions; only the index round-trip below is gated on engine support.+(deftest exploration-search-spec-is-registered-test+ ;; Explorations are still ingested into the search index; that the closed search surface omits them is pinned in+ ;; `metabase.explorations.disabled-test`.(testing "the exploration search-model is wired up"- (is (= :model/Exploration (:model (search.spec/spec "exploration"))))- (is (contains? search.config/all-models "exploration")))- (testing "an exploration is indexed and returned from the default search"- (when (search/supports-index?)- (search.tu/with-temp-index-table- (mt/with-temp [:model/Collection coll {}- :model/Exploration e {:name "searchable-research" :collection_id (:id coll)}]- (letfn [(research-hits [user]- (->> (search.tu/search-results "searchable-research"- {:search-engine "appdb"- :current-user-id (mt/user->id user)})- (filter (comp #{"searchable-research"} :name))- (mapv (juxt :model :id))))]- (search.ingestion/update!- (#'search.ingestion/query->documents- (#'search.ingestion/spec-index-reducible "exploration" [:= :this.id (:id e)]))- [])- (testing "a user who can read the collection finds it"- (is (= [["exploration" (:id e)]] (research-hits :crowberto))))- (testing "a user without collection perms does not"- (mt/with-non-admin-groups-no-collection-perms coll- (is (= [] (research-hits :rasta)))))))))))+ (is (= :model/Exploration (:model (search.spec/spec "exploration"))))))(deftest hydrate-threads-on-exploration-test(mt/with-temp [:model/User u {}diff --git a/test/metabase/explorations/test_util.clj b/test/metabase/explorations/test_util.cljnew file mode 100644index 00000000000..d88cc83f2ed--- /dev/null+++ b/test/metabase/explorations/test_util.clj@@ -0,0 +1,28 @@+(ns metabase.explorations.test-util+ "Test helpers for the explorations module."+ (:require+ [metabase.api.routes.common :as routes.common]+ [metabase.api.util.handlers :as handlers]+ [metabase.explorations.api :as explorations.api]+ [metabase.server.test-handler :as server.test-handler]))++(set! *warn-on-reflection* true)++(def ^:private api-routes-with-explorations+ "The application's API route tree with `/api/exploration` mounted in front of it, wrapped the same way+ [[metabase.api-routes.routes/route-map]] mounted it before explorations were disabled."+ (delay+ (handlers/routes+ (handlers/route-map-handler {"/exploration" (routes.common/+auth explorations.api/routes)})+ (server.test-handler/app-api-routes))))++(defn do-with-exploration-routes+ "Run `thunk` with `/api/exploration` served by the test HTTP client. The application does not mount the explorations+ API while the feature is disabled, so tests that exercise its endpoints over HTTP need this."+ [thunk]+ (server.test-handler/do-with-api-routes @api-routes-with-explorations thunk))++(defn exploration-routes-fixture+ "`clojure.test` fixture form of [[do-with-exploration-routes]]."+ [f]+ (do-with-exploration-routes f))diff --git a/test/metabase/metabot/agent/profiles_test.clj b/test/metabase/metabot/agent/profiles_test.cljindex dae850ce0cd..11759ada3a9 100644--- a/test/metabase/metabot/agent/profiles_test.clj+++ b/test/metabase/metabot/agent/profiles_test.clj@@ -5,6 +5,7 @@[metabase.entity-retrieval.core :as entity-retrieval][metabase.metabot.agent.profiles :as profiles][metabase.metabot.scope :as scope]+ [metabase.metabot.test-util :as mut][metabase.metabot.tools :as tools][metabase.metabot.tools.transforms :as tools.transforms][metabase.premium-features.core :as premium-features]@@ -260,11 +261,18 @@(assoc base :skills? false :always-on-skills [:read-resource])))))))(deftest explorations-profile-disables-skills-test- (binding [scope/*current-user-scope* api-scope/unrestricted]- (testing "explorations opts out of skills so read_resource does not inject load_skill"- (let [profile (profiles/get-profile :explorations)- tools (profiles/profile->tools profile [])]- (is (false? (:skills? profile)))- (is (contains? tools "read_resource")- "precondition: read_resource is active (would otherwise match a skill)")- (is (not (contains? tools "load_skill")))))))+ (mut/do-with-registered-profile!+ profiles/explorations-profile+ (fn []+ (binding [scope/*current-user-scope* api-scope/unrestricted]+ (testing "explorations opts out of skills so read_resource does not inject load_skill"+ (let [profile (profiles/get-profile :explorations)+ tools (profiles/profile->tools profile [])]+ (is (false? (:skills? profile)))+ (is (contains? tools "read_resource")+ "precondition: read_resource is active (would otherwise match a skill)")+ (is (not (contains? tools "load_skill")))))))))++(deftest explorations-profile-not-registered-test+ (testing "The :explorations profile is not registered while explorations are disabled"+ (is (nil? (profiles/get-profile :explorations)))))diff --git a/test/metabase/metabot/test_util.clj b/test/metabase/metabot/test_util.cljindex 48b7fdbd5de..38f1b022f79 100644--- a/test/metabase/metabot/test_util.clj+++ b/test/metabase/metabot/test_util.clj@@ -2,6 +2,8 @@(:require[clojure.java.io :as io][clojure.string :as str]+ [mb.hawk.parallel]+ [metabase.metabot.agent.profiles :as profiles][metabase.metabot.self.core :as self.core][metabase.metabot.tools :as metabot.tools][metabase.util.json :as json]@@ -170,3 +172,19 @@"Tool map for tests — keyed by tool name string."(let [tool-defs (map #(%) [get-time-tool convert-currency-tool mock-llm-tool no-arg-tool])](into {} (map (juxt :tool-name identity)) tool-defs)))++;;; ──────────────────────────────────────────────────────────────────+;;; Profiles+;;; ──────────────────────────────────────────────────────────────────++(defn do-with-registered-profile!+ "Run `thunk` with `profile` registered in the agent profile registry, restoring the registry afterwards. For+ profiles the application defines but does not register, such as [[profiles/explorations-profile]]."+ [profile thunk]+ (mb.hawk.parallel/assert-test-is-not-parallel "do-with-registered-profile!")+ (let [registry @#'profiles/*profiles]+ (try+ (#'profiles/register-profile! profile)+ (thunk)+ (finally+ (swap! registry dissoc (:name profile))))))diff --git a/test/metabase/metabot/tools/explorations_test.clj b/test/metabase/metabot/tools/explorations_test.cljindex 745b1b957f6..d20a6aabc09 100644--- a/test/metabase/metabot/tools/explorations_test.clj+++ b/test/metabase/metabot/tools/explorations_test.clj@@ -8,6 +8,7 @@[metabase.metabot.agent.streaming :as streaming][metabase.metabot.scope :as scope][metabase.metabot.self.core :as metabot.self]+ [metabase.metabot.test-util :as mut][metabase.metabot.tools.explorations :as tools.explorations][metabase.test :as mt][metabase.util.json :as json]))@@ -227,18 +228,21 @@"Draft")))))(deftest explorations-profile-renders-research-plan-in-system-prompt-test- (testing "the registered :explorations profile wires research-plan-system-context, so a draft plan+ (mut/do-with-registered-profile!+ profiles/explorations-profile+ (fn []+ (testing "the registered :explorations profile wires research-plan-system-context, so a draft planreaches the LLM's system prompt (the feature the generic agent no longer knows about)"- (let [profile (profiles/get-profile :explorations)- plan {:name "Why was revenue down?"- :groups [{:block_id "metric:42"- :metric {:id 42 :name "Revenue"}- :dimensions [{:id "d1" :name "Region"}]}]}- content (:content (messages/build-system-message {:research_plan plan} profile {}))]- (is (str/includes? content "Current research plan"))- (is (str/includes? content "Why was revenue down?"))- (is (str/includes? content "[metric:42] Revenue, broken out by: Region (d1)")))- (testing "and omits the plan section entirely when there is no plan"- (let [content (:content (messages/build-system-message- {} (profiles/get-profile :explorations) {}))]- (is (not (str/includes? content "Current research plan")))))))+ (let [profile (profiles/get-profile :explorations)+ plan {:name "Why was revenue down?"+ :groups [{:block_id "metric:42"+ :metric {:id 42 :name "Revenue"}+ :dimensions [{:id "d1" :name "Region"}]}]}+ content (:content (messages/build-system-message {:research_plan plan} profile {}))]+ (is (str/includes? content "Current research plan"))+ (is (str/includes? content "Why was revenue down?"))+ (is (str/includes? content "[metric:42] Revenue, broken out by: Region (d1)")))+ (testing "and omits the plan section entirely when there is no plan"+ (let [content (:content (messages/build-system-message+ {} (profiles/get-profile :explorations) {}))]+ (is (not (str/includes? content "Current research plan")))))))))diff --git a/test/metabase/search/api_test.clj b/test/metabase/search/api_test.cljindex 5831c6f1248..8f7108d4674 100644--- a/test/metabase/search/api_test.clj+++ b/test/metabase/search/api_test.clj@@ -2295,12 +2295,3 @@:q table-name :models "table" :search_engine "appdb"))](is (seq rows))(is (every? (comp nil? :is_published) rows)))))))))))--(deftest exploration-description-searchable-in-place-test- (testing "explorations match on :description in the in-place engine (parity with the appdb spec)"- (let [description (mt/random-name)]- (mt/with-temp [:model/Exploration _ {:name "desc-probe-exploration"- :description description- :creator_id (mt/user->id :crowberto)}]- (is (=? [{:model "exploration" :name "desc-probe-exploration"}]- (search-request-data :crowberto :q description :search_engine "in-place")))))))diff --git a/test/metabase/search/filter_test.clj b/test/metabase/search/filter_test.cljindex 5e803dd5bf6..e10c67e07b7 100644--- a/test/metabase/search/filter_test.clj+++ b/test/metabase/search/filter_test.clj@@ -67,7 +67,7 @@(is (= (disj search.config/all-models "transform")(search.filter/search-context->applicable-models (with-all-models-and-regular-user {:archived? false})))))(testing "We only search for certain models in the trash"- (is (= #{"dashboard" "dataset" "document" "exploration" "segment" "measure" "collection" "action" "metric" "card"}+ (is (= #{"dashboard" "dataset" "document" "segment" "measure" "collection" "action" "metric" "card"}(search.filter/search-context->applicable-models (with-all-models-and-regular-user {:archived? true})))))(testing "Indexed entities and transforms (which are admin-only) are not visible for sandboxed users"(is (= (disj search.config/all-models "indexed-entity" "transform")@@ -143,7 +143,6 @@"measure""transform""document"- "exploration""database""action""indexed-entity"diff --git a/test/metabase/search/in_place/filter_test.clj b/test/metabase/search/in_place/filter_test.cljindex 3ab910fea92..a94361f5543 100644--- a/test/metabase/search/in_place/filter_test.clj+++ b/test/metabase/search/in_place/filter_test.clj@@ -43,7 +43,7 @@(deftest ^:parallel ->applicable-models-test-2(testing "optional filters will return intersection of support models and provided models\n"(testing "created by"- (is (= #{"dashboard" "dataset" "document" "exploration" "action" "card" "metric" "measure"}+ (is (= #{"dashboard" "dataset" "document" "action" "card" "metric" "measure"}(search.filter/search-context->applicable-models(merge default-search-ctx{:created-by #{1}}))))@@ -53,7 +53,7 @@{:models #{"dashboard" "dataset" "table"}:created-by #{1}})))))(testing "created at"- (is (= #{"dashboard" "table" "dataset" "document" "exploration" "collection" "database" "action" "card" "metric" "transform" "measure"}+ (is (= #{"dashboard" "table" "dataset" "document" "collection" "database" "action" "card" "metric" "transform" "measure"}(search.filter/search-context->applicable-models(merge default-search-ctx{:created-at "past3days"}))))diff --git a/test/metabase/server/test_handler.clj b/test/metabase/server/test_handler.cljindex d0c20af5f4c..5c8584fb80a 100644--- a/test/metabase/server/test_handler.clj+++ b/test/metabase/server/test_handler.clj@@ -5,28 +5,50 @@[metabase.util.log :as log][metabase.util.malli :as mu]))-(mu/defn- make-test-handler :- ::api.macros/handler+(defn app-api-routes+ "The application's own API route tree, the handler mounted under `/api`."[];; late-bound: a static require here would drag the whole API route tree into the server module- (let [api-routes #_{:clj-kondo/ignore [:metabase/modules]} (requiring-resolve 'metabase.api-routes.core/routes)- server-routes (server/make-routes api-routes)- handler (server/make-handler server-routes)]- (fn [request respond raise]- (letfn [(raise' [e]- (log/errorf "ERROR HANDLING REQUEST! <async raise> %s" request)- (log/error e)- (raise e))]- (try- (handler request respond raise')- (catch Throwable e- (log/errorf "ERROR HANDLING REQUEST! <async thrown> %s" request)- (log/error e)- (throw e)))))))+ #_{:clj-kondo/ignore [:metabase/modules]} (requiring-resolve 'metabase.api-routes.core/routes))++(mu/defn make-test-handler :- ::api.macros/handler+ "Build the full Ring handler (server routes plus middleware) that serves `api-routes` under `/api`. Defaults to+ [[app-api-routes]]."+ ([]+ (make-test-handler (app-api-routes)))++ ([api-routes :- ::api.macros/handler]+ (let [server-routes (server/make-routes api-routes)+ handler (server/make-handler server-routes)]+ (fn [request respond raise]+ (letfn [(raise' [e]+ (log/errorf "ERROR HANDLING REQUEST! <async raise> %s" request)+ (log/error e)+ (raise e))]+ (try+ (handler request respond raise')+ (catch Throwable e+ (log/errorf "ERROR HANDLING REQUEST! <async thrown> %s" request)+ (log/error e)+ (throw e))))))))(def ^:private -test-handler(delay (make-test-handler)))+(def ^:dynamic *test-handler*+ "When bound, [[test-handler]] returns this handler instead of the default one built from [[app-api-routes]]. Bind+ it via [[do-with-api-routes]] to test API routes that the application does not mount."+ nil)+(defn test-handler"Build the Ring handler used in tests and by `dev`."[]- @-test-handler)+ (or *test-handler* @-test-handler))++(defn do-with-api-routes+ "Run `thunk` with the test HTTP client serving `api-routes` under `/api` instead of the application's own route+ tree. `api-routes` is a Ring handler such as one built with [[metabase.api.util.handlers/routes]]; compose it with+ [[app-api-routes]] to fall through to the application's routes."+ [api-routes thunk]+ (binding [*test-handler* (make-test-handler api-routes)]+ (thunk)))