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,
|
2022-07-29 06:35:55 +00:00
|
|
|
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")
|
2022-01-31 08:37:49 +00:00
|
|
|
.click()
|
|
|
|
.get(selectSelector)
|
|
|
|
.find("input")
|
|
|
|
.first()
|
|
|
|
.click({ force: true });
|
2021-09-27 10:04:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Cypress.Commands.add("fillMultiSelect", (selectSelector, option) => {
|
|
|
|
cy.fillAutocompleteSelect(selectSelector, option).then(returnedOption => {
|
|
|
|
cy.get(SHARED_ELEMENTS.header)
|
|
|
|
.first()
|
2022-10-27 09:27:34 +00:00
|
|
|
.click({ force: true })
|
|
|
|
.get(SHARED_ELEMENTS.multiAutocomplete.selectedOptions)
|
|
|
|
.should("be.visible");
|
2021-09-27 10:04:21 +00:00
|
|
|
return cy.wrap(returnedOption);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Cypress.Commands.add("fillBaseSelect", (selectSelector, value) => {
|
|
|
|
cy.get(selectSelector)
|
2022-07-29 06:35:55 +00:00
|
|
|
.should("not.have.attr", "aria-disabled", "true")
|
2021-09-27 10:04:21 +00:00
|
|
|
.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) {
|
2022-10-21 08:12:23 +00:00
|
|
|
cy.get(BUTTON_SELECTORS.selectOption)
|
|
|
|
.first()
|
|
|
|
.then(detachedOption => {
|
|
|
|
cy.get(selectSelector).clear();
|
|
|
|
cy.get(selectSelector).type(option);
|
|
|
|
cy.wrap(detachedOption).should(det => {
|
|
|
|
Cypress.dom.isDetached(det);
|
|
|
|
});
|
2022-10-28 08:39:22 +00:00
|
|
|
cy.contains(BUTTON_SELECTORS.selectOption, option)
|
|
|
|
.should("be.visible")
|
2023-01-05 07:06:46 +00:00
|
|
|
.click({ force: true });
|
2022-10-21 08:12:23 +00:00
|
|
|
cy.wrap(option).as("option");
|
|
|
|
});
|
2021-04-01 12:33:36 +00:00
|
|
|
} 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
|
|
|
});
|