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{
|
||||
id
|
||||
name
|
||||
values{name}
|
||||
}
|
||||
attributeErrors{
|
||||
field
|
||||
|
|
|
@ -4,9 +4,31 @@ class ProductDetails {
|
|||
id
|
||||
name
|
||||
}
|
||||
|
||||
fragment Price on TaxedMoney {
|
||||
gross {
|
||||
amount
|
||||
currency
|
||||
}
|
||||
}
|
||||
|
||||
fragment ProductVariantFields on ProductVariant {
|
||||
id
|
||||
sku
|
||||
name
|
||||
pricing {
|
||||
price {
|
||||
...Price
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query ProductDetails{
|
||||
product(id: "${productId}", channel: "${channelId}") {
|
||||
...BasicProductFields
|
||||
variants {
|
||||
...ProductVariantFields
|
||||
}
|
||||
isAvailable
|
||||
isAvailableForPurchase
|
||||
availableForPurchase
|
||||
|
|
|
@ -77,7 +77,12 @@ describe("creating variants", () => {
|
|||
channelId: defaultChannel.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(
|
||||
createdProduct.id,
|
||||
defaultChannel.slug
|
||||
|
@ -87,7 +92,7 @@ describe("creating variants", () => {
|
|||
})
|
||||
.then(variants => {
|
||||
// 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(
|
||||
// productDetailsResp.body[0].data.product.variants[0].pricing.price
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { PRODUCTS_SELECTORS } from "../../elements/catalog/product-selectors";
|
||||
import { VARIANTS_SELECTORS } from "../../elements/catalog/variants-selectors";
|
||||
class VariantsSteps {
|
||||
createFirstVariant(sku, warehouseId, price) {
|
||||
cy.get(PRODUCTS_SELECTORS.addVariantsButton)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.attributeCheckbox)
|
||||
.first()
|
||||
createFirstVariant({ sku, warehouseId, price, attribute }) {
|
||||
cy.get(PRODUCTS_SELECTORS.addVariantsButton).click();
|
||||
cy.get(`${VARIANTS_SELECTORS.attributeCheckbox}`)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.nextButton)
|
||||
.click();
|
||||
|
|
|
@ -33,7 +33,7 @@ class StoreFrontProductUtils {
|
|||
getProductVariants(productId, channelSlug) {
|
||||
return this.productDetails
|
||||
.getProductDetails(productId, channelSlug)
|
||||
.then(resp => resp.body.data.product.variants.edges);
|
||||
.then(resp => resp.body.data.product.variants);
|
||||
}
|
||||
}
|
||||
export default StoreFrontProductUtils;
|
||||
|
|
Loading…
Reference in a new issue