Skip to content
Snippets Groups Projects
Unverified Commit 710c54c0 authored by Paul Rosenzweig's avatar Paul Rosenzweig Committed by GitHub
Browse files

Fix table selection for single db with multiple schemas (#10766)

parent 8328e2f3
No related branches found
No related tags found
No related merge requests found
......@@ -250,7 +250,7 @@ export default class DataSelector extends Component {
this.props.databases.length === 1 &&
!this.props.segments;
if (useOnlyAvailableDatabase) {
setTimeout(() => this.onChangeDatabase(0));
setTimeout(() => this.onChangeDatabase(0, true));
}
this.hydrateActiveStep();
......
import React from "react";
import { delay } from "metabase/lib/promise";
import { mountWithStore } from "__support__/integration_tests";
import { DatabaseSchemaAndTableDataSelector } from "metabase/query_builder/components/DataSelector.jsx";
jest.mock("metabase/components/Popover.jsx");
describe("DatabaseSchemaAndTableDataSelector", () => {
it("should render with one db that has multiple schemas", async () => {
const { wrapper } = mountWithStore(
<DatabaseSchemaAndTableDataSelector
databases={[
{
id: 1,
name: "db-1",
tables: [
{ display_name: "table-1", schema: "schema-1" },
{ display_name: "table-2", schema: "schema-2" },
],
},
]}
isOpen={true}
/>,
);
// this await is because onChangeDatabase get scheduled for the next tick
await delay(0);
const schemaNames = wrapper.find("h4").map(e => e.text());
expect(schemaNames).toEqual(["Schema-1", "Schema-2"]);
wrapper
.find("TestPopover")
.find("a")
.first()
.simulate("click");
expect(wrapper.find("h4").text()).toBe("table-1");
});
});
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