tests for products
This commit is contained in:
parent
1c51419685
commit
1b4da95e81
4 changed files with 130 additions and 96 deletions
|
@ -45,7 +45,8 @@ class Channels {
|
||||||
channelErrors{
|
channelErrors{
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
}`;
|
}
|
||||||
|
}`;
|
||||||
return cy.sendRequestWithQuery(deleteChannelMutation);
|
return cy.sendRequestWithQuery(deleteChannelMutation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,19 +94,26 @@ class Product {
|
||||||
price = 1,
|
price = 1,
|
||||||
costPrice = 1
|
costPrice = 1
|
||||||
) {
|
) {
|
||||||
|
const channelListings = channelId
|
||||||
|
? `channelListings:{
|
||||||
|
channelId:"${channelId}"
|
||||||
|
price:"${price}"
|
||||||
|
costPrice:"${costPrice}"
|
||||||
|
}`
|
||||||
|
: "";
|
||||||
|
const stocks = warehouseId
|
||||||
|
? `stocks:{
|
||||||
|
warehouse:"${warehouseId}"
|
||||||
|
quantity:${quantity}
|
||||||
|
}`
|
||||||
|
: "";
|
||||||
|
|
||||||
const mutation = `mutation{
|
const mutation = `mutation{
|
||||||
productVariantBulkCreate(product: "${productId}", variants: {
|
productVariantBulkCreate(product: "${productId}", variants: {
|
||||||
attributes: []
|
attributes: []
|
||||||
sku: "${sku}"
|
sku: "${sku}"
|
||||||
channelListings: {
|
${channelListings}
|
||||||
channelId: "${channelId}"
|
${stocks}
|
||||||
price: "${price}"
|
|
||||||
costPrice: "${costPrice}"
|
|
||||||
}
|
|
||||||
stocks: {
|
|
||||||
warehouse: "${warehouseId}"
|
|
||||||
quantity: ${quantity}
|
|
||||||
}
|
|
||||||
}) {
|
}) {
|
||||||
productVariants{
|
productVariants{
|
||||||
id
|
id
|
||||||
|
|
|
@ -34,9 +34,12 @@ describe("Publish products", () => {
|
||||||
});
|
});
|
||||||
it("should update product to published", () => {
|
it("should update product to published", () => {
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
let defaultChannel;
|
||||||
productsUtils
|
channelsUtils
|
||||||
.createProductInChannel(
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
productsUtils.createProductInChannel(
|
||||||
productName,
|
productName,
|
||||||
defaultChannel.id,
|
defaultChannel.id,
|
||||||
null,
|
null,
|
||||||
|
@ -44,62 +47,68 @@ describe("Publish products", () => {
|
||||||
productType.id,
|
productType.id,
|
||||||
attribute.id,
|
attribute.id,
|
||||||
category.id,
|
category.id,
|
||||||
null,
|
1,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true
|
true
|
||||||
)
|
);
|
||||||
.then(() => {
|
})
|
||||||
const product = productsUtils.getCreatedProduct();
|
.then(() => {
|
||||||
const productUrl = `${URL_LIST.products}${product.id}`;
|
const product = productsUtils.getCreatedProduct();
|
||||||
productSteps.updateProductPublish(productUrl, true);
|
const productUrl = `${URL_LIST.products}${product.id}`;
|
||||||
frontShopProductUtils
|
productSteps.updateProductPublish(productUrl, true);
|
||||||
.isProductVisible(product.id, defaultChannel.slug, productName)
|
frontShopProductUtils.isProductVisible(
|
||||||
.then(isVisible => {
|
product.id,
|
||||||
expect(isVisible).to.be.eq(true);
|
defaultChannel.slug,
|
||||||
});
|
productName
|
||||||
});
|
);
|
||||||
});
|
})
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it("should update product to not published", () => {
|
it("should update product to not published", () => {
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
let defaultChannel;
|
||||||
productsUtils
|
let product;
|
||||||
.createProductInChannel(
|
|
||||||
productName,
|
channelsUtils
|
||||||
productType.id,
|
.getDefaultChannel()
|
||||||
attribute.id,
|
.then(channel => {
|
||||||
category.id,
|
defaultChannel = channel;
|
||||||
defaultChannel.id,
|
productsUtils.createProductInChannel(
|
||||||
productName,
|
productName,
|
||||||
defaultChannel.id,
|
defaultChannel.id,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
productType.id,
|
productType.id,
|
||||||
attribute.id,
|
attribute.id,
|
||||||
category.id,
|
category.id
|
||||||
null,
|
);
|
||||||
false,
|
})
|
||||||
false,
|
.then(() => {
|
||||||
true
|
product = productsUtils.getCreatedProduct();
|
||||||
)
|
const productUrl = `${URL_LIST.products}${product.id}`;
|
||||||
.then(() => {
|
productSteps.updateProductPublish(productUrl, false);
|
||||||
const product = productsUtils.getCreatedProduct();
|
frontShopProductUtils.isProductVisible(
|
||||||
const productUrl = `${URL_LIST.products}${product.id}`;
|
product.id,
|
||||||
productSteps.updateProductPublish(productUrl, false);
|
defaultChannel.slug,
|
||||||
frontShopProductUtils
|
productName
|
||||||
.isProductVisible(productId, defaultChannel.slug, productName)
|
);
|
||||||
.then(isVisible => {
|
})
|
||||||
expect(isVisible).to.be.eq(false);
|
.then(isVisible => {
|
||||||
});
|
expect(isVisible).to.be.eq(false);
|
||||||
cy.loginInShop().then(() => {
|
cy.loginInShop();
|
||||||
frontShopProductUtils
|
})
|
||||||
.isProductVisible(product.id, defaultChannel.slug, productName)
|
.then(() => {
|
||||||
.then(isVisible => {
|
frontShopProductUtils.isProductVisible(
|
||||||
expect(isVisible).to.be.eq(true);
|
product.id,
|
||||||
});
|
defaultChannel.slug,
|
||||||
});
|
productName
|
||||||
});
|
);
|
||||||
});
|
})
|
||||||
|
.then(isVisible => {
|
||||||
|
expect(isVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,61 +34,78 @@ describe("Products displayed in listings", () => {
|
||||||
});
|
});
|
||||||
it("should update product to visible in listings", () => {
|
it("should update product to visible in listings", () => {
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
let defaultChannel;
|
||||||
productsUtils
|
channelsUtils
|
||||||
.createProductInChannel(
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
productsUtils.createProductInChannel(
|
||||||
productName,
|
productName,
|
||||||
|
defaultChannel.id,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
productType.id,
|
productType.id,
|
||||||
attribute.id,
|
attribute.id,
|
||||||
category.id,
|
category.id,
|
||||||
defaultChannel.id,
|
1,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
)
|
);
|
||||||
.then(() => {
|
})
|
||||||
const productId = productsUtils.getCreatedProductId();
|
.then(() => {
|
||||||
const productUrl = `${URL_LIST.products}${productId}`;
|
const product = productsUtils.getCreatedProduct();
|
||||||
productSteps.updateProductVisibleInListings(productUrl);
|
const productUrl = `${URL_LIST.products}${product.id}`;
|
||||||
frontShopProductUtils
|
productSteps.updateProductVisibleInListings(productUrl);
|
||||||
.isProductVisibleInSearchResult(productName, defaultChannel.slug)
|
frontShopProductUtils.isProductVisibleInSearchResult(
|
||||||
.then(isProductVisible => {
|
productName,
|
||||||
expect(isProductVisible).to.be.eq(true);
|
defaultChannel.slug
|
||||||
});
|
);
|
||||||
});
|
})
|
||||||
});
|
.then(isProductVisible => {
|
||||||
|
expect(isProductVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it("should update product to not visible in listings", () => {
|
it("should update product to not visible in listings", () => {
|
||||||
const productName = `${startsWith}${faker.random.number()}`;
|
const productName = `${startsWith}${faker.random.number()}`;
|
||||||
channelsUtils.getDefaultChannel().then(defaultChannel => {
|
let defaultChannel;
|
||||||
productsUtils
|
channelsUtils
|
||||||
.createProductInChannel(
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
productsUtils.createProductInChannel(
|
||||||
productName,
|
productName,
|
||||||
|
defaultChannel.id,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
productType.id,
|
productType.id,
|
||||||
attribute.id,
|
attribute.id,
|
||||||
category.id,
|
category.id,
|
||||||
defaultChannel.id,
|
1,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true
|
true
|
||||||
)
|
);
|
||||||
.then(() => {
|
})
|
||||||
const productId = productsUtils.getCreatedProductId();
|
.then(() => {
|
||||||
const productUrl = `${URL_LIST.products}${productId}`;
|
const product = productsUtils.getCreatedProduct();
|
||||||
productSteps.updateProductVisibleInListings(productUrl);
|
const productUrl = `${URL_LIST.products}${product.id}`;
|
||||||
frontShopProductUtils
|
productSteps.updateProductVisibleInListings(productUrl);
|
||||||
.isProductVisibleInSearchResult(productName, defaultChannel.slug)
|
frontShopProductUtils
|
||||||
.then(isProductVisible => {
|
.isProductVisibleInSearchResult(productName, defaultChannel.slug)
|
||||||
expect(isProductVisible).to.be.eq(false);
|
.then(isProductVisible => {
|
||||||
});
|
expect(isProductVisible).to.be.eq(false);
|
||||||
cy.loginInShop().then(() => {
|
|
||||||
frontShopProductUtils
|
|
||||||
.isProductVisibleInSearchResult(productName, defaultChannel.slug)
|
|
||||||
.then(isProductVisible => {
|
|
||||||
expect(isProductVisible).to.be.eq(true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
cy.loginInShop();
|
||||||
});
|
})
|
||||||
|
.then(() => {
|
||||||
|
frontShopProductUtils.isProductVisibleInSearchResult(
|
||||||
|
productName,
|
||||||
|
defaultChannel.slug
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(isProductVisible => {
|
||||||
|
expect(isProductVisible).to.be.eq(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue