diff --git a/frontend/src/metabase/query_builder/components/DataSelector/DataSelector.jsx b/frontend/src/metabase/query_builder/components/DataSelector/DataSelector.jsx index 0246bef2e6f999eae21d140ff8455014ec2bac74..4ba341e486569e2b3d69c8fd50b56272ed2a761d 100644 --- a/frontend/src/metabase/query_builder/components/DataSelector/DataSelector.jsx +++ b/frontend/src/metabase/query_builder/components/DataSelector/DataSelector.jsx @@ -184,7 +184,6 @@ class DataSelectorInner extends Component { const DataSelector = _.compose( Databases.loadList({ - query: { saved: true }, loadingAndErrorWrapper: false, listName: "allDatabases", }), @@ -456,8 +455,8 @@ export class UnconnectedDataSelector extends Component { } async componentDidUpdate(prevProps) { - const { loading } = this.props; - const loadedDatasets = prevProps.loading && !loading; + const { allLoading } = this.props; + const loadedDatasets = prevProps.allLoading && !allLoading; // Once datasets are queried with the search endpoint, // this would hide the initial loading and view. @@ -690,7 +689,10 @@ export class UnconnectedDataSelector extends Component { const loadersForSteps = { // NOTE: make sure to return the action's resulting promise [DATABASE_STEP]: () => { - return this.props.fetchDatabases(this.props.databaseQuery); + return Promise.all([ + this.props.fetchDatabases(this.props.databaseQuery), + this.props.fetchDatabases({ saved: true }), + ]); }, [SCHEMA_STEP]: () => { return Promise.all([ @@ -765,20 +767,19 @@ export class UnconnectedDataSelector extends Component { showSavedQuestionPicker = () => this.setState({ isSavedQuestionPickerShown: true }); - onChangeDataBucket = selectedDataBucketId => { - const { databases } = this.props; + onChangeDataBucket = async selectedDataBucketId => { if (selectedDataBucketId === DATA_BUCKET.RAW_DATA) { - this.switchToStep(DATABASE_STEP, { selectedDataBucketId }); + await this.switchToStep(DATABASE_STEP, { selectedDataBucketId }); return; } - this.switchToStep( + await this.switchToStep( DATABASE_STEP, { selectedDataBucketId, }, false, ); - const database = databases.find(db => db.is_saved_questions); + const database = this.props.databases.find(db => db.is_saved_questions); if (database) { this.onChangeDatabase(database); } diff --git a/frontend/test/metabase/scenarios/dashboard/dashboard-management.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/dashboard-management.cy.spec.js index d6f885ad7a3594819d2834255be46015e904defa..6843833a3f51b197bbe4c2258256f9fd7bd8742b 100644 --- a/frontend/test/metabase/scenarios/dashboard/dashboard-management.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/dashboard-management.cy.spec.js @@ -26,10 +26,12 @@ describe("managing dashboard from the dashboard's edit menu", () => { onlyOn(permission === "curate", () => { describe(`${user} user`, () => { beforeEach(() => { + cy.intercept("GET", "/api/dashboard/1").as("getDashboard"); cy.intercept("PUT", "/api/dashboard/1").as("updateDashboard"); cy.signIn(user); visitDashboard(1); + assertOnRequest("getDashboard"); cy.get("main header").within(() => { cy.icon("ellipsis").click(); }); @@ -41,6 +43,7 @@ describe("managing dashboard from the dashboard's edit menu", () => { .type("1") .blur(); assertOnRequest("updateDashboard"); + assertOnRequest("getDashboard"); cy.get("main header").within(() => { cy.icon("info").click(); @@ -54,8 +57,10 @@ describe("managing dashboard from the dashboard's edit menu", () => { }); assertOnRequest("updateDashboard"); + assertOnRequest("getDashboard"); cy.reload(); + assertOnRequest("getDashboard"); cy.findByDisplayValue("Orders in a dashboard1"); }); diff --git a/frontend/test/metabase/scenarios/dashboard/dashboard.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/dashboard.cy.spec.js index b335085d4b17c28af7ffc140fb41b71f3462816d..e1d1b583014a2c365568fa5e95e5956ad8bc15df 100644 --- a/frontend/test/metabase/scenarios/dashboard/dashboard.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/dashboard.cy.spec.js @@ -59,8 +59,10 @@ describe("scenarios > dashboard", () => { }); it("should update the name and description", () => { + cy.intercept("GET", "/api/dashboard/1").as("getDashboard"); cy.intercept("PUT", "/api/dashboard/1").as("updateDashboard"); visitDashboard(1); + cy.wait("@getDashboard"); cy.findByTestId("dashboard-name-heading") .click() @@ -68,6 +70,7 @@ describe("scenarios > dashboard", () => { .blur(); cy.wait("@updateDashboard"); + cy.wait("@getDashboard"); cy.get("main header").within(() => { cy.icon("info").click(); @@ -80,8 +83,12 @@ describe("scenarios > dashboard", () => { .blur(); }); cy.wait("@updateDashboard"); + cy.wait("@getDashboard"); + // refresh page and check that title/desc were updated visitDashboard(1); + cy.wait("@getDashboard"); + cy.findByDisplayValue("Orders per year"); cy.get("main header").within(() => { diff --git a/frontend/test/metabase/scenarios/dashboard/reproductions/20637-add-series-to-dashcard.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/reproductions/20637-add-series-to-dashcard.cy.spec.js index 0473b8da55e2163240b282d7b563eb4a8d499589..2ab2ba779e159222cd58c98ec9c2948704dff1e8 100644 --- a/frontend/test/metabase/scenarios/dashboard/reproductions/20637-add-series-to-dashcard.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/reproductions/20637-add-series-to-dashcard.cy.spec.js @@ -1,4 +1,4 @@ -import { restore } from "__support__/e2e/helpers"; +import { restore, saveDashboard } from "__support__/e2e/helpers"; import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database"; @@ -34,16 +34,6 @@ describe("adding an additional series to a dashcard (metabase#20637)", () => { }); }); -function saveDashboard() { - cy.intercept("PUT", "/api/dashboard/*").as("updateDashboard"); - cy.intercept("PUT", "/api/dashboard/*/cards").as("updateDashCards"); - cy.intercept("GET", "/api/dashboard/*").as("loadDashboard"); - - cy.findByText("Save").click(); - - cy.wait(["@updateDashboard", "@updateDashCards", "@loadDashboard"]); -} - function createQuestionsAndDashboard() { const dashcardQuestion = { name: "20637 Question 1", diff --git a/frontend/test/metabase/scenarios/native/reproductions/18418-saved-question-db-appears-in-db-picker.cy.spec.js b/frontend/test/metabase/scenarios/native/reproductions/18418-saved-question-db-appears-in-db-picker.cy.spec.js index 1db23fe30c5bb3e0e06bb803403a0d103219bb06..70a33c11e129b1c3b345342348fd9fb16c37def5 100644 --- a/frontend/test/metabase/scenarios/native/reproductions/18418-saved-question-db-appears-in-db-picker.cy.spec.js +++ b/frontend/test/metabase/scenarios/native/reproductions/18418-saved-question-db-appears-in-db-picker.cy.spec.js @@ -32,7 +32,6 @@ describe("issue 18418", () => { // Clicking native question's database picker usually opens a popover with a list of databases // As default Cypress environment has only the sample database available, we expect no popup to appear - cy.findByTextEnsureVisible("Sample Database").click(); cy.get(POPOVER_ELEMENT).should("not.exist"); }); }); diff --git a/frontend/test/metabase/scenarios/question/notebook.cy.spec.js b/frontend/test/metabase/scenarios/question/notebook.cy.spec.js index 1e6ac7104ceb99e8b90f2fb1061f1e3f091b4568..ebc1d960c22e5dd4f46c1dd9612543f698f74814 100644 --- a/frontend/test/metabase/scenarios/question/notebook.cy.spec.js +++ b/frontend/test/metabase/scenarios/question/notebook.cy.spec.js @@ -434,6 +434,19 @@ describe("scenarios > question > notebook", () => { popover().contains("A_COLUMN"); popover().contains("No description"); }); + + it("should allow to pick a saved question when there are models", () => { + cy.createNativeQuestion({ + name: "Orders, Model", + dataset: true, + native: { query: "SELECT * FROM ORDERS" }, + }); + + startNewQuestion(); + cy.findByText("Saved Questions").click(); + cy.findByText("Orders, Count").click(); + visualize(); + }); }); function addSimpleCustomColumn(name) { diff --git a/frontend/test/metabase/scenarios/visualizations/line-bar-tooltips.cy.spec.js b/frontend/test/metabase/scenarios/visualizations/line-bar-tooltips.cy.spec.js index 50d99c09b2139600c91c9b41e3dc987a45bac6a3..48b1c64236ae8dc21cd394615fa48af338ba4dfb 100644 --- a/frontend/test/metabase/scenarios/visualizations/line-bar-tooltips.cy.spec.js +++ b/frontend/test/metabase/scenarios/visualizations/line-bar-tooltips.cy.spec.js @@ -1,4 +1,9 @@ -import { restore, popover, visitDashboard } from "__support__/e2e/helpers"; +import { + restore, + popover, + visitDashboard, + saveDashboard, +} from "__support__/e2e/helpers"; import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database"; @@ -490,5 +495,6 @@ function saveDashCardVisualizationOptions() { cy.get(".Modal").within(() => { cy.findByText("Done").click(); }); - cy.findByText("Save").click(); + + saveDashboard(); }