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";
|
|
|
|
|
2021-12-14 11:14:40 +00:00
|
|
|
import { ATTRIBUTES_DETAILS } from "../../../elements/attribute/attributes_details";
|
2021-07-23 09:46:44 +00:00
|
|
|
import { ATTRIBUTES_LIST } from "../../../elements/attribute/attributes_list";
|
2022-01-17 10:03:52 +00:00
|
|
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
|
|
|
import { attributeDetailsUrl, urlList } from "../../../fixtures/urlList";
|
|
|
|
import {
|
|
|
|
createAttribute,
|
2022-06-27 16:49:35 +00:00
|
|
|
getAttribute,
|
2022-01-17 10:03:52 +00:00
|
|
|
} 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";
|
2022-01-17 10:03:52 +00:00
|
|
|
import {
|
|
|
|
createAttributeWithInputType,
|
2022-06-27 16:49:35 +00:00
|
|
|
fillUpAttributeNameAndCode,
|
2022-01-17 10:03:52 +00:00
|
|
|
} 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 product attribute", () => {
|
|
|
|
const startsWith = "AttrCreate";
|
|
|
|
const attributesTypes = [
|
|
|
|
{ type: "DROPDOWN", testCase: "SALEOR_0501" },
|
|
|
|
{ type: "MULTISELECT", testCase: "SALEOR_0502" },
|
|
|
|
{ type: "FILE", testCase: "SALEOR_0503" },
|
|
|
|
{ type: "RICH_TEXT", testCase: "SALEOR_0504" },
|
|
|
|
{ type: "BOOLEAN", testCase: "SALEOR_0505" },
|
|
|
|
{ type: "DATE", testCase: "SALEOR_0523" },
|
2022-06-27 16:49:35 +00:00
|
|
|
{ type: "DATE_TIME", testCase: "SALEOR_0524" },
|
2022-06-27 09:30:51 +00:00
|
|
|
];
|
|
|
|
const attributeReferenceType = [
|
|
|
|
{ type: "PRODUCT", testCase: "SALEOR_0506" },
|
2022-06-27 16:49:35 +00:00
|
|
|
{ type: "PAGE", testCase: "SALEOR_0507" },
|
2022-09-22 09:14:53 +00:00
|
|
|
{ type: "PRODUCT_VARIANT", testCase: "SALEOR_0539" },
|
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_0508",
|
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_0509",
|
2022-06-27 09:30:51 +00:00
|
|
|
},
|
2022-06-27 16:49:35 +00:00
|
|
|
{ unitSystem: "without selecting unit", testCase: "SALEOR_0510" },
|
2022-06-27 09:30:51 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
deleteAttributesStartsWith(startsWith);
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData()
|
|
|
|
.loginUserViaRequest()
|
|
|
|
.visit(urlList.attributes)
|
|
|
|
.get(ATTRIBUTES_LIST.createAttributeButton)
|
|
|
|
.click();
|
|
|
|
});
|
|
|
|
|
|
|
|
attributesTypes.forEach(attributeType => {
|
|
|
|
it(
|
|
|
|
`should be able to create ${attributeType.type} attribute. TC:${attributeType.testCase}`,
|
2022-09-22 09:14:53 +00:00
|
|
|
{ tags: ["@attribute", "@allEnv", "@stable"] },
|
2022-06-27 09:30:51 +00:00
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
2022-01-17 10:03:52 +00:00
|
|
|
|
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 ${entityType.type} attribute. TC:${entityType.testCase}`,
|
|
|
|
{ tags: ["@attribute", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const attributeType = "REFERENCE";
|
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
2022-01-17 10:03:52 +00:00
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
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}`,
|
2022-09-22 09:14:53 +00:00
|
|
|
{ tags: ["@attribute", "@allEnv", "@stable"] },
|
2022-06-27 09:30:51 +00:00
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const attributeType = "NUMERIC";
|
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
2022-01-17 10:03:52 +00:00
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
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_0511",
|
|
|
|
{ tags: ["@attribute", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const attributeType = "BOOLEAN";
|
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
2022-01-17 10:03:52 +00:00
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
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-12-14 11:14:40 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should create swatch attribute. TC:SALEOR_0531",
|
|
|
|
{ tags: ["@attribute", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2021-12-14 11:14:40 +00:00
|
|
|
const attributeType = "SWATCH";
|
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
createAttributeWithInputType({
|
|
|
|
name: attributeName,
|
2022-06-27 16:49:35 +00:00
|
|
|
attributeType,
|
2021-12-14 11:14:40 +00:00
|
|
|
})
|
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
valueRequired: true,
|
2021-12-14 11:14:40 +00:00
|
|
|
});
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-12-14 11:14:40 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should create swatch attribute with image. TC:SALEOR_0532",
|
|
|
|
{ tags: ["@attribute", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2021-12-14 11:14:40 +00:00
|
|
|
const attributeType = "SWATCH";
|
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
const swatchImage = "images/saleorDemoProductSneakers.png";
|
|
|
|
createAttributeWithInputType({
|
|
|
|
name: attributeName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
swatchImage,
|
2021-12-14 11:14:40 +00:00
|
|
|
})
|
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
|
|
|
attributeType,
|
2022-06-27 16:49:35 +00:00
|
|
|
valueRequired: true,
|
2021-12-14 11:14:40 +00:00
|
|
|
});
|
|
|
|
cy.get(ATTRIBUTES_DETAILS.swatchValueImage)
|
|
|
|
.invoke("attr", "style")
|
|
|
|
.should("include", "saleorDemoProductSneakers");
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-01-17 10:03:52 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able delete product attribute. TC:SALEOR_0525",
|
|
|
|
{ tags: ["@attribute", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2022-01-17 10:03:52 +00:00
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
|
|
|
|
createAttribute({
|
2022-06-27 16:49:35 +00:00
|
|
|
name: attributeName,
|
2022-01-17 10:03:52 +00:00
|
|
|
}).then(attribute => {
|
|
|
|
cy.visit(attributeDetailsUrl(attribute.id))
|
|
|
|
.get(BUTTON_SELECTORS.deleteButton)
|
|
|
|
.click()
|
|
|
|
.addAliasToGraphRequest("AttributeDelete")
|
|
|
|
.get(BUTTON_SELECTORS.submit)
|
|
|
|
.click()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@AttributeDelete");
|
|
|
|
getAttribute(attribute.id).should("be.null");
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-01-17 10:03:52 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
|
|
|
"should be able update product attribute. TC:SALEOR_0526",
|
|
|
|
{ tags: ["@attribute", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
2022-01-17 10:03:52 +00:00
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
const attributeUpdatedName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
|
|
|
|
createAttribute({
|
2022-06-27 16:49:35 +00:00
|
|
|
name: attributeName,
|
2022-01-17 10:03:52 +00:00
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
cy.visit(attributeDetailsUrl(attribute.id));
|
|
|
|
fillUpAttributeNameAndCode(attributeUpdatedName);
|
|
|
|
cy.addAliasToGraphRequest("AttributeUpdate")
|
|
|
|
.get(BUTTON_SELECTORS.confirm)
|
|
|
|
.click()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@AttributeUpdate");
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expect(attribute.name).to.eq(attributeUpdatedName);
|
|
|
|
expect(attribute.slug).to.eq(attributeUpdatedName);
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|