Skip to content
Snippets Groups Projects
Unverified Commit ecbaf616 authored by Nick Fitzpatrick's avatar Nick Fitzpatrick Committed by GitHub
Browse files

Update to Cypress 12 (#29396)

* Updating to cypress 12

* updating deps

* Updating Tests. Be Green Plz

* removing custom test id from select button

* Select Button Tuning
parent 00a42d8d
No related branches found
No related tags found
No related merge requests found
Showing
with 76 additions and 50 deletions
......@@ -36,7 +36,7 @@ export function openNativeEditor({
databaseName && cy.findByText(databaseName).click();
return cy.get(".ace_content").as(alias).should("be.visible");
return cy.findByTestId("native-query-editor").as(alias).should("be.visible");
}
/**
......
......@@ -22,6 +22,10 @@ export function rightSidebar() {
return cy.findAllByTestId("sidebar-right");
}
export function leftSidebar() {
return cy.findByTestId("sidebar-left");
}
export function navigationSidebar() {
return cy.get("#root aside").first();
}
......
......@@ -108,7 +108,7 @@ describe("scenarios > admin > localization", () => {
{ visitQuestion: true },
);
cy.get(".TableInteractive-header").next().as("resultTable");
cy.findByTestId("TableInteractive-root").as("resultTable");
cy.get("@resultTable").within(() => {
// The third cell in the first row (CREATED_AT_DAY)
......
import { popover } from "e2e/support/helpers";
export function crudGroupMappingsWidget(authenticationMethod) {
cy.visit("/admin/settings/authentication/" + authenticationMethod);
cy.wait("@getSettings");
......@@ -84,13 +86,15 @@ const addGroupsToMapping = (mappingName, groups) => {
});
groups.forEach(group => {
cy.findByText(group).click();
cy.findByText(group)
.closest(".List-section")
.within(() => {
cy.icon("check");
});
popover().within(() => {
cy.findByText(group).click();
cy.findByText(group)
.closest(".List-section")
.within(() => {
cy.icon("check");
});
});
});
};
......
......@@ -31,7 +31,7 @@ describe("issue 21135", () => {
// We should probably use data-testid or some better selector but it is crucial
// to narrow the results to the preview area to avoid false positive result.
cy.get("[class*=TableInteractive]").within(() => {
cy.findByTestId("preview-root").within(() => {
cy.findByText("Rustic Paper Wallet");
cy.findAllByText("Price").should("have.length", 2);
......
......@@ -55,7 +55,10 @@ const MODEL_NAME = "Test Action Model";
restore(`${dialect}-writable`);
cy.signInAsAdmin();
resyncDatabase({ dbId: WRITABLE_DB_ID, tableName: TEST_TABLE });
createModelFromTableName({ tableName: TEST_TABLE, modelName: MODEL_NAME });
createModelFromTableName({
tableName: TEST_TABLE,
modelName: MODEL_NAME,
});
});
it("adds a custom query action to a dashboard and runs it", () => {
......@@ -87,13 +90,13 @@ const MODEL_NAME = "Test Action Model";
dragField(1, 0);
cy.findByRole("dialog").within(() => {
cy.findAllByText("Number").click({ multiple: true })
cy.findAllByText("Number").each(el => {
cy.wrap(el).click();
});
cy.findByText("Save").click();
});
cy.findByPlaceholderText("My new fantastic action").type(
ACTION_NAME
);
cy.findByPlaceholderText("My new fantastic action").type(ACTION_NAME);
cy.findByText("Create").click();
createDashboardWithActionButton({
......@@ -102,7 +105,7 @@ const MODEL_NAME = "Test Action Model";
});
filterWidget().click();
addWidgetStringFilter("1")
addWidgetStringFilter("1");
clickHelper("Update Score");
......@@ -246,8 +249,14 @@ const MODEL_NAME = "Test Action Model";
resetTestTable({ type: dialect, table: TEST_COLUMNS_TABLE });
restore(`${dialect}-writable`);
cy.signInAsAdmin();
resyncDatabase({ dbId: WRITABLE_DB_ID, tableName: TEST_COLUMNS_TABLE });
createModelFromTableName({ tableName: TEST_COLUMNS_TABLE, modelName: MODEL_NAME });
resyncDatabase({
dbId: WRITABLE_DB_ID,
tableName: TEST_COLUMNS_TABLE,
});
createModelFromTableName({
tableName: TEST_COLUMNS_TABLE,
modelName: MODEL_NAME,
});
});
it("can update various data types via implicit actions", () => {
......@@ -569,7 +578,8 @@ const MODEL_NAME = "Test Action Model";
});
});
});
});
},
);
});
function createDashboardWithActionButton({
......
......@@ -62,11 +62,6 @@ describe("support > permissions (metabase#8472)", () => {
});
it("should not allow a nocollection user to visit the page, hence cannot see the filter", () => {
cy.server();
cy.route("GET", "/api/dashboard/1/params/search/100 Main Street").as(
"search",
);
cy.signIn("nocollection");
cy.request({
method: "GET",
......
......@@ -75,7 +75,7 @@ describe("operators in questions", () => {
cy.findByText("Is").click();
});
popover().within(() => {
cy.findByTestId("operator-select-list").within(() => {
expected.text.expected.map(e => cy.contains(e).should("exist"));
expected.text.unexpected.map(e => cy.contains(e).should("not.exist"));
});
......@@ -92,7 +92,7 @@ describe("operators in questions", () => {
cy.findByText("Equal to").click();
});
popover().within(() => {
cy.findByTestId("operator-select-list").within(() => {
expected.number.expected.map(e => cy.contains(e).should("exist"));
expected.number.unexpected.map(e => cy.contains(e).should("not.exist"));
});
......@@ -190,7 +190,7 @@ describe("operators in questions", () => {
cy.findByText("Is").click();
});
popover().within(() => {
cy.findByTestId("operator-select-list").within(() => {
expected.id.expected.map(e => cy.contains(e).should("exist"));
expected.id.unexpected.map(e => cy.contains(e).should("not.exist"));
});
......@@ -207,7 +207,7 @@ describe("operators in questions", () => {
cy.findByText("Is").click();
});
popover().within(() => {
cy.findByTestId("operator-select-list").within(() => {
expected.geo.expected.map(e => cy.contains(e).should("exist"));
expected.geo.unexpected.map(e => cy.contains(e).should("not.exist"));
});
......
......@@ -522,7 +522,7 @@ describe("scenarios > models", () => {
});
cy.get(".NativeQueryEditor .Icon-play").click();
cy.wait("@query");
cy.get(".TableInteractive").within(() => {
cy.findByTestId("TableInteractive-root").within(() => {
cy.findByText("USER_ID");
cy.findByText("PRODUCT_ID");
cy.findByText("TAX");
......
......@@ -4,7 +4,7 @@ import {
openNativeEditor,
visitQuestionAdhoc,
summarize,
sidebar,
rightSidebar,
filter,
filterField,
} from "e2e/support/helpers";
......@@ -152,7 +152,7 @@ describe("scenarios > question > native", () => {
cy.icon("close").click();
});
summarize();
sidebar().within(() => {
rightSidebar().within(() => {
cy.icon("close").click();
});
cy.findByText("Done").click();
......
......@@ -4,6 +4,7 @@ import {
popover,
describeEE,
openNativeEditor,
rightSidebar,
} from "e2e/support/helpers";
import { USER_GROUPS } from "e2e/support/cypress_data";
......@@ -52,6 +53,8 @@ describeEE("scenarios > question > snippets", () => {
collection_id: null,
});
cy.intercept("GET", "api/collection/*").as("collection");
openNativeEditor();
// create folder
......@@ -74,8 +77,12 @@ describeEE("scenarios > question > snippets", () => {
.parent()
.within(() => {
cy.icon("chevrondown").click({ force: true });
cy.findByText("Edit").click();
});
rightSidebar().within(() => {
cy.findByText("Edit").click();
});
modal().within(() => cy.findByText("Top folder").click());
popover().within(() => cy.findByText("my favorite snippets").click());
cy.intercept("/api/collection/root/items?namespace=snippets").as(
......
......@@ -84,7 +84,7 @@ describe("user > settings", () => {
cy.visit("/account/password");
// Validate common passwords
cy.findByLabelText("Create a password")
cy.findByLabelText(/Create a password/i)
.as("passwordInput")
.type("qwerty123")
.blur();
......
......@@ -264,6 +264,7 @@ function assertSearchResultBadge(itemName, opts) {
const { expectBadge } = opts;
cy.findByText(itemName, opts)
.parentsUntil("[data-testid=search-result-item]")
.last()
.within(() => {
cy.icon("badge").should(expectBadge ? "exist" : "not.exist");
});
......
import {
restore,
visitQuestion,
sidebar,
rightSidebar,
visitQuestionAdhoc,
} from "e2e/support/helpers";
import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
......@@ -99,7 +99,7 @@ describe("scenarios > organization > timelines > question", () => {
cy.icon("calendar").click();
cy.findByText("Releases").should("be.visible");
sidebar().within(() => cy.icon("ellipsis").click());
rightSidebar().within(() => cy.icon("ellipsis").click());
cy.findByText("Edit event").click();
cy.findByLabelText("Event name").clear().type("RC2");
......@@ -125,7 +125,7 @@ describe("scenarios > organization > timelines > question", () => {
cy.icon("calendar").click();
cy.findByText("Builds").should("be.visible");
sidebar().within(() => cy.icon("ellipsis").click());
rightSidebar().within(() => cy.icon("ellipsis").click());
cy.findByText("Move event").click();
cy.findByText("Releases").click();
cy.button("Move").click();
......@@ -147,7 +147,7 @@ describe("scenarios > organization > timelines > question", () => {
cy.icon("calendar").click();
cy.findByText("Releases").should("be.visible");
sidebar().within(() => cy.icon("ellipsis").click());
rightSidebar().within(() => cy.icon("ellipsis").click());
cy.findByText("Archive event").click();
cy.wait("@updateEvent");
cy.findByText("RC1").should("not.exist");
......@@ -385,7 +385,7 @@ describe("scenarios > organization > timelines > question", () => {
cy.icon("calendar").click();
cy.findByText("Releases").should("be.visible");
cy.findByText("Add an event").should("not.exist");
sidebar().within(() => cy.icon("ellipsis").should("not.exist"));
rightSidebar().within(() => cy.icon("ellipsis").should("not.exist"));
});
});
});
......
......@@ -601,5 +601,10 @@ function visitNestedQueryAdHoc(id) {
}
function openHeaderCellContextMenu(cell) {
cy.findAllByTestId("header-cell").should("be.visible").contains(cell).click();
cy.findByTestId("TableInteractive-root").within(() => {
cy.findAllByTestId("header-cell")
.should("be.visible")
.contains(cell)
.click();
});
}
......@@ -97,7 +97,7 @@ describe("scenarios > question > notebook", () => {
cy.findByText("ID between 96 97").click();
cy.findByText("Between").click();
popover().within(() => {
cy.findByTestId("operator-select-list").within(() => {
cy.contains("Is not");
cy.contains("Greater than");
cy.contains("Less than");
......
......@@ -2,9 +2,9 @@ import {
restore,
openOrdersTable,
popover,
sidebar,
summarize,
visitDashboard,
rightSidebar,
} from "e2e/support/helpers";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
......@@ -205,7 +205,7 @@ describe("scenarios > question > null", () => {
openOrdersTable();
summarize();
sidebar().within(() => {
rightSidebar().within(() => {
// remove pre-selected "Count"
cy.icon("close").click();
});
......
......@@ -5,7 +5,7 @@ import {
visualize,
openProductsTable,
summarize,
sidebar,
leftSidebar,
} from "e2e/support/helpers";
describe("issue 18207", () => {
......@@ -66,7 +66,7 @@ describe("issue 18207", () => {
// Why is it not a table?
cy.contains("Visualization").click();
sidebar().within(() => {
leftSidebar().within(() => {
cy.icon("table").click();
cy.findByTestId("Table-button").realHover();
cy.icon("gear").click();
......
......@@ -3,7 +3,7 @@ import {
appBar,
popover,
openNavigationSidebar,
sidebar,
leftSidebar,
visitQuestion,
POPOVER_ELEMENT,
} from "e2e/support/helpers";
......@@ -75,7 +75,7 @@ describe("11914, 18978, 18977", () => {
function setVisualizationTo(vizName) {
cy.findByTestId("viz-type-button").click();
sidebar().within(() => {
leftSidebar().within(() => {
cy.icon(vizName).click();
cy.icon(vizName).realHover();
cy.icon("gear").click();
......@@ -83,17 +83,17 @@ function setVisualizationTo(vizName) {
});
selectFromDropdown("Created At");
sidebar().within(() => {
leftSidebar().within(() => {
cy.findByText("Y-axis").parent().findByText("Select a field").click();
});
selectFromDropdown("Quantity");
sidebar().findByText("Done").click();
leftSidebar().findByText("Done").click();
}
function addGoalLine() {
cy.findByTestId("viz-settings-button").click();
sidebar().within(() => {
leftSidebar().within(() => {
cy.findByText("Display").click();
cy.findByText("Goal line").parent().find("input").click();
cy.findByText("Done").click();
......
......@@ -201,7 +201,7 @@ describe("scenarios > question > summarize sidebar", () => {
"**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.findByTestId("expression-suggestions-list").within(() => {
cy.contains("Reviewer");
});
});
......
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