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

preload databases and tables in QB init (#12063)

parent 63916fa4
No related branches found
No related tags found
No related merge requests found
......@@ -60,6 +60,7 @@ import { getCardAfterVisualizationClick } from "metabase/visualizations/lib/util
import { getPersistableDefaultSettingsForSeries } from "metabase/visualizations/lib/settings/visualization";
import Questions from "metabase/entities/questions";
import Databases from "metabase/entities/databases";
import { getMetadata } from "metabase/selectors/metadata";
import { setRequestUnloaded } from "metabase/redux/requests";
......@@ -298,6 +299,10 @@ export const initializeQB = (location, params) => {
dispatch(resetQB());
dispatch(cancelQuery());
// preload metadata that's used in DataSelector
dispatch(Databases.actions.fetchList({ include: "tables" }));
dispatch(Databases.actions.fetchList({ saved: true }));
const { currentUser } = getState();
let card, originalCard;
......
......@@ -27,15 +27,14 @@ describe("query builder loading behavior", () => {
});
it("should incrementally load data if not preloaded", () => {
// we visit the new question page but refresh after starting a simple
// question to wipe out the preloaded data.
cy.server();
// stub out the preload call to fetch all tables
cy.route({ url: "/api/database?include=tables", response: [] });
// let the other preload happen since it matches the actual call from the component
cy.route({ url: "/api/database?saved=true" }).as("fetch1");
cy.visit("/question/new");
cy.contains("Simple question").click();
cy.server();
cy.reload();
cy.route({ url: "/api/database?include=tables" }).as("preload");
cy.route({ url: "/api/database?saved=true" }).as("fetch1");
cy.route({ url: "/api/database/1/schemas" }).as("fetch2");
cy.route({ url: "/api/database/1/schema/PUBLIC" }).as("fetch3");
......@@ -47,6 +46,5 @@ describe("query builder loading behavior", () => {
cy.get("@fetch1").should("exist");
cy.get("@fetch2").should("exist");
cy.get("@fetch3").should("exist");
cy.get("@preload").should("not.exist");
});
});
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