From 66c07b56594460587a6ba19caed1c92793a4ae96 Mon Sep 17 00:00:00 2001 From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com> Date: Tue, 23 Aug 2022 19:14:10 +0200 Subject: [PATCH] [E2E] Fix/update `createNestedQuestion` helper (#24929) * [E2E] Fix/update `createNestedQuestion` helper * Handle undefined values * Slightly speed 14787 up --- .../scenarios/question/nested.cy.spec.js | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/frontend/test/metabase/scenarios/question/nested.cy.spec.js b/frontend/test/metabase/scenarios/question/nested.cy.spec.js index 185aaa25ac7..a0800e27579 100644 --- a/frontend/test/metabase/scenarios/question/nested.cy.spec.js +++ b/frontend/test/metabase/scenarios/question/nested.cy.spec.js @@ -185,7 +185,9 @@ describe("scenarios > question > nested", () => { }; const nestedQuestionDetails = { - filter: [">", ["field", ORDERS.TOTAL, null], 50], + query: { + filter: [">", ["field", ORDERS.TOTAL, null], 50], + }, }; // Create new question which uses previously defined metric @@ -255,7 +257,7 @@ describe("scenarios > question > nested", () => { const baseQuestionDetails = { name: "14787", - query: ordersJoinProductsQuery, + query: { ...ordersJoinProductsQuery, limit: 5 }, }; createNestedQuestion({ baseQuestionDetails }); @@ -553,26 +555,32 @@ describe("scenarios > question > nested", () => { }); function createNestedQuestion( - { baseQuestionDetails, nestedQuestionDetails }, + { baseQuestionDetails, nestedQuestionDetails = {} }, { loadBaseQuestionMetadata = false, visitNestedQuestion = true } = {}, ) { + if (!baseQuestionDetails) { + throw new Error("Please provide the base question details"); + } + createBaseQuestion(baseQuestionDetails).then(({ body: { id } }) => { loadBaseQuestionMetadata && visitQuestion(id); - return cy.createQuestion( - { - name: "Nested Question", - query: { - "source-table": `card__${id}`, - }, - ...nestedQuestionDetails, - }, - { - visitQuestion: visitNestedQuestion, - wrapId: true, - idAlias: "nestedQuestionId", + const { query: nestedQuery, ...details } = nestedQuestionDetails; + + const composite = { + name: "Nested Question", + query: { + ...nestedQuery, + "source-table": `card__${id}`, }, - ); + ...details, + }; + + return cy.createQuestion(composite, { + visitQuestion: visitNestedQuestion, + wrapId: true, + idAlias: "nestedQuestionId", + }); }); function createBaseQuestion(query) { -- GitLab