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,
|
|
|
|
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";
|
2021-07-23 09:46:44 +00:00
|
|
|
import filterTests from "../../../support/filterTests";
|
2022-01-17 10:03:52 +00:00
|
|
|
import {
|
|
|
|
createAttributeWithInputType,
|
|
|
|
fillUpAttributeNameAndCode
|
|
|
|
} from "../../../support/pages/attributesPage";
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2021-09-27 10:04:21 +00:00
|
|
|
filterTests({ definedTags: ["all"] }, () => {
|
2022-04-13 10:55:05 +00:00
|
|
|
describe("As an admin I want to create product attribute", () => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const startsWith = "AttrCreate";
|
|
|
|
const attributesTypes = [
|
2022-04-13 10:55:05 +00:00
|
|
|
{ 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" },
|
|
|
|
{ type: "DATE_TIME", testCase: "SALEOR_0524" }
|
|
|
|
];
|
|
|
|
const attributeReferenceType = [
|
|
|
|
{ type: "PRODUCT", testCase: "SALEOR_0506" },
|
|
|
|
{ type: "PAGE", testCase: "SALEOR_0507" }
|
2021-07-23 09:46:44 +00:00
|
|
|
];
|
|
|
|
const attributeNumericType = [
|
2022-04-13 10:55:05 +00:00
|
|
|
{
|
|
|
|
unitSystem: "IMPERIAL",
|
|
|
|
unitsOf: "DISTANCE",
|
|
|
|
unit: "FT",
|
|
|
|
testCase: "SALEOR_0508"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
unitSystem: "METRIC",
|
|
|
|
unitsOf: "VOLUME",
|
|
|
|
unit: "CUBIC_CENTIMETER",
|
|
|
|
testCase: "SALEOR_0509"
|
|
|
|
},
|
|
|
|
{ unitSystem: "without selecting unit", testCase: "SALEOR_0510" }
|
2021-07-23 09:46:44 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
deleteAttributesStartsWith(startsWith);
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData()
|
|
|
|
.loginUserViaRequest()
|
|
|
|
.visit(urlList.attributes)
|
|
|
|
.get(ATTRIBUTES_LIST.createAttributeButton)
|
|
|
|
.click();
|
|
|
|
});
|
|
|
|
|
|
|
|
attributesTypes.forEach(attributeType => {
|
2022-04-13 10:55:05 +00:00
|
|
|
it(`should be able to create ${attributeType.type} attribute. TC:${attributeType.testCase}`, () => {
|
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,
|
|
|
|
attributeType: attributeType.type
|
|
|
|
})
|
2021-07-23 09:46:44 +00:00
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
2022-04-13 10:55:05 +00:00
|
|
|
attributeType: attributeType.type
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
attributeReferenceType.forEach(entityType => {
|
2022-04-13 10:55:05 +00:00
|
|
|
it(`should be able to create ${entityType.type} attribute. TC:${entityType.testCase}`, () => {
|
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-04-13 10:55:05 +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-04-13 10:55:05 +00:00
|
|
|
entityType: entityType.type
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
attributeNumericType.forEach(numericSystemType => {
|
2022-04-13 10:55:05 +00:00
|
|
|
it(`should be able to create numeric ${numericSystemType.unitSystem} attribute. TC:${numericSystemType.testCase}`, () => {
|
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,
|
|
|
|
numericSystemType
|
|
|
|
})
|
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
|
|
|
attributeType,
|
|
|
|
unit: numericSystemType.unit
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-04-13 10:55:05 +00:00
|
|
|
it("should be able to create attribute without require value. TC:SALEOR_0511", () => {
|
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,
|
|
|
|
valueRequired: false
|
|
|
|
})
|
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
|
|
|
attributeType,
|
|
|
|
valueRequired: false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2021-12-14 11:14:40 +00:00
|
|
|
|
2022-04-13 10:55:05 +00:00
|
|
|
it("should create swatch attribute. TC:SALEOR_0531", () => {
|
2021-12-14 11:14:40 +00:00
|
|
|
const attributeType = "SWATCH";
|
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
createAttributeWithInputType({
|
|
|
|
name: attributeName,
|
|
|
|
attributeType
|
|
|
|
})
|
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
|
|
|
attributeType,
|
|
|
|
valueRequired: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-04-13 10:55:05 +00:00
|
|
|
it("should create swatch attribute with image. TC:SALEOR_0532", () => {
|
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,
|
|
|
|
swatchImage
|
|
|
|
})
|
|
|
|
.then(({ attribute }) => {
|
|
|
|
getAttribute(attribute.id);
|
|
|
|
})
|
|
|
|
.then(attribute => {
|
|
|
|
expectCorrectDataInAttribute(attribute, {
|
|
|
|
attributeName,
|
|
|
|
attributeType,
|
|
|
|
valueRequired: true
|
|
|
|
});
|
|
|
|
cy.get(ATTRIBUTES_DETAILS.swatchValueImage)
|
|
|
|
.invoke("attr", "style")
|
|
|
|
.should("include", "saleorDemoProductSneakers");
|
|
|
|
});
|
|
|
|
});
|
2022-01-17 10:03:52 +00:00
|
|
|
|
2022-04-13 10:55:05 +00:00
|
|
|
it("should be able delete product attribute. TC:SALEOR_0525", () => {
|
2022-01-17 10:03:52 +00:00
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
|
|
|
|
createAttribute({
|
|
|
|
name: attributeName
|
|
|
|
}).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-04-13 10:55:05 +00:00
|
|
|
it("should be able update product attribute. TC:SALEOR_0526", () => {
|
2022-01-17 10:03:52 +00:00
|
|
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
const attributeUpdatedName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
|
|
|
|
createAttribute({
|
|
|
|
name: attributeName
|
|
|
|
})
|
|
|
|
.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);
|
|
|
|
});
|
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
|
|
|
});
|