2023-03-09 08:18:07 +00:00
|
|
|
import { PAGE_DETAILS_SELECTORS } from "../../elements/pages/page-details";
|
|
|
|
import { PAGES_LIST_SELECTORS } from "../../elements/pages/pages-list";
|
2021-09-27 10:04:21 +00:00
|
|
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
|
|
|
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
|
|
|
import { urlList } from "../../fixtures/urlList";
|
2021-07-27 08:57:17 +00:00
|
|
|
|
|
|
|
export const attributesTypes = {
|
|
|
|
DROPDOWN: addSelectAttributeValue,
|
|
|
|
MULTISELECT: addSelectAttributeValue,
|
|
|
|
RICH_TEXT: addRichTextAttributeValue,
|
|
|
|
BOOLEAN: addBooleanAttributeValue,
|
2022-09-02 08:07:43 +00:00
|
|
|
NUMERIC: addNumericAttributeValue,
|
2021-07-27 08:57:17 +00:00
|
|
|
};
|
2022-10-04 14:02:17 +00:00
|
|
|
|
|
|
|
export function fillUpPageTypeDialog({ pageTypeName }) {
|
|
|
|
const organization = {};
|
|
|
|
return cy
|
2023-03-09 08:18:07 +00:00
|
|
|
.fillAutocompleteSelect(
|
|
|
|
PAGES_LIST_SELECTORS.dialogPageTypeInput,
|
|
|
|
pageTypeName,
|
|
|
|
)
|
2022-10-04 14:02:17 +00:00
|
|
|
.then(selected => {
|
|
|
|
organization.pageType = selected;
|
|
|
|
return organization;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-27 08:57:17 +00:00
|
|
|
export function createPage({
|
|
|
|
pageName,
|
|
|
|
pageTypeName,
|
|
|
|
isPublished = false,
|
|
|
|
attributeType = "DROPDOWN",
|
2022-09-02 08:07:43 +00:00
|
|
|
attributeValue,
|
2021-07-27 08:57:17 +00:00
|
|
|
}) {
|
|
|
|
openCreatePageAndFillUpGeneralFields({ pageName, pageTypeName, isPublished });
|
|
|
|
attributesTypes[attributeType](attributeValue);
|
|
|
|
return savePage();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addSelectAttributeValue(attributeValue) {
|
2023-03-09 08:18:07 +00:00
|
|
|
cy.fillAutocompleteSelect(
|
|
|
|
PAGE_DETAILS_SELECTORS.attributeValues,
|
|
|
|
attributeValue,
|
|
|
|
);
|
2021-07-27 08:57:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function addRichTextAttributeValue(attributeValue) {
|
2023-03-09 08:18:07 +00:00
|
|
|
cy.get(PAGE_DETAILS_SELECTORS.attributeValues)
|
2021-07-27 08:57:17 +00:00
|
|
|
.find(SHARED_ELEMENTS.richTextEditor.empty)
|
|
|
|
.should("exist")
|
2023-03-09 08:18:07 +00:00
|
|
|
.get(PAGE_DETAILS_SELECTORS.attributeValues)
|
|
|
|
.find(PAGE_DETAILS_SELECTORS.richTextEditorAttributeValue)
|
2021-07-27 08:57:17 +00:00
|
|
|
.type(attributeValue)
|
|
|
|
.wait(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addBooleanAttributeValue() {
|
2023-03-09 08:18:07 +00:00
|
|
|
cy.get(PAGE_DETAILS_SELECTORS.booleanAttributeValueCheckbox).click();
|
2021-07-27 08:57:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function addNumericAttributeValue(attributeValue) {
|
2023-03-09 08:18:07 +00:00
|
|
|
cy.get(PAGE_DETAILS_SELECTORS.numericAttributeValueInput).type(
|
|
|
|
attributeValue,
|
2023-06-20 08:29:28 +00:00
|
|
|
{ force: true },
|
2023-03-09 08:18:07 +00:00
|
|
|
);
|
2021-07-27 08:57:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function openCreatePageAndFillUpGeneralFields({
|
|
|
|
pageName,
|
|
|
|
pageTypeName,
|
2022-09-02 08:07:43 +00:00
|
|
|
isPublished,
|
2021-07-27 08:57:17 +00:00
|
|
|
}) {
|
2023-03-09 08:18:07 +00:00
|
|
|
cy.visit(urlList.pages).get(PAGES_LIST_SELECTORS.createPageButton).click();
|
2022-10-04 14:02:17 +00:00
|
|
|
fillUpPageTypeDialog({ pageTypeName });
|
|
|
|
cy.get(BUTTON_SELECTORS.submit)
|
2021-07-27 08:57:17 +00:00
|
|
|
.click()
|
2023-03-09 08:18:07 +00:00
|
|
|
.get(PAGE_DETAILS_SELECTORS.nameInput)
|
2021-07-27 08:57:17 +00:00
|
|
|
.type(pageName);
|
2022-09-02 08:07:43 +00:00
|
|
|
if (!isPublished) {
|
2023-03-09 08:18:07 +00:00
|
|
|
cy.get(PAGE_DETAILS_SELECTORS.isNotPublishedCheckbox).click();
|
2021-07-27 08:57:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function savePage() {
|
2021-09-27 10:04:21 +00:00
|
|
|
return cy
|
|
|
|
.addAliasToGraphRequest("PageCreate")
|
2021-07-27 08:57:17 +00:00
|
|
|
.get(BUTTON_SELECTORS.confirm)
|
2021-09-27 10:04:21 +00:00
|
|
|
.click()
|
|
|
|
.confirmationMessageShouldDisappear()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@PageCreate")
|
|
|
|
.its("response.body.data.pageCreate.page");
|
2021-07-27 08:57:17 +00:00
|
|
|
}
|