Skip to content

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

chore: Convert metabase-lib/v1 metadata utils to TypeScript (#79072)

Andrei Chernykh563476b20788
diff --git a/frontend/src/metabase-lib/v1/metadata/utils/models.unit.spec.js b/frontend/src/metabase-lib/v1/metadata/utils/models.unit.spec.ts
similarity index 75%
rename from frontend/src/metabase-lib/v1/metadata/utils/models.unit.spec.js
rename to frontend/src/metabase-lib/v1/metadata/utils/models.unit.spec.ts
index abe280f5924..7192cbe2fa4 100644
--- a/frontend/src/metabase-lib/v1/metadata/utils/models.unit.spec.js
+++ b/frontend/src/metabase-lib/v1/metadata/utils/models.unit.spec.ts
@@ -1,6 +1,7 @@
import _ from "underscore";
import { createMockMetadata } from "__support__/metadata";
+import { checkNotNull } from "metabase/utils/types";
import Question from "metabase-lib/v1/Question";
import {
checkCanBeModel,
@@ -9,8 +10,18 @@ import {
getModelCacheSchemaName,
isAdHocModelOrMetricQuestion,
} from "metabase-lib/v1/metadata/utils/models";
+import type {
+ Card,
+ ModelCacheState,
+ NativeDatasetQuery,
+ StructuredDatasetQuery,
+ TableId,
+ TemplateTagType,
+ TemplateTags,
+} from "metabase-types/api";
import {
COMMON_DATABASE_FEATURES,
+ createMockTemplateTag,
getMockModelCacheInfo,
} from "metabase-types/api/mocks";
import {
@@ -23,17 +34,10 @@ import {
createSampleDatabase,
} from "metabase-types/api/mocks/presets";
-function getTemplateTag(tag = {}) {
- return {
- id: "_",
- name: "_",
- "display-name": "_",
- type: "card",
- ...tag,
- };
-}
-
-function createSavedNativeCard({ tags = {}, ...rest } = {}) {
+function createSavedNativeCard({
+ tags = {},
+ ...rest
+}: Partial<Card<NativeDatasetQuery>> & { tags?: TemplateTags } = {}) {
return _createSavedNativeCard({
...rest,
dataset_query: {
@@ -47,7 +51,10 @@ function createSavedNativeCard({ tags = {}, ...rest } = {}) {
});
}
-function createNativeModelCard({ tags = {}, ...rest } = {}) {
+function createNativeModelCard({
+ tags = {},
+ ...rest
+}: Partial<Card<NativeDatasetQuery>> & { tags?: TemplateTags } = {}) {
return _createNativeModelCard({
...rest,
dataset_query: {
@@ -61,7 +68,10 @@ function createNativeModelCard({ tags = {}, ...rest } = {}) {
});
}
-function createSavedStructuredCard({ sourceTable = ORDERS_ID, ...rest } = {}) {
+function createSavedStructuredCard({
+ sourceTable = ORDERS_ID,
+ ...rest
+}: Partial<Card<StructuredDatasetQuery>> & { sourceTable?: TableId } = {}) {
return _createSavedStructuredCard({
...rest,
dataset_query: {
@@ -74,7 +84,10 @@ function createSavedStructuredCard({ sourceTable = ORDERS_ID, ...rest } = {}) {
});
}
-function createStructuredModelCard({ sourceTable = ORDERS_ID, ...rest } = {}) {
+function createStructuredModelCard({
+ sourceTable = ORDERS_ID,
+ ...rest
+}: Partial<Card<StructuredDatasetQuery>> & { sourceTable?: TableId } = {}) {
return _createStructuredModelCard({
...rest,
dataset_query: {
@@ -87,24 +100,27 @@ function createStructuredModelCard({ sourceTable = ORDERS_ID, ...rest } = {}) {
});
}
-function setup({ cards, hasNestedQueriesSupport = true } = {}) {
+function setup({
+ cards = [],
+ hasNestedQueriesSupport = true,
+}: { cards?: Card[]; hasNestedQueriesSupport?: boolean } = {}) {
const features = hasNestedQueriesSupport
? COMMON_DATABASE_FEATURES
: _.without(COMMON_DATABASE_FEATURES, "nested-queries");
const metadata = createMockMetadata({
databases: [createSampleDatabase({ features })],
- questions: cards ? cards : [],
+ questions: cards,
});
- const ordersTable = metadata.table(ORDERS_ID);
+ const ordersTable = checkNotNull(metadata.table(ORDERS_ID));
return { metadata, ordersTable };
}
describe("data model utils", () => {
describe("checkCanBeModel", () => {
- const UNSUPPORTED_TEMPLATE_TAG_TYPES = [
+ const UNSUPPORTED_TEMPLATE_TAG_TYPES: TemplateTagType[] = [
"text",
"number",
"date",
@@ -130,7 +146,7 @@ describe("data model utils", () => {
const card = createSavedNativeCard();
const { metadata } = setup({ cards: [card] });
- const question = metadata.question(card.id);
+ const question = checkNotNull(metadata.question(card.id));
expect(checkCanBeModel(question)).toBe(true);
});
@@ -142,7 +158,7 @@ describe("data model utils", () => {
hasNestedQueriesSupport: false,
});
- const question = metadata.question(card.id);
+ const question = checkNotNull(metadata.question(card.id));
expect(checkCanBeModel(question)).toBe(true);
});
@@ -150,12 +166,12 @@ describe("data model utils", () => {
it("returns true when 'card' variables are used", () => {
const card = createSavedNativeCard({
tags: {
- "#5": getTemplateTag({ type: "card" }),
+ "#5": createMockTemplateTag({ type: "card" }),
},
});
const { metadata } = setup({ cards: [card] });
- const question = metadata.question(card.id);
+ const question = checkNotNull(metadata.question(card.id));
expect(checkCanBeModel(question)).toBe(true);
});
@@ -164,12 +180,12 @@ describe("data model utils", () => {
it(`returns false when '${tagType}' variables are used`, () => {
const card = createSavedNativeCard({
tags: {
- foo: getTemplateTag({ type: tagType }),
+ foo: createMockTemplateTag({ type: tagType }),
},
});
const { metadata } = setup({ cards: [card] });
- const question = metadata.question(card.id);
+ const question = checkNotNull(metadata.question(card.id));
expect(checkCanBeModel(question)).toBe(false);
});
@@ -178,13 +194,13 @@ describe("data model utils", () => {
it("returns false if at least one unsupported variable type is used", () => {
const card = createSavedNativeCard({
tags: {
- "#5": getTemplateTag({ type: "card" }),
- foo: getTemplateTag({ type: "dimension" }),
+ "#5": createMockTemplateTag({ type: "card" }),
+ foo: createMockTemplateTag({ type: "dimension" }),
},
});
const { metadata } = setup({ cards: [card] });
- const question = metadata.question(card.id);
+ const question = checkNotNull(metadata.question(card.id));
expect(checkCanBeModel(question)).toBe(false);
});
@@ -208,7 +224,7 @@ describe("data model utils", () => {
const card = createNativeModelCard();
const { metadata } = setup({ cards: [card] });
- const question = metadata.question(card.id);
+ const question = checkNotNull(metadata.question(card.id));
expect(isAdHocModelOrMetricQuestion(question, question)).toBe(false);
});
@@ -216,7 +232,7 @@ describe("data model utils", () => {
it("identifies when model goes into ad-hoc exploration mode", () => {
const modelCard = createStructuredModelCard({ id: 1 });
const { metadata } = setup({ cards: [modelCard] });
- const originalQuestion = metadata.question(modelCard.id);
+ const originalQuestion = checkNotNull(metadata.question(modelCard.id));
const question = originalQuestion.composeQuestion();
expect(isAdHocModelOrMetricQuestion(question, originalQuestion)).toBe(
@@ -232,7 +248,7 @@ describe("data model utils", () => {
});
const { metadata } = setup({ cards: [modelCard] });
- const originalQuestion = metadata.question(modelCard.id);
+ const originalQuestion = checkNotNull(metadata.question(modelCard.id));
const question = new Question(composedModelCard, metadata);
expect(isAdHocModelOrMetricQuestion(question, originalQuestion)).toBe(
@@ -248,7 +264,7 @@ describe("data model utils", () => {
});
const { metadata } = setup({ cards: [modelCard] });
- const originalQuestion = metadata.question(modelCard.id);
+ const originalQuestion = checkNotNull(metadata.question(modelCard.id));
const question = new Question(composedModelCard, metadata);
expect(isAdHocModelOrMetricQuestion(question, originalQuestion)).toBe(
@@ -264,7 +280,7 @@ describe("data model utils", () => {
});
const { metadata } = setup({ cards: [modelCard] });
- const originalQuestion = metadata.question(modelCard.id);
+ const originalQuestion = checkNotNull(metadata.question(modelCard.id));
const question = new Question(composedModelCard, metadata);
expect(isAdHocModelOrMetricQuestion(question, originalQuestion)).toBe(
@@ -274,19 +290,16 @@ describe("data model utils", () => {
});
describe("checkCanRefreshModelCache", () => {
- const testCases = {
- creating: true,
- refreshing: false,
- persisted: true,
- error: true,
- deletable: false,
- off: false,
- };
- const states = Object.keys(testCases);
-
- states.forEach((state) => {
- const canRefresh = testCases[state];
+ const testCases: { state: ModelCacheState; canRefresh: boolean }[] = [
+ { state: "creating", canRefresh: true },
+ { state: "refreshing", canRefresh: false },
+ { state: "persisted", canRefresh: true },
+ { state: "error", canRefresh: true },
+ { state: "deletable", canRefresh: false },
+ { state: "off", canRefresh: false },
+ ];
+ testCases.forEach(({ state, canRefresh }) => {
it(`returns '${canRefresh}' for '${state}' caching state`, () => {
const info = getMockModelCacheInfo({ state });
expect(checkCanRefreshModelCache(info)).toBe(canRefresh);
@@ -312,8 +325,8 @@ describe("data model utils", () => {
it("returns 0 for completely missing metadata", () => {
const percent = getDatasetMetadataCompletenessPercentage([
- { display_name: "Created_At" },
- { display_name: "Products → Category" },
+ { name: "created_at", display_name: "Created_At" },
+ { name: "category", display_name: "Products → Category" },
]);
expect(percent).toBe(0);
});
@@ -321,11 +334,13 @@ describe("data model utils", () => {
it("returns 1 for complete metadata", () => {
const percent = getDatasetMetadataCompletenessPercentage([
{
+ name: "created_at",
display_name: "Created At",
description: "Date created",
semantic_type: "DateTime",
},
{
+ name: "category",
display_name: "Product Category",
description: "The name is pretty self-explaining",
semantic_type: "String",
@@ -336,8 +351,9 @@ describe("data model utils", () => {
it("returns 0.5 for half-complete metadata", () => {
const percent = getDatasetMetadataCompletenessPercentage([
- { display_name: "Created_At" },
+ { name: "created_at", display_name: "Created_At" },
{
+ name: "category",
display_name: "Product Category",
description: "The name is pretty self-explaining",
semantic_type: "String",
@@ -348,8 +364,9 @@ describe("data model utils", () => {
it("returns percent value for partially complete metadata", () => {
const percent = getDatasetMetadataCompletenessPercentage([
- { display_name: "Created_At" },
+ { name: "created_at", display_name: "Created_At" },
{
+ name: "category",
display_name: "Product Category",
semantic_type: "String",
},
diff --git a/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.js b/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.js
deleted file mode 100644
index 32ea4e31084..00000000000
--- a/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import { generateSchemaId } from "metabase-lib/v1/metadata/utils/schema";
-
-export const SAVED_QUESTIONS_VIRTUAL_DB_ID = -1337;
-const ROOT_COLLECTION_VIRTUAL_SCHEMA_NAME = "Everything else";
-
-export const ROOT_COLLECTION_VIRTUAL_SCHEMA = getCollectionVirtualSchemaId({
- id: null,
-});
-
-export function getCollectionVirtualSchemaName(collection) {
- const isRoot =
- !collection || collection.id === null || collection.id === "root";
- return isRoot
- ? ROOT_COLLECTION_VIRTUAL_SCHEMA_NAME
- : collection.schemaName || collection.name;
-}
-
-export function getCollectionVirtualSchemaId(collection) {
- const collectionName = getCollectionVirtualSchemaName(collection);
- return generateSchemaId(SAVED_QUESTIONS_VIRTUAL_DB_ID, collectionName);
-}
-
-export function getQuestionVirtualTableId(id) {
- return `card__${id}`;
-}
-
-export function isVirtualCardId(tableId) {
- return typeof tableId === "string" && tableId.startsWith("card__");
-}
-
-export function getQuestionIdFromVirtualTableId(tableId) {
- if (typeof tableId !== "string") {
- return null;
- }
- const id = parseInt(tableId.replace("card__", ""));
- return Number.isSafeInteger(id) ? id : null;
-}
-
-export function convertSavedQuestionToVirtualTable(card) {
- return {
- id: getQuestionVirtualTableId(card.id),
- display_name: card.name,
- description: card.description,
- moderated_status: card.moderated_status,
- // we may not have permissions
- db_id: card.dataset_query?.database,
- type: "question",
- schema: getCollectionVirtualSchemaId(card.collection),
- schema_name: getCollectionVirtualSchemaName(card.collection),
- };
-}
diff --git a/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.ts b/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.ts
new file mode 100644
index 00000000000..b2125b1fd14
--- /dev/null
+++ b/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.ts
@@ -0,0 +1,86 @@
+import { generateSchemaId } from "metabase-lib/v1/metadata/utils/schema";
+import type {
+ Card,
+ CardId,
+ Collection,
+ ModerationReviewStatus,
+ SchemaName,
+ TableId,
+ VirtualTableId,
+} from "metabase-types/api";
+
+export const SAVED_QUESTIONS_VIRTUAL_DB_ID = -1337;
+const ROOT_COLLECTION_VIRTUAL_SCHEMA_NAME = "Everything else";
+
+// Subset of a collection used to derive its virtual schema. `schemaName` only
+// exists on enriched collection-tree items; plain Collections fall back to `name`.
+type VirtualSchemaCollection = {
+ id?: Collection["id"] | null;
+ name: Collection["name"];
+ schemaName?: SchemaName;
+};
+
+export const ROOT_COLLECTION_VIRTUAL_SCHEMA = generateSchemaId(
+ SAVED_QUESTIONS_VIRTUAL_DB_ID,
+ ROOT_COLLECTION_VIRTUAL_SCHEMA_NAME,
+);
+
+export function getCollectionVirtualSchemaName(
+ collection?: VirtualSchemaCollection | null,
+): string {
+ const isRoot =
+ !collection || collection.id === null || collection.id === "root";
+ return isRoot
+ ? ROOT_COLLECTION_VIRTUAL_SCHEMA_NAME
+ : collection.schemaName || collection.name;
+}
+
+export function getCollectionVirtualSchemaId(
+ collection?: VirtualSchemaCollection | null,
+): string {
+ const collectionName = getCollectionVirtualSchemaName(collection);
+ return generateSchemaId(SAVED_QUESTIONS_VIRTUAL_DB_ID, collectionName);
+}
+
+export function getQuestionVirtualTableId(id: CardId | string): VirtualTableId {
+ return `card__${id}`;
+}
+
+export function isVirtualCardId(
+ tableId?: TableId | null,
+): tableId is VirtualTableId {
+ return typeof tableId === "string" && tableId.startsWith("card__");
+}
+
+export function getQuestionIdFromVirtualTableId(
+ tableId?: TableId | null,
+): CardId | null {
+ if (typeof tableId !== "string") {
+ return null;
+ }
+ const id = parseInt(tableId.replace("card__", ""));
+ return Number.isSafeInteger(id) ? id : null;
+}
+
+// The card fields this conversion reads. `moderated_status` is a hydrated extra
+// present on some API payloads but not on the Card type itself.
+type ConvertibleCard = Pick<
+ Card,
+ "id" | "name" | "description" | "collection" | "dataset_query"
+> & {
+ moderated_status?: ModerationReviewStatus;
+};
+
+export function convertSavedQuestionToVirtualTable(card: ConvertibleCard) {
+ return {
+ id: getQuestionVirtualTableId(card.id),
+ display_name: card.name,
+ description: card.description,
+ moderated_status: card.moderated_status,
+ // we may not have permissions
+ db_id: card.dataset_query?.database,
+ type: "question",
+ schema: getCollectionVirtualSchemaId(card.collection),
+ schema_name: getCollectionVirtualSchemaName(card.collection),
+ };
+}
diff --git a/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.unit.spec.ts b/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.unit.spec.ts
index 0bb2c79cb92..70c1ffd4925 100644
--- a/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.unit.spec.ts
+++ b/frontend/src/metabase-lib/v1/metadata/utils/saved-questions.unit.spec.ts
@@ -1,3 +1,8 @@
+import {
+ createMockCollection,
+ createMockStructuredDatasetQuery,
+} from "metabase-types/api/mocks";
+
import {
SAVED_QUESTIONS_VIRTUAL_DB_ID,
convertSavedQuestionToVirtualTable,
@@ -11,12 +16,13 @@ import {
describe("saved question helpers", () => {
describe("getCollectionVirtualSchemaName", () => {
it("should return 'Everything else' for root collection", () => {
- expect(getCollectionVirtualSchemaName({ id: null })).toBe(
- "Everything else",
- );
- expect(getCollectionVirtualSchemaName({ id: "root" })).toBe(
- "Everything else",
- );
+ expect(getCollectionVirtualSchemaName(null)).toBe("Everything else");
+ expect(
+ getCollectionVirtualSchemaName({ id: null, name: "Our analytics" }),
+ ).toBe("Everything else");
+ expect(
+ getCollectionVirtualSchemaName({ id: "root", name: "Our analytics" }),
+ ).toBe("Everything else");
});
it("should return 'Everything else' if collection is not passed", () => {
@@ -48,11 +54,15 @@ describe("saved question helpers", () => {
expectedName: encodeURIComponent("Everything else"),
},
{
- collection: { id: null },
+ collection: null,
+ expectedName: encodeURIComponent("Everything else"),
+ },
+ {
+ collection: { id: null, name: "Our analytics" },
expectedName: encodeURIComponent("Everything else"),
},
{
- collection: { id: "root" },
+ collection: { id: "root" as const, name: "Our analytics" },
expectedName: encodeURIComponent("Everything else"),
},
{ collection: { id: 3, name: "Marketing" }, expectedName: "Marketing" },
@@ -87,14 +97,12 @@ describe("saved question helpers", () => {
expect(isVirtualCardId(4)).toBe(false);
});
- it("should return false for garbage", () => {
+ it("should return false for non-virtual ids", () => {
expect(isVirtualCardId()).toBe(false);
expect(isVirtualCardId(null)).toBe(false);
- expect(isVirtualCardId(null)).toBe(false);
expect(isVirtualCardId(0)).toBe(false);
expect(isVirtualCardId(-1)).toBe(false);
expect(isVirtualCardId("1")).toBe(false);
- expect(isVirtualCardId({ foo: "bar" })).toBe(false);
});
});
@@ -110,13 +118,7 @@ describe("saved question helpers", () => {
});
});
- [
- { id: undefined },
- { id: null },
- { id: 123 },
- { id: true },
- { id: { foo: "bar" } },
- ].forEach((testCase) => {
+ [{ id: undefined }, { id: null }, { id: 123 }].forEach((testCase) => {
const { id } = testCase;
it(`should handle non string input (${id})`, () => {
@@ -136,19 +138,14 @@ describe("saved question helpers", () => {
id: 11,
name: "Q1",
description: "Text",
- moderated_status: "verified",
- dataset_query: {
- database: 4,
- },
+ moderated_status: "verified" as const,
+ dataset_query: createMockStructuredDatasetQuery({ database: 4 }),
};
it("correctly converts questions in normal collections", () => {
const question = {
...COMMON_QUESTION_DATA,
- collection: {
- id: 8,
- name: "Marketing",
- },
+ collection: createMockCollection({ id: 8, name: "Marketing" }),
};
expect(convertSavedQuestionToVirtualTable(question)).toEqual({
diff --git a/frontend/src/metabase-lib/v1/metadata/utils/schema.unit.spec.js b/frontend/src/metabase-lib/v1/metadata/utils/schema.unit.spec.ts
similarity index 86%
rename from frontend/src/metabase-lib/v1/metadata/utils/schema.unit.spec.js
rename to frontend/src/metabase-lib/v1/metadata/utils/schema.unit.spec.ts
index 9309ea0bb17..a5db28bcd82 100644
--- a/frontend/src/metabase-lib/v1/metadata/utils/schema.unit.spec.js
+++ b/frontend/src/metabase-lib/v1/metadata/utils/schema.unit.spec.ts
@@ -1,7 +1,14 @@
+import type { DatabaseId, SchemaId, SchemaName } from "metabase-types/api";
+
import { generateSchemaId, getSchemaName, parseSchemaId } from "./schema";
-const SCHEMA_TEST_CASES = [
- { dbId: 1, schemaName: 2, schema: "1:2" },
+type SchemaTestCase = {
+ dbId: DatabaseId;
+ schemaName?: SchemaName;
+ schema: SchemaId;
+};
+
+const SCHEMA_TEST_CASES: SchemaTestCase[] = [
{ dbId: 1, schemaName: "2", schema: "1:2" },
{ dbId: 1, schema: "1:" },
{
@@ -26,7 +33,7 @@ describe("parseSchemaId", () => {
const { schema, dbId, schemaName } = testCase;
const expectedDatabaseId = dbId;
- const expectedSchemaName = schemaName ? String(schemaName) : "";
+ const expectedSchemaName = schemaName ?? "";
it(`parses "${schema}" correctly`, () => {
const [parsedDatabaseId, parsedSchemaName] = parseSchemaId(schema);
@@ -66,7 +73,7 @@ describe("parseSchemaId", () => {
describe("getSchemaName", () => {
SCHEMA_TEST_CASES.forEach((testCase) => {
const { schema, schemaName } = testCase;
- const expectedSchemaName = schemaName ? String(schemaName) : "";
+ const expectedSchemaName = schemaName ?? "";
it(`returns "${expectedSchemaName}" for "${schema}"`, () => {
expect(getSchemaName(schema)).toBe(expectedSchemaName);
diff --git a/frontend/src/metabase/detail-view/pages/ModelDetailPage/ModelDetailPage.tsx b/frontend/src/metabase/detail-view/pages/ModelDetailPage/ModelDetailPage.tsx
index 827f8f1be08..ad814670dcf 100644
--- a/frontend/src/metabase/detail-view/pages/ModelDetailPage/ModelDetailPage.tsx
+++ b/frontend/src/metabase/detail-view/pages/ModelDetailPage/ModelDetailPage.tsx
@@ -43,9 +43,12 @@ export function ModelDetailPage() {
isLoading: isMetadataLoading,
} = useGetCardQueryMetadataQuery(cardId == null ? skipToken : cardId);
- const table = queryMetadata?.tables?.find(
- (table) => table.id === getQuestionVirtualTableId(cardId),
- );
+ const virtualTableId =
+ cardId == null ? undefined : getQuestionVirtualTableId(cardId);
+ const table =
+ virtualTableId != null
+ ? queryMetadata?.tables?.find((table) => table.id === virtualTableId)
+ : undefined;
const metadata = useSelector(getMetadata);
const tableQuery = useMemo(
() => getTableQuery(metadata, table),
diff --git a/frontend/src/metabase/redux/entities/tables-reducer.unit.spec.ts b/frontend/src/metabase/redux/entities/tables-reducer.unit.spec.ts
index dfc4eb13b1b..305d2b95e63 100644
--- a/frontend/src/metabase/redux/entities/tables-reducer.unit.spec.ts
+++ b/frontend/src/metabase/redux/entities/tables-reducer.unit.spec.ts
@@ -1,6 +1,7 @@
import { cardCreated, cardUpdated } from "metabase/redux/cards";
import { convertSavedQuestionToVirtualTable } from "metabase-lib/v1/metadata/utils/saved-questions";
import type { Card } from "metabase-types/api";
+import { createMockStructuredDatasetQuery } from "metabase-types/api/mocks";
import { tablesReducer } from "./tables-reducer";
@@ -9,13 +10,15 @@ describe("tablesReducer", () => {
function getQuestion({
id = 5,
name = "Q1",
+ description = null,
collection = null,
- dataset_query = { database: 1 },
+ dataset_query = createMockStructuredDatasetQuery({ database: 1 }),
archived = false,
} = {}) {
const question = {
id,
name,
+ description,
collection,
dataset_query,
archived,