Skip to content

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

add documents to search on link dashcards (#75892)

Nick Fitzpatrick90d86d090c87
diff --git a/frontend/src/metabase/dashboard/visualizations/LinkViz/LinkViz.tsx b/frontend/src/metabase/dashboard/visualizations/LinkViz/LinkViz.tsx
index ca31f9f7048..4b9ca7616d4 100644
--- a/frontend/src/metabase/dashboard/visualizations/LinkViz/LinkViz.tsx
+++ b/frontend/src/metabase/dashboard/visualizations/LinkViz/LinkViz.tsx
@@ -43,6 +43,7 @@ const MODELS_TO_SEARCH: SearchModel[] = [
"collection",
"database",
"table",
+ "document",
];
export interface LinkVizProps {
diff --git a/frontend/src/metabase/dashboard/visualizations/LinkViz/LinkViz.unit.spec.tsx b/frontend/src/metabase/dashboard/visualizations/LinkViz/LinkViz.unit.spec.tsx
index 94c7df6a7a6..ed5a300e660 100644
--- a/frontend/src/metabase/dashboard/visualizations/LinkViz/LinkViz.unit.spec.tsx
+++ b/frontend/src/metabase/dashboard/visualizations/LinkViz/LinkViz.unit.spec.tsx
@@ -366,6 +366,47 @@ describe("LinkViz", () => {
});
});
+ it("should find Documents when searching (UXW-4440)", async () => {
+ const documentSearchDashcard = createMockLinkDashboardCard({
+ url: "Quarterly",
+ });
+ const searchDocumentItem = createMockCollectionItem({
+ id: 2,
+ model: "document",
+ name: "Quarterly Plan Doc",
+ collection: searchCardCollection,
+ });
+ setupSearchEndpoints([searchDocumentItem]);
+ setupUserRecipientsEndpoint({ users: [createMockUser()] });
+ setupCollectionByIdEndpoint({
+ collections: [searchCardCollection],
+ });
+
+ const { changeSpy } = setup({
+ isEditing: true,
+ dashcard: documentSearchDashcard,
+ settings:
+ documentSearchDashcard.visualization_settings as LinkCardVizSettings,
+ });
+
+ const searchInput = screen.getByPlaceholderText("https://example.com");
+
+ await userEvent.click(searchInput);
+ await waitForLoaderToBeRemoved();
+
+ await userEvent.click(await screen.findByText("Quarterly Plan Doc"));
+
+ expect(changeSpy).toHaveBeenCalledWith({
+ link: {
+ entity: expect.objectContaining({
+ id: 2,
+ name: "Quarterly Plan Doc",
+ model: "document",
+ }),
+ },
+ });
+ });
+
it("clicking a recent item should update the entity", async () => {
const recentTableItem = createMockRecentTableItem({
model: "table",