Skip to content

Commit

Permalink
Add "remapped" version of the repro for metabase#14724 (metabase#14738)
Browse files Browse the repository at this point in the history
* Run repro for metabase#14724 in 2 versions: "remapped" and "default"

* Use helper function for value remapping
  • Loading branch information
nemanjaglumac authored Feb 10, 2021
1 parent bc1d034 commit 9193319
Showing 1 changed file with 51 additions and 39 deletions.
90 changes: 51 additions & 39 deletions frontend/test/metabase/scenarios/question/nested.cy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
popover,
createNativeQuestion,
openOrdersTable,
remapDisplayValueToFK,
} from "__support__/cypress";

import { SAMPLE_DATASET } from "__support__/cypress_sample_dataset";
Expand Down Expand Up @@ -335,11 +336,10 @@ describe("scenarios > question > nested", () => {
cy.route("POST", "/api/dataset").as("dataset");

cy.log("**-- 1. Remap Product ID's display value to `title` --**");
cy.request("POST", `/api/field/${ORDERS.PRODUCT_ID}/dimension`, {
field_id: ORDERS.PRODUCT_ID,
remapDisplayValueToFK({
display_value: ORDERS.PRODUCT_ID,
name: "Product ID",
human_readable_field_id: PRODUCTS.TITLE,
type: "external",
fk: PRODUCTS.TITLE,
});

cy.log("**-- 2. Save simple 'Orders' table with remapped values --**");
Expand All @@ -366,46 +366,58 @@ describe("scenarios > question > nested", () => {
cy.findAllByText("Awesome Concrete Shoes");
});

it("should use question with joins as a base for a new question (metabase#14724)", () => {
const QUESTION_NAME = "14724";
["remapped", "default"].forEach(test => {
it(`${test.toUpperCase()} version:\n should use question with joins as a base for a new question (metabase#14724)`, () => {
const QUESTION_NAME = "14724";

if (test === "remapped") {
cy.state("runnable").skip(); // Unskip or remove this line when "remapped" version of the issue is fixed
cy.log("**-- Remap Product ID's display value to `title` --**");
remapDisplayValueToFK({
display_value: ORDERS.PRODUCT_ID,
name: "Product ID",
fk: PRODUCTS.TITLE,
});
}

cy.server();
cy.route("POST", "/api/dataset").as("dataset");
cy.server();
cy.route("POST", "/api/dataset").as("dataset");

cy.request("POST", "/api/card", {
name: QUESTION_NAME,
dataset_query: {
type: "query",
query: {
"source-table": ORDERS_ID,
joins: [
{
fields: "all",
"source-table": PRODUCTS_ID,
condition: [
"=",
["field-id", ORDERS.PRODUCT_ID],
["joined-field", "Products", ["field-id", PRODUCTS.ID]],
],
alias: "Products",
},
],
cy.request("POST", "/api/card", {
name: QUESTION_NAME,
dataset_query: {
type: "query",
query: {
"source-table": ORDERS_ID,
joins: [
{
fields: "all",
"source-table": PRODUCTS_ID,
condition: [
"=",
["field-id", ORDERS.PRODUCT_ID],
["joined-field", "Products", ["field-id", PRODUCTS.ID]],
],
alias: "Products",
},
],
},
database: 1,
},
database: 1,
},
display: "table",
visualization_settings: {},
});
display: "table",
visualization_settings: {},
});

// Start new question from a saved one
cy.visit("/question/new");
cy.findByText("Simple question").click();
cy.findByText("Saved Questions").click();
cy.findByText(QUESTION_NAME).click();
// Start new question from a saved one
cy.visit("/question/new");
cy.findByText("Simple question").click();
cy.findByText("Saved Questions").click();
cy.findByText(QUESTION_NAME).click();

cy.wait("@dataset").then(xhr => {
expect(xhr.response.body.error).not.to.exist;
cy.wait("@dataset").then(xhr => {
expect(xhr.response.body.error).not.to.exist;
});
cy.contains("37.65");
});
cy.contains("37.65");
});
});

0 comments on commit 9193319

Please sign in to comment.