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-08-17 10:36:41 +00:00
|
|
|
import { BUTTON_SELECTORS, PAGE_DETAILS_SELECTORS } from "../../elements";
|
|
|
|
import { pageDetailsUrl, urlList } from "../../fixtures/urlList";
|
2023-07-05 12:23:56 +00:00
|
|
|
import {
|
|
|
|
attributeRequests,
|
|
|
|
pageRequests,
|
|
|
|
pageTypeRequests,
|
|
|
|
} from "../../support/api/requests";
|
2023-08-17 10:36:41 +00:00
|
|
|
import { pageDetailsPage, pagesPage } from "../../support/pages";
|
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;
|
2023-07-05 12:23:56 +00:00
|
|
|
let pageTypeId;
|
2022-06-27 09:30:51 +00:00
|
|
|
|
|
|
|
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(() => {
|
2023-07-28 07:48:41 +00:00
|
|
|
cy.loginUserViaRequest();
|
2023-07-05 12:23:56 +00:00
|
|
|
attributeRequests
|
|
|
|
.createAttribute({ name, type: "PAGE_TYPE" })
|
2022-06-27 09:30:51 +00:00
|
|
|
.then(attributeResp => {
|
|
|
|
attribute = attributeResp;
|
2023-07-05 12:23:56 +00:00
|
|
|
pageTypeRequests.createPageType({ name, attributeId: attribute.id });
|
2022-06-27 09:30:51 +00:00
|
|
|
})
|
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(() => {
|
2023-07-28 07:48:41 +00:00
|
|
|
cy.loginUserViaRequest();
|
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 not published page",
|
|
|
|
{ tags: ["@pages", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2023-07-05 12:23:56 +00:00
|
|
|
cy.addAliasToGraphRequest("PageType");
|
|
|
|
const pageName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
cy.visit(urlList.pages);
|
|
|
|
pagesPage.openCreatePageDialog();
|
|
|
|
pagesPage.selectPageTypeOnIndex(0);
|
|
|
|
cy.clickSubmitButton();
|
|
|
|
cy.waitForRequestAndCheckIfNoErrors("@PageType");
|
2023-08-17 10:36:41 +00:00
|
|
|
pageDetailsPage.typePageName(pageName).should("have.value", pageName);
|
2023-07-05 12:23:56 +00:00
|
|
|
cy.get(PAGE_DETAILS_SELECTORS.isNotPublishedCheckbox).click();
|
|
|
|
pagesPage.savePage().then(page => {
|
|
|
|
pageRequests.getPage(page.id).then(page => {
|
|
|
|
expect(page.title).to.eq(pageName);
|
2021-09-27 10:04:21 +00:00
|
|
|
expect(page.isPublished).to.be.false;
|
2023-07-05 12:23:56 +00:00
|
|
|
pageRequests.getPage(page.id, "token").should("be.null");
|
2021-09-27 10:04:21 +00:00
|
|
|
});
|
2023-07-05 12:23:56 +00:00
|
|
|
});
|
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
|
|
|
|
2023-07-05 12:23:56 +00:00
|
|
|
pagesPage
|
|
|
|
.createPage({
|
|
|
|
pageName: randomName,
|
|
|
|
pageTypeName: name,
|
|
|
|
isPublished: true,
|
|
|
|
})
|
2021-07-27 08:57:17 +00:00
|
|
|
.then(page => {
|
2023-07-05 12:23:56 +00:00
|
|
|
pageRequests.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
|
|
|
);
|
|
|
|
|
2023-07-05 12:23:56 +00:00
|
|
|
Object.keys(pagesPage.attributesTypes).forEach(attributeType => {
|
2022-06-27 09:30:51 +00:00
|
|
|
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
|
|
|
() => {
|
2023-07-05 12:23:56 +00:00
|
|
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
2021-09-27 10:04:21 +00:00
|
|
|
const attributeValues = [attributeValuesOnPage[attributeType]];
|
2023-07-05 12:23:56 +00:00
|
|
|
attributeRequests
|
|
|
|
.createAttribute({
|
|
|
|
name: randomName,
|
|
|
|
type: "PAGE_TYPE",
|
|
|
|
inputType: attributeType,
|
|
|
|
attributeValues,
|
2021-09-27 10:04:21 +00:00
|
|
|
})
|
2023-07-05 12:23:56 +00:00
|
|
|
.then(attributeResp => {
|
|
|
|
attribute = attributeResp;
|
|
|
|
pageTypeRequests
|
|
|
|
.createPageType({
|
|
|
|
name: randomName,
|
|
|
|
attributeId: attribute.id,
|
|
|
|
})
|
|
|
|
.then(createPageResponse => {
|
|
|
|
pageTypeId = createPageResponse.pageType.id;
|
|
|
|
cy.visit(`${urlList.addPageType}${pageTypeId}`);
|
|
|
|
pagesPage
|
|
|
|
.createPageWithAttribute({
|
|
|
|
pageName: randomName,
|
|
|
|
pageTypeName: randomName,
|
|
|
|
attributeType,
|
|
|
|
attributeValue: attributeValuesOnPage[attributeType],
|
|
|
|
})
|
|
|
|
.then(page => {
|
|
|
|
pageRequests.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(
|
|
|
|
attributeValuesOnPage[attributeType].toString(),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
expect(page.attributes[0].values[0].name).to.includes(
|
|
|
|
"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()}`;
|
|
|
|
|
2023-07-05 12:23:56 +00:00
|
|
|
pageRequests
|
|
|
|
.createPage({
|
|
|
|
pageTypeId: pageType.id,
|
|
|
|
title: randomName,
|
|
|
|
})
|
|
|
|
.then(({ page }) => {
|
|
|
|
cy.visit(pageDetailsUrl(page.id))
|
|
|
|
.get(BUTTON_SELECTORS.deleteButton)
|
|
|
|
.click()
|
|
|
|
.addAliasToGraphRequest("PageRemove")
|
|
|
|
.get(BUTTON_SELECTORS.submit)
|
|
|
|
.click()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@PageRemove");
|
|
|
|
pageRequests.getPage(page.id).should("be.null");
|
|
|
|
});
|
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
|
|
|
|
2023-07-05 12:23:56 +00:00
|
|
|
pageRequests
|
|
|
|
.createPage({
|
|
|
|
pageTypeId: pageType.id,
|
|
|
|
title: randomName,
|
|
|
|
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)
|
2023-05-04 08:57:18 +00:00
|
|
|
.clear()
|
|
|
|
.type(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");
|
2023-07-05 12:23:56 +00:00
|
|
|
pageRequests.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
|
|
|
});
|
|
|
|
});
|