Tests - fixes pages scenarios (#3857)
* test fixes for pages scenarios * fixed pages tests - should create published page should keep failing since waits for BE fix
This commit is contained in:
parent
52bac3b8f5
commit
ad341e9954
7 changed files with 144 additions and 77 deletions
|
@ -3,22 +3,30 @@
|
|||
|
||||
import faker from "faker";
|
||||
|
||||
import { PAGE_DETAILS_SELECTORS } from "../../elements/pages/page-details";
|
||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||
import { pageDetailsUrl } from "../../fixtures/urlList";
|
||||
import { createAttribute } from "../../support/api/requests/Attribute";
|
||||
import {
|
||||
createPage as createPageRequest,
|
||||
getPage,
|
||||
} from "../../support/api/requests/Page";
|
||||
import { createPageType } from "../../support/api/requests/PageType";
|
||||
import { attributesTypes, createPage } from "../../support/pages/pagesPage";
|
||||
BUTTON_SELECTORS,
|
||||
PAGE_DETAILS_SELECTORS,
|
||||
} from "../../elements";
|
||||
import {
|
||||
pageDetailsUrl,
|
||||
urlList,
|
||||
} from "../../fixtures/urlList";
|
||||
import {
|
||||
attributeRequests,
|
||||
pageRequests,
|
||||
pageTypeRequests,
|
||||
} from "../../support/api/requests";
|
||||
import {
|
||||
pageDetailsPage,
|
||||
pagesPage,
|
||||
} from "../../support/pages";
|
||||
|
||||
describe("Tests for pages", () => {
|
||||
const startsWith = `Pages`;
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
let attribute;
|
||||
let pageType;
|
||||
let pageTypeId;
|
||||
|
||||
const attributeValuesOnPage = {
|
||||
NUMERIC: 1,
|
||||
|
@ -30,10 +38,11 @@ describe("Tests for pages", () => {
|
|||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
createAttribute({ name, type: "PAGE_TYPE" })
|
||||
attributeRequests
|
||||
.createAttribute({ name, type: "PAGE_TYPE" })
|
||||
.then(attributeResp => {
|
||||
attribute = attributeResp;
|
||||
createPageType({ name, attributeId: attribute.id });
|
||||
pageTypeRequests.createPageType({ name, attributeId: attribute.id });
|
||||
})
|
||||
.then(({ pageType: pageTypeResp }) => {
|
||||
pageType = pageTypeResp;
|
||||
|
@ -49,17 +58,21 @@ describe("Tests for pages", () => {
|
|||
"should create not published page",
|
||||
{ tags: ["@pages", "@allEnv", "@stable"] },
|
||||
() => {
|
||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createPage({ pageName: randomName, pageTypeName: name })
|
||||
.then(page => {
|
||||
getPage(page.id);
|
||||
})
|
||||
.then(page => {
|
||||
expect(page.title).to.eq(randomName);
|
||||
cy.addAliasToGraphRequest("PageType");
|
||||
const pageName = `${startsWith}${faker.datatype.number()}`;
|
||||
cy.visit(urlList.pages);
|
||||
pagesPage.openCreatePageDialog();
|
||||
pagesPage.selectPageTypeOnIndex(0);
|
||||
cy.clickSubmitButton();
|
||||
cy.waitForRequestAndCheckIfNoErrors("@PageType");
|
||||
pageDetailsPage.typePageName(pageName);
|
||||
cy.get(PAGE_DETAILS_SELECTORS.isNotPublishedCheckbox).click();
|
||||
pagesPage.savePage().then(page => {
|
||||
pageRequests.getPage(page.id).then(page => {
|
||||
expect(page.title).to.eq(pageName);
|
||||
expect(page.isPublished).to.be.false;
|
||||
expect(page.attributes[0].attribute.id).to.eq(attribute.id);
|
||||
getPage(page.id, "token").should("be.null");
|
||||
pageRequests.getPage(page.id, "token").should("be.null");
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
|
@ -70,13 +83,14 @@ describe("Tests for pages", () => {
|
|||
() => {
|
||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createPage({
|
||||
pagesPage
|
||||
.createPage({
|
||||
pageName: randomName,
|
||||
pageTypeName: name,
|
||||
isPublished: true,
|
||||
})
|
||||
.then(page => {
|
||||
getPage(page.id, "token");
|
||||
pageRequests.getPage(page.id, "token");
|
||||
})
|
||||
.then(page => {
|
||||
expect(page.title).to.eq(randomName);
|
||||
|
@ -86,33 +100,44 @@ describe("Tests for pages", () => {
|
|||
},
|
||||
);
|
||||
|
||||
Object.keys(attributesTypes).forEach(attributeType => {
|
||||
Object.keys(pagesPage.attributesTypes).forEach(attributeType => {
|
||||
it(
|
||||
`should create page with ${attributeType} attribute`,
|
||||
{ tags: ["@pages", "@allEnv", "@stable"] },
|
||||
() => {
|
||||
const randomName = `AAA-${startsWith}${faker.datatype.number()}`;
|
||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
const attributeValues = [attributeValuesOnPage[attributeType]];
|
||||
createAttribute({
|
||||
attributeRequests
|
||||
.createAttribute({
|
||||
name: randomName,
|
||||
type: "PAGE_TYPE",
|
||||
inputType: attributeType,
|
||||
attributeValues,
|
||||
}).then(attributeResp => {
|
||||
})
|
||||
.then(attributeResp => {
|
||||
attribute = attributeResp;
|
||||
createPageType({ name: randomName, attributeId: attribute.id });
|
||||
});
|
||||
createPage({
|
||||
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 => {
|
||||
getPage(page.id);
|
||||
pageRequests.getPage(page.id);
|
||||
})
|
||||
.then(page => {
|
||||
expect(page.attributes[0].values[0].inputType).to.eq(attributeType);
|
||||
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(),
|
||||
|
@ -123,6 +148,8 @@ describe("Tests for pages", () => {
|
|||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@ -130,10 +157,12 @@ describe("Tests for pages", () => {
|
|||
it("should delete page", { tags: ["@pages", "@allEnv", "@stable"] }, () => {
|
||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createPageRequest({
|
||||
pageRequests
|
||||
.createPage({
|
||||
pageTypeId: pageType.id,
|
||||
title: randomName,
|
||||
}).then(({ page }) => {
|
||||
})
|
||||
.then(({ page }) => {
|
||||
cy.visit(pageDetailsUrl(page.id))
|
||||
.get(BUTTON_SELECTORS.deleteButton)
|
||||
.click()
|
||||
|
@ -141,7 +170,7 @@ describe("Tests for pages", () => {
|
|||
.get(BUTTON_SELECTORS.submit)
|
||||
.click()
|
||||
.waitForRequestAndCheckIfNoErrors("@PageRemove");
|
||||
getPage(page.id).should("be.null");
|
||||
pageRequests.getPage(page.id).should("be.null");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -149,7 +178,8 @@ describe("Tests for pages", () => {
|
|||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
const updatedName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createPageRequest({
|
||||
pageRequests
|
||||
.createPage({
|
||||
pageTypeId: pageType.id,
|
||||
title: randomName,
|
||||
isPublished: true,
|
||||
|
@ -165,7 +195,7 @@ describe("Tests for pages", () => {
|
|||
.get(BUTTON_SELECTORS.confirm)
|
||||
.click()
|
||||
.waitForRequestAndCheckIfNoErrors("@PageUpdate");
|
||||
getPage(page.id);
|
||||
pageRequests.getPage(page.id);
|
||||
})
|
||||
.then(page => {
|
||||
expect(page.title).to.eq(updatedName);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
export const PAGES_LIST_SELECTORS = {
|
||||
createPageButton: '[data-test-id="create-page"]',
|
||||
dialogPageTypeInput: "[data-test-id='dialog-page-type']",
|
||||
dialogPageTypeInputOptions:
|
||||
"[data-test-id='single-autocomplete-select-option']",
|
||||
};
|
||||
|
|
|
@ -16,6 +16,7 @@ export const urlList = {
|
|||
navigation: "navigation/",
|
||||
orders: "orders/",
|
||||
pages: "pages/",
|
||||
addPageType: "pages/add?page-type-id=",
|
||||
pageTypes: "page-types/",
|
||||
permissionsGroups: "permission-groups/",
|
||||
plugins: "plugins/",
|
||||
|
|
|
@ -10,3 +10,6 @@ export {
|
|||
} from "./StaffMembers";
|
||||
export * as productsRequests from "./Product";
|
||||
export * as productsTypeRequests from "./ProductType";
|
||||
export * as attributeRequests from "./Attribute";
|
||||
export * as pageRequests from "./Page";
|
||||
export * as pageTypeRequests from "./PageType";
|
||||
|
|
|
@ -37,3 +37,5 @@ export * as productDetailsPage from "./catalog/products/productDetailsPage";
|
|||
export * as priceListComponent from "./catalog/products/priceListComponent";
|
||||
export * as variantsPage from "./catalog/products/VariantsPage";
|
||||
export * as channelsPage from "./channelsPage";
|
||||
export * as pagesPage from "./pagesPage";
|
||||
export * as pageDetailsPage from "./pageDetailsPage";
|
||||
|
|
5
cypress/support/pages/pageDetailsPage.js
Normal file
5
cypress/support/pages/pageDetailsPage.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { PAGE_DETAILS_SELECTORS } from "../../elements/pages/page-details";
|
||||
|
||||
export function typePageName(pageName) {
|
||||
return cy.get(PAGE_DETAILS_SELECTORS.nameInput).type(pageName);
|
||||
}
|
|
@ -36,6 +36,20 @@ export function createPage({
|
|||
attributesTypes[attributeType](attributeValue);
|
||||
return savePage();
|
||||
}
|
||||
export function createPageWithAttribute({
|
||||
pageName,
|
||||
pageTypeName,
|
||||
isPublished = false,
|
||||
attributeType = "DROPDOWN",
|
||||
attributeValue,
|
||||
}) {
|
||||
cy.get(PAGE_DETAILS_SELECTORS.nameInput).type(pageName);
|
||||
if (!isPublished) {
|
||||
cy.get(PAGE_DETAILS_SELECTORS.isNotPublishedCheckbox).click();
|
||||
}
|
||||
attributesTypes[attributeType](attributeValue);
|
||||
return savePage();
|
||||
}
|
||||
|
||||
export function addSelectAttributeValue(attributeValue) {
|
||||
cy.fillAutocompleteSelect(
|
||||
|
@ -81,7 +95,7 @@ function openCreatePageAndFillUpGeneralFields({
|
|||
}
|
||||
}
|
||||
|
||||
function savePage() {
|
||||
export function savePage() {
|
||||
return cy
|
||||
.addAliasToGraphRequest("PageCreate")
|
||||
.get(BUTTON_SELECTORS.confirm)
|
||||
|
@ -90,3 +104,13 @@ function savePage() {
|
|||
.waitForRequestAndCheckIfNoErrors("@PageCreate")
|
||||
.its("response.body.data.pageCreate.page");
|
||||
}
|
||||
export function openCreatePageDialog() {
|
||||
return cy.get(PAGES_LIST_SELECTORS.createPageButton).click();
|
||||
}
|
||||
export function selectPageTypeOnIndex(index) {
|
||||
cy.get(PAGES_LIST_SELECTORS.dialogPageTypeInput).click();
|
||||
return cy
|
||||
.get(PAGES_LIST_SELECTORS.dialogPageTypeInputOptions)
|
||||
.eq(index)
|
||||
.click();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue