2021-10-25 14:38:54 +00:00
|
|
|
export default class AttributesTab {
|
|
|
|
private saveAttributeBtn = "save-attributes";
|
2022-06-27 08:47:41 +00:00
|
|
|
private addAttributeBtn = "attributes-add-row";
|
2021-10-25 14:38:54 +00:00
|
|
|
private attributesTab = "attributes";
|
2022-04-20 17:11:46 +00:00
|
|
|
private attributeRow = "[data-testid=row]";
|
|
|
|
private keyInput = (index: number) => `attributes[${index}].key`;
|
|
|
|
private valueInput = (index: number) => `attributes[${index}].value`;
|
2021-10-25 14:38:54 +00:00
|
|
|
|
2022-06-27 08:47:41 +00:00
|
|
|
public goToAttributesTab() {
|
2021-10-25 14:38:54 +00:00
|
|
|
cy.findByTestId(this.attributesTab).click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-06-27 08:47:41 +00:00
|
|
|
public addAttribute(key: string, value: string) {
|
2022-04-20 17:11:46 +00:00
|
|
|
cy.get(this.attributeRow)
|
|
|
|
.its("length")
|
|
|
|
.then((index) => {
|
|
|
|
cy.findByTestId(this.keyInput(index - 1)).type(key);
|
|
|
|
cy.findByTestId(this.valueInput(index - 1)).type(value);
|
|
|
|
});
|
2021-10-25 14:38:54 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-06-27 08:47:41 +00:00
|
|
|
public save() {
|
2021-10-25 14:38:54 +00:00
|
|
|
cy.findByTestId(this.saveAttributeBtn).click();
|
|
|
|
return this;
|
|
|
|
}
|
2022-06-27 08:47:41 +00:00
|
|
|
|
|
|
|
public revert() {
|
|
|
|
cy.get(".pf-c-button.pf-m-link").contains("Revert").click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public deleteAttributeButton(row: number) {
|
|
|
|
cy.findByTestId(`attributes[${row - 1}].remove`).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public addAnAttributeButton() {
|
|
|
|
cy.findByTestId(this.addAttributeBtn).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public deleteAttribute(rowIndex: number) {
|
|
|
|
this.deleteAttributeButton(rowIndex);
|
|
|
|
this.save();
|
|
|
|
|
|
|
|
cy.findAllByTestId(`attributes[${rowIndex - 1}].key`).should(
|
|
|
|
"have.value",
|
|
|
|
""
|
|
|
|
);
|
|
|
|
cy.findAllByTestId(`attributes[${rowIndex - 1}].value`).should(
|
|
|
|
"have.value",
|
|
|
|
""
|
|
|
|
);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public asseertRowItemsEqualTo(amount: number) {
|
|
|
|
cy.findAllByTestId("row").its("length").should("be.eq", amount);
|
|
|
|
return this;
|
|
|
|
}
|
2021-10-25 14:38:54 +00:00
|
|
|
}
|