2022-04-20 17:11:46 +00:00
|
|
|
import type { KeyValueType } from "../../../../../src/components/key-value-form/key-value-convert";
|
2022-04-20 09:29:35 +00:00
|
|
|
|
|
|
|
export default class KeyValueInput {
|
|
|
|
private name: string;
|
|
|
|
|
|
|
|
constructor(name: string) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
2022-04-20 17:11:46 +00:00
|
|
|
fillKeyValue({ key, value }: KeyValueType, index = 0) {
|
|
|
|
cy.findByTestId(`${this.name}[${index}].key`).clear().type(key);
|
|
|
|
cy.findByTestId(`${this.name}[${index}].value`).clear().type(value);
|
2022-04-20 09:29:35 +00:00
|
|
|
cy.findByTestId(`${this.name}-add-row`).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-04-20 17:11:46 +00:00
|
|
|
deleteRow(index: number) {
|
|
|
|
cy.findByTestId(`${this.name}[${index}].remove`).click();
|
2022-04-20 09:29:35 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-04-20 17:11:46 +00:00
|
|
|
validateRows(numberOfRows: number) {
|
|
|
|
cy.findAllByTestId("row").should("have.length", numberOfRows);
|
2022-04-20 09:29:35 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
save() {
|
|
|
|
cy.findByTestId("save-attributes").click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|