Skip to content
Snippets Groups Projects
Unverified Commit 9f681a38 authored by Noah Moss's avatar Noah Moss Committed by GitHub
Browse files

Add new copy to description fields in sample dataset (#19681)

parent 5d91c0e9
No related merge requests found
......@@ -26,7 +26,7 @@ describe("scenarios > admin > databases > table", () => {
"Select any table to see its schema and add or edit metadata.",
).should("not.exist");
cy.get(
"input[value='This is a confirmed order for a product from a user.']",
"input[value='Confirmed Sample Company orders for a product, from a user.']",
);
});
......
......@@ -13,7 +13,9 @@ describe("scenarios > native question > data reference sidebar", () => {
// Force-clicking was needed here because Cypress complains that "ORDERS" is covered by a <div>
// TODO: Maybe re-think the structure of that component because that div seems unnecessary anyway
cy.findByText("ORDERS").click({ force: true });
cy.findByText("This is a confirmed order for a product from a user.");
cy.findByText(
"Confirmed Sample Company orders for a product, from a user.",
);
cy.findByText("9 columns");
cy.findByText("QUANTITY").click({ force: true });
......
......@@ -84,7 +84,9 @@ describe("scenarios > reference > databases", () => {
popover().within(() => {
// check for the table's description
cy.contains("This is our product catalog");
cy.contains(
"Includes a catalog of all the products ever sold by the famed Sample Company.",
);
// check for table column metadata
cy.findByText("8 columns");
......
......@@ -313,7 +313,9 @@ describe("smoketest > admin_setup", () => {
.clear()
.type("Test Table");
cy.get("[value='This is a confirmed order for a product from a user.']")
cy.get(
"[value='Confirmed Sample Company orders for a product, from a user.']",
)
.clear()
.type("Testing table description");
});
......
No preview for this file type
......@@ -9,6 +9,7 @@
[clojure.tools.logging :as log]
[metabase.driver :as driver]
[metabase.driver.util :as driver.u]
[metabase.models.database :refer [Database]]
[metabase.models.field :refer [Field]]
[metabase.models.table :refer [Table]]
[metabase.sync.fetch-metadata :as fetch-metadata]
......@@ -20,7 +21,7 @@
[toucan.db :as db]))
(def ^:private KeypathComponents
{:table-name su/NonBlankString
{:table-name (s/maybe su/NonBlankString)
:field-name (s/maybe su/NonBlankString)
:k s/Keyword})
......@@ -28,13 +29,14 @@
"Parse a KEYPATH into components for easy use."
;; TODO: this does not support schemas in dbs :(
[keypath :- su/NonBlankString]
;; keypath will have one of two formats:
;; keypath will have one of three formats:
;; property (for database-level properties)
;; table_name.property
;; table_name.field_name.property
(let [[table-name second-part third-part] (str/split keypath #"\.")]
{:table-name table-name
(let [[first-part second-part third-part] (str/split keypath #"\.")]
{:table-name (when second-part first-part)
:field-name (when third-part second-part)
:k (keyword (or third-part second-part))}))
:k (keyword (or third-part second-part first-part))}))
(s/defn ^:private set-property! :- s/Bool
"Set a property for a Field or Table in DATABASE. Returns `true` if a property was successfully set."
......@@ -43,16 +45,16 @@
;; ignore legacy entries that try to set field_type since it's no longer part of Field
(when-not (= k :field_type)
;; fetch the corresponding Table, then set the Table or Field property
(when-let [table-id (db/select-one-id Table
;; TODO: this needs to support schemas
:db_id (u/the-id database)
:name table-name
:active true)]
(if field-name
(db/update-where! Field {:name field-name, :table_id table-id}
k value)
(db/update! Table table-id
k value))))))
(if table-name
(when-let [table-id (db/select-one-id Table
;; TODO: this needs to support schemas
:db_id (u/the-id database)
:name table-name
:active true)]
(if field-name
(db/update-where! Field {:name field-name, :table_id table-id} k value)
(db/update! Table table-id k value)))
(db/update! Database (u/the-id database) k value)))))
(s/defn ^:private sync-metabase-metadata-table!
"Databases may include a table named `_metabase_metadata` (case-insentive) which includes descriptions or other
......
......@@ -35,11 +35,13 @@
:description nil
:id true
:fields [{:name "filming", :description nil}]}
(get-table-and-fields-descriptions table))))
(get-table-and-fields-descriptions table)))
(is (nil? (:description (Database (u/the-id db))))))
(metabase-metadata/sync-metabase-metadata! db)
(testing "after"
(is (= {:name "movies"
:description "A cinematic adventure."
:id true
:fields [{:name "filming", :description "If the movie is currently being filmed."}]}
(get-table-and-fields-descriptions table)))))))))
(get-table-and-fields-descriptions table)))
(is (= "Information about movies" (:description (Database (u/the-id db)))))))))))
......@@ -91,6 +91,7 @@
(defmethod driver/table-rows-seq ::moviedb [_ _ table]
(when (= (:name table) "_metabase_metadata")
[{:keypath "movies.filming.description", :value "If the movie is currently being filmed."}
{:keypath "movies.description", :value "A cinematic adventure."}]))
{:keypath "movies.description", :value "A cinematic adventure."}
{:keypath "description", :value "Information about movies"}]))
(defmethod driver/supports? [::moviedb :foreign-keys] [_ _] true)
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