Skip to content

Commit 3d0d7c6

Browse files
committed
different reset button click for Wildfly
1 parent ee276b3 commit 3d0d7c6

1 file changed

Lines changed: 45 additions & 41 deletions

File tree

packages/testsuite/cypress/support/form-editing.ts

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,58 @@ Cypress.Commands.add("cancelForm", (formId) => {
1616
});
1717

1818
Cypress.Commands.add("resetForm", (formId, managementApi, address) => {
19-
const resetButton = "#" + formId + ' a.clickable[data-operation="reset"';
20-
// Setting the force parameter to true is a workaround turning off cypress checks whether the reset button is clickable,
21-
// as those checks sometimes fail. Next lines check the functionality (not) invoked by the button sufficiently.
22-
cy.get(resetButton).click({ force: true });
23-
cy.get("body").then(($body) => {
24-
if ($body.find(".modal-footer .btn-hal.btn-primary").length) {
25-
cy.get(".modal-footer .btn-hal.btn-primary").click({ force: true });
26-
cy.verifySuccess();
27-
} else {
28-
cy.get(".toast-notifications-list-pf .alert-warning")
29-
.contains("None of the attributes could be reset.")
30-
.should("be.visible");
31-
}
32-
});
33-
cy.task("execute:cli", {
34-
managementApi: `${managementApi}/management`,
35-
operation: "read-resource-description",
36-
address: address,
37-
}).then((result) => {
38-
expect((result as { outcome: string }).outcome).to.equal("success");
39-
const attributes = (
40-
result as {
41-
result: { attributes: { [key: string]: { default?: string } } };
42-
}
43-
).result.attributes;
44-
const attributesWithDefaultValues = Object.keys(attributes)
45-
.filter((key: string) => Object.prototype.hasOwnProperty.call(attributes[key], "default"))
46-
.map((key) => {
47-
const obj: {
48-
[index: string]: undefined | string | number | boolean;
49-
} = {};
50-
obj["name"] = key;
51-
obj["defaultValue"] = attributes[key].default;
52-
return obj;
19+
const resetButton = `#${formId} a.clickable[data-operation="reset"]`;
20+
cy.isEAP(managementApi).then((isEAP) => {
21+
if (isEAP) {
22+
cy.get(resetButton).click();
23+
cy.get("body").then(($body) => {
24+
if ($body.find(".modal-footer .btn-hal.btn-primary").length) {
25+
cy.get(".modal-footer .btn-hal.btn-primary").click({ force: true });
26+
cy.verifySuccess();
27+
} else {
28+
cy.get(".toast-notifications-list-pf .alert-warning")
29+
.contains("None of the attributes could be reset.")
30+
.should("be.visible");
31+
}
5332
});
54-
attributesWithDefaultValues.forEach((attributeWithDefaultValue) => {
5533
cy.task("execute:cli", {
5634
managementApi: `${managementApi}/management`,
57-
operation: "read-attribute",
35+
operation: "read-resource-description",
5836
address: address,
59-
name: attributeWithDefaultValue.name,
6037
}).then((result) => {
6138
expect((result as { outcome: string }).outcome).to.equal("success");
62-
expect((result as { result: string | number | boolean }).result).to.equal(
63-
attributeWithDefaultValue.defaultValue
64-
);
39+
const attributes = (
40+
result as {
41+
result: { attributes: { [key: string]: { default?: string } } };
42+
}
43+
).result.attributes;
44+
const attributesWithDefaultValues = Object.keys(attributes)
45+
.filter((key: string) => Object.prototype.hasOwnProperty.call(attributes[key], "default"))
46+
.map((key) => {
47+
const obj: {
48+
[index: string]: undefined | string | number | boolean;
49+
} = {};
50+
obj["name"] = key;
51+
obj["defaultValue"] = attributes[key].default;
52+
return obj;
53+
});
54+
attributesWithDefaultValues.forEach((attributeWithDefaultValue) => {
55+
cy.task("execute:cli", {
56+
managementApi: `${managementApi}/management`,
57+
operation: "read-attribute",
58+
address: address,
59+
name: attributeWithDefaultValue.name,
60+
}).then((result) => {
61+
expect((result as { outcome: string }).outcome).to.equal("success");
62+
expect((result as { result: string | number | boolean }).result).to.equal(
63+
attributeWithDefaultValue.defaultValue
64+
);
65+
});
66+
});
6567
});
66-
});
68+
} else {
69+
cy.contains(resetButton).should("not.exist");
70+
}
6771
});
6872
});
6973

0 commit comments

Comments
 (0)