Skip to content

Commit

Permalink
Merge branch 'sync-3.9' of github.com:metabase/metabase into sync-3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
camsaul committed Mar 14, 2018
2 parents 034c33d + 99670b6 commit 6e8159c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 19 deletions.
64 changes: 47 additions & 17 deletions frontend/test/parameters/parameters.integ.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,22 @@ const METABASE_SECRET_KEY =
describe("parameters", () => {
let question, dashboard;

const cleanup = [];

beforeAll(async () => {
useSharedAdminLogin();

// enable public sharing
await SettingsApi.put({ key: "enable-public-sharing", value: true });
cleanup.push(() =>
SettingsApi.put({ key: "enable-public-sharing", value: false }),
);

await SettingsApi.put({ key: "enable-embedding", value: true });
cleanup.push(() =>
SettingsApi.put({ key: "enable-embedding", value: false }),
);

await SettingsApi.put({
key: "embedding-secret-key",
value: METABASE_SECRET_KEY,
Expand All @@ -61,6 +71,27 @@ describe("parameters", () => {
name: "User ID",
human_readable_field_id: PEOPLE_NAME_FIELD_ID,
});
cleanup.push(() =>
MetabaseApi.field_dimension_delete({
fieldId: ORDER_USER_ID_FIELD_ID,
}),
);

// set each of these fields to have "has_field_values" = "search"
for (const fieldId of [
ORDER_USER_ID_FIELD_ID,
PEOPLE_ID_FIELD_ID,
PEOPLE_NAME_FIELD_ID,
]) {
const field = await MetabaseApi.field_get({
fieldId: fieldId,
});
await MetabaseApi.field_update({
id: fieldId,
has_field_values: "search",
});
cleanup.push(() => MetabaseApi.field_update(field));
}

const store = await createTestStore();
await store.dispatch(fetchTableMetadata(1));
Expand Down Expand Up @@ -116,6 +147,12 @@ describe("parameters", () => {
.setDisplay("scalar")
.setDisplayName("Test Question");
question = await createSavedQuestion(unsavedQuestion);
cleanup.push(() =>
CardApi.update({
id: question.id(),
archived: true,
}),
);

// create a dashboard
dashboard = await createDashboard({
Expand All @@ -128,6 +165,13 @@ describe("parameters", () => {
{ name: "User", slug: "user_id", id: "4", type: "id" },
],
});
cleanup.push(() =>
DashboardApi.update({
id: dashboard.id,
archived: true,
}),
);

const dashcard = await DashboardApi.addcard({
dashId: dashboard.id,
cardId: question.id(),
Expand Down Expand Up @@ -358,22 +402,8 @@ describe("parameters", () => {

afterAll(async () => {
useSharedAdminLogin();
// archive the dash so we don't impact other tests
await DashboardApi.update({
id: dashboard.id,
archived: true,
});
// archive the card so we don't impact other tests
await CardApi.update({
id: question.id(),
archived: true,
});
// do some cleanup so that we don't impact other tests
await SettingsApi.put({ key: "enable-public-sharing", value: false });
await SettingsApi.put({ key: "enable-embedding", value: false });
await MetabaseApi.field_dimension_delete({
fieldId: ORDER_USER_ID_FIELD_ID,
});
await Promise.all(cleanup.map(fn => fn()));
});
});

Expand Down Expand Up @@ -439,10 +469,10 @@ async function sharedParametersTests(getAppAndStore) {
widget => widget.find(TokenField).props().placeholder,
);
expect(placeholders).toEqual([
"Enter an ID",
"Search by Name or enter an ID",
"Search by Name",
"Search the list",
"Enter an ID",
"Search by Name or enter an ID",
]);
});

Expand Down
4 changes: 2 additions & 2 deletions src/metabase/models/table.clj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
[tables]
(with-objects :segments
(fn [table-ids]
(db/select Segment :table_id [:in table-ids], {:order-by [[:name :asc]]}))
(db/select Segment :table_id [:in table-ids], :is_active true, {:order-by [[:name :asc]]}))
tables))

(defn with-metrics
Expand All @@ -122,7 +122,7 @@
[tables]
(with-objects :metrics
(fn [table-ids]
(db/select Metric :table_id [:in table-ids], {:order-by [[:name :asc]]}))
(db/select Metric :table_id [:in table-ids], :is_active true, {:order-by [[:name :asc]]}))
tables))

(defn with-fields
Expand Down

0 comments on commit 6e8159c

Please sign in to comment.