saleor-dashboard/cypress/e2e/catalog/giftCards/purchaseGiftCard.js
poulch d5ed6fb202
Feature flags (#2961)
* [Feature Flags] Abstraction over flags provider (#2928)

* Remove useFlag hook

* [Feature Flags] GraphQL build multiple schemas (#2937)

* Build script

* Refactor build types script

* Remove old codegen.yml

* Clean feature flags in script

* Refactor schema path

* Restore useAuthProvider

* Update configuration file

* encapsulate details for feature flags provider

* Add proper env to flagsmith provider

* Remove flagsmith mocks

* Vite config define global variables

* Render flagmisth provider only when is used

* Keep name service agnostic

* Test with mocked flagsmith

* Use global FLAGS varaible for env flags

* Fix type issue with FLAGS

* Fix build issue

* Remove duplicate translations

* Fix typo

* Prepare for QA tests

* Remove test feature flag
2023-01-16 14:55:38 +01:00

115 lines
3.2 KiB
JavaScript

/// <reference types="cypress" />
import faker from "faker";
import { deleteGiftCardsWithTagStartsWith } from "../../../support/api/utils/catalog/giftCardUtils";
import * as channelsUtils from "../../../support/api/utils/channelsUtils";
import { createWaitingForCaptureOrder } from "../../../support/api/utils/ordersUtils";
import * as productsUtils from "../../../support/api/utils/products/productsUtils";
import {
createShipping,
deleteShippingStartsWith,
} from "../../../support/api/utils/shippingUtils";
describe("As a customer I should be able to purchase gift card as a product", () => {
const startsWith = "GiftCardsCheckout";
const productPrice = 50;
const shippingPrice = 50;
const email = "example@example.com";
let defaultChannel;
let productType;
let attribute;
let category;
let shippingMethod;
let variants;
let address;
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;
cy.checkIfDataAreNotNull({
defaultChannel,
productType,
attribute,
category,
shippingMethod,
variants,
address,
});
});
});
beforeEach(() => {
cy.clearSessionData().loginUserViaRequest();
});
it(
"should be able to purchase gift card as a product. TC: SALEOR_1008",
{ tags: ["@giftCard", "@allEnv", "@stable"] },
() => {
giftCardData.tag = `${startsWith}${faker.datatype.number()}`;
createWaitingForCaptureOrder({
address,
channelSlug: defaultChannel.slug,
email,
shippingMethodName: shippingMethod.name,
variantsList: variants,
}).then(({ order }) => {
expect(order.id).to.be.ok;
});
},
);
});