Fix variant selection attribute (#1935)
* fix variant selection attribute * Add TC to names * variant selection attribute only for this test * variant selection attribute only for this test
This commit is contained in:
parent
168887ac3b
commit
6358ee0b89
6 changed files with 82 additions and 45 deletions
|
@ -32,6 +32,9 @@ export const urlList = {
|
||||||
warehouses: "warehouses/"
|
warehouses: "warehouses/"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const addVariantUrl = productId =>
|
||||||
|
`${urlList.products}${productId}/${urlList.variants}add`;
|
||||||
|
|
||||||
export const appDetailsUrl = appId => `${urlList.apps}custom/${appId}`;
|
export const appDetailsUrl = appId => `${urlList.apps}custom/${appId}`;
|
||||||
|
|
||||||
export const attributeDetailsUrl = attributeId =>
|
export const attributeDetailsUrl = attributeId =>
|
||||||
|
|
|
@ -1,35 +1,30 @@
|
||||||
/// <reference types="cypress"/>
|
/// <reference types="cypress"/>
|
||||||
/// <reference types="../../../support"/>
|
/// <reference types="../../../support"/>
|
||||||
|
|
||||||
import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details";
|
import faker from "faker";
|
||||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
|
||||||
import { productDetailsUrl } from "../../../fixtures/urlList";
|
import { addVariantUrl } from "../../../fixtures/urlList";
|
||||||
import { createAttribute } from "../../../support/api/requests/Attribute";
|
|
||||||
import { createCategory } from "../../../support/api/requests/Category";
|
import { createCategory } from "../../../support/api/requests/Category";
|
||||||
import { getVariant } from "../../../support/api/requests/Product";
|
import { getVariant } from "../../../support/api/requests/Product";
|
||||||
import {
|
|
||||||
createTypeProduct,
|
|
||||||
productAttributeAssignmentUpdate
|
|
||||||
} from "../../../support/api/requests/ProductType";
|
|
||||||
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
||||||
import {
|
import {
|
||||||
createProductInChannelWithoutVariants,
|
createProductInChannelWithoutVariants,
|
||||||
deleteProductsStartsWith
|
deleteProductsStartsWith
|
||||||
} from "../../../support/api/utils/products/productsUtils";
|
} from "../../../support/api/utils/products/productsUtils";
|
||||||
|
import { createProductTypeWithNewVariantSelectionAttribute } from "../../../support/api/utils/productTypeUtils";
|
||||||
import filterTests from "../../../support/filterTests";
|
import filterTests from "../../../support/filterTests";
|
||||||
import { fillUpVariantDetails } from "../../../support/pages/catalog/products/VariantsPage";
|
import { fillUpVariantDetails } from "../../../support/pages/catalog/products/VariantsPage";
|
||||||
|
|
||||||
filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
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 startsWith = "VarSel";
|
||||||
|
|
||||||
const attributesTypes = [
|
const attributesTypes = [
|
||||||
"DROPDOWN",
|
{ key: "DROPDOWN", TC: "SALEOR_0534" },
|
||||||
"MULTISELECT",
|
{ key: "MULTISELECT", TC: "SALEOR_0535" },
|
||||||
"BOOLEAN",
|
{ key: "BOOLEAN", TC: "SALEOR_0536" },
|
||||||
"NUMERIC",
|
{ key: "NUMERIC", TC: "SALEOR_0537" },
|
||||||
"SWATCH",
|
{ key: "SWATCH", TC: "SALEOR_0538" }
|
||||||
"DATE"
|
|
||||||
];
|
];
|
||||||
let channel;
|
let channel;
|
||||||
let category;
|
let category;
|
||||||
|
@ -49,34 +44,22 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
attributesTypes.forEach(attributeType => {
|
attributesTypes.forEach(attributeType => {
|
||||||
it(`should create variant with ${attributeType} attribute`, () => {
|
it(`should create variant with ${attributeType.key} attribute. TC: ${attributeType.TC}`, () => {
|
||||||
const name = `${startsWith}${attributeType}`;
|
const name = `${startsWith}${
|
||||||
const inputType = attributeType;
|
attributeType.key
|
||||||
|
}${faker.datatype.number()}`;
|
||||||
|
const inputType = attributeType.key;
|
||||||
const attributeValues = ["1", "2"];
|
const attributeValues = ["1", "2"];
|
||||||
let productType;
|
let productType;
|
||||||
let attribute;
|
|
||||||
|
|
||||||
createAttribute({
|
createProductTypeWithNewVariantSelectionAttribute({
|
||||||
name,
|
name,
|
||||||
inputType,
|
inputType,
|
||||||
attributeValues
|
attributeValues
|
||||||
})
|
})
|
||||||
.then(attributeResp => {
|
.then(({ productType: productTypeResp }) => {
|
||||||
attribute = attributeResp;
|
|
||||||
createTypeProduct({
|
|
||||||
name,
|
|
||||||
attributeId: attribute.id,
|
|
||||||
productAttributes: false
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(productTypeResp => {
|
|
||||||
productType = productTypeResp;
|
productType = productTypeResp;
|
||||||
productAttributeAssignmentUpdate({
|
|
||||||
productTypeId: productType.id,
|
|
||||||
attributeId: attribute.id
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
createProductInChannelWithoutVariants({
|
createProductInChannelWithoutVariants({
|
||||||
categoryId: category.id,
|
categoryId: category.id,
|
||||||
productTypeId: productType.id,
|
productTypeId: productType.id,
|
||||||
|
@ -86,19 +69,17 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
})
|
})
|
||||||
.then(productResp => {
|
.then(productResp => {
|
||||||
product = productResp;
|
product = productResp;
|
||||||
cy.visit(productDetailsUrl(product.id))
|
|
||||||
.get(PRODUCT_DETAILS.addVariantsButton)
|
cy.visit(addVariantUrl(product.id)).addAliasToGraphRequest(
|
||||||
.click()
|
"VariantCreate"
|
||||||
.get(PRODUCT_DETAILS.createSingleVariantCheckbox)
|
);
|
||||||
.click()
|
|
||||||
.get(BUTTON_SELECTORS.submit)
|
|
||||||
.click()
|
|
||||||
.addAliasToGraphRequest("VariantCreate");
|
|
||||||
fillUpVariantDetails({
|
fillUpVariantDetails({
|
||||||
sku: name,
|
sku: name,
|
||||||
attributeName: attributeValues[0],
|
attributeName: attributeValues[0],
|
||||||
attributeType
|
attributeType: inputType
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.wait("@VariantCreate");
|
cy.wait("@VariantCreate");
|
||||||
})
|
})
|
||||||
.then(({ response }) => {
|
.then(({ response }) => {
|
||||||
|
@ -108,6 +89,7 @@ filterTests({ definedTags: ["all"], version: "3.1.0" }, () => {
|
||||||
})
|
})
|
||||||
.then(({ attributes }) => {
|
.then(({ attributes }) => {
|
||||||
expect(attributes[0].attribute.inputType).to.eq(inputType);
|
expect(attributes[0].attribute.inputType).to.eq(inputType);
|
||||||
|
cy.confirmationMessageShouldAppear();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,7 +78,7 @@ export function deleteProductType(productTypeId) {
|
||||||
export function productAttributeAssignmentUpdate({
|
export function productAttributeAssignmentUpdate({
|
||||||
productTypeId,
|
productTypeId,
|
||||||
attributeId,
|
attributeId,
|
||||||
variantSelection = true
|
variantSelection = false
|
||||||
}) {
|
}) {
|
||||||
const mutation = `mutation {
|
const mutation = `mutation {
|
||||||
productAttributeAssignmentUpdate(
|
productAttributeAssignmentUpdate(
|
||||||
|
|
51
cypress/support/api/utils/productTypeUtils.js
Normal file
51
cypress/support/api/utils/productTypeUtils.js
Normal file
|
@ -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 }));
|
||||||
|
}
|
1
cypress/support/index.d.ts
vendored
1
cypress/support/index.d.ts
vendored
|
@ -34,6 +34,7 @@ declare namespace Cypress {
|
||||||
fillUpAddressForm(address: {}): Chainable<any>;
|
fillUpAddressForm(address: {}): Chainable<any>;
|
||||||
fillUpBasicAddress(address: {}): Chainable<any>;
|
fillUpBasicAddress(address: {}): Chainable<any>;
|
||||||
confirmationMessageShouldDisappear(): Chainable<any>;
|
confirmationMessageShouldDisappear(): Chainable<any>;
|
||||||
|
confirmationMessageShouldAppear(): Chainable<any>;
|
||||||
waitForProgressBarToNotExist(): Chainable<any>;
|
waitForProgressBarToNotExist(): Chainable<any>;
|
||||||
waitForProgressBarToNotBeVisible(): Chainable<any>;
|
waitForProgressBarToNotBeVisible(): Chainable<any>;
|
||||||
visitAndWaitForProgressBarToDisappear(url: string): Chainable<any>;
|
visitAndWaitForProgressBarToDisappear(url: string): Chainable<any>;
|
||||||
|
|
Loading…
Reference in a new issue