Skip to content
Snippets Groups Projects
Unverified Commit 609693d8 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

[E2E] Consolidate question [WIP] (#24733)

* Remove test that is not relevant anymore

* Move browse data test where it belongs

* Move repro 16108 to the `sharing` reproductions

* Consolidate tests regarding the new question data picker

* Remove duplicate test

Exactly the same copy lives in `saved.cy.spec.js`

* Move tests related to aggregation to where they belong

* Migrate data picker reproductions over from `new-menu` spec

* Move test to the saved questions

* Remove the `describe` block related to "simple" question mode

Simple or Custom question modes do not exist anymore.
When opening a new question data picker, it's always in the custom/notebook mode.

The new "simple" mode now refers to an already opened table or a saved question.

* Move repro 15808 to nested questions
parent 79422044
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,11 @@ describe("scenarios > browse data", () => {
cy.findByText(/Browse data/).click();
cy.location("pathname").should("eq", "/browse");
cy.findByText(/^Our data$/i);
cy.findByText("Sample Database");
cy.findByText("Learn about our data").click();
cy.location("pathname").should("eq", "/reference/databases");
cy.go("back");
cy.findByText("Sample Database").click();
cy.findByText("Products").click();
cy.findByText("Rustic Paper Wallet");
});
});
import {
restore,
popover,
modal,
startNewQuestion,
getCollectionIdFromSlug,
} from "__support__/e2e/helpers";
import { restore, popover, modal } from "__support__/e2e/helpers";
describe("metabase > scenarios > navbar > new menu", () => {
beforeEach(() => {
......@@ -51,45 +45,4 @@ describe("metabase > scenarios > navbar > new menu", () => {
"Test collection",
);
});
it("should suggest questions saved in collections with colon in their name (metabase#14287)", () => {
cy.request("POST", "/api/collection", {
name: "foo:bar",
color: "#509EE3",
parent_id: null,
}).then(({ body: { id: COLLECTION_ID } }) => {
// Move question #1 ("Orders") to newly created collection
cy.request("PUT", "/api/card/1", {
collection_id: COLLECTION_ID,
});
// Sanity check: make sure Orders is indeed inside new collection
cy.visit(`/collection/${COLLECTION_ID}`);
cy.findByText("Orders");
});
startNewQuestion();
popover().within(() => {
cy.findByText("Saved Questions").click();
// Note: collection name's first letter is capitalized
cy.findByText(/foo:bar/i).click();
cy.findByText("Orders");
});
});
it("'Saved Questions' prompt should respect nested collections structure (metabase#14178)", () => {
getCollectionIdFromSlug("second_collection", id => {
// Move first question in a DB snapshot ("Orders") to a "Second collection"
cy.request("PUT", "/api/card/1", {
collection_id: id,
});
});
startNewQuestion();
popover().within(() => {
cy.findByText("Saved Questions").click();
cy.findByText("First collection");
cy.findByText("Second collection").should("not.exist");
});
});
});
import { restore, startNewQuestion } from "__support__/e2e/helpers";
describe("scenarios > question > loading behavior", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("should incrementally load data", () => {
cy.server();
// stub out the preload call to fetch all tables
cy.route({
url: "/api/database?include=tables",
status: 500,
response: {},
});
// let the other preload happen since it matches the actual call from the component
cy.route({ url: "/api/database?saved=true" }).as("fetch1");
startNewQuestion();
cy.route({ url: "/api/database/1/schemas" }).as("fetch2");
cy.route({ url: "/api/database/1/schema/PUBLIC" }).as("fetch3");
cy.contains("Sample Database").click();
cy.contains("Orders");
// confirm that schemas and schema tables were fetched individually,
// but the bulk load never happened.
cy.get("@fetch1").should("exist");
cy.get("@fetch2").should("exist");
cy.get("@fetch3").should("exist");
});
});
......@@ -8,6 +8,8 @@ import {
getDimensionByName,
summarize,
startNewQuestion,
filter,
filterField,
} from "__support__/e2e/helpers";
import { SAMPLE_DB_ID } from "__support__/e2e/cypress_data";
......@@ -532,6 +534,27 @@ describe("scenarios > question > nested", () => {
);
});
});
it("should be able to use integer filter on a nested query based on a saved native question (metabase#15808)", () => {
cy.createNativeQuestion({
name: "15808",
native: { query: "select * from products" },
});
startNewQuestion();
cy.findByText("Saved Questions").click();
cy.findByText("15808").click();
visualize();
filter();
filterField("RATING", {
operator: "Equal to",
value: "4",
});
cy.findByTestId("apply-filters").click();
cy.findByText("Synergistic Granite Chair");
cy.findByText("Rustic Paper Wallet").should("not.exist");
});
});
function ordersJoinProducts(name) {
......
import {
browse,
enterCustomColumnDetails,
openOrdersTable,
openReviewsTable,
popover,
restore,
visualize,
summarize,
startNewQuestion,
visitQuestion,
visitQuestionAdhoc,
getCollectionIdFromSlug,
} from "__support__/e2e/helpers";
import { SAMPLE_DB_ID } from "__support__/e2e/cypress_data";
......@@ -25,379 +21,196 @@ describe("scenarios > question > new", () => {
cy.signInAsAdmin();
});
it("data selector popover should not be too small (metabase#15591)", () => {
// Add 10 more databases
for (let i = 0; i < 10; i++) {
cy.request("POST", "/api/database", {
engine: "h2",
name: "Sample" + i,
details: {
db: "zip:./target/uberjar/metabase.jar!/sample-database.db;USER=GUEST;PASSWORD=guest",
},
auto_run_queries: false,
is_full_sync: false,
schedules: {},
});
}
startNewQuestion();
cy.contains("Pick your starting data");
cy.findByText("Sample3").isVisibleInPopover();
});
describe("data picker", () => {
it("data selector popover should not be too small (metabase#15591)", () => {
// Add 10 more databases
for (let i = 0; i < 10; i++) {
cy.request("POST", "/api/database", {
engine: "h2",
name: "Sample" + i,
details: {
db: "zip:./target/uberjar/metabase.jar!/sample-database.db;USER=GUEST;PASSWORD=guest",
},
auto_run_queries: false,
is_full_sync: false,
schedules: {},
});
}
it("should display a tooltip for CTA icons on an individual question (metabase#16108)", () => {
openOrdersTable();
cy.icon("download").realHover();
cy.findByText("Download full results");
cy.icon("bell").realHover();
cy.findByText("Get alerts");
cy.icon("share").realHover();
cy.findByText("Sharing");
});
startNewQuestion();
describe("browse data", () => {
it("should load orders table and summarize", () => {
cy.visit("/");
browse().click();
cy.contains("Sample Database").click();
cy.contains("Orders").click();
cy.contains("37.65");
cy.contains("Pick your starting data");
cy.findByText("Sample3").isVisibleInPopover();
});
});
describe("data picker search", () => {
describe("on a (custom) question page", () => {
beforeEach(() => {
startNewQuestion();
cy.findByPlaceholderText("Search for a table…").type("Ord");
});
it("new question data picker search should work for both saved questions and database tables", () => {
cy.intercept("GET", "/api/search?q=*", cy.spy().as("searchQuery")).as(
"search",
);
it("should allow to search saved questions", () => {
cy.findByText("Orders, Count").click();
startNewQuestion();
visualize();
cy.findByText("18,760");
});
cy.get(".List-section")
.should("have.length", 2)
.and("contain", "Sample Database")
.and("contain", "Saved Questions");
// should not trigger search for an empty string
cy.findByPlaceholderText("Search for a table…").type(" ").blur();
cy.findByPlaceholderText("Search for a table…").type("ord");
cy.wait("@search");
cy.get("@searchQuery").should("have.been.calledOnce");
// Search results include both saved questions and database tables
cy.findAllByTestId("search-result-item").should(
"have.length.at.least",
4,
);
it("should allow to search and select tables", () => {
cy.findAllByText("Orders")
.eq(1)
.closest("li")
.findByText("Table in")
.parent()
.findByTestId("search-result-item-name")
.click();
cy.contains("Saved question in Our analytics");
cy.findAllByRole("link", { name: "Our analytics" })
.should("have.attr", "href")
.and("eq", "/collection/root");
cy.contains("Table in Sample Database");
cy.findAllByRole("link", { name: "Sample Database" })
.should("have.attr", "href")
.and("eq", `/browse/${SAMPLE_DB_ID}-sample-database`);
// Discarding the search qquery should take us back to the original selector
// that starts with the list of databases and saved questions
cy.findByPlaceholderText("Search for a table…")
.next()
.find(".Icon-close")
.click();
visualize();
cy.findByText("Saved Questions").click();
// Search is now scoped to questions only
cy.findByPlaceholderText("Search for a question…");
cy.findByTestId("select-list")
.as("rightSide")
// should display the collection tree on the left side
.should("contain", "Orders")
.and("contain", "Orders, Count");
cy.get("@rightSide")
.siblings()
.should("have.length", 1)
.as("leftSide")
// should display the collection tree on the left side
.should("contain", "Our analytics")
.and("contain", "Your personal collection")
.and("contain", "All personal collections");
cy.findByText("Orders, Count").click();
cy.findByText("Orders").should("not.exist");
visualize();
cy.findByText("18,760");
// should reopen saved question picker after returning back to editor mode
cy.icon("notebook").click();
cy.findByTestId("data-step-cell").contains("Orders, Count").click();
// It is now possible to choose another saved question
cy.findByText("Orders");
cy.findByText("Saved Questions").click();
popover().contains("Sample Database").click();
cy.findByText("Products").click();
cy.findByTestId("data-step-cell").contains("Products");
visualize();
cy.findByText("Rustic Paper Wallet");
});
cy.url().should("include", "question#");
cy.findByText("Sample Database");
it("should suggest questions saved in collections with colon in their name (metabase#14287)", () => {
cy.request("POST", "/api/collection", {
name: "foo:bar",
color: "#509EE3",
parent_id: null,
}).then(({ body: { id: COLLECTION_ID } }) => {
// Move question #1 ("Orders") to newly created collection
cy.request("PUT", "/api/card/1", {
collection_id: COLLECTION_ID,
});
// Sanity check: make sure Orders is indeed inside new collection
cy.visit(`/collection/${COLLECTION_ID}`);
cy.findByText("Orders");
});
});
it("should ignore an empty search string", () => {
cy.intercept("/api/search", req => {
expect("Unexpected call to /api/search").to.be.false;
});
startNewQuestion();
cy.findByPlaceholderText("Search for a table…").type(" ");
});
});
describe("saved question picker", () => {
describe("on a (custom) question page", () => {
beforeEach(() => {
startNewQuestion();
popover().within(() => {
cy.findByText("Saved Questions").click();
});
it("should display the collection tree on the left side", () => {
popover().findByText("Our analytics");
});
it("should display the saved questions list on the right side", () => {
cy.findByText("Orders, Count, Grouped by Created At (year)");
// Note: collection name's first letter is capitalized
cy.findByText(/foo:bar/i).click();
cy.findByText("Orders");
cy.findByText("Orders, Count").click();
visualize();
cy.findByText("18,760");
});
it("should redisplay the saved question picker when changing a question", () => {
cy.findByText("Orders, Count").click();
// Try to choose a different saved question
cy.findByTestId("data-step-cell").click();
popover().within(() => {
cy.findByText("Our analytics");
cy.findByText("Orders");
cy.findByText("Orders, Count, Grouped by Created At (year)").click();
});
visualize();
cy.findByText("2016");
cy.findByText("5,834");
});
it("should perform a search scoped to saved questions", () => {
cy.findByPlaceholderText("Search for a question…").type("Grouped");
cy.findByText("Orders, Count, Grouped by Created At (year)").click();
visualize();
cy.findByText("2018");
});
it("should reopen saved question picker after returning back to editor mode", () => {
cy.findByText("Orders, Count, Grouped by Created At (year)").click();
visualize();
cy.icon("notebook").click();
cy.findByTestId("data-step-cell").click();
cy.findByTestId("select-list").within(() => {
cy.findByText("Orders, Count, Grouped by Created At (year)");
});
});
});
});
describe("ask a (simple) question", () => {
it.skip("should handle (removing) multiple metrics when one is sorted (metabase#13990)", () => {
cy.intercept("POST", `/api/dataset`).as("dataset");
cy.createQuestion(
{
name: "12625",
query: {
"source-table": ORDERS_ID,
aggregation: [
["count"],
["sum", ["field", ORDERS.SUBTOTAL, null]],
["sum", ["field", ORDERS.TOTAL, null]],
],
breakout: [
["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }],
],
"order-by": [["desc", ["aggregation", 1]]],
},
},
{ visitQuestion: true },
);
summarize();
// CSS class of a sorted header cell
cy.get("[class*=TableInteractive-headerCellData--sorted]").as(
"sortedCell",
);
// At this point only "Sum of Subtotal" should be sorted
cy.get("@sortedCell").its("length").should("eq", 1);
removeMetricFromSidebar("Sum of Subtotal");
cy.wait("@dataset");
cy.findByText("Sum of Subtotal").should("not.exist");
// "Sum of Total" should not be sorted, nor any other header cell
cy.get("@sortedCell").its("length").should("eq", 0);
removeMetricFromSidebar("Sum of Total");
cy.wait("@dataset");
cy.findByText(/No results!/i).should("not.exist");
cy.contains("744"); // `Count` for year 2016
});
it("should remove `/notebook` from URL when converting question to SQL/Native (metabase#12651)", () => {
openOrdersTable();
cy.url().should("include", "question#");
// Isolate icons within "QueryBuilder" scope because there is also `.Icon-sql` in top navigation
cy.get(".QueryBuilder .Icon-notebook").click();
cy.url().should("include", "question/notebook#");
cy.get(".QueryBuilder .Icon-sql").click();
cy.findByText("Convert this question to SQL").click();
cy.url().should("include", "question#");
});
it("composite keys should act as filters on click (metabase#13717)", () => {
cy.request("PUT", `/api/field/${ORDERS.QUANTITY}`, {
semantic_type: "type/PK",
it("'Saved Questions' prompt should respect nested collections structure (metabase#14178)", () => {
getCollectionIdFromSlug("second_collection", id => {
// Move first question in a DB snapshot ("Orders") to a "Second collection"
cy.request("PUT", "/api/card/1", {
collection_id: id,
});
});
openOrdersTable();
cy.get(".TableInteractive-cellWrapper--lastColumn") // Quantity (last in the default order for Sample Database)
.eq(1) // first table body cell
.should("contain", "2") // quantity for order ID#1
.click();
cy.wait("@dataset");
cy.get(
"#main-data-grid .TableInteractive-cellWrapper--firstColumn",
).should("have.length.gt", 1);
cy.log(
"**Reported at v0.34.3 - v0.37.0.2 / probably was always like this**",
);
cy.log(
"**It should display the table with all orders with the selected quantity.**",
);
cy.get(".TableInteractive");
cy.get(".TableInteractive-cellWrapper--firstColumn") // ID (first in the default order for Sample Database)
.eq(1) // first table body cell
.should("contain", 1)
.click();
cy.wait("@dataset");
cy.log("only one row should appear after filtering by ID");
cy.get(
"#main-data-grid .TableInteractive-cellWrapper--firstColumn",
).should("have.length", 1);
});
// flaky test (#19454)
it.skip("should show an info popover when hovering over summarize dimension options", () => {
openReviewsTable();
summarize();
cy.findByText("Group by")
.parent()
.findByText("Title")
.trigger("mouseenter");
popover().contains("Title");
popover().contains("199 distinct values");
});
});
describe("ask a (custom) question", () => {
it("should load orders table", () => {
startNewQuestion();
cy.contains("Sample Database").click();
cy.contains("Orders").click();
visualize();
cy.contains("37.65");
});
it("should show a table info popover when hovering over the table name in the header", () => {
visitQuestion(1);
cy.findByTestId("question-table-badges").trigger("mouseenter");
cy.findByText("9 columns");
});
it("should allow using `Custom Expression` in orders metrics (metabase#12899)", () => {
openOrdersTable({ mode: "notebook" });
summarize({ mode: "notebook" });
popover().contains("Custom Expression").click();
popover().within(() => {
enterCustomColumnDetails({ formula: "2 * Max([Total])" });
cy.findByPlaceholderText("Name (required)").type("twice max total");
cy.findByText("Done").click();
});
visualize();
cy.findByText("318.7");
});
it.skip("should keep manually entered parenthesis intact (metabase#13306)", () => {
const FORMULA =
"Sum([Total]) / (Sum([Product → Price]) * Average([Quantity]))";
openOrdersTable({ mode: "notebook" });
summarize({ mode: "notebook" });
popover().contains("Custom Expression").click();
popover().within(() => {
cy.get(".ace_text-input").type(FORMULA).blur();
cy.log("Fails after blur in v0.36.6");
// Implicit assertion
cy.contains(FORMULA);
cy.findByText("Saved Questions").click();
cy.findByText("First collection");
cy.findByText("Second collection").should("not.exist");
});
});
});
it("distinct inside custom expression should suggest non-numeric types (metabase#13469)", () => {
openReviewsTable({ mode: "notebook" });
summarize({ mode: "notebook" });
popover().contains("Custom Expression").click();
it("should remove `/notebook` from URL when converting question to SQL/Native (metabase#12651)", () => {
openOrdersTable();
enterCustomColumnDetails({ formula: "Distinct([R" });
cy.url().should("include", "question#");
// Isolate icons within "QueryBuilder" scope because there is also `.Icon-sql` in top navigation
cy.get(".QueryBuilder .Icon-notebook").click();
cy.url().should("include", "question/notebook#");
cy.get(".QueryBuilder .Icon-sql").click();
cy.findByText("Convert this question to SQL").click();
cy.url().should("include", "question#");
});
cy.log(
"**The point of failure for ANY non-numeric value reported in v0.36.4**",
);
// the default type for "Reviewer" is "No semantic type"
popover().within(() => {
cy.contains("Reviewer");
});
it("composite keys should act as filters on click (metabase#13717)", () => {
cy.request("PUT", `/api/field/${ORDERS.QUANTITY}`, {
semantic_type: "type/PK",
});
it("summarizing by distinct datetime should allow granular selection (metabase#13098)", () => {
// Go straight to orders table in custom questions
openOrdersTable({ mode: "notebook" });
summarize({ mode: "notebook" });
popover().within(() => {
cy.findByText("Number of distinct values of ...").click();
cy.log(
"**Test fails at this point as there isn't an extra field next to 'Created At'**",
);
// instead of relying on DOM structure that might change
// (i.e. find "Created At" -> parent -> parent -> parent -> find "by month")
// access it directly from the known common parent
cy.get(".List-item").contains("by month").click({ force: true });
});
// this should be among the granular selection choices
cy.findByText("Hour of Day").click();
});
});
openOrdersTable();
it("'read-only' user should be able to resize column width (metabase#9772)", () => {
cy.signIn("readonly");
visitQuestion(1);
cy.findByText("Tax")
.closest(".TableInteractive-headerCellData")
.as("headerCell")
.then($cell => {
const originalWidth = $cell[0].getBoundingClientRect().width;
// Retries the assertion a few times to ensure it waits for DOM changes
// More context: https://github.com/metabase/metabase/pull/21823#discussion_r855302036
function assertColumnResized(attempt = 0) {
cy.get("@headerCell").then($newCell => {
const newWidth = $newCell[0].getBoundingClientRect().width;
if (newWidth === originalWidth && attempt < 3) {
cy.wait(100);
assertColumnResized(++attempt);
} else {
expect(newWidth).to.be.gt(originalWidth);
}
});
}
cy.wrap($cell)
.find(".react-draggable")
.trigger("mousedown", 0, 0, { force: true })
.trigger("mousemove", 100, 0, { force: true })
.trigger("mouseup", 100, 0, { force: true });
assertColumnResized();
});
cy.get(".TableInteractive-cellWrapper--lastColumn") // Quantity (last in the default order for Sample Database)
.eq(1) // first table body cell
.should("contain", "2") // quantity for order ID#1
.click();
cy.wait("@dataset");
cy.get("#main-data-grid .TableInteractive-cellWrapper--firstColumn").should(
"have.length.gt",
1,
);
cy.log(
"**Reported at v0.34.3 - v0.37.0.2 / probably was always like this**",
);
cy.log(
"**It should display the table with all orders with the selected quantity.**",
);
cy.get(".TableInteractive");
cy.get(".TableInteractive-cellWrapper--firstColumn") // ID (first in the default order for Sample Database)
.eq(1) // first table body cell
.should("contain", 1)
.click();
cy.wait("@dataset");
cy.log("only one row should appear after filtering by ID");
cy.get("#main-data-grid .TableInteractive-cellWrapper--firstColumn").should(
"have.length",
1,
);
});
it("should handle ad-hoc question with old syntax (metabase#15372)", () => {
......@@ -416,12 +229,3 @@ describe("scenarios > question > new", () => {
cy.findByText("37.65");
});
});
function removeMetricFromSidebar(metricName) {
cy.get("[class*=SummarizeSidebar__AggregationToken]")
.contains(metricName)
.parent()
.find(".Icon-close")
.should("be.visible")
.click();
}
......@@ -5,15 +5,11 @@ import {
openOrdersTable,
summarize,
visitQuestion,
startNewQuestion,
visualize,
openQuestionActions,
questionInfoButton,
rightSidebar,
appbar,
getCollectionIdFromSlug,
filter,
filterField,
} from "__support__/e2e/helpers";
describe("scenarios > question > saved", () => {
......@@ -153,27 +149,6 @@ describe("scenarios > question > saved", () => {
cy.findByText(/This is a question/i).should("not.exist");
});
it("should be able to use integer filter on a nested query based on a saved native question (metabase#15808)", () => {
cy.createNativeQuestion({
name: "15808",
native: { query: "select * from products" },
});
startNewQuestion();
cy.findByText("Saved Questions").click();
cy.findByText("15808").click();
visualize();
filter();
filterField("RATING", {
operator: "Equal to",
value: "4",
});
cy.findByTestId("apply-filters").click();
cy.findByText("Synergistic Granite Chair");
cy.findByText("Rustic Paper Wallet").should("not.exist");
});
it("should show table name in header with a table info popover on hover", () => {
visitQuestion(1);
cy.findByTestId("question-table-badges").trigger("mouseenter");
......@@ -213,4 +188,38 @@ describe("scenarios > question > saved", () => {
cy.findByText("Started from").should("not.exist");
});
});
it("'read-only' user should be able to resize column width (metabase#9772)", () => {
cy.signIn("readonly");
visitQuestion(1);
cy.findByText("Tax")
.closest(".TableInteractive-headerCellData")
.as("headerCell")
.then($cell => {
const originalWidth = $cell[0].getBoundingClientRect().width;
// Retries the assertion a few times to ensure it waits for DOM changes
// More context: https://github.com/metabase/metabase/pull/21823#discussion_r855302036
function assertColumnResized(attempt = 0) {
cy.get("@headerCell").then($newCell => {
const newWidth = $newCell[0].getBoundingClientRect().width;
if (newWidth === originalWidth && attempt < 3) {
cy.wait(100);
assertColumnResized(++attempt);
} else {
expect(newWidth).to.be.gt(originalWidth);
}
});
}
cy.wrap($cell)
.find(".react-draggable")
.trigger("mousedown", 0, 0, { force: true })
.trigger("mousemove", 100, 0, { force: true })
.trigger("mouseup", 100, 0, { force: true });
assertColumnResized();
});
});
});
......@@ -5,6 +5,11 @@ import {
getRemoveDimensionButton,
summarize,
visitQuestion,
popover,
openReviewsTable,
openOrdersTable,
enterCustomColumnDetails,
visualize,
} from "__support__/e2e/helpers";
import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database";
......@@ -153,4 +158,135 @@ describe("scenarios > question > summarize sidebar", () => {
// The actual check that will fail until this issue gets fixed
cy.findAllByText("Week").first().isVisibleInPopover();
});
it("should allow using `Custom Expression` in orders metrics (metabase#12899)", () => {
openOrdersTable({ mode: "notebook" });
summarize({ mode: "notebook" });
popover().contains("Custom Expression").click();
popover().within(() => {
enterCustomColumnDetails({ formula: "2 * Max([Total])" });
cy.findByPlaceholderText("Name (required)").type("twice max total");
cy.findByText("Done").click();
});
visualize();
cy.findByText("318.7");
});
it.skip("should keep manually entered parenthesis intact (metabase#13306)", () => {
const FORMULA =
"Sum([Total]) / (Sum([Product → Price]) * Average([Quantity]))";
openOrdersTable({ mode: "notebook" });
summarize({ mode: "notebook" });
popover().contains("Custom Expression").click();
popover().within(() => {
cy.get(".ace_text-input").type(FORMULA).blur();
cy.log("Fails after blur in v0.36.6");
// Implicit assertion
cy.contains(FORMULA);
});
});
it("distinct inside custom expression should suggest non-numeric types (metabase#13469)", () => {
openReviewsTable({ mode: "notebook" });
summarize({ mode: "notebook" });
popover().contains("Custom Expression").click();
enterCustomColumnDetails({ formula: "Distinct([R" });
cy.log(
"**The point of failure for ANY non-numeric value reported in v0.36.4**",
);
// the default type for "Reviewer" is "No semantic type"
popover().within(() => {
cy.contains("Reviewer");
});
});
it("summarizing by distinct datetime should allow granular selection (metabase#13098)", () => {
// Go straight to orders table in custom questions
openOrdersTable({ mode: "notebook" });
summarize({ mode: "notebook" });
popover().within(() => {
cy.findByText("Number of distinct values of ...").click();
cy.log(
"**Test fails at this point as there isn't an extra field next to 'Created At'**",
);
// instead of relying on DOM structure that might change
// (i.e. find "Created At" -> parent -> parent -> parent -> find "by month")
// access it directly from the known common parent
cy.get(".List-item").contains("by month").click({ force: true });
});
// this should be among the granular selection choices
cy.findByText("Hour of Day").click();
});
it.skip("should handle (removing) multiple metrics when one is sorted (metabase#12625)", () => {
cy.intercept("POST", `/api/dataset`).as("dataset");
cy.createQuestion(
{
name: "12625",
query: {
"source-table": ORDERS_ID,
aggregation: [
["count"],
["sum", ["field", ORDERS.SUBTOTAL, null]],
["sum", ["field", ORDERS.TOTAL, null]],
],
breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }]],
"order-by": [["desc", ["aggregation", 1]]],
},
},
{ visitQuestion: true },
);
summarize();
// CSS class of a sorted header cell
cy.get("[class*=TableInteractive-headerCellData--sorted]").as("sortedCell");
// At this point only "Sum of Subtotal" should be sorted
cy.get("@sortedCell").its("length").should("eq", 1);
removeMetricFromSidebar("Sum of Subtotal");
cy.wait("@dataset");
cy.findByText("Sum of Subtotal").should("not.exist");
// "Sum of Total" should not be sorted, nor any other header cell
cy.get("@sortedCell").its("length").should("eq", 0);
removeMetricFromSidebar("Sum of Total");
cy.wait("@dataset");
cy.findByText(/No results!/i).should("not.exist");
cy.contains("744"); // `Count` for year 2016
});
// flaky test (#19454)
it.skip("should show an info popover when hovering over summarize dimension options", () => {
openReviewsTable();
summarize();
cy.findByText("Group by")
.parent()
.findByText("Title")
.trigger("mouseenter");
popover().contains("Title");
popover().contains("199 distinct values");
});
});
function removeMetricFromSidebar(metricName) {
cy.get("[class*=SummarizeSidebar__AggregationToken]")
.contains(metricName)
.parent()
.find(".Icon-close")
.should("be.visible")
.click();
}
import { restore, visitQuestion } from "__support__/e2e/helpers";
describe("issue 16108", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("should display a tooltip for CTA icons on an individual question (metabase#16108)", () => {
visitQuestion(1);
cy.icon("download").realHover();
cy.findByText("Download full results");
cy.icon("bell").realHover();
cy.findByText("Get alerts");
cy.icon("share").realHover();
cy.findByText("Sharing");
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment