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
This commit is contained in:
Karolina Rakoczy 2022-01-31 10:25:59 +01:00 committed by GitHub
parent 5ede05affe
commit 9b1fce078a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 9 deletions

View file

@ -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"]'
};

View file

@ -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 })

View file

@ -97,6 +97,7 @@ export function getProductType(productTypeId) {
productType(id:"${productTypeId}"){
id
name
kind
isShippingRequired
weight{
value

View file

@ -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()