tests for available for purchase
This commit is contained in:
parent
5fa5eda4a7
commit
a33b13aaa2
4 changed files with 84 additions and 53 deletions
|
@ -46,6 +46,7 @@ class Product {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
cy.sendRequestWithQuery(mutation);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateChannelPriceInVariant(variantId, channelId) {
|
updateChannelPriceInVariant(variantId, channelId) {
|
||||||
|
@ -106,7 +107,7 @@ class Product {
|
||||||
warehouse: "${warehouseId}"
|
warehouse: "${warehouseId}"
|
||||||
quantity: ${quantity}
|
quantity: ${quantity}
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
productVariants{
|
productVariants{
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
@ -115,7 +116,7 @@ class Product {
|
||||||
field
|
field
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(mutation);
|
return cy.sendRequestWithQuery(mutation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,16 +27,24 @@ describe("Products available in listings", () => {
|
||||||
shippingUtils.deleteShipping(startsWith);
|
shippingUtils.deleteShipping(startsWith);
|
||||||
productsUtils.deleteProperProducts(startsWith);
|
productsUtils.deleteProperProducts(startsWith);
|
||||||
|
|
||||||
channelsUtils.getDefaultChannel().then(channel => {
|
channelsUtils
|
||||||
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
defaultChannel = channel;
|
defaultChannel = channel;
|
||||||
cy.fixture("addresses").then(json => {
|
cy.fixture("addresses");
|
||||||
shippingUtils
|
})
|
||||||
.createShipping(defaultChannel, name, json.plAddress, 10)
|
.then(addressesFixture => {
|
||||||
|
shippingUtils.createShipping(
|
||||||
|
defaultChannel,
|
||||||
|
name,
|
||||||
|
addressesFixture.plAddress,
|
||||||
|
10
|
||||||
|
);
|
||||||
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
warehouse = shippingUtils.getWarehouse();
|
warehouse = shippingUtils.getWarehouse();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
productsUtils.createTypeAttributeAndCategoryForProduct(name).then(() => {
|
||||||
productType = productsUtils.getProductType();
|
productType = productsUtils.getProductType();
|
||||||
attribute = productsUtils.getAttribute();
|
attribute = productsUtils.getAttribute();
|
||||||
|
@ -50,7 +58,6 @@ describe("Products available in listings", () => {
|
||||||
|
|
||||||
it("should update product to available for purchase", () => {
|
it("should update product to available for purchase", () => {
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
productsUtils.createProductInChannel(productName);
|
|
||||||
productsUtils
|
productsUtils
|
||||||
.createProductInChannel(
|
.createProductInChannel(
|
||||||
productName,
|
productName,
|
||||||
|
@ -59,28 +66,29 @@ describe("Products available in listings", () => {
|
||||||
10,
|
10,
|
||||||
productType.id,
|
productType.id,
|
||||||
attribute.id,
|
attribute.id,
|
||||||
category,
|
category.id,
|
||||||
|
1,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true,
|
true
|
||||||
1
|
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const productUrl = `${
|
const productUrl = `${URL_LIST.products}${
|
||||||
URL_LIST.products
|
productsUtils.getCreatedProduct().id
|
||||||
}${productsUtils.getCreatedProductId()}`;
|
}`;
|
||||||
productSteps.updateProductIsAvailableForPurchase(productUrl, true);
|
productSteps.updateProductIsAvailableForPurchase(productUrl, true);
|
||||||
frontShopProductUtils
|
})
|
||||||
.isProductAvailableForPurchase(
|
.then(() => {
|
||||||
productsUtils.getCreatedProductId(),
|
frontShopProductUtils.isProductAvailableForPurchase(
|
||||||
|
productsUtils.getCreatedProduct().id,
|
||||||
defaultChannel.slug,
|
defaultChannel.slug,
|
||||||
productName
|
productName
|
||||||
)
|
);
|
||||||
|
})
|
||||||
.then(isProductVisible => {
|
.then(isProductVisible => {
|
||||||
expect(isProductVisible).to.be.eq(true);
|
expect(isProductVisible).to.be.eq(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
it("should update product to not available for purchase", () => {
|
it("should update product to not available for purchase", () => {
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
productsUtils
|
productsUtils
|
||||||
|
@ -91,20 +99,20 @@ describe("Products available in listings", () => {
|
||||||
10,
|
10,
|
||||||
productType.id,
|
productType.id,
|
||||||
attribute.id,
|
attribute.id,
|
||||||
category,
|
category.id,
|
||||||
|
1,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
true
|
||||||
1
|
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const productUrl = `${
|
const productUrl = `${URL_LIST.products}${
|
||||||
URL_LIST.products
|
productsUtils.getCreatedProduct().id
|
||||||
}${productsUtils.getCreatedProductId()}`;
|
}`;
|
||||||
productSteps.updateProductIsAvailableForPurchase(productUrl, false);
|
productSteps.updateProductIsAvailableForPurchase(productUrl, false);
|
||||||
frontShopProductUtils
|
frontShopProductUtils
|
||||||
.isProductAvailableForPurchase(
|
.isProductAvailableForPurchase(
|
||||||
productsUtils.getCreatedProductId(),
|
productsUtils.getCreatedProduct().id,
|
||||||
defaultChannel.slug,
|
defaultChannel.slug,
|
||||||
productName
|
productName
|
||||||
)
|
)
|
||||||
|
|
|
@ -38,20 +38,23 @@ describe("Publish products", () => {
|
||||||
productsUtils
|
productsUtils
|
||||||
.createProductInChannel(
|
.createProductInChannel(
|
||||||
productName,
|
productName,
|
||||||
|
defaultChannel.id,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
productType.id,
|
productType.id,
|
||||||
attribute.id,
|
attribute.id,
|
||||||
category.id,
|
category.id,
|
||||||
defaultChannel.id,
|
null,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const productId = productsUtils.getCreatedProductId();
|
const product = productsUtils.getCreatedProduct();
|
||||||
const productUrl = `${URL_LIST.products}${productId}`;
|
const productUrl = `${URL_LIST.products}${product.id}`;
|
||||||
productSteps.updateProductPublish(productUrl, true);
|
productSteps.updateProductPublish(productUrl, true);
|
||||||
frontShopProductUtils
|
frontShopProductUtils
|
||||||
.isProductVisible(productId, defaultChannel.slug, productName)
|
.isProductVisible(product.id, defaultChannel.slug, productName)
|
||||||
.then(isVisible => {
|
.then(isVisible => {
|
||||||
expect(isVisible).to.be.eq(true);
|
expect(isVisible).to.be.eq(true);
|
||||||
});
|
});
|
||||||
|
@ -68,13 +71,21 @@ describe("Publish products", () => {
|
||||||
attribute.id,
|
attribute.id,
|
||||||
category.id,
|
category.id,
|
||||||
defaultChannel.id,
|
defaultChannel.id,
|
||||||
true,
|
productName,
|
||||||
|
defaultChannel.id,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
productType.id,
|
||||||
|
attribute.id,
|
||||||
|
category.id,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
false,
|
false,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const productId = productsUtils.getCreatedProductId();
|
const product = productsUtils.getCreatedProduct();
|
||||||
const productUrl = `${URL_LIST.products}${productId}`;
|
const productUrl = `${URL_LIST.products}${product.id}`;
|
||||||
productSteps.updateProductPublish(productUrl, false);
|
productSteps.updateProductPublish(productUrl, false);
|
||||||
frontShopProductUtils
|
frontShopProductUtils
|
||||||
.isProductVisible(productId, defaultChannel.slug, productName)
|
.isProductVisible(productId, defaultChannel.slug, productName)
|
||||||
|
@ -83,7 +94,7 @@ describe("Publish products", () => {
|
||||||
});
|
});
|
||||||
cy.loginInShop().then(() => {
|
cy.loginInShop().then(() => {
|
||||||
frontShopProductUtils
|
frontShopProductUtils
|
||||||
.isProductVisible(productId, defaultChannel.slug, productName)
|
.isProductVisible(product.id, defaultChannel.slug, productName)
|
||||||
.then(isVisible => {
|
.then(isVisible => {
|
||||||
expect(isVisible).to.be.eq(true);
|
expect(isVisible).to.be.eq(true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,11 +30,20 @@ class ProductsUtils {
|
||||||
productTypeId,
|
productTypeId,
|
||||||
attributeId,
|
attributeId,
|
||||||
categoryId,
|
categoryId,
|
||||||
price
|
price,
|
||||||
|
isPublished = true,
|
||||||
|
isAvailableForPurchase = true,
|
||||||
|
visibleInListings = true
|
||||||
) {
|
) {
|
||||||
return this.createProduct(attributeId, name, productTypeId, categoryId)
|
return this.createProduct(attributeId, name, productTypeId, categoryId)
|
||||||
.then(() =>
|
.then(() =>
|
||||||
this.productRequest.updateChannelInProduct(this.product.id, channelId)
|
this.productRequest.updateChannelInProduct(
|
||||||
|
this.product.id,
|
||||||
|
channelId,
|
||||||
|
isPublished,
|
||||||
|
isAvailableForPurchase,
|
||||||
|
visibleInListings
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.createVariant(
|
this.createVariant(
|
||||||
|
@ -101,7 +110,9 @@ class ProductsUtils {
|
||||||
resp.body.data.productVariantBulkCreate.productVariants)
|
resp.body.data.productVariantBulkCreate.productVariants)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
getCreatedProduct() {
|
||||||
|
return this.product;
|
||||||
|
}
|
||||||
getCreatedVariants() {
|
getCreatedVariants() {
|
||||||
return this.variants;
|
return this.variants;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue