parent
8d20394518
commit
41e80d71c0
5 changed files with 80 additions and 226 deletions
|
@ -10,6 +10,8 @@ export const ATTRIBUTES_DETAILS = {
|
||||||
},
|
},
|
||||||
attributesInputTypes: {
|
attributesInputTypes: {
|
||||||
DROPDOWN: '[data-test-id="DROPDOWN"]',
|
DROPDOWN: '[data-test-id="DROPDOWN"]',
|
||||||
|
DATE: '[data-test-id="DATE"]',
|
||||||
|
DATE_TIME: '[data-test-id="DATE_TIME"]',
|
||||||
MULTISELECT: '[data-test-id="MULTISELECT"]',
|
MULTISELECT: '[data-test-id="MULTISELECT"]',
|
||||||
FILE: '[data-test-id="FILE"]',
|
FILE: '[data-test-id="FILE"]',
|
||||||
REFERENCE: '[data-test-id="REFERENCE"]',
|
REFERENCE: '[data-test-id="REFERENCE"]',
|
||||||
|
|
|
@ -5,12 +5,19 @@ import faker from "faker";
|
||||||
|
|
||||||
import { ATTRIBUTES_DETAILS } from "../../../elements/attribute/attributes_details";
|
import { ATTRIBUTES_DETAILS } from "../../../elements/attribute/attributes_details";
|
||||||
import { ATTRIBUTES_LIST } from "../../../elements/attribute/attributes_list";
|
import { ATTRIBUTES_LIST } from "../../../elements/attribute/attributes_list";
|
||||||
import { urlList } from "../../../fixtures/urlList";
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||||
import { getAttribute } from "../../../support/api/requests/Attribute";
|
import { attributeDetailsUrl, urlList } from "../../../fixtures/urlList";
|
||||||
|
import {
|
||||||
|
createAttribute,
|
||||||
|
getAttribute
|
||||||
|
} from "../../../support/api/requests/Attribute";
|
||||||
import { deleteAttributesStartsWith } from "../../../support/api/utils/attributes/attributeUtils";
|
import { deleteAttributesStartsWith } from "../../../support/api/utils/attributes/attributeUtils";
|
||||||
import { expectCorrectDataInAttribute } from "../../../support/api/utils/attributes/checkAttributeData";
|
import { expectCorrectDataInAttribute } from "../../../support/api/utils/attributes/checkAttributeData";
|
||||||
import filterTests from "../../../support/filterTests";
|
import filterTests from "../../../support/filterTests";
|
||||||
import { createAttributeWithInputType } from "../../../support/pages/attributesPage";
|
import {
|
||||||
|
createAttributeWithInputType,
|
||||||
|
fillUpAttributeNameAndCode
|
||||||
|
} from "../../../support/pages/attributesPage";
|
||||||
|
|
||||||
filterTests({ definedTags: ["all"] }, () => {
|
filterTests({ definedTags: ["all"] }, () => {
|
||||||
describe("Create attribute with type", () => {
|
describe("Create attribute with type", () => {
|
||||||
|
@ -20,7 +27,9 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
"MULTISELECT",
|
"MULTISELECT",
|
||||||
"FILE",
|
"FILE",
|
||||||
"RICH_TEXT",
|
"RICH_TEXT",
|
||||||
"BOOLEAN"
|
"BOOLEAN",
|
||||||
|
"DATE",
|
||||||
|
"DATE_TIME"
|
||||||
];
|
];
|
||||||
const attributeReferenceType = ["PRODUCT", "PAGE"];
|
const attributeReferenceType = ["PRODUCT", "PAGE"];
|
||||||
const attributeNumericType = [
|
const attributeNumericType = [
|
||||||
|
@ -45,6 +54,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
attributesTypes.forEach(attributeType => {
|
attributesTypes.forEach(attributeType => {
|
||||||
it(`should create ${attributeType} attribute`, () => {
|
it(`should create ${attributeType} attribute`, () => {
|
||||||
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
createAttributeWithInputType({ name: attributeName, attributeType })
|
createAttributeWithInputType({ name: attributeName, attributeType })
|
||||||
.then(({ attribute }) => {
|
.then(({ attribute }) => {
|
||||||
getAttribute(attribute.id);
|
getAttribute(attribute.id);
|
||||||
|
@ -62,6 +72,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
it(`should create reference ${entityType} attribute`, () => {
|
it(`should create reference ${entityType} attribute`, () => {
|
||||||
const attributeType = "REFERENCE";
|
const attributeType = "REFERENCE";
|
||||||
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
createAttributeWithInputType({
|
createAttributeWithInputType({
|
||||||
name: attributeName,
|
name: attributeName,
|
||||||
attributeType,
|
attributeType,
|
||||||
|
@ -84,6 +95,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
it(`should create numeric attribute - ${numericSystemType.unitSystem}`, () => {
|
it(`should create numeric attribute - ${numericSystemType.unitSystem}`, () => {
|
||||||
const attributeType = "NUMERIC";
|
const attributeType = "NUMERIC";
|
||||||
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
createAttributeWithInputType({
|
createAttributeWithInputType({
|
||||||
name: attributeName,
|
name: attributeName,
|
||||||
attributeType,
|
attributeType,
|
||||||
|
@ -105,6 +117,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
it("should create attribute without required value", () => {
|
it("should create attribute without required value", () => {
|
||||||
const attributeType = "BOOLEAN";
|
const attributeType = "BOOLEAN";
|
||||||
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
const attributeName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
createAttributeWithInputType({
|
createAttributeWithInputType({
|
||||||
name: attributeName,
|
name: attributeName,
|
||||||
attributeType,
|
attributeType,
|
||||||
|
@ -164,5 +177,44 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
.should("include", "saleorDemoProductSneakers");
|
.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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,32 +3,29 @@
|
||||||
|
|
||||||
import faker from "faker";
|
import faker from "faker";
|
||||||
|
|
||||||
import { SALES_SELECTORS } from "../../../elements/discounts/sales";
|
import { SALES_SELECTORS } from "../../elements/discounts/sales";
|
||||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
||||||
import { saleDetailsUrl } from "../../../fixtures/urlList";
|
import { saleDetailsUrl } from "../../fixtures/urlList";
|
||||||
import { createCheckout } from "../../../support/api/requests/Checkout";
|
import { createCheckout } from "../../support/api/requests/Checkout";
|
||||||
import { updateSale } from "../../../support/api/requests/Discounts/Sales";
|
import { updateSale } from "../../support/api/requests/Discounts/Sales";
|
||||||
import {
|
import { createVariant, getVariant } from "../../support/api/requests/Product";
|
||||||
createVariant,
|
import { getDefaultChannel } from "../../support/api/utils/channelsUtils";
|
||||||
getVariant
|
|
||||||
} from "../../../support/api/requests/Product";
|
|
||||||
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
|
||||||
import {
|
import {
|
||||||
createSaleInChannel,
|
createSaleInChannel,
|
||||||
createSaleInChannelWithProduct,
|
createSaleInChannelWithProduct,
|
||||||
deleteSalesStartsWith
|
deleteSalesStartsWith
|
||||||
} from "../../../support/api/utils/discounts/salesUtils";
|
} from "../../support/api/utils/discounts/salesUtils";
|
||||||
import {
|
import {
|
||||||
createProductInChannel,
|
createProductInChannel,
|
||||||
createTypeAttributeAndCategoryForProduct,
|
createTypeAttributeAndCategoryForProduct,
|
||||||
deleteProductsStartsWith
|
deleteProductsStartsWith
|
||||||
} from "../../../support/api/utils/products/productsUtils";
|
} from "../../support/api/utils/products/productsUtils";
|
||||||
import {
|
import {
|
||||||
createShipping,
|
createShipping,
|
||||||
deleteShippingStartsWith
|
deleteShippingStartsWith
|
||||||
} from "../../../support/api/utils/shippingUtils";
|
} from "../../support/api/utils/shippingUtils";
|
||||||
import filterTests from "../../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
|
|
||||||
filterTests({ definedTags: ["all"] }, () => {
|
filterTests({ definedTags: ["all"] }, () => {
|
||||||
describe("Create sale with assigned products", () => {
|
describe("Create sale with assigned products", () => {
|
|
@ -1,202 +0,0 @@
|
||||||
/// <reference types="cypress"/>
|
|
||||||
/// <reference types="../../../support"/>
|
|
||||||
|
|
||||||
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));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -36,11 +36,8 @@ export function fillUpAttributeCreateFields({
|
||||||
attributeType,
|
attributeType,
|
||||||
valueRequired
|
valueRequired
|
||||||
}) {
|
}) {
|
||||||
cy.get(ATTRIBUTES_DETAILS.nameInput)
|
fillUpAttributeNameAndCode(name);
|
||||||
.type(name)
|
cy.get(ATTRIBUTES_DETAILS.inputTypeSelect)
|
||||||
.get(ATTRIBUTES_DETAILS.codeInput)
|
|
||||||
.type(name)
|
|
||||||
.get(ATTRIBUTES_DETAILS.inputTypeSelect)
|
|
||||||
.click()
|
.click()
|
||||||
.get(ATTRIBUTES_DETAILS.attributesInputTypes[attributeType])
|
.get(ATTRIBUTES_DETAILS.attributesInputTypes[attributeType])
|
||||||
.click();
|
.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() {
|
export function saveAttribute() {
|
||||||
cy.addAliasToGraphRequest("AttributeCreate");
|
cy.addAliasToGraphRequest("AttributeCreate");
|
||||||
submitAttribute();
|
submitAttribute();
|
||||||
|
|
Loading…
Reference in a new issue