
* [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
132 lines
4 KiB
JavaScript
132 lines
4 KiB
JavaScript
/// <reference types="cypress"/>
|
|
/// <reference types="../../support"/>
|
|
|
|
import faker from "faker";
|
|
|
|
import {
|
|
addProductsToCheckout,
|
|
createCheckout,
|
|
} from "../../support/api/requests/Checkout";
|
|
import { getVariants } from "../../support/api/requests/Product";
|
|
import { createWaitingForCaptureOrder } from "../../support/api/utils/ordersUtils";
|
|
import { createNewProductWithSeveralVariants } from "../../support/api/utils/products/productsUtils";
|
|
|
|
describe("Manage products stocks in checkout", () => {
|
|
const startsWith = "CyStocksCheckout-";
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
let defaultChannel;
|
|
let address;
|
|
let shippingMethod;
|
|
let variantsWithLowStock;
|
|
let variantsWithoutTrackInventory;
|
|
let lastVariantInStock;
|
|
|
|
before(() => {
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
const variantsData = [
|
|
{
|
|
name: "variantsWithLowStock",
|
|
trackInventory: true,
|
|
quantityInWarehouse: 1,
|
|
},
|
|
{
|
|
name: "variantsWithoutTrackInventory",
|
|
trackInventory: false,
|
|
quantityInWarehouse: 0,
|
|
},
|
|
{
|
|
name: "lastVariantInStock",
|
|
trackInventory: true,
|
|
quantityInWarehouse: 1,
|
|
},
|
|
];
|
|
|
|
createNewProductWithSeveralVariants(name, variantsData).then(resp => {
|
|
defaultChannel = resp.defaultChannel;
|
|
address = resp.address;
|
|
shippingMethod = resp.shippingMethod;
|
|
variantsWithLowStock = resp.createdVariants.find(
|
|
variant => variant.name === "variantsWithLowStock",
|
|
);
|
|
variantsWithoutTrackInventory = resp.createdVariants.find(
|
|
variant => variant.name === "variantsWithoutTrackInventory",
|
|
);
|
|
lastVariantInStock = resp.createdVariants.find(
|
|
variant => variant.name === "lastVariantInStock",
|
|
);
|
|
cy.checkIfDataAreNotNull({
|
|
defaultChannel,
|
|
address,
|
|
shippingMethod,
|
|
variantsWithLowStock,
|
|
variantsWithoutTrackInventory,
|
|
lastVariantInStock,
|
|
});
|
|
});
|
|
});
|
|
|
|
it(
|
|
"should not be possible to add product with quantity greater than stock to checkout. TC: SALEOR_0405",
|
|
{ tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] },
|
|
() => {
|
|
createCheckout({
|
|
channelSlug: defaultChannel.slug,
|
|
address,
|
|
billingAddress: address,
|
|
email: "email@example.com",
|
|
variantsList: [variantsWithLowStock],
|
|
auth: "token",
|
|
})
|
|
.then(({ checkout: checkout }) => {
|
|
addProductsToCheckout(checkout.id, [variantsWithLowStock], 2);
|
|
})
|
|
.then(({ errors }) => {
|
|
expect(
|
|
errors[0],
|
|
"should return error on field quantity",
|
|
).to.have.property("field", "quantity");
|
|
});
|
|
},
|
|
);
|
|
|
|
it(
|
|
"should buy product with no quantity if tracking is not set. TC: SALEOR_0406",
|
|
{ tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] },
|
|
() => {
|
|
createWaitingForCaptureOrder({
|
|
address,
|
|
channelSlug: defaultChannel.slug,
|
|
email: "example@example.com",
|
|
shippingMethodName: shippingMethod.name,
|
|
variantsList: [variantsWithoutTrackInventory],
|
|
}).then(({ order }) => {
|
|
expect(order, "order should be created").to.be.ok;
|
|
});
|
|
},
|
|
);
|
|
|
|
it(
|
|
"should create checkout with last product in stock. TC: SALEOR_0419",
|
|
{ tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] },
|
|
() => {
|
|
createWaitingForCaptureOrder({
|
|
address,
|
|
channelSlug: defaultChannel.slug,
|
|
email: "example@example.com",
|
|
shippingMethodName: shippingMethod.name,
|
|
variantsList: [lastVariantInStock],
|
|
})
|
|
.then(({ order }) => {
|
|
expect(order, "order should be created").to.be.ok;
|
|
getVariants([lastVariantInStock]);
|
|
})
|
|
.then(variantsList => {
|
|
const variant = variantsList.edges[0];
|
|
expect(variant.node.stocks[0].quantityAllocated).to.eq(1);
|
|
expect(variant.node.stocks[0].quantity).to.eq(1);
|
|
});
|
|
},
|
|
);
|
|
});
|