
* New datagrid view for product variant management (#2040) * Split simple and product with variants updates * Simplify code * Change selectedVariantsIds to availableVariants selectedVariantsIds suggested that these variants *were just* selected * Add datagrid component Add datagrid component Add actions column Add column picker Add ts-ignore comment Remove unused import Fix after rebase Add story Fix column picking Fix column dragging Add column resizing Extract components to own files Apply styles from class Improve data storage Extract state to hook Expose handlers Fix styles Fix header overflow Add select all option Add cell types Fix types Add number type cell Add min to stocks Fix types Generate columns from shop data Add number type editor Fix tests Update src/components/Datagrid/Datagrid.tsx Co-authored-by: Jonatan Witoszek <jonatanwitoszek@gmail.com> Reconstruct data after column toggling Minor fixes Add missing id Remove unused import Fix container width Keep changes in state Drop onChange usage Use glide datagrid * Add column picker * Memoize callbacks * Add right toolbar * Make toolbar as prop * Clean up code * Fix styling * Lint files * Save variant data in datagrid (#2161) * Allow rows to be deleted * Add row adding * Clean up code * Improve mutations * Add stock saving * Add sku and attribute saving * Display notification after all mutations * Fix types * Save channels in datagrid (#2197) * wip * Merge simple and variantable handlers * Move channel setting to form * Link availability card to form * Extract listing management to hook * Update only touched channels * Improve channel listing managemend * Display channel data in datagrid * Save variant channels * Save changes in channel listings * Group columns * Fix types * Display touched fields * Return errors from hook * Display errors in cells * Improve naming * Improve naming * Use reliable called/loading state * Update src/components/Datagrid/cells.ts Co-authored-by: Michał Droń <dron.official@yahoo.com> * Apply fixes from review Co-authored-by: Michał Droń <dron.official@yahoo.com> * Fix type error * Trigger CI * Trigger CI * Save added and deleted variants (#2237) * Save new variants * Update channel data * Remove bulk variant delete dialog * Do not fetch products from api after save * Extract types * Reset errors after api response * Display error when creating variants * Fix variant reordering * Remove commented code * Fix imports * Edit attributes in datagrid (#2305) * Add basic dropdown cell * Fix clickaway * Add choice customization * Add callback to fetch choices * Add attriute value search * wip * Pass getSuggestions cb using props * Fix row adding * Fix choice creation * Add styles to datagrid (#2315) * Improve cell styling * Prevent navigation when scrolling horizontally * Fix text editor styles * Remove unused variable * Update whole row after editing cell * Translate column names * Improve empty message * Highlight newly created rows * Add name editing * Add disabled context menu to added rows * Add column groups * Translate column groups names * Save edited name * Fix missing column id error * Add card to datagrid * Improve shadow on scroll * Improve fonts * Fix toolbar placement * Update api type definitions * Fix copypasting from excel * Fix editor font weight * Improve dark theme * Improve cell coloring * Drop styling from story * Add docs to datagrid (#2339) * Add docs * Add summary * Datagrid fix bugs (#2341) * Pass refetch to form to avoid double calls * Add missing prop * Remove paddings (#2352) * remove paddings * remove paddings * remove paddings * remove vertical scroll * update tests * styles, currency * Fix variants tests in datagrid (#2365) * refactor variant test after adding datagrid * adding assertion to check if datagrid table is visible * adding check for datagrid * fix flaky tests in variants * fix flaky tests in variants * small changes * amedments * update styles * refactoring, handle prices * update snapshots * messages * snap * scrolling handle, css for safari * snap, random mock * update overflow * history back hook * fix cross-price changing, scroll optimization * trigger ci * channel checking when adding new variant Co-authored-by: Michał Droń <dron.official@yahoo.com> Co-authored-by: Patryk Andrzejewski <vox3r69@gmail.com> Co-authored-by: Ewa Czerniak <ewa.czerniak@saleor.io>
184 lines
6.3 KiB
JavaScript
184 lines
6.3 KiB
JavaScript
/// <reference types="cypress"/>
|
|
/// <reference types="../../support"/>
|
|
|
|
import faker from "faker";
|
|
|
|
import { PRODUCT_DETAILS } from "../../elements/catalog/products/product-details";
|
|
import { VARIANTS_SELECTORS } from "../../elements/catalog/products/variants-selectors";
|
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
|
import { urlList } from "../../fixtures/urlList";
|
|
import { ONE_PERMISSION_USERS } from "../../fixtures/users";
|
|
import { createChannel } from "../../support/api/requests/Channels";
|
|
import {
|
|
createProduct,
|
|
updateChannelInProduct,
|
|
} from "../../support/api/requests/Product";
|
|
import * as productUtils from "../../support/api/utils/products/productsUtils";
|
|
import { getProductVariants } from "../../support/api/utils/storeFront/storeFrontProductUtils";
|
|
import { createVariant } from "../../support/pages/catalog/products/VariantsPage";
|
|
|
|
describe("As an admin I should be able to create variant", () => {
|
|
const startsWith = "CyCreateVariants-";
|
|
const attributeValues = ["value1", "value2"];
|
|
|
|
let defaultChannel;
|
|
let warehouse;
|
|
let attribute;
|
|
let productType;
|
|
let category;
|
|
let newChannel;
|
|
|
|
before(() => {
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
productUtils
|
|
.createShippingProductTypeAttributeAndCategory(name, attributeValues)
|
|
.then(resp => {
|
|
attribute = resp.attribute;
|
|
productType = resp.productType;
|
|
category = resp.category;
|
|
defaultChannel = resp.defaultChannel;
|
|
warehouse = resp.warehouse;
|
|
|
|
createChannel({ isActive: true, name, currencyCode: "PLN" });
|
|
})
|
|
.then(resp => (newChannel = resp));
|
|
});
|
|
|
|
beforeEach(() => {
|
|
cy.clearSessionData().loginUserViaRequest(
|
|
"auth",
|
|
ONE_PERMISSION_USERS.product,
|
|
);
|
|
});
|
|
|
|
it(
|
|
"should be able to create variant visible for the customers in all channels. TC: SALEOR_2901",
|
|
{ tags: ["@variants", "@allEnv", "@critical", "@stable"] },
|
|
() => {
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
const price = 10;
|
|
let createdProduct;
|
|
|
|
createProduct({
|
|
attributeId: attribute.id,
|
|
name,
|
|
productTypeId: productType.id,
|
|
categoryId: category.id,
|
|
})
|
|
.then(resp => {
|
|
createdProduct = resp;
|
|
|
|
updateChannelInProduct({
|
|
productId: createdProduct.id,
|
|
channelId: defaultChannel.id,
|
|
});
|
|
updateChannelInProduct({
|
|
productId: createdProduct.id,
|
|
channelId: newChannel.id,
|
|
});
|
|
cy.visit(`${urlList.products}${createdProduct.id}`)
|
|
.waitForProgressBarToNotBeVisible()
|
|
.get(PRODUCT_DETAILS.addVariantButton)
|
|
.should("exist")
|
|
.click()
|
|
.get(PRODUCT_DETAILS.dataGridTable)
|
|
.should("be.visible")
|
|
.get(PRODUCT_DETAILS.firstRowDataGrid)
|
|
.click({ force: true })
|
|
.type(name)
|
|
.get(BUTTON_SELECTORS.confirm)
|
|
.click()
|
|
.confirmationMessageShouldAppear()
|
|
.reload()
|
|
.waitForProgressBarToNotBeVisible()
|
|
.get(PRODUCT_DETAILS.dataGridTable)
|
|
.should("be.visible")
|
|
.wait(1000)
|
|
.get(BUTTON_SELECTORS.showMoreButton)
|
|
.click()
|
|
.get(PRODUCT_DETAILS.editVariant)
|
|
.click()
|
|
.get(VARIANTS_SELECTORS.manageChannels)
|
|
.click()
|
|
.get(VARIANTS_SELECTORS.allChannels)
|
|
.check()
|
|
.get(BUTTON_SELECTORS.submit)
|
|
.click();
|
|
createVariant({
|
|
channelName: [defaultChannel.name, newChannel.name],
|
|
sku: name,
|
|
price,
|
|
attributeName: attributeValues[0],
|
|
});
|
|
getProductVariants(createdProduct.id, defaultChannel.slug);
|
|
})
|
|
.then(([variant]) => {
|
|
expect(variant).to.have.property("name", name);
|
|
expect(variant).to.have.property("price", price);
|
|
expect(variant).to.have.property("currency", "USD");
|
|
getProductVariants(createdProduct.id, newChannel.slug);
|
|
})
|
|
.then(([variant]) => {
|
|
expect(variant).to.have.property("name", name);
|
|
expect(variant).to.have.property("price", price);
|
|
expect(variant).to.have.property("currency", "PLN");
|
|
});
|
|
},
|
|
);
|
|
|
|
it(
|
|
"should be able to create several variants visible for the customers. TC: SALEOR_2902",
|
|
{ tags: ["@variants", "@allEnv", "@critical", "@stable"] },
|
|
() => {
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
const secondVariantSku = `${startsWith}${faker.datatype.number()}`;
|
|
const variants = [{ price: 7 }, { name: attributeValues[1], price: 16 }];
|
|
let createdProduct;
|
|
|
|
productUtils
|
|
.createProductInChannel({
|
|
name,
|
|
attributeId: attribute.id,
|
|
channelId: defaultChannel.id,
|
|
warehouseId: warehouse.id,
|
|
productTypeId: productType.id,
|
|
categoryId: category.id,
|
|
price: variants[0].price,
|
|
})
|
|
.then(({ product: productResp }) => {
|
|
createdProduct = productResp;
|
|
|
|
cy.visit(`${urlList.products}${createdProduct.id}`)
|
|
.get(BUTTON_SELECTORS.showMoreButton)
|
|
.click()
|
|
.get(PRODUCT_DETAILS.editVariant)
|
|
.click()
|
|
.get(PRODUCT_DETAILS.addVariantButton)
|
|
.click()
|
|
.then(() => {
|
|
createVariant({
|
|
sku: secondVariantSku,
|
|
attributeName: variants[1].name,
|
|
price: variants[1].price,
|
|
channelName: defaultChannel.name,
|
|
});
|
|
getProductVariants(createdProduct.id, defaultChannel.slug);
|
|
})
|
|
.then(([firstVariant, secondVariant]) => {
|
|
expect(firstVariant).to.have.property("price", variants[0].price);
|
|
expect(firstVariant).to.have.property("name", "value");
|
|
expect(firstVariant).to.have.property("currency", "USD");
|
|
expect(secondVariant).to.have.property("name", "value2");
|
|
expect(secondVariant).to.have.property(
|
|
"price",
|
|
variants[1].price,
|
|
);
|
|
expect(secondVariant).to.have.property("currency", "USD");
|
|
});
|
|
});
|
|
},
|
|
);
|
|
});
|