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

[E2E] Chain the custom `button` command (#31196)

* Make custom `button` command chainable

* Chain `.button` directly

No need to use `.within()` anymore.
We can chain the button command directly because it now receives
the previously yielded subject.

* Fix collections bulk actions test
parent 9ff037d3
No related branches found
No related tags found
No related merge requests found
Cypress.Commands.add("button", (button_name, timeout) => { Cypress.Commands.add(
cy.findByRole("button", { name: button_name, timeout: timeout }); "button",
}); {
prevSubject: "optional",
},
(subject, button_name, timeout) => {
const config = {
name: button_name,
timeout,
};
if (subject) {
cy.wrap(subject).findByRole("button", config);
} else {
cy.findByRole("button", config);
}
},
);
...@@ -505,6 +505,7 @@ describe("scenarios > collection defaults", () => { ...@@ -505,6 +505,7 @@ describe("scenarios > collection defaults", () => {
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(/item(s)? selected/) cy.findByText(/item(s)? selected/)
.parent()
.button("Archive") .button("Archive")
.click(); .click();
...@@ -522,6 +523,7 @@ describe("scenarios > collection defaults", () => { ...@@ -522,6 +523,7 @@ describe("scenarios > collection defaults", () => {
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(/item(s)? selected/) cy.findByText(/item(s)? selected/)
.parent()
.button("Move") .button("Move")
.click(); .click();
......
...@@ -104,6 +104,6 @@ function removeAllExpressions() { ...@@ -104,6 +104,6 @@ function removeAllExpressions() {
function updateQuestion() { function updateQuestion() {
cy.intercept("PUT", "/api/card/*").as("updateQuestion"); cy.intercept("PUT", "/api/card/*").as("updateQuestion");
cy.findByText("Save").click(); cy.findByText("Save").click();
modal().within(() => cy.button("Save").click()); modal().button("Save").click();
cy.wait("@updateQuestion"); cy.wait("@updateQuestion");
} }
...@@ -29,7 +29,7 @@ describe("issue 28971", () => { ...@@ -29,7 +29,7 @@ describe("issue 28971", () => {
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
popover().within(() => cy.findByText("Orders").click()); popover().within(() => cy.findByText("Orders").click());
cy.button("Save").click(); cy.button("Save").click();
modal().within(() => cy.button("Save").click()); modal().button("Save").click();
cy.wait("@createCard"); cy.wait("@createCard");
filter(); filter();
......
...@@ -252,7 +252,7 @@ describe("scenarios > organization > timelines > collection", () => { ...@@ -252,7 +252,7 @@ describe("scenarios > organization > timelines > collection", () => {
cy.findByText("Move event").click(); cy.findByText("Move event").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Releases").click(); cy.findByText("Releases").click();
getModal().within(() => cy.button("Move").click()); getModal().button("Move").click();
cy.wait("@updateEvent"); cy.wait("@updateEvent");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("RC2").should("not.exist"); cy.findByText("RC2").should("not.exist");
...@@ -284,7 +284,7 @@ describe("scenarios > organization > timelines > collection", () => { ...@@ -284,7 +284,7 @@ describe("scenarios > organization > timelines > collection", () => {
cy.findByText("Move event").click(); cy.findByText("Move event").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Releases").click(); cy.findByText("Releases").click();
getModal().within(() => cy.button("Move").click()); getModal().button("Move").click();
cy.wait("@updateEvent"); cy.wait("@updateEvent");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("RC2").should("not.exist"); cy.findByText("RC2").should("not.exist");
......
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