tests for variants
This commit is contained in:
parent
83bf59889e
commit
ded6cdd5c4
5 changed files with 35 additions and 8 deletions
|
@ -9,6 +9,8 @@ class Attribute {
|
||||||
}){
|
}){
|
||||||
attribute{
|
attribute{
|
||||||
id
|
id
|
||||||
|
name
|
||||||
|
values{name}
|
||||||
}
|
}
|
||||||
attributeErrors{
|
attributeErrors{
|
||||||
field
|
field
|
||||||
|
|
|
@ -4,9 +4,31 @@ class ProductDetails {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fragment Price on TaxedMoney {
|
||||||
|
gross {
|
||||||
|
amount
|
||||||
|
currency
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment ProductVariantFields on ProductVariant {
|
||||||
|
id
|
||||||
|
sku
|
||||||
|
name
|
||||||
|
pricing {
|
||||||
|
price {
|
||||||
|
...Price
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
query ProductDetails{
|
query ProductDetails{
|
||||||
product(id: "${productId}", channel: "${channelId}") {
|
product(id: "${productId}", channel: "${channelId}") {
|
||||||
...BasicProductFields
|
...BasicProductFields
|
||||||
|
variants {
|
||||||
|
...ProductVariantFields
|
||||||
|
}
|
||||||
isAvailable
|
isAvailable
|
||||||
isAvailableForPurchase
|
isAvailableForPurchase
|
||||||
availableForPurchase
|
availableForPurchase
|
||||||
|
|
|
@ -77,7 +77,12 @@ describe("creating variants", () => {
|
||||||
channelId: defaultChannel.id
|
channelId: defaultChannel.id
|
||||||
});
|
});
|
||||||
cy.visit(`${urlList.products}${createdProduct.id}`);
|
cy.visit(`${urlList.products}${createdProduct.id}`);
|
||||||
variantsSteps.createFirstVariant(name, warehouse.id, price);
|
variantsSteps.createFirstVariant({
|
||||||
|
sku: name,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
price,
|
||||||
|
attribute: attribute.values[0].name
|
||||||
|
});
|
||||||
storeFrontProductUtils.getProductVariants(
|
storeFrontProductUtils.getProductVariants(
|
||||||
createdProduct.id,
|
createdProduct.id,
|
||||||
defaultChannel.slug
|
defaultChannel.slug
|
||||||
|
@ -87,7 +92,7 @@ describe("creating variants", () => {
|
||||||
})
|
})
|
||||||
.then(variants => {
|
.then(variants => {
|
||||||
// expect(productDetailsResp.body[0].data.product.name).to.equal(name);
|
// expect(productDetailsResp.body[0].data.product.name).to.equal(name);
|
||||||
expect(variants[0].name).to.equal(name);
|
expect(variants[0].name).to.equal(attribute.values[0]);
|
||||||
expect(variants[0].pricing.price.gross.amount).to.equal(price);
|
expect(variants[0].pricing.price.gross.amount).to.equal(price);
|
||||||
// expect(
|
// expect(
|
||||||
// productDetailsResp.body[0].data.product.variants[0].pricing.price
|
// productDetailsResp.body[0].data.product.variants[0].pricing.price
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { PRODUCTS_SELECTORS } from "../../elements/catalog/product-selectors";
|
import { PRODUCTS_SELECTORS } from "../../elements/catalog/product-selectors";
|
||||||
import { VARIANTS_SELECTORS } from "../../elements/catalog/variants-selectors";
|
import { VARIANTS_SELECTORS } from "../../elements/catalog/variants-selectors";
|
||||||
class VariantsSteps {
|
class VariantsSteps {
|
||||||
createFirstVariant(sku, warehouseId, price) {
|
createFirstVariant({ sku, warehouseId, price, attribute }) {
|
||||||
cy.get(PRODUCTS_SELECTORS.addVariantsButton)
|
cy.get(PRODUCTS_SELECTORS.addVariantsButton).click();
|
||||||
.click()
|
cy.get(`${VARIANTS_SELECTORS.attributeCheckbox}`)
|
||||||
.get(VARIANTS_SELECTORS.attributeCheckbox)
|
|
||||||
.first()
|
|
||||||
.click()
|
.click()
|
||||||
.get(VARIANTS_SELECTORS.nextButton)
|
.get(VARIANTS_SELECTORS.nextButton)
|
||||||
.click();
|
.click();
|
||||||
|
|
|
@ -33,7 +33,7 @@ class StoreFrontProductUtils {
|
||||||
getProductVariants(productId, channelSlug) {
|
getProductVariants(productId, channelSlug) {
|
||||||
return this.productDetails
|
return this.productDetails
|
||||||
.getProductDetails(productId, channelSlug)
|
.getProductDetails(productId, channelSlug)
|
||||||
.then(resp => resp.body.data.product.variants.edges);
|
.then(resp => resp.body.data.product.variants);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default StoreFrontProductUtils;
|
export default StoreFrontProductUtils;
|
||||||
|
|
Loading…
Reference in a new issue