Skip to content
Snippets Groups Projects
Unverified Commit 6585f0c1 authored by Tim Macdonald's avatar Tim Macdonald Committed by GitHub
Browse files

Search by table description (#33089)

* Search by table description

[Fixes #25792]
parent ae9d22cb
No related branches found
No related tags found
No related merge requests found
...@@ -86,9 +86,11 @@ describe("scenarios > search", () => { ...@@ -86,9 +86,11 @@ describe("scenarios > search", () => {
cy.get("@searchBox").type("{enter}"); cy.get("@searchBox").type("{enter}");
cy.wait("@search"); cy.wait("@search");
cy.findByTestId("search-result-item").within(() => { cy.findAllByTestId("search-result-item")
getProductsSearchResults(); .first()
}); .within(() => {
getProductsSearchResults();
});
}); });
it("should work for user with permissions (metabase#12332)", () => { it("should work for user with permissions (metabase#12332)", () => {
......
...@@ -101,7 +101,8 @@ ...@@ -101,7 +101,8 @@
(defmethod searchable-columns-for-model "table" (defmethod searchable-columns-for-model "table"
[_] [_]
[:name [:name
:display_name]) :display_name
:description])
(defmethod searchable-columns-for-model "indexed-entity" (defmethod searchable-columns-for-model "indexed-entity"
[_] [_]
......
...@@ -322,8 +322,8 @@ ...@@ -322,8 +322,8 @@
(mt/with-temp* [PermissionsGroup [group] (mt/with-temp* [PermissionsGroup [group]
PermissionsGroupMembership [_ {:user_id (mt/user->id :rasta), :group_id (u/the-id group)}]] PermissionsGroupMembership [_ {:user_id (mt/user->id :rasta), :group_id (u/the-id group)}]]
(perms/grant-permissions! group (perms/collection-read-path {:metabase.models.collection.root/is-root? true})) (perms/grant-permissions! group (perms/collection-read-path {:metabase.models.collection.root/is-root? true}))
(is (= (remove (comp #{"collection"} :model) (default-search-results)) (is (ordered-subset? (remove (comp #{"collection"} :model) (default-search-results))
(search-request-data :rasta :q "test"))))))) (search-request-data :rasta :q "test")))))))
(testing "Users without root collection permissions should still see other collections they have access to" (testing "Users without root collection permissions should still see other collections they have access to"
(mt/with-non-admin-groups-no-root-collection-perms (mt/with-non-admin-groups-no-root-collection-perms
...@@ -350,14 +350,14 @@ ...@@ -350,14 +350,14 @@
PermissionsGroupMembership [_ {:user_id (mt/user->id :rasta), :group_id (u/the-id group)}]] PermissionsGroupMembership [_ {:user_id (mt/user->id :rasta), :group_id (u/the-id group)}]]
(perms/grant-permissions! group (perms/collection-read-path {:metabase.models.collection.root/is-root? true})) (perms/grant-permissions! group (perms/collection-read-path {:metabase.models.collection.root/is-root? true}))
(perms/grant-collection-read-permissions! group collection) (perms/grant-collection-read-permissions! group collection)
(is (= (sorted-results (is (ordered-subset? (sorted-results
(reverse (reverse
(into (into
(default-results-with-collection) (default-results-with-collection)
(for [row (default-search-results) (for [row (default-search-results)
:when (not= "collection" (:model row))] :when (not= "collection" (:model row))]
(update row :name #(str/replace % "test" "test2")))))) (update row :name #(str/replace % "test" "test2"))))))
(search-request-data :rasta :q "test")))))))) (search-request-data :rasta :q "test"))))))))
(testing "Users with access to multiple collections should see results from all collections they have access to" (testing "Users with access to multiple collections should see results from all collections they have access to"
(with-search-items-in-collection {coll-1 :collection} "test" (with-search-items-in-collection {coll-1 :collection} "test"
...@@ -366,13 +366,13 @@ ...@@ -366,13 +366,13 @@
PermissionsGroupMembership [_ {:user_id (mt/user->id :rasta), :group_id (u/the-id group)}]] PermissionsGroupMembership [_ {:user_id (mt/user->id :rasta), :group_id (u/the-id group)}]]
(perms/grant-collection-read-permissions! group (u/the-id coll-1)) (perms/grant-collection-read-permissions! group (u/the-id coll-1))
(perms/grant-collection-read-permissions! group (u/the-id coll-2)) (perms/grant-collection-read-permissions! group (u/the-id coll-2))
(is (= (sorted-results (is (ordered-subset? (sorted-results
(reverse (reverse
(into (into
(default-results-with-collection) (default-results-with-collection)
(map (fn [row] (update row :name #(str/replace % "test" "test2"))) (map (fn [row] (update row :name #(str/replace % "test" "test2")))
(default-results-with-collection))))) (default-results-with-collection)))))
(search-request-data :rasta :q "test"))))))) (search-request-data :rasta :q "test")))))))
(testing "User should only see results in the collection they have access to" (testing "User should only see results in the collection they have access to"
(mt/with-non-admin-groups-no-root-collection-perms (mt/with-non-admin-groups-no-root-collection-perms
...@@ -618,6 +618,12 @@ ...@@ -618,6 +618,12 @@
(do-test-users [user [:crowberto :rasta]] (do-test-users [user [:crowberto :rasta]]
(is (= [(assoc (default-table-search-row "RoundTable") :name lancelot)] (is (= [(assoc (default-table-search-row "RoundTable") :name lancelot)]
(search-request-data user :q "Lancelot"))))))) (search-request-data user :q "Lancelot")))))))
(testing "You should be able to search by their description"
(let [lancelot "Lancelot's Favorite Furniture"]
(t2.with-temp/with-temp [Table _ {:name "RoundTable" :description lancelot}]
(do-test-users [user [:crowberto :rasta]]
(is (= [(assoc (default-table-search-row "RoundTable") :description lancelot :table_description lancelot)]
(search-request-data user :q "Lancelot")))))))
(testing "When searching with ?archived=true, normal Tables should not show up in the results" (testing "When searching with ?archived=true, normal Tables should not show up in the results"
(let [table-name (mt/random-name)] (let [table-name (mt/random-name)]
(t2.with-temp/with-temp [Table _ {:name table-name}] (t2.with-temp/with-temp [Table _ {:name table-name}]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment