diff --git a/frontend/test/metabase/scenarios/question/reproductions/24839-summarize-source-question-with-summarization.cy.spec.js b/frontend/test/metabase/scenarios/question/reproductions/24839-summarize-source-question-with-summarization.cy.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..bfcf68b3d04537c7dcbc448c1cbf22a9b5dea699 --- /dev/null +++ b/frontend/test/metabase/scenarios/question/reproductions/24839-summarize-source-question-with-summarization.cy.spec.js @@ -0,0 +1,57 @@ +import { restore, visitQuestionAdhoc, popover } from "__support__/e2e/helpers"; +import { SAMPLE_DB_ID } from "__support__/e2e/cypress_data"; +import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database"; + +const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE; + +const questionDetails = { + name: "24839", + query: { + "source-table": ORDERS_ID, + aggregation: [ + ["sum", ["field", ORDERS.QUANTITY, null]], + ["avg", ["field", ORDERS.TOTAL, null]], + ], + breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]], + }, + display: "line", +}; + +describe("issue 24839: should be able to summarize a nested question based on the source question with aggregations (metabase#24839)", () => { + beforeEach(() => { + restore(); + cy.signInAsAdmin(); + + cy.createQuestion(questionDetails).then(({ body: { id } }) => { + // Start ad-hoc nested question based on the saved one + visitQuestionAdhoc({ + dataset_query: { + database: SAMPLE_DB_ID, + query: { "source-table": `card__${id}` }, + type: "query", + }, + }); + }); + }); + + it.skip("from the notebook GUI (metabase#24839-1)", () => { + cy.icon("notebook").click(); + cy.findByText("Summarize").click(); + cy.findByText("Sum of ...").click(); + popover() + .should("contain", "Sum of Quantity") + .and("contain", "Average of Total"); + }); + + it("from a table header cell (metabase#24839-2)", () => { + cy.findAllByTestId("header-cell").contains("Average of Total").click(); + + popover().contains("Distinct values").click(); + + cy.get(".ScalarValue").invoke("text").should("eq", "49"); + + cy.findByTestId("aggregation-item") + .invoke("text") + .should("eq", "Distinct values of Average of Total"); + }); +});