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 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 {
|
import {
|
||||||
createPage as createPageRequest,
|
BUTTON_SELECTORS,
|
||||||
getPage,
|
PAGE_DETAILS_SELECTORS,
|
||||||
} from "../../support/api/requests/Page";
|
} from "../../elements";
|
||||||
import { createPageType } from "../../support/api/requests/PageType";
|
import {
|
||||||
import { attributesTypes, createPage } from "../../support/pages/pagesPage";
|
pageDetailsUrl,
|
||||||
|
urlList,
|
||||||
|
} from "../../fixtures/urlList";
|
||||||
|
import {
|
||||||
|
attributeRequests,
|
||||||
|
pageRequests,
|
||||||
|
pageTypeRequests,
|
||||||
|
} from "../../support/api/requests";
|
||||||
|
import {
|
||||||
|
pageDetailsPage,
|
||||||
|
pagesPage,
|
||||||
|
} from "../../support/pages";
|
||||||
|
|
||||||
describe("Tests for pages", () => {
|
describe("Tests for pages", () => {
|
||||||
const startsWith = `Pages`;
|
const startsWith = `Pages`;
|
||||||
const name = `${startsWith}${faker.datatype.number()}`;
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
let attribute;
|
let attribute;
|
||||||
let pageType;
|
let pageType;
|
||||||
|
let pageTypeId;
|
||||||
|
|
||||||
const attributeValuesOnPage = {
|
const attributeValuesOnPage = {
|
||||||
NUMERIC: 1,
|
NUMERIC: 1,
|
||||||
|
@ -30,10 +38,11 @@ describe("Tests for pages", () => {
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
createAttribute({ name, type: "PAGE_TYPE" })
|
attributeRequests
|
||||||
|
.createAttribute({ name, type: "PAGE_TYPE" })
|
||||||
.then(attributeResp => {
|
.then(attributeResp => {
|
||||||
attribute = attributeResp;
|
attribute = attributeResp;
|
||||||
createPageType({ name, attributeId: attribute.id });
|
pageTypeRequests.createPageType({ name, attributeId: attribute.id });
|
||||||
})
|
})
|
||||||
.then(({ pageType: pageTypeResp }) => {
|
.then(({ pageType: pageTypeResp }) => {
|
||||||
pageType = pageTypeResp;
|
pageType = pageTypeResp;
|
||||||
|
@ -49,18 +58,22 @@ describe("Tests for pages", () => {
|
||||||
"should create not published page",
|
"should create not published page",
|
||||||
{ tags: ["@pages", "@allEnv", "@stable"] },
|
{ tags: ["@pages", "@allEnv", "@stable"] },
|
||||||
() => {
|
() => {
|
||||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
cy.addAliasToGraphRequest("PageType");
|
||||||
|
const pageName = `${startsWith}${faker.datatype.number()}`;
|
||||||
createPage({ pageName: randomName, pageTypeName: name })
|
cy.visit(urlList.pages);
|
||||||
.then(page => {
|
pagesPage.openCreatePageDialog();
|
||||||
getPage(page.id);
|
pagesPage.selectPageTypeOnIndex(0);
|
||||||
})
|
cy.clickSubmitButton();
|
||||||
.then(page => {
|
cy.waitForRequestAndCheckIfNoErrors("@PageType");
|
||||||
expect(page.title).to.eq(randomName);
|
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.isPublished).to.be.false;
|
||||||
expect(page.attributes[0].attribute.id).to.eq(attribute.id);
|
pageRequests.getPage(page.id, "token").should("be.null");
|
||||||
getPage(page.id, "token").should("be.null");
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -70,13 +83,14 @@ describe("Tests for pages", () => {
|
||||||
() => {
|
() => {
|
||||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
createPage({
|
pagesPage
|
||||||
pageName: randomName,
|
.createPage({
|
||||||
pageTypeName: name,
|
pageName: randomName,
|
||||||
isPublished: true,
|
pageTypeName: name,
|
||||||
})
|
isPublished: true,
|
||||||
|
})
|
||||||
.then(page => {
|
.then(page => {
|
||||||
getPage(page.id, "token");
|
pageRequests.getPage(page.id, "token");
|
||||||
})
|
})
|
||||||
.then(page => {
|
.then(page => {
|
||||||
expect(page.title).to.eq(randomName);
|
expect(page.title).to.eq(randomName);
|
||||||
|
@ -86,42 +100,55 @@ describe("Tests for pages", () => {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Object.keys(attributesTypes).forEach(attributeType => {
|
Object.keys(pagesPage.attributesTypes).forEach(attributeType => {
|
||||||
it(
|
it(
|
||||||
`should create page with ${attributeType} attribute`,
|
`should create page with ${attributeType} attribute`,
|
||||||
{ tags: ["@pages", "@allEnv", "@stable"] },
|
{ tags: ["@pages", "@allEnv", "@stable"] },
|
||||||
() => {
|
() => {
|
||||||
const randomName = `AAA-${startsWith}${faker.datatype.number()}`;
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||||
const attributeValues = [attributeValuesOnPage[attributeType]];
|
const attributeValues = [attributeValuesOnPage[attributeType]];
|
||||||
createAttribute({
|
attributeRequests
|
||||||
name: randomName,
|
.createAttribute({
|
||||||
type: "PAGE_TYPE",
|
name: randomName,
|
||||||
inputType: attributeType,
|
type: "PAGE_TYPE",
|
||||||
attributeValues,
|
inputType: attributeType,
|
||||||
}).then(attributeResp => {
|
attributeValues,
|
||||||
attribute = attributeResp;
|
|
||||||
createPageType({ name: randomName, attributeId: attribute.id });
|
|
||||||
});
|
|
||||||
createPage({
|
|
||||||
pageName: randomName,
|
|
||||||
pageTypeName: randomName,
|
|
||||||
attributeType,
|
|
||||||
attributeValue: attributeValuesOnPage[attributeType],
|
|
||||||
})
|
|
||||||
.then(page => {
|
|
||||||
getPage(page.id);
|
|
||||||
})
|
})
|
||||||
.then(page => {
|
.then(attributeResp => {
|
||||||
expect(page.attributes[0].values[0].inputType).to.eq(attributeType);
|
attribute = attributeResp;
|
||||||
if (attributeType !== "BOOLEAN") {
|
pageTypeRequests
|
||||||
expect(page.attributes[0].values[0].name).to.eq(
|
.createPageType({
|
||||||
attributeValuesOnPage[attributeType].toString(),
|
name: randomName,
|
||||||
);
|
attributeId: attribute.id,
|
||||||
} else {
|
})
|
||||||
expect(page.attributes[0].values[0].name).to.includes(
|
.then(createPageResponse => {
|
||||||
"Yes".toString(),
|
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(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -130,30 +157,33 @@ describe("Tests for pages", () => {
|
||||||
it("should delete page", { tags: ["@pages", "@allEnv", "@stable"] }, () => {
|
it("should delete page", { tags: ["@pages", "@allEnv", "@stable"] }, () => {
|
||||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
createPageRequest({
|
pageRequests
|
||||||
pageTypeId: pageType.id,
|
.createPage({
|
||||||
title: randomName,
|
pageTypeId: pageType.id,
|
||||||
}).then(({ page }) => {
|
title: randomName,
|
||||||
cy.visit(pageDetailsUrl(page.id))
|
})
|
||||||
.get(BUTTON_SELECTORS.deleteButton)
|
.then(({ page }) => {
|
||||||
.click()
|
cy.visit(pageDetailsUrl(page.id))
|
||||||
.addAliasToGraphRequest("PageRemove")
|
.get(BUTTON_SELECTORS.deleteButton)
|
||||||
.get(BUTTON_SELECTORS.submit)
|
.click()
|
||||||
.click()
|
.addAliasToGraphRequest("PageRemove")
|
||||||
.waitForRequestAndCheckIfNoErrors("@PageRemove");
|
.get(BUTTON_SELECTORS.submit)
|
||||||
getPage(page.id).should("be.null");
|
.click()
|
||||||
});
|
.waitForRequestAndCheckIfNoErrors("@PageRemove");
|
||||||
|
pageRequests.getPage(page.id).should("be.null");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should update page", { tags: ["@pages", "@allEnv", "@stable"] }, () => {
|
it("should update page", { tags: ["@pages", "@allEnv", "@stable"] }, () => {
|
||||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||||
const updatedName = `${startsWith}${faker.datatype.number()}`;
|
const updatedName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
createPageRequest({
|
pageRequests
|
||||||
pageTypeId: pageType.id,
|
.createPage({
|
||||||
title: randomName,
|
pageTypeId: pageType.id,
|
||||||
isPublished: true,
|
title: randomName,
|
||||||
})
|
isPublished: true,
|
||||||
|
})
|
||||||
.then(({ page }) => {
|
.then(({ page }) => {
|
||||||
cy.visit(pageDetailsUrl(page.id))
|
cy.visit(pageDetailsUrl(page.id))
|
||||||
.get(PAGE_DETAILS_SELECTORS.nameInput)
|
.get(PAGE_DETAILS_SELECTORS.nameInput)
|
||||||
|
@ -165,7 +195,7 @@ describe("Tests for pages", () => {
|
||||||
.get(BUTTON_SELECTORS.confirm)
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
.click()
|
.click()
|
||||||
.waitForRequestAndCheckIfNoErrors("@PageUpdate");
|
.waitForRequestAndCheckIfNoErrors("@PageUpdate");
|
||||||
getPage(page.id);
|
pageRequests.getPage(page.id);
|
||||||
})
|
})
|
||||||
.then(page => {
|
.then(page => {
|
||||||
expect(page.title).to.eq(updatedName);
|
expect(page.title).to.eq(updatedName);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
export const PAGES_LIST_SELECTORS = {
|
export const PAGES_LIST_SELECTORS = {
|
||||||
createPageButton: '[data-test-id="create-page"]',
|
createPageButton: '[data-test-id="create-page"]',
|
||||||
dialogPageTypeInput: "[data-test-id='dialog-page-type']",
|
dialogPageTypeInput: "[data-test-id='dialog-page-type']",
|
||||||
|
dialogPageTypeInputOptions:
|
||||||
|
"[data-test-id='single-autocomplete-select-option']",
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,7 @@ export const urlList = {
|
||||||
navigation: "navigation/",
|
navigation: "navigation/",
|
||||||
orders: "orders/",
|
orders: "orders/",
|
||||||
pages: "pages/",
|
pages: "pages/",
|
||||||
|
addPageType: "pages/add?page-type-id=",
|
||||||
pageTypes: "page-types/",
|
pageTypes: "page-types/",
|
||||||
permissionsGroups: "permission-groups/",
|
permissionsGroups: "permission-groups/",
|
||||||
plugins: "plugins/",
|
plugins: "plugins/",
|
||||||
|
|
|
@ -10,3 +10,6 @@ export {
|
||||||
} from "./StaffMembers";
|
} from "./StaffMembers";
|
||||||
export * as productsRequests from "./Product";
|
export * as productsRequests from "./Product";
|
||||||
export * as productsTypeRequests from "./ProductType";
|
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 priceListComponent from "./catalog/products/priceListComponent";
|
||||||
export * as variantsPage from "./catalog/products/VariantsPage";
|
export * as variantsPage from "./catalog/products/VariantsPage";
|
||||||
export * as channelsPage from "./channelsPage";
|
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);
|
attributesTypes[attributeType](attributeValue);
|
||||||
return savePage();
|
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) {
|
export function addSelectAttributeValue(attributeValue) {
|
||||||
cy.fillAutocompleteSelect(
|
cy.fillAutocompleteSelect(
|
||||||
|
@ -81,7 +95,7 @@ function openCreatePageAndFillUpGeneralFields({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function savePage() {
|
export function savePage() {
|
||||||
return cy
|
return cy
|
||||||
.addAliasToGraphRequest("PageCreate")
|
.addAliasToGraphRequest("PageCreate")
|
||||||
.get(BUTTON_SELECTORS.confirm)
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
|
@ -90,3 +104,13 @@ function savePage() {
|
||||||
.waitForRequestAndCheckIfNoErrors("@PageCreate")
|
.waitForRequestAndCheckIfNoErrors("@PageCreate")
|
||||||
.its("response.body.data.pageCreate.page");
|
.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