test for create page type (#1213)
This commit is contained in:
parent
f68410b7cb
commit
0c21788d61
13 changed files with 137 additions and 19 deletions
|
@ -1,10 +1,14 @@
|
||||||
export function createAttribute(name, attributeValues = ["value"]) {
|
export function createAttribute({
|
||||||
|
name,
|
||||||
|
attributeValues = ["value"],
|
||||||
|
type = "PRODUCT_TYPE"
|
||||||
|
}) {
|
||||||
const values = attributeValues.map(element => `{name:"${element}"}`);
|
const values = attributeValues.map(element => `{name:"${element}"}`);
|
||||||
const mutation = `mutation{
|
const mutation = `mutation{
|
||||||
attributeCreate(input:{
|
attributeCreate(input:{
|
||||||
name:"${name}"
|
name:"${name}"
|
||||||
valueRequired:false
|
valueRequired:false
|
||||||
type:PRODUCT_TYPE
|
type:${type}
|
||||||
values: [${values}]
|
values: [${values}]
|
||||||
}){
|
}){
|
||||||
attribute{
|
attribute{
|
||||||
|
|
28
cypress/apiRequests/PageTypes.js
Normal file
28
cypress/apiRequests/PageTypes.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
export function getPageType(pageTypeId) {
|
||||||
|
const query = `query{
|
||||||
|
pageType(id:"${pageTypeId}"){
|
||||||
|
id
|
||||||
|
name
|
||||||
|
attributes{
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(query).its("body.data.pageType");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createPageType(name) {
|
||||||
|
const mutation = `mutation{
|
||||||
|
pageTypeCreate(input:{ name: "${name}"}){
|
||||||
|
pageType{
|
||||||
|
name
|
||||||
|
id
|
||||||
|
}
|
||||||
|
errors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation).its("body.data.pageTypeCreate");
|
||||||
|
}
|
4
cypress/elements/pageTypes/pageTypeDetails.js
Normal file
4
cypress/elements/pageTypes/pageTypeDetails.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export const PAGE_TYPE_DETAILS = {
|
||||||
|
nameInput: '[name="name"]',
|
||||||
|
assignAttributesButton: '[data-test-id="assignAttributes"]'
|
||||||
|
};
|
3
cypress/elements/pageTypes/pageTypesList.js
Normal file
3
cypress/elements/pageTypes/pageTypesList.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export const PAGE_TYPES_LIST = {
|
||||||
|
createPageTypeButton: '[data-test-id="createPageType"]'
|
||||||
|
};
|
|
@ -19,7 +19,7 @@ describe("Tests for product types", () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
deleteProductsStartsWith(startsWith);
|
deleteProductsStartsWith(startsWith);
|
||||||
createAttribute(startsWith);
|
createAttribute({ name: startsWith });
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
61
cypress/integration/allEnv/pages/pageTypes.js
Normal file
61
cypress/integration/allEnv/pages/pageTypes.js
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { createAttribute } from "../../../apiRequests/Attribute";
|
||||||
|
import { createPageType, getPageType } from "../../../apiRequests/PageTypes";
|
||||||
|
import { PAGE_TYPE_DETAILS } from "../../../elements/pageTypes/pageTypeDetails";
|
||||||
|
import { PAGE_TYPES_LIST } from "../../../elements/pageTypes/pageTypesList";
|
||||||
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||||
|
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
||||||
|
import { assignElements } from "../../../steps/shared/assignElements";
|
||||||
|
import { confirmationMessageShouldDisappear } from "../../../steps/shared/confirmationMessage";
|
||||||
|
import { pageTypeDetailsUrl, urlList } from "../../../url/urlList";
|
||||||
|
|
||||||
|
describe("Tests for page types", () => {
|
||||||
|
const startsWith = "PageTypes";
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should create page type", () => {
|
||||||
|
const randomName = startsWith + faker.datatype.number();
|
||||||
|
|
||||||
|
cy.visit(urlList.pageTypes)
|
||||||
|
.get(PAGE_TYPES_LIST.createPageTypeButton)
|
||||||
|
.click()
|
||||||
|
.get(PAGE_TYPE_DETAILS.nameInput)
|
||||||
|
.type(randomName)
|
||||||
|
.addAliasToGraphRequest("PageTypeCreate")
|
||||||
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
|
.click();
|
||||||
|
confirmationMessageShouldDisappear();
|
||||||
|
cy.wait("@PageTypeCreate")
|
||||||
|
.its("response.body.data.pageTypeCreate.pageType")
|
||||||
|
.then(pageType => {
|
||||||
|
getPageType(pageType.id);
|
||||||
|
})
|
||||||
|
.then(pageType => {
|
||||||
|
expect(pageType.name).to.eq(randomName);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should assign attribute", () => {
|
||||||
|
const randomName = startsWith + faker.datatype.number();
|
||||||
|
|
||||||
|
createAttribute({ name: randomName, type: "PAGE_TYPE" });
|
||||||
|
createPageType(randomName)
|
||||||
|
.then(({ pageType }) => {
|
||||||
|
cy.visit(pageTypeDetailsUrl(pageType.id))
|
||||||
|
.get(SHARED_ELEMENTS.progressBar)
|
||||||
|
.should("be.not.visible")
|
||||||
|
.get(PAGE_TYPE_DETAILS.assignAttributesButton)
|
||||||
|
.click();
|
||||||
|
assignElements(randomName, false);
|
||||||
|
confirmationMessageShouldDisappear();
|
||||||
|
getPageType(pageType.id);
|
||||||
|
})
|
||||||
|
.then(pageType => {
|
||||||
|
expect(pageType.attributes[0].name).to.eq(randomName);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -62,7 +62,7 @@ describe("Purchase products with all products types", () => {
|
||||||
shippingMethod = shippingMethodResp;
|
shippingMethod = shippingMethodResp;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
createAttribute(name)
|
createAttribute({ name })
|
||||||
.then(attributeResp => {
|
.then(attributeResp => {
|
||||||
attribute = attributeResp;
|
attribute = attributeResp;
|
||||||
createCategory(name);
|
createCategory(name);
|
||||||
|
|
|
@ -51,7 +51,7 @@ describe("Create product", () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
productUtils.deleteProductsStartsWith(startsWith);
|
productUtils.deleteProductsStartsWith(startsWith);
|
||||||
createAttribute(name).then(attributeResp => {
|
createAttribute({ name }).then(attributeResp => {
|
||||||
attribute = attributeResp;
|
attribute = attributeResp;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,26 +1,28 @@
|
||||||
export const urlList = {
|
export const urlList = {
|
||||||
apiUri: Cypress.env("API_URI"),
|
apiUri: Cypress.env("API_URI"),
|
||||||
|
addProduct: "products/add",
|
||||||
|
apps: "apps/",
|
||||||
|
attributes: "attributes/",
|
||||||
channels: "channels/",
|
channels: "channels/",
|
||||||
|
categories: "categories/",
|
||||||
|
collections: "collections/",
|
||||||
configuration: "configuration/",
|
configuration: "configuration/",
|
||||||
|
customers: "customers/",
|
||||||
draftOrders: "orders/drafts/",
|
draftOrders: "orders/drafts/",
|
||||||
homePage: "/",
|
homePage: "/",
|
||||||
|
newPassword: "new-password/",
|
||||||
orders: "orders/",
|
orders: "orders/",
|
||||||
|
pageTypes: "page-types/",
|
||||||
|
permissionsGroups: "permission-groups/",
|
||||||
products: "products/",
|
products: "products/",
|
||||||
addProduct: "products/add",
|
productTypes: "product-types/",
|
||||||
warehouses: "warehouses/",
|
|
||||||
shippingMethods: "shipping/",
|
shippingMethods: "shipping/",
|
||||||
sales: "discounts/sales/",
|
sales: "discounts/sales/",
|
||||||
collections: "collections/",
|
shippingMethods: "shipping/",
|
||||||
vouchers: "discounts/vouchers/",
|
|
||||||
staffMembers: "staff/",
|
staffMembers: "staff/",
|
||||||
newPassword: "new-password/",
|
vouchers: "discounts/vouchers/",
|
||||||
permissionsGroups: "permission-groups/",
|
warehouses: "warehouses/",
|
||||||
categories: "categories/",
|
weightRete: "weight/"
|
||||||
weightRete: "weight/",
|
|
||||||
attributes: "attributes/",
|
|
||||||
productTypes: "product-types/",
|
|
||||||
apps: "apps/",
|
|
||||||
customers: "customers/"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const productDetailsUrl = productId => `${urlList.products}${productId}`;
|
export const productDetailsUrl = productId => `${urlList.products}${productId}`;
|
||||||
|
@ -48,4 +50,7 @@ export const warehouseDetailsUrl = warehouseId =>
|
||||||
export const productTypeDetailsUrl = productTypeId =>
|
export const productTypeDetailsUrl = productTypeId =>
|
||||||
`${urlList.productTypes}${productTypeId}`;
|
`${urlList.productTypes}${productTypeId}`;
|
||||||
|
|
||||||
|
export const pageTypeDetailsUrl = pageTypeId =>
|
||||||
|
`${urlList.pageTypes}${pageTypeId}`;
|
||||||
|
|
||||||
export const appDetailsUrl = appId => `${urlList.apps}custom/${appId}`;
|
export const appDetailsUrl = appId => `${urlList.apps}custom/${appId}`;
|
||||||
|
|
|
@ -73,7 +73,7 @@ export function createTypeAttributeAndCategoryForProduct(
|
||||||
let productType;
|
let productType;
|
||||||
let category;
|
let category;
|
||||||
return attributeRequest
|
return attributeRequest
|
||||||
.createAttribute(name, attributeValues)
|
.createAttribute({ name, attributeValues })
|
||||||
.then(attributeResp => {
|
.then(attributeResp => {
|
||||||
attribute = attributeResp;
|
attribute = attributeResp;
|
||||||
createTypeProduct({ name, attributeId: attributeResp.id });
|
createTypeProduct({ name, attributeId: attributeResp.id });
|
||||||
|
|
|
@ -91,6 +91,7 @@ const PageTypeAttributes: React.FC<PageTypeAttributesProps> = props => {
|
||||||
color="primary"
|
color="primary"
|
||||||
variant="text"
|
variant="text"
|
||||||
onClick={() => onAttributeAssign(AttributeTypeEnum[type])}
|
onClick={() => onAttributeAssign(AttributeTypeEnum[type])}
|
||||||
|
data-test-id="assignAttributes"
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Assign attribute"
|
defaultMessage="Assign attribute"
|
||||||
|
|
|
@ -48,7 +48,12 @@ const PageTypeListPage: React.FC<PageTypeListPageProps> = ({
|
||||||
{intl.formatMessage(sectionNames.configuration)}
|
{intl.formatMessage(sectionNames.configuration)}
|
||||||
</AppHeader>
|
</AppHeader>
|
||||||
<PageHeader title={intl.formatMessage(sectionNames.pageTypes)}>
|
<PageHeader title={intl.formatMessage(sectionNames.pageTypes)}>
|
||||||
<Button color="primary" variant="contained" onClick={onAdd}>
|
<Button
|
||||||
|
color="primary"
|
||||||
|
variant="contained"
|
||||||
|
onClick={onAdd}
|
||||||
|
data-test-id="createPageType"
|
||||||
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="create page type"
|
defaultMessage="create page type"
|
||||||
description="button"
|
description="button"
|
||||||
|
|
|
@ -151492,6 +151492,7 @@ exports[`Storyshots Views / Page types / Page type details default 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="assignAttributes"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -152359,6 +152360,7 @@ exports[`Storyshots Views / Page types / Page type details form errors 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="assignAttributes"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -153228,6 +153230,7 @@ exports[`Storyshots Views / Page types / Page type details loading 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="assignAttributes"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -153615,6 +153618,7 @@ exports[`Storyshots Views / Page types / Page type details no attributes 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="assignAttributes"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -153985,6 +153989,7 @@ exports[`Storyshots Views / Page types / Page types list default 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||||
|
data-test-id="createPageType"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -154398,6 +154403,7 @@ exports[`Storyshots Views / Page types / Page types list loading 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||||
|
data-test-id="createPageType"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -154720,6 +154726,7 @@ exports[`Storyshots Views / Page types / Page types list no data 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||||
|
data-test-id="createPageType"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue