2021-09-27 10:04:21 +00:00
|
|
|
/// <reference types="cypress"/>
|
|
|
|
/// <reference types="../../../support"/>
|
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
import faker from "faker";
|
|
|
|
|
|
|
|
import { ATTRIBUTES_DETAILS } from "../../../elements/attribute/attributes_details";
|
|
|
|
import { ATTRIBUTES_LIST } from "../../../elements/attribute/attributes_list";
|
2021-09-27 10:04:21 +00:00
|
|
|
import { urlList } from "../../../fixtures/urlList";
|
2022-06-27 09:30:51 +00:00
|
|
|
import { getAttribute } from "../../../support/api/requests/Attribute";
|
2021-09-27 10:04:21 +00:00
|
|
|
import { deleteAttributesStartsWith } from "../../../support/api/utils/attributes/attributeUtils";
|
|
|
|
import { expectCorrectDataInAttribute } from "../../../support/api/utils/attributes/checkAttributeData";
|
|
|
|
import { createAttributeWithInputType } from "../../../support/pages/attributesPage";
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
describe("As an admin I want to create content attribute", () => {
|
|
|
|
const startsWith = "AttrCont";
|
|
|
|
const attributesTypes = [
|
|
|
|
{ type: "DROPDOWN", testCase: "SALEOR_0512" },
|
|
|
|
{ type: "MULTISELECT", testCase: "SALEOR_0513" },
|
|
|
|
{ type: "FILE", testCase: "SALEOR_0514" },
|
|
|
|
{ type: "RICH_TEXT", testCase: "SALEOR_0515" },
|
|
|
|
{ type: "BOOLEAN", testCase: "SALEOR_0516" },
|
|
|
|
{ type: "DATE", testCase: "SALEOR_0527" },
|
2022-06-27 16:49:35 +00:00
|
|
|
{ type: "DATE_TIME", testCase: "SALEOR_0528" },
|
2022-06-27 09:30:51 +00:00
|
|
|
];
|
|
|
|
const attributeReferenceType = [
|
|
|
|
{ type: "PRODUCT", testCase: "SALEOR_0517" },
|
2022-06-27 16:49:35 +00:00
|
|
|
{ type: "PAGE", testCase: "SALEOR_0518" },
|
2022-06-27 09:30:51 +00:00
|
|
|
];
|
|
|
|
const attributeNumericType = [
|
|
|
|
{
|
|
|
|
unitSystem: "IMPERIAL",
|
|
|
|
unitsOf: "DISTANCE",
|
|
|
|
unit: "FT",
|
2022-06-27 16:49:35 +00:00
|
|
|
testCase: "SALEOR_0519",
|
2022-06-27 09:30:51 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
unitSystem: "METRIC",
|
|
|
|
unitsOf: "VOLUME",
|
|
|
|
unit: "CUBIC_CENTIMETER",
|
2022-06-27 16:49:35 +00:00
|
|
|
testCase: "SALEOR_0520",
|
2022-06-27 09:30:51 +00:00
|
|
|
},
|
2022-06-27 16:49:35 +00:00
|
|
|
{ unitSystem: "without selecting unit", testCase: "SALEOR_0521" },
|
2022-06-27 09:30:51 +00:00
|
|
|
];
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
deleteAttributesStartsWith(startsWith);
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData()
|
|
|
|
.loginUserViaRequest()
|
|
|
|
.visit(urlList.attributes)
|
|
|
|
.get(ATTRIBUTES_LIST.createAttributeButton)
|
|
|
|
.click()
|
|
|
|
.get(ATTRIBUTES_DETAILS.pageTypeAttributeCheckbox)
|
|
|
|
.click();
|
|
|
|
});
|
2022-01-24 12:09:48 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
attributesTypes.forEach(attributeType => {
|
|
|
|
it(
|
|
|
|
`should be able to create ${attributeType.type} attribute. TC:${attributeType.testCase}`,
|
|
|
|
{ tags: ["@attribute", "@allEnv"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
2022-04-13 10:55:05 +00:00
|
|
|
createAttributeWithInputType({
|
|
|
|
name: attributeName,
|
2022-06-27 16:49:35 +00:00
|
|
|
attributeType: attributeType.type,
|
2022-04-13 10:55:05 +00:00
|
|
|
})
|
2021-07-23 09:46:44 +00:00
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
2022-06-27 16:49:35 +00:00
|
|
|
attributeType: attributeType.type,
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
attributeReferenceType.forEach(entityType => {
|
|
|
|
it(
|
|
|
|
`should be able to create reference to ${entityType.type} attribute. TC:${entityType.testCase}`,
|
|
|
|
{ tags: ["@attribute", "@allEnv"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const attributeType = "REFERENCE";
|
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
createAttributeWithInputType({
|
|
|
|
name: attributeName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
entityType: entityType.type,
|
2021-07-23 09:46:44 +00:00
|
|
|
})
|
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
entityType: entityType.type,
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
attributeNumericType.forEach(numericSystemType => {
|
|
|
|
it(
|
|
|
|
`should be able to create numeric ${numericSystemType.unitSystem} attribute. TC: ${numericSystemType.testCase}`,
|
|
|
|
{ tags: ["@attribute", "@allEnv"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const attributeType = "NUMERIC";
|
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
createAttributeWithInputType({
|
|
|
|
name: attributeName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
numericSystemType,
|
2021-07-23 09:46:44 +00:00
|
|
|
})
|
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
unit: numericSystemType.unit,
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able to create attribute without require value TC:SALEOR_0522",
|
|
|
|
{ tags: ["@attribute", "@allEnv"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const attributeType = "BOOLEAN";
|
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
createAttributeWithInputType({
|
|
|
|
name: attributeName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
valueRequired: false,
|
2021-07-23 09:46:44 +00:00
|
|
|
})
|
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
valueRequired: false,
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|