
* [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
100 lines
3.2 KiB
JavaScript
100 lines
3.2 KiB
JavaScript
/// <reference types="cypress"/>
|
|
/// <reference types="../../../support"/>
|
|
|
|
import faker from "faker";
|
|
|
|
import { addVariantUrl } from "../../../fixtures/urlList";
|
|
import { createCategory } from "../../../support/api/requests/Category";
|
|
import { getVariant } from "../../../support/api/requests/Product";
|
|
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
|
import {
|
|
createProductInChannelWithoutVariants,
|
|
deleteProductsStartsWith,
|
|
} from "../../../support/api/utils/products/productsUtils";
|
|
import { createProductTypeWithNewVariantSelectionAttribute } from "../../../support/api/utils/productTypeUtils";
|
|
import { fillUpVariantDetails } from "../../../support/pages/catalog/products/VariantsPage";
|
|
|
|
describe("As an admin I want to use attributes in variant selection", () => {
|
|
const startsWith = "VarSel";
|
|
|
|
const attributesTypes = [
|
|
{ key: "DROPDOWN", TC: "SALEOR_0534" },
|
|
{ key: "BOOLEAN", TC: "SALEOR_0536" },
|
|
{ key: "NUMERIC", TC: "SALEOR_0537" },
|
|
{ key: "SWATCH", TC: "SALEOR_0538" },
|
|
];
|
|
let channel;
|
|
let category;
|
|
|
|
before(() => {
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
deleteProductsStartsWith(startsWith);
|
|
getDefaultChannel().then(defaultChannel => (channel = defaultChannel));
|
|
createCategory({ name: startsWith }).then(
|
|
categoryResp => (category = categoryResp),
|
|
cy.checkIfDataAreNotNull({ channel, category }),
|
|
);
|
|
});
|
|
|
|
beforeEach(() => {
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
});
|
|
|
|
attributesTypes.forEach(attributeType => {
|
|
it(
|
|
`should create variant with ${attributeType.key} attribute. TC: ${attributeType.TC}`,
|
|
{ tags: ["@attribute", "@allEnv"] },
|
|
() => {
|
|
const name = `${startsWith}${
|
|
attributeType.key
|
|
}${faker.datatype.number()}`;
|
|
const inputType = attributeType.key;
|
|
const attributeValues = ["1", "2"];
|
|
let productType;
|
|
let product;
|
|
|
|
createProductTypeWithNewVariantSelectionAttribute({
|
|
name,
|
|
inputType,
|
|
attributeValues,
|
|
})
|
|
.then(({ productType: productTypeResp }) => {
|
|
productType = productTypeResp;
|
|
|
|
createProductInChannelWithoutVariants({
|
|
categoryId: category.id,
|
|
productTypeId: productType.id,
|
|
name,
|
|
channelId: channel.id,
|
|
});
|
|
})
|
|
.then(productResp => {
|
|
product = productResp;
|
|
|
|
cy.visit(addVariantUrl(product.id)).addAliasToGraphRequest(
|
|
"VariantCreate",
|
|
);
|
|
|
|
fillUpVariantDetails({
|
|
sku: name,
|
|
attributeName: attributeValues[0],
|
|
attributeType: inputType,
|
|
costPrice: 10,
|
|
price: 10,
|
|
});
|
|
|
|
cy.wait("@VariantCreate");
|
|
})
|
|
.then(({ response }) => {
|
|
const variant =
|
|
response.body.data.productVariantCreate.productVariant;
|
|
getVariant(variant.id, channel.slug);
|
|
})
|
|
.then(({ attributes }) => {
|
|
expect(attributes[0].attribute.inputType).to.eq(inputType);
|
|
cy.confirmationMessageShouldAppear();
|
|
});
|
|
},
|
|
);
|
|
});
|
|
});
|