2021-04-01 12:33:36 +00:00
|
|
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
2021-09-10 08:59:46 +00:00
|
|
|
import {
|
|
|
|
selectorWithDataValue,
|
|
|
|
SHARED_ELEMENTS
|
|
|
|
} from "../../elements/shared/sharedElements";
|
2021-04-01 12:33:36 +00:00
|
|
|
|
|
|
|
export function fillAutocompleteSelect(selectSelector, option) {
|
|
|
|
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-07-12 08:50:50 +00:00
|
|
|
|
2021-09-10 08:59:46 +00:00
|
|
|
export function fillMultiSelect(selectSelector, option) {
|
|
|
|
fillAutocompleteSelect(selectSelector, option).then(returnedOption => {
|
|
|
|
cy.get(SHARED_ELEMENTS.header)
|
|
|
|
.first()
|
|
|
|
.click({ force: true });
|
|
|
|
return cy.wrap(returnedOption);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-12 08:50:50 +00:00
|
|
|
export function fillBaseSelect(selectSelector, value) {
|
|
|
|
cy.get(selectSelector)
|
|
|
|
.click()
|
|
|
|
.get(selectorWithDataValue(value))
|
|
|
|
.click();
|
|
|
|
}
|
2021-09-08 11:32:05 +00:00
|
|
|
|
|
|
|
export function createNewOption(selectSelector, newOption) {
|
|
|
|
cy.get(selectSelector).type(newOption);
|
|
|
|
cy.contains(BUTTON_SELECTORS.selectOption, newOption)
|
|
|
|
.should("be.visible")
|
|
|
|
.click();
|
|
|
|
}
|