test bulk delete products (#3633)

* wip

* bulk delete 2 products

* removed unused helper

* added TC number
This commit is contained in:
wojteknowacki 2023-05-11 15:03:37 +02:00 committed by GitHub
parent 70c7f3a2f8
commit cf4adbc1af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 86 additions and 18 deletions

View file

@ -0,0 +1,70 @@
/// <reference types="cypress"/>
/// <reference types="../../../support"/>
import faker from "faker";
import { BUTTON_SELECTORS, PRODUCTS_LIST } from "../../../elements/";
import { DIALOGS_MESSAGES } from "../../../fixtures/";
import { urlList } from "../../../fixtures/urlList";
import { getDefaultChannel, productsUtils } from "../../../support/api/utils/";
import { ensureCanvasStatic } from "../../../support/customCommands/sharedElementsOperations/canvas";
describe("Test for deleting products", () => {
const startsWith = "AABulkDeleteCypress";
const name = `${startsWith}${faker.datatype.number()}`;
const name2 = `${startsWith}${faker.datatype.number()}`;
let channel;
let product;
before(() => {
cy.clearSessionData().loginUserViaRequest();
productsUtils.deleteProductsStartsWith(startsWith);
getDefaultChannel()
.then(channelResp => {
channel = channelResp;
productsUtils.createTypeAttributeAndCategoryForProduct({ name });
})
.then(({ attribute, category, productType }) => {
productsUtils.createProductInChannel({
attributeId: attribute.id,
categoryId: category.id,
channelId: channel.id,
name,
productTypeId: productType.id,
});
productsUtils.createProductInChannel({
attributeId: attribute.id,
categoryId: category.id,
channelId: channel.id,
name: name2,
productTypeId: productType.id,
});
})
.then(({ product: productResp }) => {
product = productResp;
cy.checkIfDataAreNotNull({ channel, product });
});
});
it(
"should delete 2 first products on products grid view - SALEOR_2709",
{ tags: ["@metadata", "@allEnv", "@stable"] },
() => {
cy.clearSessionData().loginUserViaRequest();
cy.visit(urlList.products);
// checks two first rows on products data grid
cy.clickGridCell(0, 0);
cy.clickGridCell(0, 1);
cy.clickOnElement(BUTTON_SELECTORS.deleteProductsButton);
cy.contains(DIALOGS_MESSAGES.confirmProductsDeletion).should(
"be.visible",
);
cy.addAliasToGraphRequest("productBulkDelete")
.clickSubmitButton()
.waitForRequestAndCheckIfNoErrors("@productBulkDelete");
ensureCanvasStatic(PRODUCTS_LIST.dataGridTable);
cy.get(BUTTON_SELECTORS.submit).should("not.exist");
cy.contains(name).should("not.exist");
cy.contains(name2).should("not.exist");
},
);
});

View file

@ -1,4 +1,2 @@
import { PRODUCT_DETAILS } from "./product-details"; export { PRODUCT_DETAILS } from "./product-details";
import { PRODUCTS_LIST } from "./products-list"; export { PRODUCTS_LIST } from "./products-list";
export { PRODUCT_DETAILS, PRODUCTS_LIST };

View file

@ -8,6 +8,7 @@ export const BUTTON_SELECTORS = {
selectOption: "[data-test-id*='select-option']", selectOption: "[data-test-id*='select-option']",
notSelectedOption: ":not([aria-selected])", notSelectedOption: ":not([aria-selected])",
deleteButton: '[data-test-id="button-bar-delete"]', deleteButton: '[data-test-id="button-bar-delete"]',
deleteProductsButton: '[data-test-id="delete-products-button"]',
deleteItemsButton: '[data-test-id="button-delete-items"]', deleteItemsButton: '[data-test-id="button-delete-items"]',
confirmDeleteButton: '[data-test-id="confirm-delete"]', confirmDeleteButton: '[data-test-id="confirm-delete"]',
expandIcon: '[data-test-id="expand-icon"]', expandIcon: '[data-test-id="expand-icon"]',

View file

@ -1,12 +1,4 @@
import { ADDRESS_SELECTORS } from "./addressForm"; export { ADDRESS_SELECTORS } from "./addressForm";
import { BUTTON_SELECTORS } from "./button-selectors"; export { BUTTON_SELECTORS } from "./button-selectors";
import { PRESETS, SEARCH } from "./presetsAndSearch"; export { PRESETS, SEARCH } from "./presetsAndSearch";
import { SHARED_ELEMENTS } from "./sharedElements"; export { SHARED_ELEMENTS } from "./sharedElements";
export {
ADDRESS_SELECTORS,
BUTTON_SELECTORS,
PRESETS,
SEARCH,
SHARED_ELEMENTS,
};

View file

@ -2,3 +2,4 @@ export { bodyMockHomePage } from "./bodyMocks";
export { orderDraftCreateDemoResponse } from "./errors/demo/orderDratCreate"; export { orderDraftCreateDemoResponse } from "./errors/demo/orderDratCreate";
export { urlList } from "./urlList"; export { urlList } from "./urlList";
export { ONE_PERMISSION_USERS } from "./users"; export { ONE_PERMISSION_USERS } from "./users";
export { DIALOGS_MESSAGES } from "./messages";

View file

@ -0,0 +1,3 @@
export const DIALOGS_MESSAGES = {
confirmProductsDeletion: "Are you sure you want to delete 2 products?",
};

View file

@ -1,3 +1,5 @@
export { createChannel, updateChannelOrderSettings } from "./Channels"; export { createChannel, updateChannelOrderSettings } from "./Channels";
export { createCustomer, deleteCustomersStartsWith } from "./Customer"; export { createCustomer, deleteCustomersStartsWith } from "./Customer";
export { getOrder } from "./Order"; export { createDraftOrder, getOrder } from "./Order";
export { updateMetadata, updatePrivateMetadata } from "./Metadata";
export { getProductMetadata } from "./storeFront/ProductDetails";

View file

@ -1,4 +1,4 @@
export { deleteChannelsStartsWith } from "./channelsUtils"; export { deleteChannelsStartsWith, getDefaultChannel } from "./channelsUtils";
export { createOrder, createReadyToFulfillOrder } from "./ordersUtils"; export { createOrder, createReadyToFulfillOrder } from "./ordersUtils";
export { createShipping, deleteShippingStartsWith } from "./shippingUtils"; export { createShipping, deleteShippingStartsWith } from "./shippingUtils";
export { export {

View file

@ -23,6 +23,7 @@ export const ProductListDeleteButton = forwardRef<
onClick={onClick} onClick={onClick}
icon={<TrashBinIcon />} icon={<TrashBinIcon />}
variant="secondary" variant="secondary"
data-test-id="delete-products-button"
/> />
</Tooltip.Trigger> </Tooltip.Trigger>
<Tooltip.Content side="bottom"> <Tooltip.Content side="bottom">