Skip to content

Commit

Permalink
force click
Browse files Browse the repository at this point in the history
  • Loading branch information
kstekovi committed Aug 14, 2023
1 parent 5dd8331 commit caa0deb
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions packages/testsuite/cypress/support/form-editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,52 @@ Cypress.Commands.add("resetForm", (formId, managementApi, address) => {
const resetButton = `#${formId} a.clickable[data-operation="reset"]`;
// Setting the force parameter to true is a workaround turning off cypress checks whether the reset button is clickable,
// as those checks sometimes fail. Next lines check the functionality (not) invoked by the button sufficiently.
cy.get(resetButton).click();
// cy.get("body").then(($body) => {
// if ($body.find(".modal-footer .btn-hal.btn-primary").length) {
// cy.get(".modal-footer .btn-hal.btn-primary").click({ force: true });
// cy.verifySuccess();
// } else {
// cy.get(".toast-notifications-list-pf .alert-warning")
// .contains("None of the attributes could be reset.")
// .should("be.visible");
// }
// });
// cy.task("execute:cli", {
// managementApi: `${managementApi}/management`,
// operation: "read-resource-description",
// address: address,
// }).then((result) => {
// expect((result as { outcome: string }).outcome).to.equal("success");
// const attributes = (
// result as {
// result: { attributes: { [key: string]: { default?: string } } };
// }
// ).result.attributes;
// const attributesWithDefaultValues = Object.keys(attributes)
// .filter((key: string) => Object.prototype.hasOwnProperty.call(attributes[key], "default"))
// .map((key) => {
// const obj: {
// [index: string]: undefined | string | number | boolean;
// } = {};
// obj["name"] = key;
// obj["defaultValue"] = attributes[key].default;
// return obj;
// });
// attributesWithDefaultValues.forEach((attributeWithDefaultValue) => {
// cy.task("execute:cli", {
// managementApi: `${managementApi}/management`,
// operation: "read-attribute",
// address: address,
// name: attributeWithDefaultValue.name,
// }).then((result) => {
// expect((result as { outcome: string }).outcome).to.equal("success");
// expect((result as { result: string | number | boolean }).result).to.equal(
// attributeWithDefaultValue.defaultValue
// );
// });
// });
// });
cy.get(resetButton).click({ force: true });
cy.get("body").then(($body) => {
if ($body.find(".modal-footer .btn-hal.btn-primary").length) {
cy.get(".modal-footer .btn-hal.btn-primary").click({ force: true });
cy.verifySuccess();
} else {
cy.get(".toast-notifications-list-pf .alert-warning")
.contains("None of the attributes could be reset.")
.should("be.visible");
}
});
cy.task("execute:cli", {
managementApi: `${managementApi}/management`,
operation: "read-resource-description",
address: address,
}).then((result) => {
expect((result as { outcome: string }).outcome).to.equal("success");
const attributes = (
result as {
result: { attributes: { [key: string]: { default?: string } } };
}
).result.attributes;
const attributesWithDefaultValues = Object.keys(attributes)
.filter((key: string) => Object.prototype.hasOwnProperty.call(attributes[key], "default"))
.map((key) => {
const obj: {
[index: string]: undefined | string | number | boolean;
} = {};
obj["name"] = key;
obj["defaultValue"] = attributes[key].default;
return obj;
});
attributesWithDefaultValues.forEach((attributeWithDefaultValue) => {
cy.task("execute:cli", {
managementApi: `${managementApi}/management`,
operation: "read-attribute",
address: address,
name: attributeWithDefaultValue.name,
}).then((result) => {
expect((result as { outcome: string }).outcome).to.equal("success");
expect((result as { result: string | number | boolean }).result).to.equal(
attributeWithDefaultValue.defaultValue
);
});
});
});
});

Cypress.Commands.add("help", () => {
Expand Down

0 comments on commit caa0deb

Please sign in to comment.