gift cards in checkout (#1376)
* gift cards in checkout * complete checkout after trying to add gift card * fix gift cards tests * fix gift cards * update snapshots * fix tests * fix gift cards in checkout * delete created channels
This commit is contained in:
parent
c9678c5167
commit
2407ae6f76
45 changed files with 405 additions and 124 deletions
|
@ -3,6 +3,7 @@ export const GIFT_CARD_DIALOG = {
|
||||||
currencySelectButton: '[id="mui-component-select-balanceCurrency"]',
|
currencySelectButton: '[id="mui-component-select-balanceCurrency"]',
|
||||||
currenciesOptions: '[data-test="selectFieldOption"]',
|
currenciesOptions: '[data-test="selectFieldOption"]',
|
||||||
expirationOptions: {
|
expirationOptions: {
|
||||||
|
setExpiryDateCheckbox: '[name="expirySelected"]',
|
||||||
neverExpireRadioButton: '[value="NEVER_EXPIRE"]',
|
neverExpireRadioButton: '[value="NEVER_EXPIRE"]',
|
||||||
expiryPeriodRadioButton: '[value="EXPIRY_PERIOD"]',
|
expiryPeriodRadioButton: '[value="EXPIRY_PERIOD"]',
|
||||||
expiryDateRadioButton: '[value="EXPIRY_DATE"]',
|
expiryDateRadioButton: '[value="EXPIRY_DATE"]',
|
||||||
|
|
3
cypress/elements/giftCard/giftCardUpdate.js
Normal file
3
cypress/elements/giftCard/giftCardUpdate.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export const GIFT_CARD_UPDATE = {
|
||||||
|
changeActiveStatusButton: '[data-test-id="enable-button"]'
|
||||||
|
};
|
|
@ -1,5 +1,4 @@
|
||||||
export const SITE_SETTINGS_DETAILS = {
|
export const SITE_SETTINGS_DETAILS = {
|
||||||
nameInput: '[name="name"]',
|
nameInput: '[name="name"]',
|
||||||
urlInput: '[name="domain"]',
|
|
||||||
descriptionInput: '[name="description"]'
|
descriptionInput: '[name="description"]'
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,3 +67,6 @@ export const warehouseDetailsUrl = warehouseId =>
|
||||||
|
|
||||||
export const productTypeDetailsUrl = productTypeId =>
|
export const productTypeDetailsUrl = productTypeId =>
|
||||||
`${urlList.productTypes}${productTypeId}`;
|
`${urlList.productTypes}${productTypeId}`;
|
||||||
|
|
||||||
|
export const giftCardDetailsUrl = giftCardId =>
|
||||||
|
`${urlList.giftCards}${giftCardId}`;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
||||||
import { categoryDetailsUrl, urlList } from "../../fixtures/urlList";
|
import { categoryDetailsUrl, urlList } from "../../fixtures/urlList";
|
||||||
import { getCategory } from "../../support/api/requests/Category";
|
import { getCategory } from "../../support/api/requests/Category";
|
||||||
import { deleteCategoriesStartsWith } from "../../support/api/utils/categoryUtils";
|
import { deleteCategoriesStartsWith } from "../../support/api/utils/catalog/categoryUtils";
|
||||||
import * as channelsUtils from "../../support/api/utils/channelsUtils";
|
import * as channelsUtils from "../../support/api/utils/channelsUtils";
|
||||||
import * as productsUtils from "../../support/api/utils/products/productsUtils";
|
import * as productsUtils from "../../support/api/utils/products/productsUtils";
|
||||||
import { deleteShippingStartsWith } from "../../support/api/utils/shippingUtils";
|
import { deleteShippingStartsWith } from "../../support/api/utils/shippingUtils";
|
||||||
|
@ -39,7 +39,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
.getDefaultChannel()
|
.getDefaultChannel()
|
||||||
.then(channel => {
|
.then(channel => {
|
||||||
defaultChannel = channel;
|
defaultChannel = channel;
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(name);
|
productsUtils.createTypeAttributeAndCategoryForProduct({ name });
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
|
|
|
@ -8,8 +8,8 @@ import { createChannel } from "../../support/api/requests/Channels";
|
||||||
import { updateChannelInProduct } from "../../support/api/requests/Product";
|
import { updateChannelInProduct } from "../../support/api/requests/Product";
|
||||||
import { getCollection } from "../../support/api/requests/storeFront/Collections";
|
import { getCollection } from "../../support/api/requests/storeFront/Collections";
|
||||||
import { searchInShop } from "../../support/api/requests/storeFront/Search";
|
import { searchInShop } from "../../support/api/requests/storeFront/Search";
|
||||||
|
import { deleteCollectionsStartsWith } from "../../support/api/utils/catalog/collectionsUtils";
|
||||||
import * as channelsUtils from "../../support/api/utils/channelsUtils";
|
import * as channelsUtils from "../../support/api/utils/channelsUtils";
|
||||||
import { deleteCollectionsStartsWith } from "../../support/api/utils/collectionsUtils";
|
|
||||||
import * as productsUtils from "../../support/api/utils/products/productsUtils";
|
import * as productsUtils from "../../support/api/utils/products/productsUtils";
|
||||||
import { deleteShippingStartsWith } from "../../support/api/utils/shippingUtils";
|
import { deleteShippingStartsWith } from "../../support/api/utils/shippingUtils";
|
||||||
import {
|
import {
|
||||||
|
@ -46,7 +46,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
.getDefaultChannel()
|
.getDefaultChannel()
|
||||||
.then(channel => {
|
.then(channel => {
|
||||||
defaultChannel = channel;
|
defaultChannel = channel;
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(name);
|
productsUtils.createTypeAttributeAndCategoryForProduct({ name });
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
import faker from "faker";
|
import faker from "faker";
|
||||||
|
|
||||||
import { getGiftCardWithTag } from "../../support/api/requests/GiftCard";
|
import { getGiftCardWithTag } from "../../support/api/requests/GiftCard";
|
||||||
|
import { deleteGiftCardsWithTagStartsWith } from "../../support/api/utils/catalog/giftCardUtils";
|
||||||
|
import { addToDate } from "../../support/api/utils/misc";
|
||||||
import filterTests from "../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
import { formatDate } from "../../support/formatData/formatDate";
|
import { formatDate } from "../../support/formatData/formatDate";
|
||||||
import {
|
import {
|
||||||
|
@ -11,8 +13,7 @@ import {
|
||||||
openAndFillUpCreateGiftCardDialog,
|
openAndFillUpCreateGiftCardDialog,
|
||||||
saveGiftCard,
|
saveGiftCard,
|
||||||
setExpiryDate,
|
setExpiryDate,
|
||||||
setExpiryPeriod,
|
setExpiryPeriod
|
||||||
setNeverExpire
|
|
||||||
} from "../../support/pages/catalog/giftCardPage";
|
} from "../../support/pages/catalog/giftCardPage";
|
||||||
|
|
||||||
filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
|
@ -23,6 +24,7 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteGiftCardsWithTagStartsWith(startsWith);
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -39,11 +41,10 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
amount,
|
amount,
|
||||||
currency
|
currency
|
||||||
});
|
});
|
||||||
setNeverExpire();
|
|
||||||
saveGiftCard()
|
saveGiftCard()
|
||||||
.then(createdGiftCardCode => {
|
.then(createdGiftCardCode => {
|
||||||
giftCardCode = createdGiftCardCode;
|
giftCardCode = createdGiftCardCode;
|
||||||
getGiftCardWithTag(name);
|
getGiftCardWithTag(name, true);
|
||||||
})
|
})
|
||||||
.then(giftCard => {
|
.then(giftCard => {
|
||||||
expect(giftCard.code).to.eq(giftCardCode);
|
expect(giftCard.code).to.eq(giftCardCode);
|
||||||
|
@ -55,6 +56,7 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
it("should create gift card with two moths expiry", () => {
|
it("should create gift card with two moths expiry", () => {
|
||||||
const name = `${startsWith}${faker.datatype.number()}`;
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
let giftCardCode;
|
let giftCardCode;
|
||||||
|
const expectedExpiryDate = addToDate(new Date(), 2, "M");
|
||||||
|
|
||||||
openAndFillUpCreateGiftCardDialog({
|
openAndFillUpCreateGiftCardDialog({
|
||||||
note: name,
|
note: name,
|
||||||
|
@ -66,14 +68,13 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
saveGiftCard()
|
saveGiftCard()
|
||||||
.then(createdGiftCardCode => {
|
.then(createdGiftCardCode => {
|
||||||
giftCardCode = createdGiftCardCode;
|
giftCardCode = createdGiftCardCode;
|
||||||
getGiftCardWithTag(name);
|
getGiftCardWithTag(name, true);
|
||||||
})
|
})
|
||||||
.then(giftCard => {
|
.then(giftCard => {
|
||||||
expect(giftCard.code).to.eq(giftCardCode);
|
expect(giftCard.code).to.eq(giftCardCode);
|
||||||
expect(giftCard.initialBalance.amount).to.eq(amount);
|
expect(giftCard.initialBalance.amount).to.eq(amount);
|
||||||
expect(giftCard.initialBalance.currency).to.eq(currency);
|
expect(giftCard.initialBalance.currency).to.eq(currency);
|
||||||
expect(giftCard.expiryPeriod.amount).to.eq(2);
|
expect(giftCard.expiryDate).to.eq(expectedExpiryDate);
|
||||||
expect(giftCard.expiryPeriod.type).to.eq("MONTH");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
saveGiftCard()
|
saveGiftCard()
|
||||||
.then(createdGiftCardCode => {
|
.then(createdGiftCardCode => {
|
||||||
giftCardCode = createdGiftCardCode;
|
giftCardCode = createdGiftCardCode;
|
||||||
getGiftCardWithTag(name);
|
getGiftCardWithTag(name, true);
|
||||||
})
|
})
|
||||||
.then(giftCard => {
|
.then(giftCard => {
|
||||||
expect(giftCard.code).to.eq(giftCardCode);
|
expect(giftCard.code).to.eq(giftCardCode);
|
||||||
|
|
159
cypress/integration/checkout/giftCardsInCheckout.js
Normal file
159
cypress/integration/checkout/giftCardsInCheckout.js
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
// <reference types="cypress" />
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { completeCheckout } from "../../support/api/requests/Checkout";
|
||||||
|
import {
|
||||||
|
createGiftCard,
|
||||||
|
getGiftCardWithId,
|
||||||
|
getGiftCardWithTag,
|
||||||
|
giftCardDeactivate
|
||||||
|
} from "../../support/api/requests/GiftCard";
|
||||||
|
import { deleteGiftCardsWithTagStartsWith } from "../../support/api/utils/catalog/giftCardUtils";
|
||||||
|
import * as channelsUtils from "../../support/api/utils/channelsUtils";
|
||||||
|
import {
|
||||||
|
addPayment,
|
||||||
|
createCheckoutWithVoucher,
|
||||||
|
purchaseProductWithPromoCode
|
||||||
|
} from "../../support/api/utils/ordersUtils";
|
||||||
|
import * as productsUtils from "../../support/api/utils/products/productsUtils";
|
||||||
|
import {
|
||||||
|
createShipping,
|
||||||
|
deleteShippingStartsWith
|
||||||
|
} from "../../support/api/utils/shippingUtils";
|
||||||
|
import filterTests from "../../support/filterTests";
|
||||||
|
import { changeGiftCardActiveStatus } from "../../support/pages/catalog/giftCardPage";
|
||||||
|
|
||||||
|
filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
|
describe("Gift cards in checkout", () => {
|
||||||
|
const startsWith = "GiftCardsCheckout";
|
||||||
|
const productPrice = 50;
|
||||||
|
const shippingPrice = 50;
|
||||||
|
|
||||||
|
let defaultChannel;
|
||||||
|
let productType;
|
||||||
|
let attribute;
|
||||||
|
let category;
|
||||||
|
let shippingMethod;
|
||||||
|
let variants;
|
||||||
|
let address;
|
||||||
|
let dataForCheckout;
|
||||||
|
const giftCardData = {
|
||||||
|
amount: 150,
|
||||||
|
currency: "USD"
|
||||||
|
};
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
channelsUtils.deleteChannelsStartsWith(startsWith);
|
||||||
|
productsUtils.deleteProductsStartsWith(startsWith);
|
||||||
|
deleteShippingStartsWith(startsWith);
|
||||||
|
deleteGiftCardsWithTagStartsWith(startsWith);
|
||||||
|
|
||||||
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
productsUtils
|
||||||
|
.createTypeAttributeAndCategoryForProduct({ name, kind: "GIFT_CARD" })
|
||||||
|
.then(
|
||||||
|
({
|
||||||
|
productType: productTypeResp,
|
||||||
|
attribute: attributeResp,
|
||||||
|
category: categoryResp
|
||||||
|
}) => {
|
||||||
|
productType = productTypeResp;
|
||||||
|
attribute = attributeResp;
|
||||||
|
category = categoryResp;
|
||||||
|
|
||||||
|
channelsUtils.getDefaultChannel();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(addresses => {
|
||||||
|
address = addresses.plAddress;
|
||||||
|
createShipping({
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
name,
|
||||||
|
address,
|
||||||
|
price: shippingPrice
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
({ shippingMethod: shippingMethodResp, warehouse: warehouse }) => {
|
||||||
|
shippingMethod = shippingMethodResp;
|
||||||
|
productsUtils.createProductInChannel({
|
||||||
|
name,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id,
|
||||||
|
price: productPrice
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(({ variantsList: variantsResp }) => {
|
||||||
|
variants = variantsResp;
|
||||||
|
|
||||||
|
dataForCheckout = {
|
||||||
|
address,
|
||||||
|
auth: "token",
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
shippingMethodId: shippingMethod.id,
|
||||||
|
variantsList: variants
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should enable gift card", () => {
|
||||||
|
giftCardData.tag = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
let giftCard;
|
||||||
|
|
||||||
|
createGiftCard(giftCardData)
|
||||||
|
.then(giftCardResp => {
|
||||||
|
giftCard = giftCardResp;
|
||||||
|
giftCardDeactivate(giftCard.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
changeGiftCardActiveStatus(giftCard.id);
|
||||||
|
dataForCheckout.voucherCode = giftCard.code;
|
||||||
|
purchaseProductWithPromoCode(dataForCheckout);
|
||||||
|
})
|
||||||
|
.then(({ order }) => {
|
||||||
|
expect(order.total.gross.amount).to.eq(0);
|
||||||
|
getGiftCardWithTag(giftCardData.tag);
|
||||||
|
})
|
||||||
|
.then(giftCardResp => {
|
||||||
|
expect(giftCardResp.initialBalance.amount).to.eq(giftCardData.amount);
|
||||||
|
expect(giftCardResp.currentBalance.amount).to.eq(
|
||||||
|
giftCardData.amount - productPrice - shippingPrice
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should disable giftCard", () => {
|
||||||
|
giftCardData.tag = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
let giftCard;
|
||||||
|
|
||||||
|
createGiftCard(giftCardData)
|
||||||
|
.then(giftCardResp => {
|
||||||
|
giftCard = giftCardResp;
|
||||||
|
changeGiftCardActiveStatus(giftCard.id);
|
||||||
|
dataForCheckout.voucherCode = giftCard.code;
|
||||||
|
createCheckoutWithVoucher(dataForCheckout);
|
||||||
|
})
|
||||||
|
.then(({ addPromoCodeResp, checkout }) => {
|
||||||
|
expect(addPromoCodeResp.checkoutErrors[0].field).to.eq("promoCode");
|
||||||
|
addPayment(checkout.id);
|
||||||
|
completeCheckout(checkout.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
getGiftCardWithId(giftCard.id);
|
||||||
|
})
|
||||||
|
.then(giftCardResp => {
|
||||||
|
expect(giftCardResp.currentBalance.amount).to.eq(giftCardData.amount);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -9,6 +9,7 @@ import {
|
||||||
addShippingMethod,
|
addShippingMethod,
|
||||||
createCheckout
|
createCheckout
|
||||||
} from "../../support/api/requests/Checkout";
|
} from "../../support/api/requests/Checkout";
|
||||||
|
import { deleteChannelsStartsWith } from "../../support/api/utils/channelsUtils";
|
||||||
import {
|
import {
|
||||||
createProductInChannel,
|
createProductInChannel,
|
||||||
createTypeAttributeAndCategoryForProduct,
|
createTypeAttributeAndCategoryForProduct,
|
||||||
|
@ -38,6 +39,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
|
|
||||||
deleteProductsStartsWith(startsWith);
|
deleteProductsStartsWith(startsWith);
|
||||||
deleteShippingStartsWith(startsWith);
|
deleteShippingStartsWith(startsWith);
|
||||||
|
deleteChannelsStartsWith(startsWith);
|
||||||
|
|
||||||
createChannel({
|
createChannel({
|
||||||
name
|
name
|
||||||
|
@ -62,7 +64,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
}) => {
|
}) => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
shippingMethod = shippingMethodResp;
|
shippingMethod = shippingMethodResp;
|
||||||
createTypeAttributeAndCategoryForProduct(name);
|
createTypeAttributeAndCategoryForProduct({ name });
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
|
|
@ -58,7 +58,7 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
|
||||||
}) => {
|
}) => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
shippingMethod = shippingMethodResp;
|
shippingMethod = shippingMethodResp;
|
||||||
createTypeAttributeAndCategoryForProduct(name);
|
createTypeAttributeAndCategoryForProduct({ name });
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
|
|
@ -45,7 +45,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
})
|
})
|
||||||
.then(({ warehouse: warehouseResp }) => {
|
.then(({ warehouse: warehouseResp }) => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
createTypeAttributeAndCategoryForProduct(name);
|
createTypeAttributeAndCategoryForProduct({ name });
|
||||||
})
|
})
|
||||||
.then(({ attribute, productType, category }) => {
|
.then(({ attribute, productType, category }) => {
|
||||||
createProductInChannel({
|
createProductInChannel({
|
||||||
|
|
|
@ -28,18 +28,19 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
deleteProductsStartsWith(startsWith);
|
deleteProductsStartsWith(startsWith);
|
||||||
createTypeAttributeAndCategoryForProduct(startsWith, [startsWith]).then(
|
createTypeAttributeAndCategoryForProduct({
|
||||||
({ attribute: attributeResp, category, productType }) => {
|
name: startsWith,
|
||||||
attribute = attributeResp;
|
attributeValues: [startsWith]
|
||||||
createProduct({
|
}).then(({ attribute: attributeResp, category, productType }) => {
|
||||||
attributeId: attribute.id,
|
attribute = attributeResp;
|
||||||
attributeValue: startsWith,
|
createProduct({
|
||||||
categoryId: category.id,
|
attributeId: attribute.id,
|
||||||
productTypeId: productType.id,
|
attributeValue: startsWith,
|
||||||
name: startsWith
|
categoryId: category.id,
|
||||||
});
|
productTypeId: productType.id,
|
||||||
}
|
name: startsWith
|
||||||
);
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should use attribute as filter", () => {
|
it("should use attribute as filter", () => {
|
||||||
|
|
|
@ -79,7 +79,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
|
|
||||||
it("should not be possible to create checkout with inactive channel", () => {
|
it("should not be possible to create checkout with inactive channel", () => {
|
||||||
const randomChannel = `${channelStartsWith}${faker.datatype.number()}`;
|
const randomChannel = `${channelStartsWith}${faker.datatype.number()}`;
|
||||||
createTypeAttributeAndCategoryForProduct(randomChannel)
|
createTypeAttributeAndCategoryForProduct({ name: randomChannel })
|
||||||
.then(({ productType, attribute, category }) => {
|
.then(({ productType, attribute, category }) => {
|
||||||
createProductInChannel({
|
createProductInChannel({
|
||||||
name: randomChannel,
|
name: randomChannel,
|
||||||
|
@ -118,7 +118,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
})
|
})
|
||||||
.then(channelResp => {
|
.then(channelResp => {
|
||||||
channel = channelResp;
|
channel = channelResp;
|
||||||
createTypeAttributeAndCategoryForProduct(randomChannel);
|
createTypeAttributeAndCategoryForProduct({ name: randomChannel });
|
||||||
})
|
})
|
||||||
.then(({ productType, attribute, category }) => {
|
.then(({ productType, attribute, category }) => {
|
||||||
createProductInChannel({
|
createProductInChannel({
|
||||||
|
|
|
@ -74,7 +74,7 @@ filterTests({ definedTags: ["stagedOnly"] }, () => {
|
||||||
shippingMethod = shippingMethodResp;
|
shippingMethod = shippingMethodResp;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
createTypeAttributeAndCategoryForProduct(name)
|
createTypeAttributeAndCategoryForProduct({ name })
|
||||||
.then(({ productType, attribute, category }) => {
|
.then(({ productType, attribute, category }) => {
|
||||||
createProductInChannel({
|
createProductInChannel({
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -13,7 +13,10 @@ import {
|
||||||
deleteCustomersStartsWith,
|
deleteCustomersStartsWith,
|
||||||
requestPasswordReset
|
requestPasswordReset
|
||||||
} from "../../../support/api/requests/Customer";
|
} from "../../../support/api/requests/Customer";
|
||||||
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
import {
|
||||||
|
deleteChannelsStartsWith,
|
||||||
|
getDefaultChannel
|
||||||
|
} from "../../../support/api/utils/channelsUtils";
|
||||||
import { getMailsForUser } from "../../../support/api/utils/users";
|
import { getMailsForUser } from "../../../support/api/utils/users";
|
||||||
import filterTests from "../../../support/filterTests";
|
import filterTests from "../../../support/filterTests";
|
||||||
|
|
||||||
|
@ -26,6 +29,7 @@ filterTests({ definedTags: ["stagedOnly"], version: "3.1.1" }, () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
deleteCustomersStartsWith(startsWith);
|
deleteCustomersStartsWith(startsWith);
|
||||||
|
deleteChannelsStartsWith(startsWith);
|
||||||
createChannel({ name: randomName });
|
createChannel({ name: randomName });
|
||||||
getDefaultChannel().then(channel => (defaultChannel = channel));
|
getDefaultChannel().then(channel => (defaultChannel = channel));
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,7 +46,9 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
})
|
})
|
||||||
.then(warehouseResp => {
|
.then(warehouseResp => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(startsWith);
|
productsUtils.createTypeAttributeAndCategoryForProduct({
|
||||||
|
name: startsWith
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
|
|
|
@ -66,7 +66,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
})
|
})
|
||||||
.then(warehouseResp => {
|
.then(warehouseResp => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
createTypeAttributeAndCategoryForProduct(name);
|
createTypeAttributeAndCategoryForProduct({ name });
|
||||||
})
|
})
|
||||||
.then(({ attribute, productType, category }) => {
|
.then(({ attribute, productType, category }) => {
|
||||||
createProductInChannel({
|
createProductInChannel({
|
||||||
|
|
|
@ -59,7 +59,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
})
|
})
|
||||||
.then(warehouseResp => {
|
.then(warehouseResp => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
createTypeAttributeAndCategoryForProduct(name);
|
createTypeAttributeAndCategoryForProduct({ name });
|
||||||
})
|
})
|
||||||
.then(({ attribute, productType, category }) => {
|
.then(({ attribute, productType, category }) => {
|
||||||
createProductInChannel({
|
createProductInChannel({
|
||||||
|
|
|
@ -44,19 +44,6 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should change site url", () => {
|
|
||||||
const url = `http://cypress${faker.datatype.number()}.saleor.com`;
|
|
||||||
|
|
||||||
cy.get(SITE_SETTINGS_DETAILS.urlInput)
|
|
||||||
.clearAndType(url)
|
|
||||||
.get(BUTTON_SELECTORS.confirm)
|
|
||||||
.click()
|
|
||||||
.confirmationMessageShouldDisappear();
|
|
||||||
getShopInfo().then(shopInfo => {
|
|
||||||
expect(shopInfo.domain.host).to.eq(url);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should change store description", () => {
|
it("should change store description", () => {
|
||||||
const description = faker.lorem.sentence();
|
const description = faker.lorem.sentence();
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
createCategory,
|
createCategory,
|
||||||
getCategory
|
getCategory
|
||||||
} from "../../support/api/requests/Category";
|
} from "../../support/api/requests/Category";
|
||||||
import { deleteCategoriesStartsWith } from "../../support/api/utils/categoryUtils";
|
import { deleteCategoriesStartsWith } from "../../support/api/utils/catalog/categoryUtils";
|
||||||
import filterTests from "../../support/filterTests";
|
import filterTests from "../../support/filterTests";
|
||||||
|
|
||||||
filterTests({ definedTags: ["all"], version: "3.1.1" }, () => {
|
filterTests({ definedTags: ["all"], version: "3.1.1" }, () => {
|
||||||
|
|
|
@ -40,7 +40,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
|
|
||||||
const name = `${startsWith}${faker.datatype.number()}`;
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
productsUtils
|
productsUtils
|
||||||
.createTypeAttributeAndCategoryForProduct(name)
|
.createTypeAttributeAndCategoryForProduct({ name })
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
productType: productTypeResp,
|
productType: productTypeResp,
|
||||||
|
|
|
@ -45,7 +45,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
const name = `${startsWith}${faker.datatype.number()}`;
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
productsUtils
|
productsUtils
|
||||||
.createTypeAttributeAndCategoryForProduct(name)
|
.createTypeAttributeAndCategoryForProduct({ name })
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
productType: productTypeResp,
|
productType: productTypeResp,
|
||||||
|
@ -143,10 +143,12 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
discountOption: discountOptions.PERCENTAGE,
|
discountOption: discountOptions.PERCENTAGE,
|
||||||
channelName: createdChannel.name
|
channelName: createdChannel.name
|
||||||
});
|
});
|
||||||
createCheckoutForCreatedVoucher(randomName).then(resp => {
|
createCheckoutForCreatedVoucher(randomName).then(
|
||||||
const errorField = resp.checkoutErrors[0].field;
|
({ addPromoCodeResp }) => {
|
||||||
expect(errorField).to.be.eq("promoCode");
|
const errorField = addPromoCodeResp.checkoutErrors[0].field;
|
||||||
});
|
expect(errorField).to.be.eq("promoCode");
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
function createCheckoutForCreatedVoucher(voucherCode) {
|
function createCheckoutForCreatedVoucher(voucherCode) {
|
||||||
|
@ -177,7 +179,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
channelName: defaultChannel.name
|
channelName: defaultChannel.name
|
||||||
});
|
});
|
||||||
return createCheckoutForCreatedVoucher(voucherCode).its(
|
return createCheckoutForCreatedVoucher(voucherCode).its(
|
||||||
"checkout.totalPrice.gross.amount"
|
"addPromoCodeResp.checkout.totalPrice.gross.amount"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -72,7 +72,9 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
|
||||||
}) => {
|
}) => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
shippingMethod = shippingMethodResp;
|
shippingMethod = shippingMethodResp;
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(randomName);
|
productsUtils.createTypeAttributeAndCategoryForProduct({
|
||||||
|
name: randomName
|
||||||
|
});
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
|
|
@ -28,7 +28,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
getDefaultChannel()
|
getDefaultChannel()
|
||||||
.then(channelResp => {
|
.then(channelResp => {
|
||||||
channel = channelResp;
|
channel = channelResp;
|
||||||
createTypeAttributeAndCategoryForProduct(name);
|
createTypeAttributeAndCategoryForProduct({ name });
|
||||||
})
|
})
|
||||||
.then(({ attribute, category, productType }) => {
|
.then(({ attribute, category, productType }) => {
|
||||||
createProductInChannel({
|
createProductInChannel({
|
||||||
|
|
|
@ -60,7 +60,9 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
})
|
})
|
||||||
.then(({ warehouse: warehouseResp }) => {
|
.then(({ warehouse: warehouseResp }) => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(randomName);
|
productsUtils.createTypeAttributeAndCategoryForProduct({
|
||||||
|
name: randomName
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
|
|
|
@ -82,7 +82,9 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
}) => {
|
}) => {
|
||||||
shippingMethod = shippingMethodResp;
|
shippingMethod = shippingMethodResp;
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(randomName);
|
productsUtils.createTypeAttributeAndCategoryForProduct({
|
||||||
|
name: randomName
|
||||||
|
});
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
|
|
@ -45,7 +45,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
productsUtils
|
productsUtils
|
||||||
.createTypeAttributeAndCategoryForProduct(name)
|
.createTypeAttributeAndCategoryForProduct({ name })
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
attribute: attributeResp,
|
attribute: attributeResp,
|
||||||
|
|
|
@ -25,7 +25,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
productsUtils.deleteProductsStartsWith(startsWith);
|
productsUtils.deleteProductsStartsWith(startsWith);
|
||||||
productsUtils
|
productsUtils
|
||||||
.createTypeAttributeAndCategoryForProduct(name)
|
.createTypeAttributeAndCategoryForProduct({ name })
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
attribute: attributeResp,
|
attribute: attributeResp,
|
||||||
|
|
|
@ -24,7 +24,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
productsUtils.deleteProductsStartsWith(startsWith);
|
productsUtils.deleteProductsStartsWith(startsWith);
|
||||||
productsUtils
|
productsUtils
|
||||||
.createTypeAttributeAndCategoryForProduct(name)
|
.createTypeAttributeAndCategoryForProduct({ name })
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
attribute: attributeResp,
|
attribute: attributeResp,
|
||||||
|
|
|
@ -41,7 +41,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
deleteShippingStartsWith(startsWith);
|
deleteShippingStartsWith(startsWith);
|
||||||
deleteProductsStartsWith(startsWith);
|
deleteProductsStartsWith(startsWith);
|
||||||
createTypeAttributeAndCategoryForProduct(name).then(
|
createTypeAttributeAndCategoryForProduct({ name }).then(
|
||||||
({
|
({
|
||||||
attribute: attributeResp,
|
attribute: attributeResp,
|
||||||
productType: productTypeResp,
|
productType: productTypeResp,
|
||||||
|
|
|
@ -63,7 +63,7 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
|
||||||
.then(resp => (newChannel = resp));
|
.then(resp => (newChannel = resp));
|
||||||
|
|
||||||
productUtils
|
productUtils
|
||||||
.createTypeAttributeAndCategoryForProduct(name, attributeValues)
|
.createTypeAttributeAndCategoryForProduct({ name, attributeValues })
|
||||||
.then(
|
.then(
|
||||||
({
|
({
|
||||||
attribute: attributeResp,
|
attribute: attributeResp,
|
||||||
|
|
|
@ -10,8 +10,8 @@ import { ONE_PERMISSION_USERS } from "../../fixtures/users";
|
||||||
import { createCategory } from "../../support/api/requests/Category";
|
import { createCategory } from "../../support/api/requests/Category";
|
||||||
import { createCollection } from "../../support/api/requests/Collections";
|
import { createCollection } from "../../support/api/requests/Collections";
|
||||||
import { getProductDetails } from "../../support/api/requests/storeFront/ProductDetails";
|
import { getProductDetails } from "../../support/api/requests/storeFront/ProductDetails";
|
||||||
|
import { deleteCollectionsStartsWith } from "../../support/api/utils/catalog/collectionsUtils";
|
||||||
import { getDefaultChannel } from "../../support/api/utils/channelsUtils";
|
import { getDefaultChannel } from "../../support/api/utils/channelsUtils";
|
||||||
import { deleteCollectionsStartsWith } from "../../support/api/utils/collectionsUtils";
|
|
||||||
import { expectCorrectProductInformation } from "../../support/api/utils/products/checkProductInfo";
|
import { expectCorrectProductInformation } from "../../support/api/utils/products/checkProductInfo";
|
||||||
import {
|
import {
|
||||||
createProductInChannel,
|
createProductInChannel,
|
||||||
|
@ -44,7 +44,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
||||||
})
|
})
|
||||||
.then(collectionResp => {
|
.then(collectionResp => {
|
||||||
collection = collectionResp;
|
collection = collectionResp;
|
||||||
createTypeAttributeAndCategoryForProduct(name);
|
createTypeAttributeAndCategoryForProduct({ name });
|
||||||
})
|
})
|
||||||
.then(({ attribute: attributeResp, category, productType }) => {
|
.then(({ attribute: attributeResp, category, productType }) => {
|
||||||
attribute = attributeResp;
|
attribute = attributeResp;
|
||||||
|
|
|
@ -101,6 +101,12 @@ export function completeCheckout(checkoutId, paymentData) {
|
||||||
checkoutComplete(checkoutId:"${checkoutId}" ${paymentDataLine}){
|
checkoutComplete(checkoutId:"${checkoutId}" ${paymentDataLine}){
|
||||||
order{
|
order{
|
||||||
id
|
id
|
||||||
|
paymentStatus
|
||||||
|
total{
|
||||||
|
gross{
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
confirmationNeeded
|
confirmationNeeded
|
||||||
confirmationData
|
confirmationData
|
||||||
|
@ -123,6 +129,7 @@ export function addVoucher(checkoutId, voucherCode) {
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
checkout{
|
checkout{
|
||||||
|
id
|
||||||
totalPrice{
|
totalPrice{
|
||||||
gross{
|
gross{
|
||||||
amount
|
amount
|
||||||
|
|
|
@ -1,23 +1,26 @@
|
||||||
export function getGiftCardWithTag(tag) {
|
import { getValueWithDefault } from "./utils/Utils";
|
||||||
return getGiftCardsWithTag(1, tag)
|
|
||||||
|
export function getGiftCardWithTag(tag, withCode = false) {
|
||||||
|
return getGiftCardsWithTag(1, tag, withCode)
|
||||||
.its("body.data.giftCards.edges")
|
.its("body.data.giftCards.edges")
|
||||||
.its(0)
|
.its(0)
|
||||||
.its("node");
|
.its("node");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGiftCardsWithTag(first, tag) {
|
export function getGiftCardsWithTag(first, tag, withCode = false) {
|
||||||
|
const codeLine = getValueWithDefault(withCode, `code`);
|
||||||
const query = `query{
|
const query = `query{
|
||||||
giftCards(first: ${first}, filter: { tag: "${tag}"}){
|
giftCards(first: ${first}, filter: { tag: "${tag}"}){
|
||||||
edges{
|
edges{
|
||||||
node{
|
node{
|
||||||
|
${codeLine}
|
||||||
|
displayCode
|
||||||
id
|
id
|
||||||
code
|
|
||||||
isActive
|
isActive
|
||||||
expiryType
|
|
||||||
expiryDate
|
expiryDate
|
||||||
expiryPeriod{
|
currentBalance{
|
||||||
|
currency
|
||||||
amount
|
amount
|
||||||
type
|
|
||||||
}
|
}
|
||||||
initialBalance{
|
initialBalance{
|
||||||
currency
|
currency
|
||||||
|
@ -29,3 +32,66 @@ export function getGiftCardsWithTag(first, tag) {
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(query);
|
return cy.sendRequestWithQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getGiftCardWithId(id) {
|
||||||
|
const query = `query{
|
||||||
|
giftCard(id:"${id}"){
|
||||||
|
isActive
|
||||||
|
currentBalance{
|
||||||
|
currency
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(query).its("body.data.giftCard");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createGiftCard({ tag, currency, amount }) {
|
||||||
|
const mutation = `mutation{
|
||||||
|
giftCardCreate(input:{
|
||||||
|
tag:"${tag}"
|
||||||
|
isActive: true
|
||||||
|
balance: {
|
||||||
|
currency: "${currency}"
|
||||||
|
amount: ${amount}
|
||||||
|
}
|
||||||
|
}){
|
||||||
|
errors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
giftCard{
|
||||||
|
code
|
||||||
|
id
|
||||||
|
isActive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy
|
||||||
|
.sendRequestWithQuery(mutation)
|
||||||
|
.its("body.data.giftCardCreate.giftCard");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function giftCardDeactivate(giftCardId) {
|
||||||
|
const mutation = `mutation{
|
||||||
|
giftCardDeactivate(id:"${giftCardId}"){
|
||||||
|
errors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteGiftCard(giftCardId) {
|
||||||
|
const mutation = `mutation{
|
||||||
|
giftCardDelete(id:"${giftCardId}"){
|
||||||
|
errors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation);
|
||||||
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export function createTypeProduct({
|
||||||
isShippingRequired:${shippable}
|
isShippingRequired:${shippable}
|
||||||
${kindLines}
|
${kindLines}
|
||||||
}){
|
}){
|
||||||
productErrors{
|
errors{
|
||||||
field
|
field
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { deleteCategory, getCategories } from "../requests/Category";
|
import { deleteCategory, getCategories } from "../../requests/Category";
|
||||||
|
|
||||||
export function deleteCategoriesStartsWith(startsWith) {
|
export function deleteCategoriesStartsWith(startsWith) {
|
||||||
cy.deleteElementsStartsWith(deleteCategory, getCategories, startsWith);
|
cy.deleteElementsStartsWith(deleteCategory, getCategories, startsWith);
|
|
@ -1,4 +1,4 @@
|
||||||
import { deleteCollection, getCollections } from "../requests/Collections";
|
import { deleteCollection, getCollections } from "../../requests/Collections";
|
||||||
|
|
||||||
export function deleteCollectionsStartsWith(startsWith) {
|
export function deleteCollectionsStartsWith(startsWith) {
|
||||||
cy.deleteElementsStartsWith(deleteCollection, getCollections, startsWith);
|
cy.deleteElementsStartsWith(deleteCollection, getCollections, startsWith);
|
12
cypress/support/api/utils/catalog/giftCardUtils.js
Normal file
12
cypress/support/api/utils/catalog/giftCardUtils.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { deleteGiftCard, getGiftCardsWithTag } from "../../requests/GiftCard";
|
||||||
|
|
||||||
|
export function deleteGiftCardsWithTagStartsWith(tag) {
|
||||||
|
getGiftCardsWithTag(100, tag).then(resp => {
|
||||||
|
const giftCardArray = resp.body.data.giftCards;
|
||||||
|
if (giftCardArray) {
|
||||||
|
giftCardArray.edges.forEach(element => {
|
||||||
|
deleteGiftCard(element.node.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
|
||||||
|
const format = "YYYY-MM-DD";
|
||||||
|
|
||||||
export function getDatePeriod(days) {
|
export function getDatePeriod(days) {
|
||||||
if (days < 1) {
|
if (days < 1) {
|
||||||
return {};
|
return {};
|
||||||
|
@ -7,10 +9,15 @@ export function getDatePeriod(days) {
|
||||||
|
|
||||||
const end = moment().startOf("day");
|
const end = moment().startOf("day");
|
||||||
const start = end.subtract(days - 1);
|
const start = end.subtract(days - 1);
|
||||||
const format = "YYYY-MM-DD";
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
gte: start.format(format),
|
gte: start.format(format),
|
||||||
lte: end.format(format)
|
lte: end.format(format)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addToDate(date, amount, periodType) {
|
||||||
|
const currentDate = moment(date);
|
||||||
|
const futureDate = moment(currentDate).add(amount, periodType);
|
||||||
|
return futureDate.format(format);
|
||||||
|
}
|
||||||
|
|
|
@ -41,7 +41,14 @@ export function createCheckoutWithVoucher({
|
||||||
}) {
|
}) {
|
||||||
let checkout;
|
let checkout;
|
||||||
return checkoutRequest
|
return checkoutRequest
|
||||||
.createCheckout({ channelSlug, email, variantsList, address, auth })
|
.createCheckout({
|
||||||
|
channelSlug,
|
||||||
|
email,
|
||||||
|
variantsList,
|
||||||
|
address,
|
||||||
|
billingAddress: address,
|
||||||
|
auth
|
||||||
|
})
|
||||||
.then(({ checkout: checkoutResp }) => {
|
.then(({ checkout: checkoutResp }) => {
|
||||||
checkout = checkoutResp;
|
checkout = checkoutResp;
|
||||||
checkoutRequest.addShippingMethod(checkout.id, shippingMethodId);
|
checkoutRequest.addShippingMethod(checkout.id, shippingMethodId);
|
||||||
|
@ -49,7 +56,38 @@ export function createCheckoutWithVoucher({
|
||||||
.then(() => {
|
.then(() => {
|
||||||
checkoutRequest.addVoucher(checkout.id, voucherCode);
|
checkoutRequest.addVoucher(checkout.id, voucherCode);
|
||||||
})
|
})
|
||||||
.its("body.data.checkoutAddPromoCode");
|
.then(resp => ({
|
||||||
|
addPromoCodeResp: resp.body.data.checkoutAddPromoCode,
|
||||||
|
checkout
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function purchaseProductWithPromoCode({
|
||||||
|
channelSlug,
|
||||||
|
email = "email@example.com",
|
||||||
|
variantsList,
|
||||||
|
address,
|
||||||
|
shippingMethodId,
|
||||||
|
voucherCode,
|
||||||
|
auth
|
||||||
|
}) {
|
||||||
|
let checkout;
|
||||||
|
|
||||||
|
return createCheckoutWithVoucher({
|
||||||
|
channelSlug,
|
||||||
|
email,
|
||||||
|
variantsList,
|
||||||
|
address,
|
||||||
|
shippingMethodId,
|
||||||
|
voucherCode,
|
||||||
|
auth
|
||||||
|
})
|
||||||
|
.then(({ checkout: checkoutResp }) => {
|
||||||
|
checkout = checkoutResp;
|
||||||
|
addPayment(checkout.id);
|
||||||
|
})
|
||||||
|
.then(() => checkoutRequest.completeCheckout(checkout.id))
|
||||||
|
.then(({ order }) => ({ checkout, order }));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createReadyToFulfillOrder({
|
export function createReadyToFulfillOrder({
|
||||||
|
|
|
@ -65,10 +65,11 @@ export function createProductInChannel({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTypeAttributeAndCategoryForProduct(
|
export function createTypeAttributeAndCategoryForProduct({
|
||||||
name,
|
name,
|
||||||
attributeValues
|
attributeValues,
|
||||||
) {
|
kind = "NORMAL"
|
||||||
|
}) {
|
||||||
let attribute;
|
let attribute;
|
||||||
let productType;
|
let productType;
|
||||||
let category;
|
let category;
|
||||||
|
@ -76,7 +77,7 @@ export function createTypeAttributeAndCategoryForProduct(
|
||||||
.createAttribute({ name, attributeValues })
|
.createAttribute({ name, attributeValues })
|
||||||
.then(attributeResp => {
|
.then(attributeResp => {
|
||||||
attribute = attributeResp;
|
attribute = attributeResp;
|
||||||
createTypeProduct({ name, attributeId: attributeResp.id });
|
createTypeProduct({ name, attributeId: attributeResp.id, kind });
|
||||||
})
|
})
|
||||||
.then(productTypeResp => {
|
.then(productTypeResp => {
|
||||||
productType = productTypeResp;
|
productType = productTypeResp;
|
||||||
|
|
|
@ -10,7 +10,10 @@ Cypress.Commands.add("clearAndType", { prevSubject: true }, (subject, text) => {
|
||||||
|
|
||||||
Cypress.Commands.add("waitForRequestAndCheckIfNoErrors", alias => {
|
Cypress.Commands.add("waitForRequestAndCheckIfNoErrors", alias => {
|
||||||
cy.wait(alias).then(resp => {
|
cy.wait(alias).then(resp => {
|
||||||
expect(resp.response.body.errors).to.be.undefined;
|
expect(
|
||||||
|
resp.response.body.errors,
|
||||||
|
`There are errors in ${alias} operation in graphql response`
|
||||||
|
).to.be.undefined;
|
||||||
return resp;
|
return resp;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { GIFT_CARD_DIALOG } from "../../../elements/giftCard/giftCardDialog";
|
import { GIFT_CARD_DIALOG } from "../../../elements/giftCard/giftCardDialog";
|
||||||
import { GIFT_CARD_LIST } from "../../../elements/giftCard/giftCardList";
|
import { GIFT_CARD_LIST } from "../../../elements/giftCard/giftCardList";
|
||||||
|
import { GIFT_CARD_UPDATE } from "../../../elements/giftCard/giftCardUpdate";
|
||||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||||
import { urlList } from "../../../fixtures/urlList";
|
import { giftCardDetailsUrl, urlList } from "../../../fixtures/urlList";
|
||||||
|
|
||||||
export function openAndFillUpCreateGiftCardDialog({
|
export function openAndFillUpCreateGiftCardDialog({
|
||||||
note,
|
note,
|
||||||
|
@ -36,16 +37,14 @@ export function saveGiftCard() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setNeverExpire() {
|
|
||||||
cy.get(GIFT_CARD_DIALOG.expirationOptions.neverExpireRadioButton).click();
|
|
||||||
}
|
|
||||||
|
|
||||||
export const expiryPeriods = {
|
export const expiryPeriods = {
|
||||||
MONTH: GIFT_CARD_DIALOG.expirationOptions.expiryPeriodMonthType
|
MONTH: GIFT_CARD_DIALOG.expirationOptions.expiryPeriodMonthType
|
||||||
};
|
};
|
||||||
|
|
||||||
export function setExpiryPeriod(amount, period) {
|
export function setExpiryPeriod(amount, period) {
|
||||||
cy.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodRadioButton)
|
cy.get(GIFT_CARD_DIALOG.expirationOptions.setExpiryDateCheckbox)
|
||||||
|
.click()
|
||||||
|
.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodRadioButton)
|
||||||
.click()
|
.click()
|
||||||
.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodAmount)
|
.get(GIFT_CARD_DIALOG.expirationOptions.expiryPeriodAmount)
|
||||||
.clearAndType(amount)
|
.clearAndType(amount)
|
||||||
|
@ -56,8 +55,17 @@ export function setExpiryPeriod(amount, period) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setExpiryDate(date) {
|
export function setExpiryDate(date) {
|
||||||
cy.get(GIFT_CARD_DIALOG.expirationOptions.expiryDateRadioButton)
|
cy.get(GIFT_CARD_DIALOG.expirationOptions.setExpiryDateCheckbox)
|
||||||
|
.click()
|
||||||
|
.get(GIFT_CARD_DIALOG.expirationOptions.expiryDateRadioButton)
|
||||||
.click()
|
.click()
|
||||||
.get(GIFT_CARD_DIALOG.expirationOptions.expiryDateInput)
|
.get(GIFT_CARD_DIALOG.expirationOptions.expiryDateInput)
|
||||||
.type(date);
|
.type(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function changeGiftCardActiveStatus(giftCardId) {
|
||||||
|
cy.visit(giftCardDetailsUrl(giftCardId))
|
||||||
|
.get(GIFT_CARD_UPDATE.changeActiveStatusButton)
|
||||||
|
.click()
|
||||||
|
.confirmationMessageShouldDisappear();
|
||||||
|
}
|
||||||
|
|
32
package-lock.json
generated
32
package-lock.json
generated
|
@ -6602,15 +6602,6 @@
|
||||||
"@types/react": "*"
|
"@types/react": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/react-responsive": {
|
|
||||||
"version": "3.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/react-responsive/-/react-responsive-3.0.3.tgz",
|
|
||||||
"integrity": "sha512-paTAvXIFgv/jG60d7WSV0+yWCjqJ05cG+KOV48SiqYGjGi9kFdss9QnVTTLnFJmbUwWnoM+VD1Iyay1JBy/HPQ==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"@types/react": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@types/react-router": {
|
"@types/react-router": {
|
||||||
"version": "5.1.13",
|
"version": "5.1.13",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react-router/-/react-router-5.1.13.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react-router/-/react-router-5.1.13.tgz",
|
||||||
|
@ -12132,11 +12123,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"css-mediaquery": {
|
|
||||||
"version": "0.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/css-mediaquery/-/css-mediaquery-0.1.2.tgz",
|
|
||||||
"integrity": "sha1-aiw3NEkoYYYxxUvTPO3TAdoYvqA="
|
|
||||||
},
|
|
||||||
"css-select": {
|
"css-select": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/css-select/-/css-select-2.1.0.tgz",
|
||||||
|
@ -21202,14 +21188,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"matchmediaquery": {
|
|
||||||
"version": "0.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/matchmediaquery/-/matchmediaquery-0.3.1.tgz",
|
|
||||||
"integrity": "sha512-Hlk20WQHRIm9EE9luN1kjRjYXAQToHOIAHPJn9buxBwuhfTHoKUcX+lXBbxc85DVQfXYbEQ4HcwQdd128E3qHQ==",
|
|
||||||
"requires": {
|
|
||||||
"css-mediaquery": "^0.1.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"math-random": {
|
"math-random": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.4.tgz",
|
||||||
|
@ -24720,16 +24698,6 @@
|
||||||
"react-popper": "^1.3.7"
|
"react-popper": "^1.3.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-responsive": {
|
|
||||||
"version": "7.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-responsive/-/react-responsive-7.0.0.tgz",
|
|
||||||
"integrity": "sha512-RukaKD+UI/MIR+P8eUgVGURfiCafRvvcVnq41scT0eEQWHwDGliH/OAlrwIr1oyz8aKLGroZa+U8mTZV5ihPfA==",
|
|
||||||
"requires": {
|
|
||||||
"hyphenate-style-name": "^1.0.0",
|
|
||||||
"matchmediaquery": "^0.3.0",
|
|
||||||
"prop-types": "^15.6.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"react-router": {
|
"react-router": {
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz",
|
||||||
|
|
|
@ -86,6 +86,7 @@ const GiftCardEnableDisableSection: React.FC = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfirmButton
|
<ConfirmButton
|
||||||
|
data-test-id="enable-button"
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
transitionState={currentOpts?.status}
|
transitionState={currentOpts?.status}
|
||||||
labels={{
|
labels={{
|
||||||
|
|
Loading…
Reference in a new issue