2021-09-27 10:04:21 +00:00
|
|
|
/// <reference types="cypress"/>
|
|
|
|
/// <reference types="../../support"/>
|
|
|
|
|
2021-07-27 08:57:17 +00:00
|
|
|
import faker from "faker";
|
|
|
|
|
2023-03-09 08:18:07 +00:00
|
|
|
import { PAGE_DETAILS_SELECTORS } from "../../elements/pages/page-details";
|
2021-12-22 13:55:08 +00:00
|
|
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
2022-06-27 09:30:51 +00:00
|
|
|
import { pageDetailsUrl } from "../../fixtures/urlList";
|
2021-09-27 10:04:21 +00:00
|
|
|
import { createAttribute } from "../../support/api/requests/Attribute";
|
2021-12-22 13:55:08 +00:00
|
|
|
import {
|
|
|
|
createPage as createPageRequest,
|
2022-06-27 16:49:35 +00:00
|
|
|
getPage,
|
2021-12-22 13:55:08 +00:00
|
|
|
} from "../../support/api/requests/Page";
|
2021-09-27 10:04:21 +00:00
|
|
|
import { createPageType } from "../../support/api/requests/PageType";
|
|
|
|
import { deleteAttributesStartsWith } from "../../support/api/utils/attributes/attributeUtils";
|
|
|
|
import { deletePageTypesStartsWith } from "../../support/api/utils/pageTypeUtils";
|
|
|
|
import { attributesTypes, createPage } from "../../support/pages/pagesPage";
|
2021-07-27 08:57:17 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
describe("Tests for pages", () => {
|
|
|
|
const startsWith = `Pages`;
|
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
let attribute;
|
|
|
|
let pageType;
|
|
|
|
|
|
|
|
const attributeValuesOnPage = {
|
|
|
|
NUMERIC: 1,
|
|
|
|
RICH_TEXT: faker.lorem.sentence(),
|
|
|
|
DROPDOWN: "value",
|
|
|
|
MULTISELECT: "value",
|
2022-06-27 16:49:35 +00:00
|
|
|
BOOLEAN: true,
|
2022-06-27 09:30:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
deleteAttributesStartsWith(startsWith);
|
|
|
|
deletePageTypesStartsWith(startsWith);
|
|
|
|
|
|
|
|
createAttribute({ name, type: "PAGE_TYPE" })
|
|
|
|
.then(attributeResp => {
|
|
|
|
attribute = attributeResp;
|
|
|
|
createPageType({ name, attributeId: attribute.id });
|
|
|
|
})
|
2023-01-16 09:43:13 +00:00
|
|
|
.then(({ pageType: pageTypeResp }) => {
|
|
|
|
pageType = pageTypeResp;
|
|
|
|
cy.checkIfDataAreNotNull({ attribute, pageType });
|
|
|
|
});
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
2021-07-27 08:57:17 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
});
|
2021-07-27 08:57:17 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should create not published page",
|
|
|
|
{ tags: ["@pages", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2021-09-27 10:04:21 +00:00
|
|
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
2021-07-27 08:57:17 +00:00
|
|
|
|
2021-09-27 10:04:21 +00:00
|
|
|
createPage({ pageName: randomName, pageTypeName: name })
|
|
|
|
.then(page => {
|
|
|
|
getPage(page.id);
|
|
|
|
})
|
|
|
|
.then(page => {
|
|
|
|
expect(page.title).to.eq(randomName);
|
|
|
|
expect(page.isPublished).to.be.false;
|
|
|
|
expect(page.attributes[0].attribute.id).to.eq(attribute.id);
|
|
|
|
getPage(page.id, "token").should("be.null");
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-27 08:57:17 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should create published page",
|
|
|
|
{ tags: ["@pages", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2021-07-27 08:57:17 +00:00
|
|
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
2021-09-27 10:04:21 +00:00
|
|
|
|
2021-07-27 08:57:17 +00:00
|
|
|
createPage({
|
|
|
|
pageName: randomName,
|
2021-09-27 10:04:21 +00:00
|
|
|
pageTypeName: name,
|
2022-06-27 16:49:35 +00:00
|
|
|
isPublished: true,
|
2021-07-27 08:57:17 +00:00
|
|
|
})
|
|
|
|
.then(page => {
|
2021-09-27 10:04:21 +00:00
|
|
|
getPage(page.id, "token");
|
2021-07-27 08:57:17 +00:00
|
|
|
})
|
|
|
|
.then(page => {
|
2021-09-27 10:04:21 +00:00
|
|
|
expect(page.title).to.eq(randomName);
|
|
|
|
expect(page.isPublished).to.be.true;
|
|
|
|
expect(page.attributes[0].attribute.id).to.eq(attribute.id);
|
2021-07-27 08:57:17 +00:00
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
Object.keys(attributesTypes).forEach(attributeType => {
|
|
|
|
it(
|
|
|
|
`should create page with ${attributeType} attribute`,
|
2022-12-30 07:21:28 +00:00
|
|
|
{ tags: ["@pages", "@allEnv", "@stable"] },
|
2022-06-27 09:30:51 +00:00
|
|
|
() => {
|
2021-09-27 10:04:21 +00:00
|
|
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
const attributeValues = [attributeValuesOnPage[attributeType]];
|
|
|
|
createAttribute({
|
|
|
|
name: randomName,
|
|
|
|
type: "PAGE_TYPE",
|
|
|
|
inputType: attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
attributeValues,
|
2021-09-27 10:04:21 +00:00
|
|
|
}).then(attributeResp => {
|
|
|
|
attribute = attributeResp;
|
|
|
|
createPageType({ name: randomName, attributeId: attribute.id });
|
|
|
|
});
|
|
|
|
createPage({
|
|
|
|
pageName: randomName,
|
|
|
|
pageTypeName: randomName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
attributeValue: attributeValuesOnPage[attributeType],
|
2021-09-27 10:04:21 +00:00
|
|
|
})
|
|
|
|
.then(page => {
|
|
|
|
getPage(page.id);
|
|
|
|
})
|
|
|
|
.then(page => {
|
|
|
|
expect(page.attributes[0].values[0].inputType).to.eq(attributeType);
|
|
|
|
if (attributeType !== "BOOLEAN") {
|
|
|
|
expect(page.attributes[0].values[0].name).to.eq(
|
2022-06-27 16:49:35 +00:00
|
|
|
attributeValuesOnPage[attributeType].toString(),
|
2021-09-27 10:04:21 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
expect(page.attributes[0].values[0].name).to.includes(
|
2022-06-27 16:49:35 +00:00
|
|
|
"Yes".toString(),
|
2021-09-27 10:04:21 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should delete page", { tags: ["@pages", "@allEnv", "@stable"] }, () => {
|
|
|
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
|
|
|
|
createPageRequest({
|
|
|
|
pageTypeId: pageType.id,
|
2022-06-27 16:49:35 +00:00
|
|
|
title: randomName,
|
2022-06-27 09:30:51 +00:00
|
|
|
}).then(({ page }) => {
|
|
|
|
cy.visit(pageDetailsUrl(page.id))
|
|
|
|
.get(BUTTON_SELECTORS.deleteButton)
|
|
|
|
.click()
|
|
|
|
.addAliasToGraphRequest("PageRemove")
|
|
|
|
.get(BUTTON_SELECTORS.submit)
|
|
|
|
.click()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@PageRemove");
|
|
|
|
getPage(page.id).should("be.null");
|
2021-09-27 10:04:21 +00:00
|
|
|
});
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
2021-12-22 13:55:08 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it("should update page", { tags: ["@pages", "@allEnv", "@stable"] }, () => {
|
|
|
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
const updatedName = `${startsWith}${faker.datatype.number()}`;
|
2021-12-22 13:55:08 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
createPageRequest({
|
|
|
|
pageTypeId: pageType.id,
|
2022-06-27 16:49:35 +00:00
|
|
|
title: randomName,
|
2022-09-02 08:07:43 +00:00
|
|
|
isPublished: true,
|
2022-06-27 09:30:51 +00:00
|
|
|
})
|
|
|
|
.then(({ page }) => {
|
2021-12-22 13:55:08 +00:00
|
|
|
cy.visit(pageDetailsUrl(page.id))
|
2023-03-09 08:18:07 +00:00
|
|
|
.get(PAGE_DETAILS_SELECTORS.nameInput)
|
2022-06-27 09:30:51 +00:00
|
|
|
.clearAndType(updatedName)
|
2023-03-09 08:18:07 +00:00
|
|
|
.get(PAGE_DETAILS_SELECTORS.isNotPublishedCheckbox)
|
2021-12-22 13:55:08 +00:00
|
|
|
.click()
|
2022-06-27 09:30:51 +00:00
|
|
|
.addAliasToGraphRequest("PageUpdate")
|
|
|
|
.get(BUTTON_SELECTORS.confirm)
|
2021-12-22 13:55:08 +00:00
|
|
|
.click()
|
2022-06-27 09:30:51 +00:00
|
|
|
.waitForRequestAndCheckIfNoErrors("@PageUpdate");
|
|
|
|
getPage(page.id);
|
2021-12-22 13:55:08 +00:00
|
|
|
})
|
2022-06-27 09:30:51 +00:00
|
|
|
.then(page => {
|
|
|
|
expect(page.title).to.eq(updatedName);
|
2022-09-02 08:07:43 +00:00
|
|
|
expect(page.isPublished).to.eq(false);
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
2021-07-27 08:57:17 +00:00
|
|
|
});
|
|
|
|
});
|