diff --git a/cypress/elements/attribute/attributes_details.js b/cypress/elements/attribute/attributes_details.js
index 5a7e74889..8b196aa73 100644
--- a/cypress/elements/attribute/attributes_details.js
+++ b/cypress/elements/attribute/attributes_details.js
@@ -10,6 +10,8 @@ export const ATTRIBUTES_DETAILS = {
},
attributesInputTypes: {
DROPDOWN: '[data-test-id="DROPDOWN"]',
+ DATE: '[data-test-id="DATE"]',
+ DATE_TIME: '[data-test-id="DATE_TIME"]',
MULTISELECT: '[data-test-id="MULTISELECT"]',
FILE: '[data-test-id="FILE"]',
REFERENCE: '[data-test-id="REFERENCE"]',
diff --git a/cypress/integration/configuration/attributes/attributes.js b/cypress/integration/configuration/attributes/attributes.js
index 173636931..bfe5f8cf8 100644
--- a/cypress/integration/configuration/attributes/attributes.js
+++ b/cypress/integration/configuration/attributes/attributes.js
@@ -5,12 +5,19 @@ import faker from "faker";
import { ATTRIBUTES_DETAILS } from "../../../elements/attribute/attributes_details";
import { ATTRIBUTES_LIST } from "../../../elements/attribute/attributes_list";
-import { urlList } from "../../../fixtures/urlList";
-import { getAttribute } from "../../../support/api/requests/Attribute";
+import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
+import { attributeDetailsUrl, urlList } from "../../../fixtures/urlList";
+import {
+ createAttribute,
+ getAttribute
+} from "../../../support/api/requests/Attribute";
import { deleteAttributesStartsWith } from "../../../support/api/utils/attributes/attributeUtils";
import { expectCorrectDataInAttribute } from "../../../support/api/utils/attributes/checkAttributeData";
import filterTests from "../../../support/filterTests";
-import { createAttributeWithInputType } from "../../../support/pages/attributesPage";
+import {
+ createAttributeWithInputType,
+ fillUpAttributeNameAndCode
+} from "../../../support/pages/attributesPage";
filterTests({ definedTags: ["all"] }, () => {
describe("Create attribute with type", () => {
@@ -20,7 +27,9 @@ filterTests({ definedTags: ["all"] }, () => {
"MULTISELECT",
"FILE",
"RICH_TEXT",
- "BOOLEAN"
+ "BOOLEAN",
+ "DATE",
+ "DATE_TIME"
];
const attributeReferenceType = ["PRODUCT", "PAGE"];
const attributeNumericType = [
@@ -45,6 +54,7 @@ filterTests({ definedTags: ["all"] }, () => {
attributesTypes.forEach(attributeType => {
it(`should create ${attributeType} attribute`, () => {
const attributeName = `${startsWith}${faker.datatype.number()}`;
+
createAttributeWithInputType({ name: attributeName, attributeType })
.then(({ attribute }) => {
getAttribute(attribute.id);
@@ -62,6 +72,7 @@ filterTests({ definedTags: ["all"] }, () => {
it(`should create reference ${entityType} attribute`, () => {
const attributeType = "REFERENCE";
const attributeName = `${startsWith}${faker.datatype.number()}`;
+
createAttributeWithInputType({
name: attributeName,
attributeType,
@@ -84,6 +95,7 @@ filterTests({ definedTags: ["all"] }, () => {
it(`should create numeric attribute - ${numericSystemType.unitSystem}`, () => {
const attributeType = "NUMERIC";
const attributeName = `${startsWith}${faker.datatype.number()}`;
+
createAttributeWithInputType({
name: attributeName,
attributeType,
@@ -105,6 +117,7 @@ filterTests({ definedTags: ["all"] }, () => {
it("should create attribute without required value", () => {
const attributeType = "BOOLEAN";
const attributeName = `${startsWith}${faker.datatype.number()}`;
+
createAttributeWithInputType({
name: attributeName,
attributeType,
@@ -164,5 +177,44 @@ filterTests({ definedTags: ["all"] }, () => {
.should("include", "saleorDemoProductSneakers");
});
});
+
+ it("should delete attribute", () => {
+ 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");
+ });
+ });
+
+ it("should update attribute", () => {
+ 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);
+ });
+ });
});
});
diff --git a/cypress/integration/discounts/sales/sales.js b/cypress/integration/discounts/sales.js
similarity index 88%
rename from cypress/integration/discounts/sales/sales.js
rename to cypress/integration/discounts/sales.js
index 2f82ef355..986445e84 100644
--- a/cypress/integration/discounts/sales/sales.js
+++ b/cypress/integration/discounts/sales.js
@@ -3,32 +3,29 @@
import faker from "faker";
-import { SALES_SELECTORS } from "../../../elements/discounts/sales";
-import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
-import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
-import { saleDetailsUrl } from "../../../fixtures/urlList";
-import { createCheckout } from "../../../support/api/requests/Checkout";
-import { updateSale } from "../../../support/api/requests/Discounts/Sales";
-import {
- createVariant,
- getVariant
-} from "../../../support/api/requests/Product";
-import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
+import { SALES_SELECTORS } from "../../elements/discounts/sales";
+import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
+import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
+import { saleDetailsUrl } from "../../fixtures/urlList";
+import { createCheckout } from "../../support/api/requests/Checkout";
+import { updateSale } from "../../support/api/requests/Discounts/Sales";
+import { createVariant, getVariant } from "../../support/api/requests/Product";
+import { getDefaultChannel } from "../../support/api/utils/channelsUtils";
import {
createSaleInChannel,
createSaleInChannelWithProduct,
deleteSalesStartsWith
-} from "../../../support/api/utils/discounts/salesUtils";
+} from "../../support/api/utils/discounts/salesUtils";
import {
createProductInChannel,
createTypeAttributeAndCategoryForProduct,
deleteProductsStartsWith
-} from "../../../support/api/utils/products/productsUtils";
+} from "../../support/api/utils/products/productsUtils";
import {
createShipping,
deleteShippingStartsWith
-} from "../../../support/api/utils/shippingUtils";
-import filterTests from "../../../support/filterTests";
+} from "../../support/api/utils/shippingUtils";
+import filterTests from "../../support/filterTests";
filterTests({ definedTags: ["all"] }, () => {
describe("Create sale with assigned products", () => {
diff --git a/cypress/integration/discounts/sales/createSaleWithAssignedProduct.js b/cypress/integration/discounts/sales/createSaleWithAssignedProduct.js
deleted file mode 100644
index b1f81cbf5..000000000
--- a/cypress/integration/discounts/sales/createSaleWithAssignedProduct.js
+++ /dev/null
@@ -1,202 +0,0 @@
-///
-///
-
-import faker from "faker";
-
-import { urlList } from "../../../fixtures/urlList";
-import { createChannel } from "../../../support/api/requests/Channels";
-import { updateChannelInProduct } from "../../../support/api/requests/Product";
-import * as channelsUtils from "../../../support/api/utils/channelsUtils";
-import { deleteSalesStartsWith } from "../../../support/api/utils/discounts/salesUtils";
-import * as productsUtils from "../../../support/api/utils/products/productsUtils";
-import {
- createShipping,
- deleteShippingStartsWith
-} from "../../../support/api/utils/shippingUtils";
-import { getProductPrice } from "../../../support/api/utils/storeFront/storeFrontProductUtils";
-import filterTests from "../../../support/filterTests";
-import {
- assignProducts,
- createSale,
- discountOptions
-} from "../../../support/pages/discounts/salesPage";
-
-filterTests({ definedTags: ["all"] }, () => {
- describe("Create sale with assigned products", () => {
- const startsWith = "CyCreateSaleProd-";
-
- let productType;
- let attribute;
- let category;
- let defaultChannel;
- let warehouse;
-
- before(() => {
- cy.clearSessionData().loginUserViaRequest();
- channelsUtils.deleteChannelsStartsWith(startsWith);
- deleteSalesStartsWith(startsWith);
- productsUtils.deleteProductsStartsWith(startsWith);
- deleteShippingStartsWith(startsWith);
-
- const name = `${startsWith}${faker.datatype.number()}`;
- productsUtils
- .createTypeAttributeAndCategoryForProduct({ name })
- .then(
- ({
- productType: productTypeResp,
- attribute: attributeResp,
- category: categoryResp
- }) => {
- productType = productTypeResp;
- attribute = attributeResp;
- category = categoryResp;
-
- channelsUtils.getDefaultChannel();
- }
- )
- .then(channel => {
- defaultChannel = channel;
- cy.fixture("addresses");
- })
- .then(addresses => {
- createShipping({
- channelId: defaultChannel.id,
- name,
- address: addresses.plAddress,
- price: 100
- });
- })
- .then(({ warehouse: warehouseResp }) => {
- warehouse = warehouseResp;
- });
- });
-
- beforeEach(() => {
- cy.clearSessionData().loginUserViaRequest();
- });
-
- it("should create percentage discount", () => {
- const saleName = `${startsWith}${faker.datatype.number()}`;
- const discountValue = 50;
- const productPrice = 100;
-
- productsUtils
- .createProductInChannel({
- name: saleName,
- channelId: defaultChannel.id,
- warehouseId: warehouse.id,
- productTypeId: productType.id,
- attributeId: attribute.id,
- categoryId: category.id,
- price: productPrice
- })
- .then(({ product: productResp }) => {
- /* Uncomment after fixing SALEOR-3367 bug
- cy.clearSessionData()
- .loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
- */
-
- cy.visit(urlList.sales);
- cy.softExpectSkeletonIsVisible();
- const product = productResp;
- createSale({
- saleName,
- channelName: defaultChannel.name,
- discountValue,
- discountOption: discountOptions.PERCENTAGE
- });
- assignProducts(product.name);
- getProductPrice(product.id, defaultChannel.slug);
- })
- .then(price => {
- const expectedPrice = (productPrice * discountValue) / 100;
- expect(expectedPrice).to.be.eq(price);
- });
- });
-
- it("should create fixed price discount", () => {
- const saleName = `${startsWith}${faker.datatype.number()}`;
- const discountValue = 50;
- const productPrice = 100;
-
- productsUtils
- .createProductInChannel({
- name: saleName,
- channelId: defaultChannel.id,
- warehouseId: warehouse.id,
- productTypeId: productType.id,
- attributeId: attribute.id,
- categoryId: category.id,
- price: productPrice
- })
- .then(({ product: productResp }) => {
- /* Uncomment after fixing SALEOR-3367 bug
- cy.clearSessionData()
- .loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
- */
-
- cy.visit(urlList.sales);
- cy.softExpectSkeletonIsVisible();
- const product = productResp;
- createSale({
- saleName,
- channelName: defaultChannel.name,
- discountValue,
- discountOption: discountOptions.FIXED
- });
- assignProducts(product.name);
- getProductPrice(product.id, defaultChannel.slug);
- })
- .then(price => {
- const expectedPrice = productPrice - discountValue;
- expect(expectedPrice).to.be.eq(price);
- });
- });
-
- it("should not displayed discount not assign to channel", () => {
- const saleName = `${startsWith}${faker.datatype.number()}`;
- let channel;
- let product;
- const discountValue = 50;
- const productPrice = 100;
-
- createChannel({ name: saleName }).then(
- channelResp => (channel = channelResp)
- );
- productsUtils
- .createProductInChannel({
- name: saleName,
- channelId: defaultChannel.id,
- warehouseId: warehouse.id,
- productTypeId: productType.id,
- attributeId: attribute.id,
- categoryId: category.id,
- price: productPrice
- })
- .then(({ product: productResp }) => {
- product = productResp;
- updateChannelInProduct({
- productId: product.id,
- channelId: channel.id
- });
- })
- .then(() => {
- /* Uncomment after fixing SALEOR-3367 bug
- cy.clearSessionData()
- .loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
- */
-
- cy.visit(urlList.sales);
- cy.softExpectSkeletonIsVisible();
- createSale({
- saleName,
- channelName: channel.name,
- discountValue
- });
- assignProducts(product.name);
- getProductPrice(product.id, defaultChannel.slug);
- })
- .then(price => expect(price).to.equal(productPrice));
- });
- });
-});
diff --git a/cypress/support/pages/attributesPage.js b/cypress/support/pages/attributesPage.js
index f0145dd98..fa87615c2 100644
--- a/cypress/support/pages/attributesPage.js
+++ b/cypress/support/pages/attributesPage.js
@@ -36,11 +36,8 @@ export function fillUpAttributeCreateFields({
attributeType,
valueRequired
}) {
- cy.get(ATTRIBUTES_DETAILS.nameInput)
- .type(name)
- .get(ATTRIBUTES_DETAILS.codeInput)
- .type(name)
- .get(ATTRIBUTES_DETAILS.inputTypeSelect)
+ fillUpAttributeNameAndCode(name);
+ cy.get(ATTRIBUTES_DETAILS.inputTypeSelect)
.click()
.get(ATTRIBUTES_DETAILS.attributesInputTypes[attributeType])
.click();
@@ -49,6 +46,14 @@ export function fillUpAttributeCreateFields({
}
}
+export function fillUpAttributeNameAndCode(name, code = name) {
+ return cy
+ .get(ATTRIBUTES_DETAILS.nameInput)
+ .clearAndType(name)
+ .get(ATTRIBUTES_DETAILS.codeInput)
+ .clearAndType(code);
+}
+
export function saveAttribute() {
cy.addAliasToGraphRequest("AttributeCreate");
submitAttribute();