Saleor 3496 tests for single permissions (#1147)
* permissions * orders, channels and discounts * tests for single permissions
This commit is contained in:
parent
2c5b0feeb1
commit
6a2524a5c7
14 changed files with 223 additions and 149 deletions
|
@ -10,6 +10,10 @@ export const PERMISSIONS = {
|
|||
app: {
|
||||
permissionSelectors: [menuSelectors.LEFT_MENU_SELECTORS.app]
|
||||
},
|
||||
channel: {
|
||||
parent: configurationAsParent,
|
||||
permissionSelectors: [CONFIGURATION_SELECTORS.channels]
|
||||
},
|
||||
customer: {
|
||||
permissionSelectors: [menuSelectors.LEFT_MENU_SELECTORS.customers]
|
||||
},
|
||||
|
|
|
@ -10,6 +10,10 @@ export const PERMISSIONS_OPTIONS = {
|
|||
user: ONE_PERMISSION_USERS.app,
|
||||
permissions: [PERMISSIONS.app]
|
||||
},
|
||||
channel: {
|
||||
user: ONE_PERMISSION_USERS.channel,
|
||||
permissions: [PERMISSIONS.channel]
|
||||
},
|
||||
customer: {
|
||||
user: ONE_PERMISSION_USERS.user,
|
||||
permissions: [PERMISSIONS.customer]
|
||||
|
|
|
@ -9,6 +9,7 @@ export const USER_WITHOUT_NAME = {
|
|||
password: Cypress.env("USER_PASSWORD")
|
||||
};
|
||||
export const ONE_PERMISSION_USERS = {
|
||||
channel: getOnePermissionUser("channel.manager@example.com"),
|
||||
shipping: getOnePermissionUser("shipping.manager@example.com"),
|
||||
giftCard: getOnePermissionUser("gift.card.manager@example.com"),
|
||||
app: getOnePermissionUser("app.manager@example.com"),
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
import faker from "faker";
|
||||
|
||||
import { createChannel } from "../../../apiRequests/Channels";
|
||||
import { LEFT_MENU_SELECTORS } from "../../../elements/account/left-menu/left-menu-selectors";
|
||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
||||
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
|
||||
import { ADD_CHANNEL_FORM_SELECTORS } from "../../../elements/channels/add-channel-form-selectors";
|
||||
import { AVAILABLE_CHANNELS_FORM } from "../../../elements/channels/available-channels-form";
|
||||
import { CHANNEL_FORM_SELECTORS } from "../../../elements/channels/channel-form-selectors";
|
||||
import { CHANNELS_SELECTORS } from "../../../elements/channels/channels-selectors";
|
||||
import { SELECT_CHANNELS_TO_ASSIGN } from "../../../elements/channels/select-channels-to-assign";
|
||||
import { CONFIGURATION_SELECTORS } from "../../../elements/configuration/configuration-selectors";
|
||||
import { HEADER_SELECTORS } from "../../../elements/header/header-selectors";
|
||||
import { DRAFT_ORDER_SELECTORS } from "../../../elements/orders/draft-order-selectors";
|
||||
import { ORDERS_SELECTORS } from "../../../elements/orders/orders-selectors";
|
||||
|
@ -29,17 +28,10 @@ describe("Channels", () => {
|
|||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
});
|
||||
|
||||
it("should navigate to channels page", () => {
|
||||
cy.visit(urlList.homePage)
|
||||
.get(LEFT_MENU_SELECTORS.configuration)
|
||||
.click()
|
||||
.get(CONFIGURATION_SELECTORS.channels)
|
||||
.click()
|
||||
.location("pathname")
|
||||
.should("contain", "channels");
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
ONE_PERMISSION_USERS.channel
|
||||
);
|
||||
});
|
||||
|
||||
it("should create new channel", () => {
|
||||
|
@ -65,6 +57,7 @@ describe("Channels", () => {
|
|||
.click();
|
||||
|
||||
// new channel should be visible at product availability form
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.addAliasToGraphRequest("InitialProductFilterAttributes");
|
||||
cy.visit(urlList.products);
|
||||
cy.wait("@InitialProductFilterAttributes");
|
||||
|
@ -135,6 +128,7 @@ describe("Channels", () => {
|
|||
slug: randomChannel,
|
||||
currencyCode: currency
|
||||
});
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.visit(urlList.orders)
|
||||
.get(ORDERS_SELECTORS.createOrder)
|
||||
.click()
|
||||
|
|
|
@ -8,10 +8,10 @@ import {
|
|||
addChannelToShippingZone
|
||||
} from "../../../apiRequests/ShippingMethod";
|
||||
import { createWarehouse } from "../../../apiRequests/Warehouse";
|
||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
||||
import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-details";
|
||||
import { SHIPPING_ZONES_LIST } from "../../../elements/shipping/shipping-zones-list";
|
||||
import { selectChannelInHeader } from "../../../steps/channelsSteps";
|
||||
import {
|
||||
createShippingRate,
|
||||
|
@ -78,7 +78,6 @@ describe("Shipping methods", () => {
|
|||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.visit(urlList.shippingMethods);
|
||||
});
|
||||
|
||||
it("should display different price for each channel", () => {
|
||||
|
@ -123,6 +122,13 @@ describe("Shipping methods", () => {
|
|||
}
|
||||
)
|
||||
.then(() => {
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping)
|
||||
.visit(urlList.shippingMethods)
|
||||
.get(SHARED_ELEMENTS.header)
|
||||
.should("be.visible")
|
||||
.get(SHARED_ELEMENTS.progressBar)
|
||||
.should("not.exist");
|
||||
cy.addAliasToGraphRequest("ShippingZone");
|
||||
cy.getTextFromElement(SHARED_ELEMENTS.table);
|
||||
})
|
||||
|
@ -159,7 +165,11 @@ describe("Shipping methods", () => {
|
|||
});
|
||||
it("should create price based shipping method", () => {
|
||||
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
ONE_PERMISSION_USERS.shipping
|
||||
);
|
||||
cy.visit(urlList.shippingMethods);
|
||||
createShippingZone(
|
||||
shippingName,
|
||||
warehouse.name,
|
||||
|
@ -185,7 +195,11 @@ describe("Shipping methods", () => {
|
|||
|
||||
it("should create weight based shipping method", () => {
|
||||
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
ONE_PERMISSION_USERS.shipping
|
||||
);
|
||||
cy.visit(urlList.shippingMethods);
|
||||
createShippingZone(
|
||||
shippingName,
|
||||
warehouse.name,
|
||||
|
|
|
@ -4,6 +4,7 @@ import faker from "faker";
|
|||
|
||||
import { createChannel } from "../../../apiRequests/Channels";
|
||||
import { updateChannelInProduct } from "../../../apiRequests/Product";
|
||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
||||
import {
|
||||
assignProducts,
|
||||
createSale,
|
||||
|
@ -88,7 +89,9 @@ describe("Sales discounts", () => {
|
|||
price: productPrice
|
||||
})
|
||||
.then(({ product: productResp }) => {
|
||||
cy.visit(urlList.sales);
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
|
||||
.visit(urlList.sales);
|
||||
const product = productResp;
|
||||
createSale({
|
||||
saleName,
|
||||
|
@ -121,7 +124,9 @@ describe("Sales discounts", () => {
|
|||
price: productPrice
|
||||
})
|
||||
.then(({ product: productResp }) => {
|
||||
cy.visit(urlList.sales);
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
|
||||
.visit(urlList.sales);
|
||||
const product = productResp;
|
||||
createSale({
|
||||
saleName,
|
||||
|
@ -166,7 +171,9 @@ describe("Sales discounts", () => {
|
|||
});
|
||||
})
|
||||
.then(() => {
|
||||
cy.visit(urlList.sales);
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
|
||||
.visit(urlList.sales);
|
||||
createSale({
|
||||
saleName,
|
||||
channelName: channel.name,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import faker from "faker";
|
||||
|
||||
import { createChannel } from "../../../apiRequests/Channels";
|
||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
||||
import {
|
||||
createVoucher,
|
||||
discountOptions
|
||||
|
@ -81,67 +82,48 @@ describe("Vouchers discounts", () => {
|
|||
.then(({ variantsList: variantsResp }) => (variants = variantsResp));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.visit(urlList.vouchers);
|
||||
});
|
||||
|
||||
it("should create percentage voucher", () => {
|
||||
const voucherCode = `${startsWith}${faker.datatype.number()}`;
|
||||
const voucherValue = 50;
|
||||
|
||||
createVoucher({
|
||||
voucherCode,
|
||||
voucherValue,
|
||||
discountOption: discountOptions.PERCENTAGE,
|
||||
channelName: defaultChannel.name
|
||||
loginAndCreateCheckoutForVoucherWithDiscount(
|
||||
discountOptions.PERCENTAGE,
|
||||
voucherValue
|
||||
).then(amount => {
|
||||
const expectedAmount =
|
||||
(productPrice * voucherValue) / 100 + shippingPrice;
|
||||
expect(amount).to.be.eq(expectedAmount);
|
||||
});
|
||||
createCheckoutForCreatedVoucher(voucherCode)
|
||||
.its("checkout.totalPrice.gross.amount")
|
||||
.then(amount => {
|
||||
const expectedAmount =
|
||||
(productPrice * voucherValue) / 100 + shippingPrice;
|
||||
expect(amount).to.be.eq(expectedAmount);
|
||||
});
|
||||
});
|
||||
|
||||
it("should create fixed price voucher", () => {
|
||||
const voucherCode = `${startsWith}${faker.datatype.number()}`;
|
||||
const voucherValue = 50;
|
||||
|
||||
createVoucher({
|
||||
voucherCode,
|
||||
voucherValue,
|
||||
discountOption: discountOptions.FIXED,
|
||||
channelName: defaultChannel.name
|
||||
loginAndCreateCheckoutForVoucherWithDiscount(
|
||||
discountOptions.FIXED,
|
||||
voucherValue
|
||||
).then(amount => {
|
||||
const expectedAmount = productPrice + shippingPrice - voucherValue;
|
||||
expect(amount).to.be.eq(expectedAmount);
|
||||
});
|
||||
createCheckoutForCreatedVoucher(voucherCode)
|
||||
.its("checkout.totalPrice.gross.amount")
|
||||
.then(amount => {
|
||||
const expectedAmount = productPrice + shippingPrice - voucherValue;
|
||||
expect(amount).to.be.eq(expectedAmount);
|
||||
});
|
||||
});
|
||||
|
||||
it("should create free shipping voucher", () => {
|
||||
const voucherCode = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createVoucher({
|
||||
voucherCode,
|
||||
discountOption: discountOptions.SHIPPING,
|
||||
channelName: defaultChannel.name
|
||||
loginAndCreateCheckoutForVoucherWithDiscount(
|
||||
discountOptions.SHIPPING,
|
||||
null
|
||||
).then(amount => {
|
||||
const expectedAmount = productPrice;
|
||||
expect(amount).to.be.eq(expectedAmount);
|
||||
});
|
||||
createCheckoutForCreatedVoucher(voucherCode)
|
||||
.its("checkout.totalPrice.gross.amount")
|
||||
.then(amount => {
|
||||
const expectedAmount = productPrice;
|
||||
expect(amount).to.be.eq(expectedAmount);
|
||||
});
|
||||
});
|
||||
|
||||
it("should create voucher not available for selected channel", () => {
|
||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
const voucherValue = 50;
|
||||
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest()
|
||||
.visit(urlList.vouchers);
|
||||
createChannel({ name: randomName })
|
||||
.then(channel => {
|
||||
createVoucher({
|
||||
|
@ -168,4 +150,24 @@ describe("Vouchers discounts", () => {
|
|||
auth: "token"
|
||||
});
|
||||
}
|
||||
|
||||
function loginAndCreateCheckoutForVoucherWithDiscount(
|
||||
discount,
|
||||
voucherValue
|
||||
) {
|
||||
const voucherCode = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
|
||||
.visit(urlList.vouchers);
|
||||
createVoucher({
|
||||
voucherCode,
|
||||
voucherValue,
|
||||
discountOption: discount,
|
||||
channelName: defaultChannel.name
|
||||
});
|
||||
return createCheckoutForCreatedVoucher(voucherCode).its(
|
||||
"checkout.totalPrice.gross.amount"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@ import {
|
|||
deleteCustomersStartsWith
|
||||
} from "../../../apiRequests/Customer";
|
||||
import { getOrder } from "../../../apiRequests/Order";
|
||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
||||
import { ORDER_REFUND } from "../../../elements/orders/order-refund";
|
||||
import { ORDERS_SELECTORS } from "../../../elements/orders/orders-selectors";
|
||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||
|
@ -91,7 +92,10 @@ describe("Orders", () => {
|
|||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
ONE_PERMISSION_USERS.order
|
||||
);
|
||||
});
|
||||
|
||||
it("should create order with selected channel", () => {
|
||||
|
@ -108,6 +112,7 @@ describe("Orders", () => {
|
|||
});
|
||||
});
|
||||
|
||||
// This test will pass after fixing SALEOR-3154
|
||||
it("should not be possible to change channel in order", () => {
|
||||
createOrder({
|
||||
customerId: customer.id,
|
||||
|
|
|
@ -3,6 +3,7 @@ import faker from "faker";
|
|||
|
||||
import { createAttribute } from "../../../apiRequests/Attribute";
|
||||
import { createTypeProduct } from "../../../apiRequests/Product";
|
||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
||||
import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details";
|
||||
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
|
||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||
|
@ -55,14 +56,10 @@ describe("Create product", () => {
|
|||
});
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.visit(urlList.products)
|
||||
.get(PRODUCTS_LIST.createProductBtn)
|
||||
.click();
|
||||
});
|
||||
|
||||
it("should create product with variants", () => {
|
||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
createTypeProduct({ name: randomName, attributeId: attribute.id });
|
||||
seo.slug = randomName;
|
||||
const productData = {
|
||||
generalInfo,
|
||||
|
@ -71,7 +68,7 @@ describe("Create product", () => {
|
|||
productOrganization: { productType: randomName },
|
||||
attribute
|
||||
};
|
||||
fillUpCommonFieldsForAllProductTypes(productData).then(
|
||||
createTpeAndFillUpProductFields(randomName, true, productData).then(
|
||||
productOrgResp => (productData.productOrganization = productOrgResp)
|
||||
);
|
||||
cy.addAliasToGraphRequest("ProductDetails");
|
||||
|
@ -86,15 +83,11 @@ describe("Create product", () => {
|
|||
expectCorrectProductInformation(productResp, productData);
|
||||
});
|
||||
});
|
||||
|
||||
it("should create product without variants", () => {
|
||||
const prices = { sellingPrice: 6, costPrice: 3 };
|
||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
seo.slug = randomName;
|
||||
createTypeProduct({
|
||||
name: randomName,
|
||||
attributeId: attribute.id,
|
||||
hasVariants: false
|
||||
});
|
||||
const productData = {
|
||||
generalInfo,
|
||||
seo,
|
||||
|
@ -102,7 +95,7 @@ describe("Create product", () => {
|
|||
productOrganization: { productType: randomName },
|
||||
attribute
|
||||
};
|
||||
fillUpCommonFieldsForAllProductTypes(productData).then(
|
||||
createTpeAndFillUpProductFields(randomName, false, productData).then(
|
||||
productOrgResp => (productData.productOrganization = productOrgResp)
|
||||
);
|
||||
selectChannelInDetailsPages();
|
||||
|
@ -126,4 +119,22 @@ describe("Create product", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
function createTpeAndFillUpProductFields(
|
||||
randomName,
|
||||
hasVariants,
|
||||
productData
|
||||
) {
|
||||
createTypeProduct({
|
||||
name: randomName,
|
||||
attributeId: attribute.id,
|
||||
hasVariants
|
||||
});
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.product)
|
||||
.visit(urlList.products)
|
||||
.get(PRODUCTS_LIST.createProductBtn)
|
||||
.click();
|
||||
return fillUpCommonFieldsForAllProductTypes(productData);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import faker from "faker";
|
||||
|
||||
import { getProductDetails } from "../../../../apiRequests/storeFront/ProductDetails";
|
||||
import { ONE_PERMISSION_USERS } from "../../../../Data/users";
|
||||
import { updateProductIsAvailableForPurchase } from "../../../../steps/catalog/products/productSteps";
|
||||
import { productDetailsUrl } from "../../../../url/urlList";
|
||||
import { getDefaultChannel } from "../../../../utils/channelsUtils";
|
||||
|
@ -55,7 +56,10 @@ describe("Products available in listings", () => {
|
|||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
ONE_PERMISSION_USERS.product
|
||||
);
|
||||
});
|
||||
|
||||
it("should update product to available for purchase", () => {
|
||||
|
@ -84,6 +88,7 @@ describe("Products available in listings", () => {
|
|||
expect(isProductAvailableForPurchase(resp)).to.be.eq(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("should update product to not available for purchase", () => {
|
||||
const productName = `${startsWith}${faker.datatype.number()}`;
|
||||
let product;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import faker from "faker";
|
||||
|
||||
import { getProductDetails } from "../../../../apiRequests/storeFront/ProductDetails";
|
||||
import { ONE_PERMISSION_USERS } from "../../../../Data/users";
|
||||
import { updateProductPublish } from "../../../../steps/catalog/products/productSteps";
|
||||
import { productDetailsUrl } from "../../../../url/urlList";
|
||||
import { getDefaultChannel } from "../../../../utils/channelsUtils";
|
||||
|
@ -14,6 +15,7 @@ describe("Published products", () => {
|
|||
let productType;
|
||||
let attribute;
|
||||
let category;
|
||||
let defaultChannel;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
|
@ -29,28 +31,33 @@ describe("Published products", () => {
|
|||
productType = productTypeResp;
|
||||
attribute = attributeResp;
|
||||
category = categoryResp;
|
||||
getDefaultChannel();
|
||||
}
|
||||
);
|
||||
)
|
||||
.then(channel => {
|
||||
defaultChannel = channel;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
ONE_PERMISSION_USERS.product
|
||||
);
|
||||
});
|
||||
|
||||
it("should update product to published", () => {
|
||||
const productName = `${startsWith}${faker.datatype.number()}`;
|
||||
let defaultChannel;
|
||||
getDefaultChannel()
|
||||
.then(channel => {
|
||||
defaultChannel = channel;
|
||||
productsUtils.createProductInChannel({
|
||||
name: productName,
|
||||
channelId: defaultChannel.id,
|
||||
productTypeId: productType.id,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id,
|
||||
isPublished: false,
|
||||
isAvailableForPurchase: false
|
||||
});
|
||||
|
||||
productsUtils
|
||||
.createProductInChannel({
|
||||
name: productName,
|
||||
channelId: defaultChannel.id,
|
||||
productTypeId: productType.id,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id,
|
||||
isPublished: false,
|
||||
isAvailableForPurchase: false
|
||||
})
|
||||
.then(({ product: productResp }) => {
|
||||
const product = productResp;
|
||||
|
@ -63,21 +70,18 @@ describe("Published products", () => {
|
|||
expect(isVisible).to.be.eq(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("should update product to not published", () => {
|
||||
const productName = `${startsWith}${faker.datatype.number()}`;
|
||||
let defaultChannel;
|
||||
let product;
|
||||
|
||||
getDefaultChannel()
|
||||
.then(channel => {
|
||||
defaultChannel = channel;
|
||||
productsUtils.createProductInChannel({
|
||||
name: productName,
|
||||
channelId: defaultChannel.id,
|
||||
productTypeId: productType.id,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id
|
||||
});
|
||||
productsUtils
|
||||
.createProductInChannel({
|
||||
name: productName,
|
||||
channelId: defaultChannel.id,
|
||||
productTypeId: productType.id,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id
|
||||
})
|
||||
.then(({ product: productResp }) => {
|
||||
product = productResp;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import faker from "faker";
|
||||
|
||||
import { searchInShop } from "../../../../apiRequests/storeFront/Search";
|
||||
import { ONE_PERMISSION_USERS } from "../../../../Data/users";
|
||||
import { updateProductVisibleInListings } from "../../../../steps/catalog/products/productSteps";
|
||||
import { productDetailsUrl } from "../../../../url/urlList";
|
||||
import { getDefaultChannel } from "../../../../utils/channelsUtils";
|
||||
|
@ -14,6 +15,7 @@ describe("Products displayed in listings", () => {
|
|||
let productType;
|
||||
let attribute;
|
||||
let category;
|
||||
let defaultChannel;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
|
@ -29,28 +31,33 @@ describe("Products displayed in listings", () => {
|
|||
productType = productTypeResp;
|
||||
attribute = attributeResp;
|
||||
category = categoryResp;
|
||||
getDefaultChannel();
|
||||
}
|
||||
);
|
||||
)
|
||||
.then(channel => {
|
||||
defaultChannel = channel;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
ONE_PERMISSION_USERS.product
|
||||
);
|
||||
});
|
||||
|
||||
it("should update product to visible in listings", () => {
|
||||
const productName = `${startsWith}${faker.datatype.number()}`;
|
||||
let defaultChannel;
|
||||
getDefaultChannel()
|
||||
.then(channel => {
|
||||
defaultChannel = channel;
|
||||
productsUtils.createProductInChannel({
|
||||
name: productName,
|
||||
channelId: defaultChannel.id,
|
||||
productTypeId: productType.id,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id,
|
||||
visibleInListings: false,
|
||||
isAvailableForPurchase: false
|
||||
});
|
||||
|
||||
productsUtils
|
||||
.createProductInChannel({
|
||||
name: productName,
|
||||
channelId: defaultChannel.id,
|
||||
productTypeId: productType.id,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id,
|
||||
visibleInListings: false,
|
||||
isAvailableForPurchase: false
|
||||
})
|
||||
.then(({ product: productResp }) => {
|
||||
const product = productResp;
|
||||
|
@ -66,20 +73,18 @@ describe("Products displayed in listings", () => {
|
|||
expect(isProductVisible).to.be.eq(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("should update product to not visible in listings", () => {
|
||||
const productName = `${startsWith}${faker.datatype.number()}`;
|
||||
let defaultChannel;
|
||||
getDefaultChannel()
|
||||
.then(channel => {
|
||||
defaultChannel = channel;
|
||||
productsUtils.createProductInChannel({
|
||||
name: productName,
|
||||
channelId: defaultChannel.id,
|
||||
productTypeId: productType.id,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id,
|
||||
visibleInListings: true
|
||||
});
|
||||
|
||||
productsUtils
|
||||
.createProductInChannel({
|
||||
name: productName,
|
||||
channelId: defaultChannel.id,
|
||||
productTypeId: productType.id,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id,
|
||||
visibleInListings: true
|
||||
})
|
||||
.then(({ product: productResp }) => {
|
||||
const product = productResp;
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
createProduct,
|
||||
updateChannelInProduct
|
||||
} from "../../../apiRequests/Product";
|
||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
||||
import {
|
||||
createFirstVariant,
|
||||
createVariant,
|
||||
|
@ -30,6 +31,7 @@ describe("Creating variants", () => {
|
|||
let attribute;
|
||||
let productType;
|
||||
let category;
|
||||
let newChannel;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
|
@ -50,7 +52,11 @@ describe("Creating variants", () => {
|
|||
address: fixtureAddresses.plAddress
|
||||
})
|
||||
)
|
||||
.then(({ warehouse: warehouseResp }) => (warehouse = warehouseResp));
|
||||
.then(({ warehouse: warehouseResp }) => {
|
||||
warehouse = warehouseResp;
|
||||
createChannel({ isActive: true, name, currencyCode: "PLN" });
|
||||
})
|
||||
.then(resp => (newChannel = resp));
|
||||
|
||||
productUtils
|
||||
.createTypeAttributeAndCategoryForProduct(name, attributeValues)
|
||||
|
@ -68,7 +74,10 @@ describe("Creating variants", () => {
|
|||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
ONE_PERMISSION_USERS.product
|
||||
);
|
||||
});
|
||||
|
||||
it("should create variant visible on frontend", () => {
|
||||
|
@ -104,6 +113,7 @@ describe("Creating variants", () => {
|
|||
expect(variant).to.have.property("price", price);
|
||||
});
|
||||
});
|
||||
|
||||
it("should create several variants", () => {
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
const secondVariantSku = `${startsWith}${faker.datatype.number()}`;
|
||||
|
@ -145,21 +155,21 @@ describe("Creating variants", () => {
|
|||
expect(secondVariant).to.have.property("price", variants[1].price);
|
||||
});
|
||||
});
|
||||
|
||||
it("should create variant for many channels", () => {
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
const variantsPrice = 10;
|
||||
let newChannel;
|
||||
let createdProduct;
|
||||
createChannel({ isActive: true, name, currencyCode: "PLN" })
|
||||
.then(resp => {
|
||||
newChannel = resp;
|
||||
createProduct({
|
||||
attributeId: attribute.id,
|
||||
name,
|
||||
productTypeId: productType.id,
|
||||
categoryId: category.id
|
||||
});
|
||||
})
|
||||
// createChannel({ isActive: true, name, currencyCode: "PLN" })
|
||||
// .then(resp => {
|
||||
// newChannel = resp;
|
||||
createProduct({
|
||||
attributeId: attribute.id,
|
||||
name,
|
||||
productTypeId: productType.id,
|
||||
categoryId: category.id
|
||||
})
|
||||
// })
|
||||
.then(productResp => {
|
||||
createdProduct = productResp;
|
||||
updateChannelInProduct({
|
||||
|
|
|
@ -3,6 +3,7 @@ import faker from "faker";
|
|||
import { createCategory } from "../../../apiRequests/Category";
|
||||
import { createCollection } from "../../../apiRequests/Collections";
|
||||
import { getProductDetails } from "../../../apiRequests/storeFront/ProductDetails";
|
||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
||||
import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details";
|
||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||
import { metadataForms } from "../../../steps/catalog/metadataSteps";
|
||||
|
@ -56,6 +57,7 @@ describe("Update products", () => {
|
|||
product = productResp;
|
||||
});
|
||||
});
|
||||
|
||||
it("Should update product", () => {
|
||||
const updatedName = `${startsWith}${faker.random.number()}`;
|
||||
let updatedCategory;
|
||||
|
@ -95,8 +97,11 @@ describe("Update products", () => {
|
|||
collection: updatedCollection.name
|
||||
}
|
||||
};
|
||||
cy.visit(productDetailsUrl(product.id));
|
||||
cy.get(PRODUCT_DETAILS.collectionRemoveButtons).click();
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.product)
|
||||
.visit(productDetailsUrl(product.id))
|
||||
.get(PRODUCT_DETAILS.collectionRemoveButtons)
|
||||
.click();
|
||||
fillUpCommonFieldsForAllProductTypes(productData, false);
|
||||
cy.addAliasToGraphRequest("UpdatePrivateMetadata");
|
||||
cy.addAliasToGraphRequest("UpdateMetadata");
|
||||
|
@ -122,15 +127,18 @@ describe("Update products", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should delete product", () => {
|
||||
cy.visit(productDetailsUrl(product.id));
|
||||
cy.addAliasToGraphRequest("ProductDelete");
|
||||
cy.get(BUTTON_SELECTORS.deleteButton)
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.product)
|
||||
.visit(productDetailsUrl(product.id))
|
||||
.addAliasToGraphRequest("ProductDelete")
|
||||
.get(BUTTON_SELECTORS.deleteButton)
|
||||
.click()
|
||||
.get(BUTTON_SELECTORS.submit)
|
||||
.click();
|
||||
cy.wait("@ProductDelete");
|
||||
cy.loginUserViaRequest("token")
|
||||
.click()
|
||||
.wait("@ProductDelete")
|
||||
.loginUserViaRequest("token")
|
||||
.then(() => {
|
||||
getProductDetails(product.id, defaultChannel.slug).its("body.data");
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue