From 9b1fce078afad1c0d2250260a09756f192aa9b37 Mon Sep 17 00:00:00 2001 From: Karolina Rakoczy Date: Mon, 31 Jan 2022 10:25:59 +0100 Subject: [PATCH] Add test for creating product type with gift card kind (#1776) * add test for creating product type with gift card type * change product type tests names * update tests names for producttypes --- .../productTypes/productTypeDetails.js | 3 +- .../integration/configuration/productTypes.js | 30 ++++++++++++++----- cypress/support/api/requests/ProductType.js | 1 + cypress/support/pages/productTypePage.js | 5 +++- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/cypress/elements/productTypes/productTypeDetails.js b/cypress/elements/productTypes/productTypeDetails.js index c4aa98dec..31ba5df39 100644 --- a/cypress/elements/productTypes/productTypeDetails.js +++ b/cypress/elements/productTypes/productTypeDetails.js @@ -4,5 +4,6 @@ export const PRODUCT_TYPE_DETAILS = { assignProductAttributeButton: '[data-test-id="assignProductsAttributes"]', assignVariantAttributeButton: '[data-test-id="assignVariantsAttributes"]', hasVariantsButton: '[name="hasVariants"]', - shippingWeightInput: '[name="weight"]' + shippingWeightInput: '[name="weight"]', + giftCardKindCheckbox: '[data-test-id="product-type-kind-option-GIFT_CARD"]' }; diff --git a/cypress/integration/configuration/productTypes.js b/cypress/integration/configuration/productTypes.js index f6510cec2..8df407835 100644 --- a/cypress/integration/configuration/productTypes.js +++ b/cypress/integration/configuration/productTypes.js @@ -15,7 +15,7 @@ import filterTests from "../../support/filterTests"; import { createProductType } from "../../support/pages/productTypePage"; filterTests({ definedTags: ["all"] }, () => { - describe("Tests for product types", () => { + describe("As an admin I want to manage product types", () => { const startsWith = "ProductType"; before(() => { @@ -31,24 +31,25 @@ filterTests({ definedTags: ["all"] }, () => { .softExpectSkeletonIsVisible(); }); - it("Create product type without shipping required", () => { + it("As an admin I should be able to create product type without shipping required", () => { const name = `${startsWith}${faker.datatype.number()}`; - createProductType(name, false) + createProductType({ name }) .then(productType => { getProductType(productType.id); }) .then(productType => { expect(productType.name).to.be.eq(name); expect(productType.isShippingRequired).to.be.false; + expect(productType.kind).to.be.eq("NORMAL"); }); }); - it("Create product type with shipping required", () => { + it("As an admin I should be able to create product type with shipping required", () => { const name = `${startsWith}${faker.datatype.number()}`; const shippingWeight = 10; - createProductType(name, shippingWeight) + createProductType({ name, shippingWeight }) .then(productType => { getProductType(productType.id); }) @@ -56,10 +57,25 @@ filterTests({ definedTags: ["all"] }, () => { expect(productType.name).to.be.eq(name); expect(productType.isShippingRequired).to.be.true; expect(productType.weight.value).to.eq(shippingWeight); + expect(productType.kind).to.be.eq("NORMAL"); }); }); - it("Update product type with product attribute", () => { + it("As an admin I should be able to create product type with gift card kind", () => { + const name = `${startsWith}${faker.datatype.number()}`; + + createProductType({ name, giftCard: true }) + .then(productType => { + getProductType(productType.id); + }) + .then(productType => { + expect(productType.name).to.be.eq(name); + expect(productType.isShippingRequired).to.be.false; + expect(productType.kind).to.be.eq("GIFT_CARD"); + }); + }); + + it("As an admin I should be able to update product type with product attribute", () => { const name = `${startsWith}${faker.datatype.number()}`; createTypeProduct({ name }) @@ -80,7 +96,7 @@ filterTests({ definedTags: ["all"] }, () => { }); }); - it("Update product type with variant attribute", () => { + it("As an admin I should be able to update product type with variant attribute", () => { const name = `${startsWith}${faker.datatype.number()}`; createTypeProduct({ name, hasVariants: false }) diff --git a/cypress/support/api/requests/ProductType.js b/cypress/support/api/requests/ProductType.js index bdfb0da01..327c38183 100644 --- a/cypress/support/api/requests/ProductType.js +++ b/cypress/support/api/requests/ProductType.js @@ -97,6 +97,7 @@ export function getProductType(productTypeId) { productType(id:"${productTypeId}"){ id name + kind isShippingRequired weight{ value diff --git a/cypress/support/pages/productTypePage.js b/cypress/support/pages/productTypePage.js index a358e3f41..2765b7f55 100644 --- a/cypress/support/pages/productTypePage.js +++ b/cypress/support/pages/productTypePage.js @@ -2,12 +2,15 @@ import { PRODUCT_TYPE_DETAILS } from "../../elements/productTypes/productTypeDet import { PRODUCT_TYPES_LIST } from "../../elements/productTypes/productTypesList"; import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors"; -export function createProductType(name, shippingWeight) { +export function createProductType({ name, shippingWeight, giftCard = false }) { cy.get(PRODUCT_TYPES_LIST.addProductTypeButton) .click() .waitForProgressBarToNotBeVisible() .get(PRODUCT_TYPE_DETAILS.nameInput) .type(name); + if (giftCard) { + cy.get(PRODUCT_TYPE_DETAILS.giftCardKindCheckbox).click(); + } if (shippingWeight) { cy.get(PRODUCT_TYPE_DETAILS.isShippingRequired) .click()