diff --git a/frontend/test/__support__/e2e/commands/api/composite/createNativeQuestionAndDashboard.js b/frontend/test/__support__/e2e/commands/api/composite/createNativeQuestionAndDashboard.js index ef37ad49cab4d59fdc85192b62a54ffbf1eb1d28..8c23032c877735b3c85716bd9f8480390e567000 100644 --- a/frontend/test/__support__/e2e/commands/api/composite/createNativeQuestionAndDashboard.js +++ b/frontend/test/__support__/e2e/commands/api/composite/createNativeQuestionAndDashboard.js @@ -1,9 +1,9 @@ Cypress.Commands.add( "createNativeQuestionAndDashboard", - ({ questionDetails, dashboardName = "Custom dashboard" } = {}) => { + ({ questionDetails, dashboardDetails } = {}) => { cy.createNativeQuestion(questionDetails).then( ({ body: { id: questionId } }) => { - cy.createDashboard(dashboardName).then( + cy.createDashboard(dashboardDetails).then( ({ body: { id: dashboardId } }) => { cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { cardId: questionId, diff --git a/frontend/test/__support__/e2e/commands/api/composite/createQuestionAndDashboard.js b/frontend/test/__support__/e2e/commands/api/composite/createQuestionAndDashboard.js index 78dfe145e0c9af79fdd05ea6140d618a74ee0cc6..6564a9648ad246a9dac5096e46c068711f8f5516 100644 --- a/frontend/test/__support__/e2e/commands/api/composite/createQuestionAndDashboard.js +++ b/frontend/test/__support__/e2e/commands/api/composite/createQuestionAndDashboard.js @@ -1,8 +1,8 @@ Cypress.Commands.add( "createQuestionAndDashboard", - ({ questionDetails, dashboardName = "Custom dashboard" } = {}) => { + ({ questionDetails, dashboardDetails } = {}) => { cy.createQuestion(questionDetails).then(({ body: { id: questionId } }) => { - cy.createDashboard(dashboardName).then( + cy.createDashboard(dashboardDetails).then( ({ body: { id: dashboardId } }) => { cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { cardId: questionId, diff --git a/frontend/test/__support__/e2e/commands/api/dashboard.js b/frontend/test/__support__/e2e/commands/api/dashboard.js index d696beb0b9d0f2115f4c8b0e5846b4f5435a597f..232f4b578a9a4435cffbbdfbb06cc888176ed663 100644 --- a/frontend/test/__support__/e2e/commands/api/dashboard.js +++ b/frontend/test/__support__/e2e/commands/api/dashboard.js @@ -1,11 +1,9 @@ Cypress.Commands.add( "createDashboard", - (name, { collection_position = null, collection_id = null } = {}) => { + ({ name = "Test Dashboard", ...dashboardDetails } = {}) => { cy.log(`Create a dashboard: ${name}`); - cy.request("POST", "/api/dashboard", { - name, - collection_position, - collection_id, - }); + + // For all the possible keys, refer to `src/metabase/api/dashboard.clj` + cy.request("POST", "/api/dashboard", { name, ...dashboardDetails }); }, ); diff --git a/frontend/test/metabase/scenarios/admin/audit/auditing.cy.spec.js b/frontend/test/metabase/scenarios/admin/audit/auditing.cy.spec.js index e895e9897b321413caf50cfe5b1053ca24e0fbca..7bb27f004c29c8ed4ab37f07a6e955352fe8a774 100644 --- a/frontend/test/metabase/scenarios/admin/audit/auditing.cy.spec.js +++ b/frontend/test/metabase/scenarios/admin/audit/auditing.cy.spec.js @@ -29,7 +29,7 @@ function generateQuestions(user) { } function generateDashboards(user) { - cy.createDashboard(`${user} dashboard`); + cy.createDashboard({ name: `${user} dashboard` }); } describeWithToken("audit > auditing", () => { diff --git a/frontend/test/metabase/scenarios/collections/collection-items-listing.cy.spec.js b/frontend/test/metabase/scenarios/collections/collection-items-listing.cy.spec.js index c1ac174dbc085172a9f589a9cd036dd030430fd9..88be801130528bd8f55d52a8442ffb52e16b9c5f 100644 --- a/frontend/test/metabase/scenarios/collections/collection-items-listing.cy.spec.js +++ b/frontend/test/metabase/scenarios/collections/collection-items-listing.cy.spec.js @@ -37,7 +37,9 @@ describe("scenarios > collection items listing", () => { }); }); - _.times(ADDED_DASHBOARDS, i => cy.createDashboard(`dashboard ${i}`)); + _.times(ADDED_DASHBOARDS, i => + cy.createDashboard({ name: `dashboard ${i}` }), + ); _.times(ADDED_QUESTIONS, i => cy.createQuestion({ name: `generated question ${i}`, @@ -99,7 +101,8 @@ describe("scenarios > collection items listing", () => { it(testName, () => { ["A", "B", "C"].forEach((letter, i) => { - cy.createDashboard(`${letter} Dashboard`, { + cy.createDashboard({ + name: `${letter} Dashboard`, collection_position: pinned ? i + 1 : null, }); @@ -213,9 +216,10 @@ describe("scenarios > collection items listing", () => { it("should allow to separately sort pinned and not pinned items", () => { ["A", "B", "C"].forEach((letter, i) => { - cy.createDashboard(`${letter} Dashboard`); + cy.createDashboard({ name: `${letter} Dashboard` }); - cy.createDashboard(`${letter} Dashboard (pinned)`, { + cy.createDashboard({ + name: `${letter} Dashboard (pinned)`, collection_position: i + 1, }); diff --git a/frontend/test/metabase/scenarios/collections/collection-types.cy.spec.js b/frontend/test/metabase/scenarios/collections/collection-types.cy.spec.js index 37df198762f88c1e1e068644d1f64a9e9969cdea..fbb51f46ee7773e1528fdbd527a72ee89eedc660 100644 --- a/frontend/test/metabase/scenarios/collections/collection-types.cy.spec.js +++ b/frontend/test/metabase/scenarios/collections/collection-types.cy.spec.js @@ -188,7 +188,10 @@ function testOfficialBadgePresence(expectBadge = true) { collection_id: collectionId, query: TEST_QUESTION_QUERY, }); - cy.createDashboard("Official Dashboard", { collection_id: collectionId }); + cy.createDashboard({ + name: "Official Dashboard", + collection_id: collectionId, + }); cy.visit(`/collection/${collectionId}`); }); @@ -247,7 +250,7 @@ function testOfficialQuestionBadgeInRegularDashboard(expectBadge = true) { collection_id: collectionId, query: TEST_QUESTION_QUERY, }, - dashboardName: "Regular Dashboard", + dashboardDetails: { name: "Regular Dashboard" }, }); }); diff --git a/frontend/test/metabase/scenarios/collections/collections.cy.spec.js b/frontend/test/metabase/scenarios/collections/collections.cy.spec.js index a1bfbcdfe6831fdcc8bf20f166a31583b577341d..d23493689e0c7f290cb0d280edd9ae813914446c 100644 --- a/frontend/test/metabase/scenarios/collections/collections.cy.spec.js +++ b/frontend/test/metabase/scenarios/collections/collections.cy.spec.js @@ -205,7 +205,7 @@ describe("scenarios > collection_defaults", () => { describe("a new dashboard", () => { it("should be in the root collection", () => { // Make new dashboard and check collection name - cy.createDashboard(dashboard_name); + cy.createDashboard({ name: dashboard_name }); cy.visit("/collection/root"); cy.findByText(dashboard_name); @@ -240,7 +240,7 @@ describe("scenarios > collection_defaults", () => { describe("a new dashboard", () => { it("should be in the root collection", () => { // Make new dashboard and check collection name - cy.createDashboard(dashboard_name); + cy.createDashboard({ name: dashboard_name }); cy.visit("/collection/root"); cy.findByText(dashboard_name); @@ -600,7 +600,7 @@ describe("scenarios > collection_defaults", () => { it("collections list on the home page shouldn't depend on the name of the first 50 objects (metabase#16784)", () => { // Although there are already some objects in the default snapshot (3 questions, 1 dashboard, 3 collections), // let's create 50 more dashboards with the letter of alphabet `D` coming before the first letter of the existing collection `F`. - _.times(50, i => cy.createDashboard(`Dashboard ${i}`)); + _.times(50, i => cy.createDashboard({ name: `Dashboard ${i}` })); cy.visit("/"); // There is already a collection named "First collection" in the default snapshot diff --git a/frontend/test/metabase/scenarios/collections/permissions.cy.spec.js b/frontend/test/metabase/scenarios/collections/permissions.cy.spec.js index 52294cee839fe54f39793a37f3ab41e1bfbba656..ddb64f8917b80f2627907f1f2a700660ecc164ab 100644 --- a/frontend/test/metabase/scenarios/collections/permissions.cy.spec.js +++ b/frontend/test/metabase/scenarios/collections/permissions.cy.spec.js @@ -595,7 +595,7 @@ describe("collection permissions", () => { it("shouldn't render revision history steps when there was no diff (metabase#1926)", () => { cy.signInAsAdmin(); - cy.createDashboard("foo").then(({ body }) => { + cy.createDashboard().then(({ body }) => { visitAndEditDashboard(body.id); }); diff --git a/frontend/test/metabase/scenarios/dashboard-filters/parameters.cy.spec.js b/frontend/test/metabase/scenarios/dashboard-filters/parameters.cy.spec.js index 5723236b2404a6e6b76782bd44c3208934cef85e..3cdd1b0e6935501144846216101da77efd50510c 100644 --- a/frontend/test/metabase/scenarios/dashboard-filters/parameters.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard-filters/parameters.cy.spec.js @@ -57,7 +57,7 @@ describe("scenarios > dashboard > parameters", () => { }); it("should search across multiple fields", () => { - cy.createDashboard("my dash"); + cy.createDashboard({ name: "my dash" }); cy.visit("/collection/root"); cy.findByText("my dash").click(); @@ -117,7 +117,7 @@ describe("scenarios > dashboard > parameters", () => { }); it("should query with a 2 argument parameter", () => { - cy.createDashboard("my dash"); + cy.createDashboard({ name: "my dash" }); cy.visit("/collection/root"); cy.findByText("my dash").click(); @@ -363,7 +363,7 @@ describe("scenarios > dashboard > parameters", () => { }, display: "scalar", }).then(({ body: { id: card_id } }) => { - cy.createDashboard("16181D").then(({ body: { id: dashboard_id } }) => { + cy.createDashboard().then(({ body: { id: dashboard_id } }) => { // Add previously created question to the dashboard cy.request("POST", `/api/dashboard/${dashboard_id}/cards`, { cardId: card_id, diff --git a/frontend/test/metabase/scenarios/dashboard/chained-filters.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/chained-filters.cy.spec.js index 8084671e9e63c6d792e10e0829a4f2ef050425cf..b95bd70013e325dabb184453c7979d784e92eb08 100644 --- a/frontend/test/metabase/scenarios/dashboard/chained-filters.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/chained-filters.cy.spec.js @@ -59,56 +59,58 @@ function createQuestion(options, callback) { // Once created, add the provided questionId to the dashboard and then // map the city/state filters to the template-tags in the native query. function createDashboard({ dashboardName, questionId }, callback) { - cy.createDashboard(dashboardName).then(({ body: { id: dashboardId } }) => { - cy.request("PUT", `/api/dashboard/${dashboardId}`, { - parameters: [ - { - name: "State", - slug: "state", - id: "e8f79be9", - type: "location/state", - }, - { - name: "City", - slug: "city", - id: "170b8e99", - type: "location/city", - filteringParameters: ["e8f79be9"], - }, - ], - }); - - cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { - cardId: questionId, - }).then(({ body: { id: dashCardId } }) => { - cy.request("PUT", `/api/dashboard/${dashboardId}/cards`, { - cards: [ + cy.createDashboard({ name: dashboardName }).then( + ({ body: { id: dashboardId } }) => { + cy.request("PUT", `/api/dashboard/${dashboardId}`, { + parameters: [ { - id: dashCardId, - card_id: questionId, - row: 0, - col: 0, - sizeX: 10, - sizeY: 10, - parameter_mappings: [ - { - parameter_id: "e8f79be9", - card_id: questionId, - target: ["dimension", ["template-tag", "state"]], - }, - { - parameter_id: "170b8e99", - card_id: questionId, - target: ["dimension", ["template-tag", "city"]], - }, - ], + name: "State", + slug: "state", + id: "e8f79be9", + type: "location/state", + }, + { + name: "City", + slug: "city", + id: "170b8e99", + type: "location/city", + filteringParameters: ["e8f79be9"], }, ], }); - callback(dashboardId); - }); - }); + cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { + cardId: questionId, + }).then(({ body: { id: dashCardId } }) => { + cy.request("PUT", `/api/dashboard/${dashboardId}/cards`, { + cards: [ + { + id: dashCardId, + card_id: questionId, + row: 0, + col: 0, + sizeX: 10, + sizeY: 10, + parameter_mappings: [ + { + parameter_id: "e8f79be9", + card_id: questionId, + target: ["dimension", ["template-tag", "state"]], + }, + { + parameter_id: "170b8e99", + card_id: questionId, + target: ["dimension", ["template-tag", "city"]], + }, + ], + }, + ], + }); + + callback(dashboardId); + }); + }, + ); } describe("scenarios > dashboard > chained filter", () => { @@ -264,7 +266,7 @@ describe("scenarios > dashboard > chained filter", () => { name: "15170", query: { "source-table": PRODUCTS_ID }, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("15170D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { // Add filter to the dashboard cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { parameters: [ diff --git a/frontend/test/metabase/scenarios/dashboard/click-behavior.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/click-behavior.cy.spec.js index 8c3cac35bf7319fb8d16a9dca8583b2cbc730f70..d9bfdd156225f679ce7630f377ffd108e70c25e2 100644 --- a/frontend/test/metabase/scenarios/dashboard/click-behavior.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/click-behavior.cy.spec.js @@ -25,7 +25,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => { }).then(({ body: { id: question1Id } }) => { cy.createNativeQuestion({ native: { query: "select 0" } }).then( ({ body: { id: nativeId } }) => { - cy.createDashboard("15993D").then(({ body: { id: dashboardId } }) => { + cy.createDashboard().then(({ body: { id: dashboardId } }) => { // Add native question to the dashboard cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { cardId: nativeId, diff --git a/frontend/test/metabase/scenarios/dashboard/dashboard-drill.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/dashboard-drill.cy.spec.js index 1d98e9bb3879c6eb73dbe6e5ce19086cc8d9a02f..7229ca8effabb712f6331f72405567bc7a4d9304 100644 --- a/frontend/test/metabase/scenarios/dashboard/dashboard-drill.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/dashboard-drill.cy.spec.js @@ -71,7 +71,7 @@ describe("scenarios > dashboard > dashboard drill", () => { "13927", `SELECT PEOPLE.STATE, PEOPLE.CITY from PEOPLE;`, ).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("13927D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { cy.log("Add question to the dashboard"); cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { @@ -407,7 +407,7 @@ describe("scenarios > dashboard > dashboard drill", () => { }, display: "bar", }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("13785D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { cy.log("Add filter to the dashboard"); cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { @@ -531,7 +531,7 @@ describe("scenarios > dashboard > dashboard drill", () => { name: "14919", query: { "source-table": PRODUCTS_ID }, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("14919D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { // Add previously added question to the dashboard cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { cardId: QUESTION_ID, @@ -605,7 +605,7 @@ describe("scenarios > dashboard > dashboard drill", () => { ], }, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("15331D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { // Add filter to the dashboard cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { parameters: [ @@ -687,7 +687,7 @@ describe("scenarios > dashboard > dashboard drill", () => { "graph.metrics": ["VALUE"], }, }).then(({ body: { id: QUESTION2_ID } }) => { - cy.createDashboard("15612D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { // Add the first question to the dashboard cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { cardId: QUESTION1_ID, @@ -752,7 +752,7 @@ describe("scenarios > dashboard > dashboard drill", () => { ], }, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("13289D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { // Add question to the dashboard cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { cardId: QUESTION_ID, @@ -919,45 +919,47 @@ function createDashboard( { dashboardName = "dashboard", questionId, visualization_settings }, callback, ) { - cy.createDashboard(dashboardName).then(({ body: { id: dashboardId } }) => { - cy.request("PUT", `/api/dashboard/${dashboardId}`, { - parameters: [ - { - name: "My Param", - slug: "my_param", - id: "e8f79be9", - type: "category", - }, - ], - }); - - cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { - cardId: questionId, - }).then(({ body: { id: dashCardId } }) => { - cy.request("PUT", `/api/dashboard/${dashboardId}/cards`, { - cards: [ + cy.createDashboard({ name: dashboardName }).then( + ({ body: { id: dashboardId } }) => { + cy.request("PUT", `/api/dashboard/${dashboardId}`, { + parameters: [ { - id: dashCardId, - card_id: questionId, - row: 0, - col: 0, - sizeX: 6, - sizeY: 6, - parameter_mappings: [ - { - parameter_id: "e8f79be9", - card_id: questionId, - target: ["dimension", ["field", 22, { "source-field": 11 }]], - }, - ], - visualization_settings, + name: "My Param", + slug: "my_param", + id: "e8f79be9", + type: "category", }, ], }); - callback(dashboardId); - }); - }); + cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { + cardId: questionId, + }).then(({ body: { id: dashCardId } }) => { + cy.request("PUT", `/api/dashboard/${dashboardId}/cards`, { + cards: [ + { + id: dashCardId, + card_id: questionId, + row: 0, + col: 0, + sizeX: 6, + sizeY: 6, + parameter_mappings: [ + { + parameter_id: "e8f79be9", + card_id: questionId, + target: ["dimension", ["field", 22, { "source-field": 11 }]], + }, + ], + visualization_settings, + }, + ], + }); + + callback(dashboardId); + }); + }, + ); } function setParamValue(paramName, text) { diff --git a/frontend/test/metabase/scenarios/dashboard/dashboard.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/dashboard.cy.spec.js index 4d35f4a91e7ffa8037994dc5f46ad42ce17da50d..62b0d99a61d15e0e65db357d1e84cfb550ca42c3 100644 --- a/frontend/test/metabase/scenarios/dashboard/dashboard.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/dashboard.cy.spec.js @@ -97,7 +97,7 @@ describe("scenarios > dashboard", () => { visualization_settings: {}, }); - cy.createDashboard("dash:11007"); + cy.createDashboard({ name: "dash:11007" }); cy.visit("/collection/root"); // enter newly created dashboard @@ -149,7 +149,7 @@ describe("scenarios > dashboard", () => { }, display: "map", }).then(({ body: { id: questionId } }) => { - cy.createDashboard("13597D").then(({ body: { id: dashboardId } }) => { + cy.createDashboard().then(({ body: { id: dashboardId } }) => { // add filter (ID) to the dashboard cy.request("PUT", `/api/dashboard/${dashboardId}`, { parameters: [ @@ -220,7 +220,7 @@ describe("scenarios > dashboard", () => { name: "14473", native: { query: "SELECT COUNT(*) FROM PRODUCTS", "template-tags": {} }, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("14473D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { cy.log("Add 4 filters to the dashboard"); cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { diff --git a/frontend/test/metabase/scenarios/dashboard/dashboard_local-only.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/dashboard_local-only.cy.spec.js index 8b50fdd7ea0edd1eb8df6705038d5508fee7b083..9b69a1f61bae54adbef654098ba432a955c2f045 100644 --- a/frontend/test/metabase/scenarios/dashboard/dashboard_local-only.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/dashboard_local-only.cy.spec.js @@ -28,7 +28,7 @@ describe("LOCAL TESTING ONLY > dashboard", () => { name: "15694", query: { "source-table": PEOPLE_ID }, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("15694D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { // Add filter to the dashboard cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { parameters: [ diff --git a/frontend/test/metabase/scenarios/dashboard/permissions.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/permissions.cy.spec.js index 1046b26b7663ad0d012a76f137759d3c5ec167b6..668ebc0b13965e9c8993b296d93080bda8a860dd 100644 --- a/frontend/test/metabase/scenarios/dashboard/permissions.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/permissions.cy.spec.js @@ -61,7 +61,7 @@ describe("scenarios > dashboard > permissions", () => { }).then(({ body: { id } }) => (secondQuestionId = id)); }); - cy.createDashboard("dashboard").then(({ body: { id: dashId } }) => { + cy.createDashboard().then(({ body: { id: dashId } }) => { cy.request("POST", `/api/dashboard/${dashId}/cards`, { cardId: firstQuestionId, }).then(({ body: { id: dashCardIdA } }) => { diff --git a/frontend/test/metabase/scenarios/dashboard/text-box.cy.spec.js b/frontend/test/metabase/scenarios/dashboard/text-box.cy.spec.js index f409c21369ebc8eeb1cbc1247cd5836d4b7561bf..3857cdb9248e6cefe3175df5773f07377ebac080 100644 --- a/frontend/test/metabase/scenarios/dashboard/text-box.cy.spec.js +++ b/frontend/test/metabase/scenarios/dashboard/text-box.cy.spec.js @@ -50,13 +50,15 @@ describe("scenarios > dashboard > text-box", () => { describe("when text-box is the only element on the dashboard", () => { beforeEach(() => { cy.server(); - cy.createDashboard("Test Dashboard"); + cy.createDashboard().then(({ body: { id } }) => { + cy.intercept("PUT", `/api/dashboard/${id}`).as("dashboardUpdated"); + + cy.visit(`/dashboard/${id}`); + }); }); // fixed in metabase#11358 it("should load after save/refresh (metabase#12873)", () => { - cy.visit(`/dashboard/2`); - cy.findByText("Test Dashboard"); cy.findByText("This dashboard is looking empty."); @@ -80,10 +82,6 @@ describe("scenarios > dashboard > text-box", () => { }); it("should have a scroll bar for long text (metabase#8333)", () => { - cy.intercept("PUT", "/api/dashboard/2").as("dashboardUpdated"); - - cy.visit(`/dashboard/2`); - addTextBox( "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", ); diff --git a/frontend/test/metabase/scenarios/native-filters/reproductions/15163.cy.spec.js b/frontend/test/metabase/scenarios/native-filters/reproductions/15163.cy.spec.js index bbd69a365c77e339e791d9f866b7c610055aeaf1..9796a41ddd96f667bb6fe590d0b9116a7ff3dc32 100644 --- a/frontend/test/metabase/scenarios/native-filters/reproductions/15163.cy.spec.js +++ b/frontend/test/metabase/scenarios/native-filters/reproductions/15163.cy.spec.js @@ -33,7 +33,7 @@ const dashboardFilter = { }; ["nodata+nosql", "nosql"].forEach(test => { - describe.skip("issue 14302", () => { + describe.skip("issue 15163", () => { beforeEach(() => { cy.intercept("POST", "/api/dataset").as("dataset"); @@ -41,7 +41,7 @@ const dashboardFilter = { cy.signInAsAdmin(); cy.createNativeQuestion(nativeQuery).then(({ body: { id: card_id } }) => { - cy.createDashboard("15163D").then(({ body: { id: dashboard_id } }) => { + cy.createDashboard().then(({ body: { id: dashboard_id } }) => { cy.addFilterToDashboard({ filter: dashboardFilter, dashboard_id }); // Add previously created question to the dashboard diff --git a/frontend/test/metabase/scenarios/question/filter.cy.spec.js b/frontend/test/metabase/scenarios/question/filter.cy.spec.js index c7d05d9a0f6f404d210ae97a17e0592bd44cd85d..ab67a3b5b17f909b98d754650a13f8f3c1553ed9 100644 --- a/frontend/test/metabase/scenarios/question/filter.cy.spec.js +++ b/frontend/test/metabase/scenarios/question/filter.cy.spec.js @@ -39,71 +39,69 @@ describe("scenarios > question > filter", () => { name: "Q2", query: { "source-table": `card__${Q1_ID}` }, }).then(({ body: { id: Q2_ID } }) => { - cy.createDashboard("12985D").then( - ({ body: { id: DASHBOARD_ID } }) => { - cy.log("Add 2 filters to the dashboard"); + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { + cy.log("Add 2 filters to the dashboard"); - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { - parameters: [ - { - name: "Date Filter", - slug: "date_filter", - id: "78d4ba0b", - type: "date/all-options", - }, - { - name: "Category", - slug: "category", - id: "20976cce", - type: "category", - }, - ], - }); + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { + parameters: [ + { + name: "Date Filter", + slug: "date_filter", + id: "78d4ba0b", + type: "date/all-options", + }, + { + name: "Category", + slug: "category", + id: "20976cce", + type: "category", + }, + ], + }); - cy.log("Add nested card to the dashboard"); + cy.log("Add nested card to the dashboard"); - cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cardId: Q2_ID, - }).then(({ body: { id: DASH_CARD_ID } }) => { - cy.log("Connect dashboard filters to the nested card"); + cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cardId: Q2_ID, + }).then(({ body: { id: DASH_CARD_ID } }) => { + cy.log("Connect dashboard filters to the nested card"); - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cards: [ - { - id: DASH_CARD_ID, - card_id: Q2_ID, - row: 0, - col: 0, - sizeX: 10, - sizeY: 8, - series: [], - visualization_settings: {}, - // Connect both filters and to the card - parameter_mappings: [ - { - parameter_id: "78d4ba0b", - card_id: Q2_ID, - target: [ - "dimension", - ["field", PRODUCTS.CREATED_AT, null], - ], - }, - { - parameter_id: "20976cce", - card_id: Q2_ID, - target: [ - "dimension", - ["field", PRODUCTS.CATEGORY, null], - ], - }, - ], - }, - ], - }); + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cards: [ + { + id: DASH_CARD_ID, + card_id: Q2_ID, + row: 0, + col: 0, + sizeX: 10, + sizeY: 8, + series: [], + visualization_settings: {}, + // Connect both filters and to the card + parameter_mappings: [ + { + parameter_id: "78d4ba0b", + card_id: Q2_ID, + target: [ + "dimension", + ["field", PRODUCTS.CREATED_AT, null], + ], + }, + { + parameter_id: "20976cce", + card_id: Q2_ID, + target: [ + "dimension", + ["field", PRODUCTS.CATEGORY, null], + ], + }, + ], + }, + ], }); - cy.visit(`/dashboard/${DASHBOARD_ID}`); - }, - ); + }); + cy.visit(`/dashboard/${DASHBOARD_ID}`); + }); }); }); @@ -133,57 +131,55 @@ describe("scenarios > question > filter", () => { filter: [">", ["field", "count", { "base-type": "type/Integer" }], 1], }, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("12985-v2D").then( - ({ body: { id: DASHBOARD_ID } }) => { - cy.log("Add a category filter to the dashboard"); + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { + cy.log("Add a category filter to the dashboard"); - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { - parameters: [ - { - name: "Category", - slug: "category", - id: "7c4htcv8", - type: "category", - }, - ], - }); + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { + parameters: [ + { + name: "Category", + slug: "category", + id: "7c4htcv8", + type: "category", + }, + ], + }); - cy.log("Add previously created question to the dashboard"); + cy.log("Add previously created question to the dashboard"); - cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cardId: QUESTION_ID, - }).then(({ body: { id: DASH_CARD_ID } }) => { - cy.log("Connect dashboard filter to the aggregated card"); + cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cardId: QUESTION_ID, + }).then(({ body: { id: DASH_CARD_ID } }) => { + cy.log("Connect dashboard filter to the aggregated card"); - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cards: [ - { - id: DASH_CARD_ID, - card_id: QUESTION_ID, - row: 0, - col: 0, - sizeX: 8, - sizeY: 6, - series: [], - visualization_settings: {}, - // Connect filter to the card - parameter_mappings: [ - { - parameter_id: "7c4htcv8", - card_id: QUESTION_ID, - target: [ - "dimension", - ["field", "CATEGORY", { "base-type": "type/Text" }], - ], - }, - ], - }, - ], - }); + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cards: [ + { + id: DASH_CARD_ID, + card_id: QUESTION_ID, + row: 0, + col: 0, + sizeX: 8, + sizeY: 6, + series: [], + visualization_settings: {}, + // Connect filter to the card + parameter_mappings: [ + { + parameter_id: "7c4htcv8", + card_id: QUESTION_ID, + target: [ + "dimension", + ["field", "CATEGORY", { "base-type": "type/Text" }], + ], + }, + ], + }, + ], }); - cy.visit(`/dashboard/${DASHBOARD_ID}`); - }, - ); + }); + cy.visit(`/dashboard/${DASHBOARD_ID}`); + }); }); cy.findByPlaceholderText("Category").click(); @@ -345,13 +341,12 @@ describe("scenarios > question > filter", () => { }, display: "pie", }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("13960D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { cy.log( "Add filters to the dashboard and set the default value to the first one", ); cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { - name: "13960D", parameters: [ { name: "Category", diff --git a/frontend/test/metabase/scenarios/question/nested.cy.spec.js b/frontend/test/metabase/scenarios/question/nested.cy.spec.js index a2f5463c8403cebd788f46186ee48177fb1d43ce..aa124aa9cc27523972a2efb585d082c5390b52ab 100644 --- a/frontend/test/metabase/scenarios/question/nested.cy.spec.js +++ b/frontend/test/metabase/scenarios/question/nested.cy.spec.js @@ -210,7 +210,7 @@ describe("scenarios > question > nested", () => { }, ); - cy.createDashboard("13186D").then(({ body: { id: DASBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASBOARD_ID } }) => { cy.visit(`/dashboard/${DASBOARD_ID}`); }); diff --git a/frontend/test/metabase/scenarios/question/nulls.cy.spec.js b/frontend/test/metabase/scenarios/question/nulls.cy.spec.js index ee86679e50305b02d7a1d86cdc6176acdf954aa9..959265effd8c8366f493b258e803b240962fa5f6 100644 --- a/frontend/test/metabase/scenarios/question/nulls.cy.spec.js +++ b/frontend/test/metabase/scenarios/question/nulls.cy.spec.js @@ -54,59 +54,61 @@ describe("scenarios > question > null", () => { display: "pie", }).then(({ body: { id: questionId } }) => { - cy.createDashboard("13626D").then(({ body: { id: dashboardId } }) => { - // add filter (ID) to the dashboard - cy.request("PUT", `/api/dashboard/${dashboardId}`, { - parameters: [ - { - id: "1f97c149", - name: "ID", - slug: "id", - type: "id", - }, - ], - }); - - // add previously created question to the dashboard - cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { - cardId: questionId, - }).then(({ body: { id: dashCardId } }) => { - // connect filter to that question - cy.request("PUT", `/api/dashboard/${dashboardId}/cards`, { - cards: [ + cy.createDashboard({ name: "13626D" }).then( + ({ body: { id: dashboardId } }) => { + // add filter (ID) to the dashboard + cy.request("PUT", `/api/dashboard/${dashboardId}`, { + parameters: [ { - id: dashCardId, - card_id: questionId, - row: 0, - col: 0, - sizeX: 8, - sizeY: 6, - parameter_mappings: [ - { - parameter_id: "1f97c149", - card_id: questionId, - target: ["dimension", ["field", ORDERS.ID, null]], - }, - ], + id: "1f97c149", + name: "ID", + slug: "id", + type: "id", }, ], }); - }); - // NOTE: The actual "Assertion" phase begins here - cy.visit(`/dashboard/${dashboardId}?id=1`); - cy.findByText("13626D"); - cy.log("Reported failing in v0.37.0.2"); - cy.get(".DashCard").within(() => { - cy.get(".LoadingSpinner").should("not.exist"); - cy.findByText("13626"); - // [quarantine]: flaking in CircleCI, passing locally - // TODO: figure out the cause of the failed test in CI after #13721 is merged - // cy.get("svg[class*=PieChart__Donut]"); - // cy.get("[class*=PieChart__Value]").contains("0"); - // cy.get("[class*=PieChart__Title]").contains(/total/i); - }); - }); + // add previously created question to the dashboard + cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { + cardId: questionId, + }).then(({ body: { id: dashCardId } }) => { + // connect filter to that question + cy.request("PUT", `/api/dashboard/${dashboardId}/cards`, { + cards: [ + { + id: dashCardId, + card_id: questionId, + row: 0, + col: 0, + sizeX: 8, + sizeY: 6, + parameter_mappings: [ + { + parameter_id: "1f97c149", + card_id: questionId, + target: ["dimension", ["field", ORDERS.ID, null]], + }, + ], + }, + ], + }); + }); + // NOTE: The actual "Assertion" phase begins here + cy.visit(`/dashboard/${dashboardId}?id=1`); + cy.findByText("13626D"); + + cy.log("Reported failing in v0.37.0.2"); + cy.get(".DashCard").within(() => { + cy.get(".LoadingSpinner").should("not.exist"); + cy.findByText("13626"); + // [quarantine]: flaking in CircleCI, passing locally + // TODO: figure out the cause of the failed test in CI after #13721 is merged + // cy.get("svg[class*=PieChart__Donut]"); + // cy.get("[class*=PieChart__Value]").contains("0"); + // cy.get("[class*=PieChart__Title]").contains(/total/i); + }); + }, + ); }); }); @@ -121,7 +123,7 @@ describe("scenarios > question > null", () => { native: { query: "SELECT 0", "template-tags": {} }, display: "scalar", }).then(({ body: { id: Q2_ID } }) => { - cy.createDashboard("13801D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { cy.log("Add both previously created questions to the dashboard"); [Q1_ID, Q2_ID].forEach((questionId, index) => { diff --git a/frontend/test/metabase/scenarios/question/view.cy.spec.js b/frontend/test/metabase/scenarios/question/view.cy.spec.js index a419669b2858f1df62aa19766a4b3a6fc7f5ec00..c7e2d7ee9fbd25ecfbe7f71938a223ba87467767 100644 --- a/frontend/test/metabase/scenarios/question/view.cy.spec.js +++ b/frontend/test/metabase/scenarios/question/view.cy.spec.js @@ -99,7 +99,7 @@ describe("scenarios > question > view", () => { cy.findByText("Yes").click(); // Native query saved in dasbhoard - cy.createDashboard("Dashboard"); + cy.createDashboard(); cy.createNativeQuestion({ name: "Question", diff --git a/frontend/test/metabase/scenarios/sharing/subscriptions.cy.spec.js b/frontend/test/metabase/scenarios/sharing/subscriptions.cy.spec.js index 139de41135ab12e66ad6839483cd0072dc9f8b26..5d1f607fd70b3ff3421de982f770a7f7cfbe61c7 100644 --- a/frontend/test/metabase/scenarios/sharing/subscriptions.cy.spec.js +++ b/frontend/test/metabase/scenarios/sharing/subscriptions.cy.spec.js @@ -15,7 +15,7 @@ describe("scenarios > dashboard > subscriptions", () => { }); it("should not allow sharing if there are no dashboard cards", () => { - cy.createDashboard("15077D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { cy.visit(`/dashboard/${DASHBOARD_ID}`); }); cy.findByText("This dashboard is looking empty."); @@ -31,7 +31,7 @@ describe("scenarios > dashboard > subscriptions", () => { }); it("should allow sharing if dashboard contains only text cards (metabase#15077)", () => { - cy.createDashboard("15077D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { cy.visit(`/dashboard/${DASHBOARD_ID}`); }); cy.icon("pencil").click(); @@ -162,48 +162,50 @@ describe("scenarios > dashboard > subscriptions", () => { }, }, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("15705D").then(({ body: { id: DASHBOARD_ID } }) => { - // Add filter to the dashboard - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { - // Using the old dashboard filter syntax - parameters: [ - { - name: "Quantity", - slug: "quantity", - id: "930e4001", - type: "category", - default: "20", - }, - ], - }); - - // Add question to the dashboard - cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cardId: QUESTION_ID, - }).then(({ body: { id: DASH_CARD_ID } }) => { - // Connect filter to that question - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cards: [ + cy.createDashboard({ name: "15705D" }).then( + ({ body: { id: DASHBOARD_ID } }) => { + // Add filter to the dashboard + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { + // Using the old dashboard filter syntax + parameters: [ { - id: DASH_CARD_ID, - card_id: QUESTION_ID, - row: 0, - col: 0, - sizeX: 12, - sizeY: 10, - parameter_mappings: [ - { - parameter_id: "930e4001", - card_id: QUESTION_ID, - target: ["variable", ["template-tag", "qty"]], - }, - ], + name: "Quantity", + slug: "quantity", + id: "930e4001", + type: "category", + default: "20", }, ], }); - }); - assignRecipient({ dashboard_id: DASHBOARD_ID }); - }); + + // Add question to the dashboard + cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cardId: QUESTION_ID, + }).then(({ body: { id: DASH_CARD_ID } }) => { + // Connect filter to that question + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cards: [ + { + id: DASH_CARD_ID, + card_id: QUESTION_ID, + row: 0, + col: 0, + sizeX: 12, + sizeY: 10, + parameter_mappings: [ + { + parameter_id: "930e4001", + card_id: QUESTION_ID, + target: ["variable", ["template-tag", "qty"]], + }, + ], + }, + ], + }); + }); + assignRecipient({ dashboard_id: DASHBOARD_ID }); + }, + ); }); // Click anywhere outside to close the popover cy.findByText("15705D").click(); diff --git a/frontend/test/metabase/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js b/frontend/test/metabase/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js index dcd6eed72fb95624ef52b0bf209035010a2bbb92..58273f3a4abd4929930c79d7dc4320b67a422166 100644 --- a/frontend/test/metabase/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js +++ b/frontend/test/metabase/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js @@ -91,60 +91,62 @@ describe("scenarios > visualizations > drillthroughs > chart drill", () => { }, display: "line", }).then(({ body: { id: Q2_ID } }) => { - cy.createDashboard("11442D").then(({ body: { id: DASHBOARD_ID } }) => { - cy.log("Add the first question to the dashboard"); - - cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cardId: Q1_ID, - }).then(({ body: { id: DASH_CARD_ID } }) => { - cy.log( - "Add additional series combining it with the second question", - ); - - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cards: [ - { - id: DASH_CARD_ID, - card_id: Q1_ID, - row: 0, - col: 0, - sizeX: 16, - sizeY: 12, - series: [ - { - id: Q2_ID, - model: "card", - }, - ], - visualization_settings: {}, - parameter_mappings: [], - }, - ], + cy.createDashboard({ name: "11442D" }).then( + ({ body: { id: DASHBOARD_ID } }) => { + cy.log("Add the first question to the dashboard"); + + cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cardId: Q1_ID, + }).then(({ body: { id: DASH_CARD_ID } }) => { + cy.log( + "Add additional series combining it with the second question", + ); + + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cards: [ + { + id: DASH_CARD_ID, + card_id: Q1_ID, + row: 0, + col: 0, + sizeX: 16, + sizeY: 12, + series: [ + { + id: Q2_ID, + model: "card", + }, + ], + visualization_settings: {}, + parameter_mappings: [], + }, + ], + }); }); - }); - cy.visit(`/dashboard/${DASHBOARD_ID}`); - - cy.log("The first series line"); - cy.get(".sub.enable-dots._0") - .find(".dot") - .eq(0) - .click({ force: true }); - cy.findByText(/Zoom in/i); - cy.findByText(/View these Orders/i); - - // Click anywhere else to close the first action panel - cy.findByText("11442D").click(); - - // Second line from the second question - cy.log("The second series line"); - cy.get(".sub.enable-dots._1") - .find(".dot") - .eq(0) - .click({ force: true }); - cy.findByText(/Zoom in/i); - cy.findByText(/View these Products/i); - }); + cy.visit(`/dashboard/${DASHBOARD_ID}`); + + cy.log("The first series line"); + cy.get(".sub.enable-dots._0") + .find(".dot") + .eq(0) + .click({ force: true }); + cy.findByText(/Zoom in/i); + cy.findByText(/View these Orders/i); + + // Click anywhere else to close the first action panel + cy.findByText("11442D").click(); + + // Second line from the second question + cy.log("The second series line"); + cy.get(".sub.enable-dots._1") + .find(".dot") + .eq(0) + .click({ force: true }); + cy.findByText(/Zoom in/i); + cy.findByText(/View these Products/i); + }, + ); }); }); }); @@ -171,60 +173,62 @@ describe("scenarios > visualizations > drillthroughs > chart drill", () => { }, display: "line", }).then(({ body: { id: Q2_ID } }) => { - cy.createDashboard("13457D").then(({ body: { id: DASHBOARD_ID } }) => { - cy.log("Add the first question to the dashboard"); - - cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cardId: Q1_ID, - }).then(({ body: { id: DASH_CARD_ID } }) => { - cy.log( - "Add additional series combining it with the second question", - ); - - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cards: [ - { - id: DASH_CARD_ID, - card_id: Q1_ID, - row: 0, - col: 0, - sizeX: 16, - sizeY: 12, - series: [ - { - id: Q2_ID, - model: "card", - }, - ], - visualization_settings: {}, - parameter_mappings: [], - }, - ], + cy.createDashboard({ name: "13457D" }).then( + ({ body: { id: DASHBOARD_ID } }) => { + cy.log("Add the first question to the dashboard"); + + cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cardId: Q1_ID, + }).then(({ body: { id: DASH_CARD_ID } }) => { + cy.log( + "Add additional series combining it with the second question", + ); + + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cards: [ + { + id: DASH_CARD_ID, + card_id: Q1_ID, + row: 0, + col: 0, + sizeX: 16, + sizeY: 12, + series: [ + { + id: Q2_ID, + model: "card", + }, + ], + visualization_settings: {}, + parameter_mappings: [], + }, + ], + }); }); - }); - cy.visit(`/dashboard/${DASHBOARD_ID}`); - - cy.log("The first series line"); - cy.get(".sub.enable-dots._0") - .find(".dot") - .eq(0) - .click({ force: true }); - cy.findByText(/Zoom in/i); - cy.findByText(/View these Orders/i); - - // Click anywhere else to close the first action panel - cy.findByText("13457D").click(); - - // Second line from the second question - cy.log("The third series line"); - cy.get(".sub.enable-dots._2") - .find(".dot") - .eq(0) - .click({ force: true }); - cy.findByText(/Zoom in/i); - cy.findByText(/View these Orders/i); - }); + cy.visit(`/dashboard/${DASHBOARD_ID}`); + + cy.log("The first series line"); + cy.get(".sub.enable-dots._0") + .find(".dot") + .eq(0) + .click({ force: true }); + cy.findByText(/Zoom in/i); + cy.findByText(/View these Orders/i); + + // Click anywhere else to close the first action panel + cy.findByText("13457D").click(); + + // Second line from the second question + cy.log("The third series line"); + cy.get(".sub.enable-dots._2") + .find(".dot") + .eq(0) + .click({ force: true }); + cy.findByText(/Zoom in/i); + cy.findByText(/View these Orders/i); + }, + ); }); }); }); @@ -532,7 +536,7 @@ describe("scenarios > visualizations > drillthroughs > chart drill", () => { }, display: "pie", }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("15250D").then(({ body: { id: DASHBOARD_ID } }) => { + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { cardId: QUESTION_ID, }).then(({ body: { id: DASH_CARD_ID } }) => { diff --git a/frontend/test/metabase/scenarios/visualizations/drillthroughs/dash_drill.cy.spec.js b/frontend/test/metabase/scenarios/visualizations/drillthroughs/dash_drill.cy.spec.js index dd66fc3c6a1fb0b0ecdd1353b1ae6fc86009012d..5a46f7e4179c256dcdf61e06f4c6acdf26f964b0 100644 --- a/frontend/test/metabase/scenarios/visualizations/drillthroughs/dash_drill.cy.spec.js +++ b/frontend/test/metabase/scenarios/visualizations/drillthroughs/dash_drill.cy.spec.js @@ -88,7 +88,7 @@ describe("scenarios > visualizations > drillthroughs > dash_drill", () => { }, display: "line", }).then(({ body: { id: CARD_ID } }) => { - cy.createDashboard(DASHBOARD_NAME).then( + cy.createDashboard({ name: DASHBOARD_NAME }).then( ({ body: { id: DASHBOARD_ID } }) => { // Prepare to wait for this specific XHR: // We need to do this because Cypress sees the string that is "card title" before card is fully rendered. @@ -139,68 +139,64 @@ describe("scenarios > visualizations > drillthroughs > dash_drill", () => { ], }, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard("13415D").then( - ({ body: { id: DASHBOARD_ID } }) => { - cy.log("Add filter with the default value to the dashboard"); + cy.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => { + cy.log("Add filter with the default value to the dashboard"); + + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { + parameters: [ + { + id: "91bace6e", + name: "Category", + slug: "category", + type: "category", + default: ["Doohickey"], + }, + ], + }); + + cy.log("Add previously created question to the dashboard"); + + cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cardId: QUESTION_ID, + }).then(({ body: { id: DASH_CARD_ID } }) => { + cy.log("Connect filter to that question"); - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}`, { - parameters: [ + cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cards: [ { - id: "91bace6e", - name: "Category", - slug: "category", - type: "category", - default: ["Doohickey"], + id: DASH_CARD_ID, + card_id: QUESTION_ID, + row: 0, + col: 0, + sizeX: 10, + sizeY: 8, + parameter_mappings: [ + { + parameter_id: "91bace6e", + card_id: QUESTION_ID, + target: [ + "dimension", + ["field", PRODUCTS.CATEGORY, null], + ], + }, + ], }, ], }); + }); + cy.server(); + cy.route("POST", `/api/card/${QUESTION_ID}/query`).as("cardQuery"); + cy.route("POST", `/api/dataset`).as("dataset"); - cy.log("Add previously created question to the dashboard"); + cy.visit(`/dashboard/${DASHBOARD_ID}`); - cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cardId: QUESTION_ID, - }).then(({ body: { id: DASH_CARD_ID } }) => { - cy.log("Connect filter to that question"); - - cy.request("PUT", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cards: [ - { - id: DASH_CARD_ID, - card_id: QUESTION_ID, - row: 0, - col: 0, - sizeX: 10, - sizeY: 8, - parameter_mappings: [ - { - parameter_id: "91bace6e", - card_id: QUESTION_ID, - target: [ - "dimension", - ["field", PRODUCTS.CATEGORY, null], - ], - }, - ], - }, - ], - }); - }); - cy.server(); - cy.route("POST", `/api/card/${QUESTION_ID}/query`).as( - "cardQuery", - ); - cy.route("POST", `/api/dataset`).as("dataset"); + cy.wait("@cardQuery"); + cy.findByText(QUESTION_NAME).click(); - cy.visit(`/dashboard/${DASHBOARD_ID}`); - - cy.wait("@cardQuery"); - cy.findByText(QUESTION_NAME).click(); - - cy.wait("@dataset"); - cy.findByText("Category is Doohickey"); - cy.findByText("177"); // Doohickeys for 2016 - }, - ); + cy.wait("@dataset"); + cy.findByText("Category is Doohickey"); + cy.findByText("177"); // Doohickeys for 2016 + }); }); }); }); @@ -216,14 +212,16 @@ function clickScalarCardTitle(card_name) { } function addCardToNewDashboard(dashboard_name, card_id) { - cy.createDashboard(dashboard_name).then(({ body: { id: DASHBOARD_ID } }) => { - // Add a card to it (with predefined size 6,4 simply for readability) - cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { - cardId: card_id, - sizeX: 6, - sizeY: 4, - }); - // Visit newly created dashboard - cy.visit(`/dashboard/${DASHBOARD_ID}`); - }); + cy.createDashboard({ name: dashboard_name }).then( + ({ body: { id: DASHBOARD_ID } }) => { + // Add a card to it (with predefined size 6,4 simply for readability) + cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { + cardId: card_id, + sizeX: 6, + sizeY: 4, + }); + // Visit newly created dashboard + cy.visit(`/dashboard/${DASHBOARD_ID}`); + }, + ); } diff --git a/frontend/test/metabase/scenarios/visualizations/line_chart.cy.spec.js b/frontend/test/metabase/scenarios/visualizations/line_chart.cy.spec.js index 28eb836adc8e3698b6ee9cacec637bd33f9cabb4..65c7ceb8321dedea20aea292b7e02583d5bdb7c6 100644 --- a/frontend/test/metabase/scenarios/visualizations/line_chart.cy.spec.js +++ b/frontend/test/metabase/scenarios/visualizations/line_chart.cy.spec.js @@ -196,7 +196,7 @@ describe("scenarios > visualizations > line chart", () => { ], ], }).then(({ body: { id: question2Id } }) => { - cy.createDashboard("16249D").then(({ body: { id: dashboardId } }) => { + cy.createDashboard().then(({ body: { id: dashboardId } }) => { addBothSeriesToDashboard({ dashboardId, firstCardId: question1Id, @@ -245,7 +245,7 @@ describe("scenarios > visualizations > line chart", () => { }, display: "line", }).then(({ body: { id: question2Id } }) => { - cy.createDashboard("16249D").then(({ body: { id: dashboardId } }) => { + cy.createDashboard().then(({ body: { id: dashboardId } }) => { addBothSeriesToDashboard({ dashboardId, firstCardId: question1Id, diff --git a/frontend/test/metabase/scenarios/visualizations/pivot_tables.cy.spec.js b/frontend/test/metabase/scenarios/visualizations/pivot_tables.cy.spec.js index b2219b6b38a9c052e953910f7a2206d9092054b1..c3a2e97c21ca84e7a70d1c2d9cea49d9a76ddb2b 100644 --- a/frontend/test/metabase/scenarios/visualizations/pivot_tables.cy.spec.js +++ b/frontend/test/metabase/scenarios/visualizations/pivot_tables.cy.spec.js @@ -527,7 +527,7 @@ describe("scenarios > visualizations > pivot tables", () => { display: "pivot", visualization_settings: {}, }).then(({ body: { id: QUESTION_ID } }) => { - cy.createDashboard(DASHBOARD_NAME).then( + cy.createDashboard({ name: DASHBOARD_NAME }).then( ({ body: { id: DASHBOARD_ID } }) => { cy.log("Add previously created question to that dashboard"); cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { @@ -587,7 +587,7 @@ describe("scenarios > visualizations > pivot tables", () => { enable_embedding: true, }); - cy.createDashboard(DASHBOARD_NAME).then( + cy.createDashboard({ name: DASHBOARD_NAME }).then( ({ body: { id: DASHBOARD_ID } }) => { cy.log("Add previously created question to that dashboard"); cy.request("POST", `/api/dashboard/${DASHBOARD_ID}/cards`, { diff --git a/frontend/test/metabase/scenarios/visualizations/scalar.cy.spec.js b/frontend/test/metabase/scenarios/visualizations/scalar.cy.spec.js index 6c745fe207638863ea8636419237ff46d2487882..861b36269f507e62afb81a9c7401bfab68c258f7 100644 --- a/frontend/test/metabase/scenarios/visualizations/scalar.cy.spec.js +++ b/frontend/test/metabase/scenarios/visualizations/scalar.cy.spec.js @@ -17,7 +17,7 @@ describe("scenarios > visualizations > scalar", () => { }; Object.entries(SCREEN_SIZES).forEach(([size, viewport]) => { - it(`should render human readable numbers on ${size} screen size (metabase#12629)`, () => { + it(`should render human readable numbers on ${size} screen size (metabase`, () => { const [width, height] = viewport; cy.skipOn(size === "mobile"); @@ -31,7 +31,7 @@ describe("scenarios > visualizations > scalar", () => { }, display: "scalar", }).then(({ body: { id: questionId } }) => { - cy.createDashboard("12629").then(({ body: { id: dashboardId } }) => { + cy.createDashboard().then(({ body: { id: dashboardId } }) => { // Add previously created question to the dashboard cy.request("POST", `/api/dashboard/${dashboardId}/cards`, { cardId: questionId, diff --git a/frontend/test/snapshot-creators/default.cy.snap.js b/frontend/test/snapshot-creators/default.cy.snap.js index 9d106baa0b8b708ffe5ac352d26ab11117df7264..c7091a35547bb69367266fa8556496aa9d629d5c 100644 --- a/frontend/test/snapshot-creators/default.cy.snap.js +++ b/frontend/test/snapshot-creators/default.cy.snap.js @@ -152,7 +152,7 @@ describe("snapshots", () => { }); // dashboard 1: Orders in a dashboard - cy.createDashboard("Orders in a dashboard"); + cy.createDashboard({ name: "Orders in a dashboard" }); cy.request("POST", `/api/dashboard/1/cards`, { cardId: 1 }).then( ({ body: { id: dashCardId } }) => { cy.request("PUT", `/api/dashboard/1/cards`, {