diff --git a/packages/testsuite/cypress/support/form-editing.ts b/packages/testsuite/cypress/support/form-editing.ts index 62f64082e..8d961a0b5 100644 --- a/packages/testsuite/cypress/support/form-editing.ts +++ b/packages/testsuite/cypress/support/form-editing.ts @@ -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", () => {