diff --git a/frontend/test/metabase/scenarios/admin/datamodel/table.cy.spec.js b/frontend/test/metabase/scenarios/admin/datamodel/table.cy.spec.js index 7121556979b40..164b3a9a48773 100644 --- a/frontend/test/metabase/scenarios/admin/datamodel/table.cy.spec.js +++ b/frontend/test/metabase/scenarios/admin/datamodel/table.cy.spec.js @@ -1,4 +1,7 @@ import { restore } from "__support__/e2e/cypress"; +import { SAMPLE_DATASET } from "__support__/e2e/cypress_sample_dataset"; + +const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATASET; describe("scenarios > admin > databases > table", () => { beforeEach(() => { @@ -53,4 +56,58 @@ describe("scenarios > admin > databases > table", () => { cy.findByText("Creation timestamp"); }); }); + + describe.skip("turning table visibility off shouldn't prevent editing related question (metabase#15947)", () => { + it("simple question (metabase#15947-1)", () => { + turnTableVisibilityOff(ORDERS_ID); + cy.visit("/question/1"); + cy.findByText("Filter"); + }); + + it("question with joins (metabase#15947-2)", () => { + cy.createQuestion({ + name: "15947", + query: { + "source-table": ORDERS_ID, + joins: [ + { + fields: "all", + "source-table": PRODUCTS_ID, + condition: [ + "=", + ["field", ORDERS.PRODUCT_ID, null], + ["field", PRODUCTS.ID, { "join-alias": "Products" }], + ], + alias: "Products", + }, + ], + filter: [ + "and", + ["=", ["field", ORDERS.QUANTITY, null], 1], + [">", ["field", PRODUCTS.RATING, { "join-alias": "Products" }], 3], + ], + aggregation: [ + ["sum", ["field", ORDERS.TOTAL, null]], + ["sum", ["field", PRODUCTS.RATING, { "join-alias": "Products" }]], + ], + breakout: [ + ["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }], + ["field", PRODUCTS.CATEGORY, { "join-alias": "Products" }], + ], + }, + }).then(({ body: { id: QUESTION_ID } }) => { + turnTableVisibilityOff(PRODUCTS_ID); + cy.visit(`/question/${QUESTION_ID}/notebook`); + cy.findByText("Quantity is equal to 1"); + cy.findByText("Rating is greater than 3"); + }); + }); + }); }); + +function turnTableVisibilityOff(table_id) { + cy.request("PUT", "/api/table", { + ids: [table_id], + visibility_type: "hidden", + }); +}