2023-03-24 08:03:48 +00:00
|
|
|
import { PAGINATION } from "../../../elements";
|
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
|
|
|
|
2023-03-24 08:03:48 +00:00
|
|
|
Cypress.Commands.add("clickRowNumberButton", () =>
|
|
|
|
cy.get(PAGINATION.rowNumberButton).click(),
|
|
|
|
);
|
|
|
|
Cypress.Commands.add("getRowNumberButton", () =>
|
|
|
|
cy.get(PAGINATION.rowNumberButton),
|
|
|
|
);
|
|
|
|
Cypress.Commands.add("clickNextPagePaginationButton", () =>
|
|
|
|
cy.get(PAGINATION.rowNumberButton),
|
|
|
|
);
|
|
|
|
Cypress.Commands.add("clickPrevPagePaginationButton", () =>
|
|
|
|
cy.get(PAGINATION.previousPagePaginationButton),
|
|
|
|
);
|
2023-04-05 07:09:53 +00:00
|
|
|
Cypress.Commands.add("clickSubmitButton", () =>
|
|
|
|
cy.get(BUTTON_SELECTORS.submit).click(),
|
|
|
|
);
|
2023-05-23 11:51:56 +00:00
|
|
|
Cypress.Commands.add("clickConfirmButton", () =>
|
|
|
|
cy.get(BUTTON_SELECTORS.confirm).click(),
|
|
|
|
);
|
2023-07-25 13:13:57 +00:00
|
|
|
Cypress.Commands.add("openColumnPicker", () =>
|
|
|
|
cy.get(SHARED_ELEMENTS.openColumnPickerButton).click(),
|
|
|
|
);
|
2023-03-24 08:03:48 +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) => {
|
2023-01-27 15:27:49 +00:00
|
|
|
let selectedOption = 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 => {
|
2023-01-27 15:27:49 +00:00
|
|
|
cy.get(selectSelector).then(select => {
|
|
|
|
if (select.find("input").length > 0) {
|
|
|
|
cy.get(selectSelector)
|
|
|
|
.find("input")
|
|
|
|
.clear()
|
|
|
|
.type(option, { delay: 10 });
|
|
|
|
} else {
|
|
|
|
cy.get(selectSelector).clear().type(option, { delay: 10 });
|
|
|
|
}
|
|
|
|
});
|
2022-10-21 08:12:23 +00:00
|
|
|
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-27 15:27:49 +00:00
|
|
|
.click({ force: true })
|
|
|
|
.then(() => selectedOption);
|
2022-10-21 08:12:23 +00:00
|
|
|
});
|
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")
|
2023-01-27 15:27:49 +00:00
|
|
|
.then(text => {
|
|
|
|
selectedOption = text;
|
|
|
|
});
|
|
|
|
return cy
|
2021-09-10 08:59:46 +00:00
|
|
|
.get(BUTTON_SELECTORS.selectOption)
|
2021-04-01 12:33:36 +00:00
|
|
|
.first()
|
2023-01-27 15:27:49 +00:00
|
|
|
.click()
|
|
|
|
.then(() => selectedOption);
|
2021-04-01 12:33:36 +00:00
|
|
|
}
|
2021-09-27 10:04:21 +00:00
|
|
|
});
|