diff --git a/cypress/fixtures/urlList.js b/cypress/fixtures/urlList.js
index d570a4940..d183387fa 100644
--- a/cypress/fixtures/urlList.js
+++ b/cypress/fixtures/urlList.js
@@ -32,6 +32,9 @@ export const urlList = {
warehouses: "warehouses/"
};
+export const addVariantUrl = productId =>
+ `${urlList.products}${productId}/${urlList.variants}add`;
+
export const appDetailsUrl = appId => `${urlList.apps}custom/${appId}`;
export const attributeDetailsUrl = attributeId =>
diff --git a/cypress/integration/configuration/attributes/attributeVariantSelection.js b/cypress/integration/configuration/attributes/attributeVariantSelection.js
index c9650978d..d9be4e422 100644
--- a/cypress/integration/configuration/attributes/attributeVariantSelection.js
+++ b/cypress/integration/configuration/attributes/attributeVariantSelection.js
@@ -1,35 +1,30 @@
///
///
-import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details";
-import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
-import { productDetailsUrl } from "../../../fixtures/urlList";
-import { createAttribute } from "../../../support/api/requests/Attribute";
+import faker from "faker";
+
+import { addVariantUrl } from "../../../fixtures/urlList";
import { createCategory } from "../../../support/api/requests/Category";
import { getVariant } from "../../../support/api/requests/Product";
-import {
- createTypeProduct,
- productAttributeAssignmentUpdate
-} from "../../../support/api/requests/ProductType";
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
import {
createProductInChannelWithoutVariants,
deleteProductsStartsWith
} from "../../../support/api/utils/products/productsUtils";
+import { createProductTypeWithNewVariantSelectionAttribute } from "../../../support/api/utils/productTypeUtils";
import filterTests from "../../../support/filterTests";
import { fillUpVariantDetails } from "../../../support/pages/catalog/products/VariantsPage";
filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
- describe("Create variant with variant selection attribute", () => {
+ describe("As an admin I want to use attributes in variant selection", () => {
const startsWith = "VarSel";
const attributesTypes = [
- "DROPDOWN",
- "MULTISELECT",
- "BOOLEAN",
- "NUMERIC",
- "SWATCH",
- "DATE"
+ { key: "DROPDOWN", TC: "SALEOR_0534" },
+ { key: "MULTISELECT", TC: "SALEOR_0535" },
+ { key: "BOOLEAN", TC: "SALEOR_0536" },
+ { key: "NUMERIC", TC: "SALEOR_0537" },
+ { key: "SWATCH", TC: "SALEOR_0538" }
];
let channel;
let category;
@@ -49,34 +44,22 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
});
attributesTypes.forEach(attributeType => {
- it(`should create variant with ${attributeType} attribute`, () => {
- const name = `${startsWith}${attributeType}`;
- const inputType = attributeType;
+ it(`should create variant with ${attributeType.key} attribute. TC: ${attributeType.TC}`, () => {
+ const name = `${startsWith}${
+ attributeType.key
+ }${faker.datatype.number()}`;
+ const inputType = attributeType.key;
const attributeValues = ["1", "2"];
let productType;
- let attribute;
- createAttribute({
+ createProductTypeWithNewVariantSelectionAttribute({
name,
inputType,
attributeValues
})
- .then(attributeResp => {
- attribute = attributeResp;
- createTypeProduct({
- name,
- attributeId: attribute.id,
- productAttributes: false
- });
- })
- .then(productTypeResp => {
+ .then(({ productType: productTypeResp }) => {
productType = productTypeResp;
- productAttributeAssignmentUpdate({
- productTypeId: productType.id,
- attributeId: attribute.id
- });
- })
- .then(() => {
+
createProductInChannelWithoutVariants({
categoryId: category.id,
productTypeId: productType.id,
@@ -86,19 +69,17 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
})
.then(productResp => {
product = productResp;
- cy.visit(productDetailsUrl(product.id))
- .get(PRODUCT_DETAILS.addVariantsButton)
- .click()
- .get(PRODUCT_DETAILS.createSingleVariantCheckbox)
- .click()
- .get(BUTTON_SELECTORS.submit)
- .click()
- .addAliasToGraphRequest("VariantCreate");
+
+ cy.visit(addVariantUrl(product.id)).addAliasToGraphRequest(
+ "VariantCreate"
+ );
+
fillUpVariantDetails({
sku: name,
attributeName: attributeValues[0],
- attributeType
+ attributeType: inputType
});
+
cy.wait("@VariantCreate");
})
.then(({ response }) => {
@@ -108,6 +89,7 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
})
.then(({ attributes }) => {
expect(attributes[0].attribute.inputType).to.eq(inputType);
+ cy.confirmationMessageShouldAppear();
});
});
});
diff --git a/cypress/integration/configuration/attributes/attributes.js b/cypress/integration/configuration/attributes/createProductAttributes.js
similarity index 100%
rename from cypress/integration/configuration/attributes/attributes.js
rename to cypress/integration/configuration/attributes/createProductAttributes.js
diff --git a/cypress/support/api/requests/ProductType.js b/cypress/support/api/requests/ProductType.js
index 6bab393fe..d205d2b66 100644
--- a/cypress/support/api/requests/ProductType.js
+++ b/cypress/support/api/requests/ProductType.js
@@ -78,7 +78,7 @@ export function deleteProductType(productTypeId) {
export function productAttributeAssignmentUpdate({
productTypeId,
attributeId,
- variantSelection = true
+ variantSelection = false
}) {
const mutation = `mutation {
productAttributeAssignmentUpdate(
diff --git a/cypress/support/api/utils/productTypeUtils.js b/cypress/support/api/utils/productTypeUtils.js
new file mode 100644
index 000000000..58ea48b6e
--- /dev/null
+++ b/cypress/support/api/utils/productTypeUtils.js
@@ -0,0 +1,51 @@
+import { createAttribute } from "../requests/Attribute";
+import { updateVariantPrice } from "../requests/Product";
+import {
+ createDigitalContent,
+ createTypeProduct,
+ productAttributeAssignmentUpdate,
+ setProductTypeAsDigital
+} from "../requests/ProductType";
+
+export function addDigitalContentAndUpdateProductType(
+ variantId,
+ productTypeId,
+ channelId,
+ price = 1
+) {
+ createDigitalContent(variantId);
+ setProductTypeAsDigital(productTypeId);
+ updateVariantPrice({ variantId, channelId, price });
+}
+
+export function createProductTypeWithNewVariantSelectionAttribute({
+ name,
+ inputType,
+ attributeValues
+}) {
+ let attribute;
+ let productType;
+
+ return createAttribute({
+ name,
+ inputType,
+ attributeValues
+ })
+ .then(attributeResp => {
+ attribute = attributeResp;
+ createTypeProduct({
+ name,
+ attributeId: attribute.id,
+ productAttributes: false
+ });
+ })
+ .then(productTypeResp => {
+ productType = productTypeResp;
+ productAttributeAssignmentUpdate({
+ productTypeId: productType.id,
+ attributeId: attribute.id,
+ variantSelection: true
+ });
+ })
+ .then(() => ({ attribute, productType }));
+}
diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts
index c9e11043d..6ae7a0f5d 100644
--- a/cypress/support/index.d.ts
+++ b/cypress/support/index.d.ts
@@ -34,6 +34,7 @@ declare namespace Cypress {
fillUpAddressForm(address: {}): Chainable;
fillUpBasicAddress(address: {}): Chainable;
confirmationMessageShouldDisappear(): Chainable;
+ confirmationMessageShouldAppear(): Chainable;
waitForProgressBarToNotExist(): Chainable;
waitForProgressBarToNotBeVisible(): Chainable;
visitAndWaitForProgressBarToDisappear(url: string): Chainable;