2021-09-27 10:04:21 +00:00
|
|
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
2021-09-10 08:59:46 +00:00
|
|
|
import {
|
|
|
|
selectorWithDataValue,
|
|
|
|
SHARED_ELEMENTS
|
2021-09-27 10:04:21 +00:00
|
|
|
} from "../../../elements/shared/sharedElements";
|
2021-04-01 12:33:36 +00:00
|
|
|
|
2021-09-27 10:04:21 +00:00
|
|
|
Cypress.Commands.add("createNewOption", (selectSelector, newOption) => {
|
|
|
|
cy.get(selectSelector).type(newOption);
|
|
|
|
cy.contains(BUTTON_SELECTORS.selectOption, newOption)
|
|
|
|
.should("be.visible")
|
|
|
|
.click();
|
|
|
|
});
|
|
|
|
|
|
|
|
Cypress.Commands.add("fillMultiSelect", (selectSelector, option) => {
|
|
|
|
cy.fillAutocompleteSelect(selectSelector, option).then(returnedOption => {
|
|
|
|
cy.get(SHARED_ELEMENTS.header)
|
|
|
|
.first()
|
|
|
|
.click({ force: true });
|
|
|
|
return cy.wrap(returnedOption);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Cypress.Commands.add("fillBaseSelect", (selectSelector, value) => {
|
|
|
|
cy.get(selectSelector)
|
|
|
|
.click()
|
|
|
|
.get(selectorWithDataValue(value))
|
|
|
|
.click();
|
|
|
|
});
|
|
|
|
|
|
|
|
Cypress.Commands.add("fillAutocompleteSelect", (selectSelector, option) => {
|
2021-04-01 12:33:36 +00:00
|
|
|
cy.get(selectSelector)
|
|
|
|
.click()
|
|
|
|
.get(BUTTON_SELECTORS.selectOption)
|
|
|
|
.should("be.visible");
|
|
|
|
if (option) {
|
2021-04-21 08:02:48 +00:00
|
|
|
cy.get(selectSelector).clearAndType(option);
|
2021-04-01 12:33:36 +00:00
|
|
|
cy.contains(BUTTON_SELECTORS.selectOption, option).click();
|
|
|
|
cy.wrap(option).as("option");
|
|
|
|
} else {
|
|
|
|
cy.get(BUTTON_SELECTORS.selectOption)
|
2021-09-10 08:59:46 +00:00
|
|
|
.wait(1000)
|
2021-04-01 12:33:36 +00:00
|
|
|
.first()
|
|
|
|
.invoke("text")
|
2021-09-10 08:59:46 +00:00
|
|
|
.as("option")
|
|
|
|
.get(BUTTON_SELECTORS.selectOption)
|
2021-04-01 12:33:36 +00:00
|
|
|
.first()
|
|
|
|
.click();
|
|
|
|
}
|
|
|
|
return cy.get("@option");
|
2021-09-27 10:04:21 +00:00
|
|
|
});
|