Skip to content
Snippets Groups Projects
Unverified Commit 8f335c42 authored by Anton Kulyk's avatar Anton Kulyk Committed by GitHub
Browse files

Fix row limit not set properly for notebook preview queries (#30105)

* Add repro test

* Fix limit was not properly set for preview queries
parent 4fb54055
No related branches found
No related tags found
No related merge requests found
......@@ -552,17 +552,35 @@ describe("scenarios > question > notebook", () => {
});
});
it("should properly render previews (metabase#28726)", () => {
it("should properly render previews (metabase#28726), (metabase#29959)", () => {
openOrdersTable({ mode: "notebook" });
cy.findByTestId("step-data-0-0").within(() => {
cy.icon("play").click();
assertTableRowCount(10);
cy.findByTextEnsureVisible("Subtotal");
cy.findByTextEnsureVisible("Tax");
cy.findByTextEnsureVisible("Total");
cy.icon("close").click();
});
cy.button("Row limit").click();
cy.findByTestId("step-limit-0-0").within(() => {
cy.findByPlaceholderText("Enter a limit").type("5");
cy.icon("play").click();
assertTableRowCount(5);
cy.findByDisplayValue("5").type("{selectall}50");
cy.button("Refresh").click();
assertTableRowCount(10);
});
});
});
function assertTableRowCount(expectedCount) {
cy.get(".Table-ID:not(.Table-FK)").should("have.length", expectedCount);
}
function addSimpleCustomColumn(name) {
enterCustomColumnDetails({ formula: "C" });
cy.findByText("ategory").click();
......
......@@ -38,8 +38,9 @@ class NotebookStepPreview extends React.Component {
getPreviewQuestion(step) {
const query = step.previewQuery;
const hasSuitableLimit = query.hasLimit() && query.limit() < 10;
return Question.create()
.setQuery(query.limit() < 10 ? query : query.updateLimit(10))
.setQuery(hasSuitableLimit ? query : query.updateLimit(10))
.setDisplay("table")
.setSettings({ "table.pivot": false });
}
......
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