merge (#1821)
This commit is contained in:
parent
f088095335
commit
b7f6a932b9
10 changed files with 94 additions and 18 deletions
|
@ -1,3 +1,5 @@
|
|||
export const CATEGORIES_LIST = {
|
||||
addCategoryButton: '[data-test-id="createCategory"]'
|
||||
};
|
||||
|
||||
export const categoryRow = categoryId => `[data-test-id="${categoryId}"]`;
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
|
||||
import faker from "faker";
|
||||
|
||||
import { CATEGORIES_LIST } from "../../elements/catalog/categories/categories-list";
|
||||
import {
|
||||
CATEGORIES_LIST,
|
||||
categoryRow
|
||||
} from "../../elements/catalog/categories/categories-list";
|
||||
import { CATEGORY_DETAILS } from "../../elements/catalog/categories/category-details";
|
||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
||||
|
@ -21,8 +24,8 @@ import {
|
|||
} from "../../support/pages/catalog/categoriesPage";
|
||||
|
||||
filterTests({ definedTags: ["all"] }, () => {
|
||||
describe("Categories", () => {
|
||||
const startsWith = "CyCollections";
|
||||
describe("As an admin I want to manage categories", () => {
|
||||
const startsWith = "CyCategories";
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
let attribute;
|
||||
|
@ -70,7 +73,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
cy.clearSessionData().loginUserViaRequest();
|
||||
});
|
||||
|
||||
it("should create category", () => {
|
||||
it("should be able to create category. TC: SALEOR_0201", () => {
|
||||
const categoryName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
cy.visit(urlList.categories)
|
||||
|
@ -88,7 +91,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should add subcategory", () => {
|
||||
it("should be able to create category as subcategory. TC: SALEOR_0202", () => {
|
||||
const categoryName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
cy.visit(categoryDetailsUrl(category.id))
|
||||
|
@ -103,7 +106,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should add product to category", () => {
|
||||
it("should be able to add product to category. TC: SALEOR_0203", () => {
|
||||
cy.visit(categoryDetailsUrl(category.id))
|
||||
.get(CATEGORY_DETAILS.productsTab)
|
||||
.click()
|
||||
|
@ -113,7 +116,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
.should("include", urlList.addProduct);
|
||||
});
|
||||
|
||||
it("should remove product from category", () => {
|
||||
it("should be able to remove product from category. TC: SALEOR_0204", () => {
|
||||
cy.visit(categoryDetailsUrl(category.id))
|
||||
.get(CATEGORY_DETAILS.productsTab)
|
||||
.click();
|
||||
|
@ -134,7 +137,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should enter category details page", () => {
|
||||
it("should be able to enter category details page. TC: SALEOR_0205", () => {
|
||||
cy.visit(urlList.categories)
|
||||
.get(SHARED_ELEMENTS.searchInput)
|
||||
.type(category.name);
|
||||
|
@ -142,10 +145,10 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
cy.contains(SHARED_ELEMENTS.header, category.name).should("be.visible");
|
||||
});
|
||||
|
||||
it("should delete category", () => {
|
||||
it("should be able to delete category. TC: SALEOR_0206", () => {
|
||||
const categoryName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createCategoryRequest(categoryName).then(categoryResp => {
|
||||
createCategoryRequest({ name: categoryName }).then(categoryResp => {
|
||||
cy.visit(categoryDetailsUrl(categoryResp.id))
|
||||
.get(BUTTON_SELECTORS.deleteButton)
|
||||
.click()
|
||||
|
@ -157,11 +160,11 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should update category", () => {
|
||||
it("should be able to update category. TC: SALEOR_0207", () => {
|
||||
const categoryName = `${startsWith}${faker.datatype.number()}`;
|
||||
const updatedName = `${startsWith}updatedCategory`;
|
||||
|
||||
createCategoryRequest(categoryName)
|
||||
createCategoryRequest({ name: categoryName })
|
||||
.then(categoryResp => {
|
||||
cy.visitAndWaitForProgressBarToDisappear(
|
||||
categoryDetailsUrl(categoryResp.id)
|
||||
|
@ -176,5 +179,69 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
expect(descriptionText).to.eq(updatedName);
|
||||
});
|
||||
});
|
||||
|
||||
it("should be able to delete several categories on categories list page. TC: SALEOR_0209", () => {
|
||||
const firstCategoryName = `${startsWith}${faker.datatype.number()}`;
|
||||
const secondCategoryName = `${startsWith}${faker.datatype.number()}`;
|
||||
let firstCategory;
|
||||
let secondCategory;
|
||||
|
||||
createCategoryRequest({ name: firstCategoryName }).then(categoryResp => {
|
||||
firstCategory = categoryResp;
|
||||
});
|
||||
createCategoryRequest({ name: secondCategoryName }).then(categoryResp => {
|
||||
secondCategory = categoryResp;
|
||||
cy.visit(urlList.categories)
|
||||
.searchInTable(startsWith)
|
||||
.get(categoryRow(firstCategory.id))
|
||||
.find(BUTTON_SELECTORS.checkbox)
|
||||
.click()
|
||||
.get(categoryRow(secondCategory.id))
|
||||
.find(BUTTON_SELECTORS.checkbox)
|
||||
.click()
|
||||
.get(BUTTON_SELECTORS.deleteIcon)
|
||||
.click()
|
||||
.addAliasToGraphRequest("CategoryBulkDelete")
|
||||
.get(BUTTON_SELECTORS.submit)
|
||||
.click()
|
||||
.waitForRequestAndCheckIfNoErrors("@CategoryBulkDelete");
|
||||
getCategory(firstCategory.id).should("be.null");
|
||||
getCategory(secondCategory.id).should("be.null");
|
||||
});
|
||||
});
|
||||
|
||||
it("should be able to remove subcategory from category. TC: SALEOR_0208", () => {
|
||||
const subCategoryName = `${startsWith}${faker.datatype.number()}`;
|
||||
const mainCategoryName = `${startsWith}${faker.datatype.number()}`;
|
||||
let subCategory;
|
||||
let mainCategory;
|
||||
|
||||
createCategoryRequest({ name: mainCategoryName })
|
||||
.then(categoryResp => {
|
||||
mainCategory = categoryResp;
|
||||
createCategoryRequest({
|
||||
name: subCategoryName,
|
||||
parent: mainCategory.id
|
||||
});
|
||||
})
|
||||
.then(categoryResp => {
|
||||
subCategory = categoryResp;
|
||||
cy.visit(categoryDetailsUrl(mainCategory.id))
|
||||
.get(categoryRow(subCategory.id))
|
||||
.find(BUTTON_SELECTORS.checkbox)
|
||||
.click()
|
||||
.get(BUTTON_SELECTORS.deleteIcon)
|
||||
.click()
|
||||
.addAliasToGraphRequest("CategoryBulkDelete")
|
||||
.get(BUTTON_SELECTORS.submit)
|
||||
.click()
|
||||
.waitForRequestAndCheckIfNoErrors("@CategoryBulkDelete");
|
||||
getCategory(subCategory.id).should("be.null");
|
||||
getCategory(mainCategory.id);
|
||||
})
|
||||
.then(categoryResp => {
|
||||
expect(categoryResp.children.edges).to.be.empty;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -79,7 +79,7 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
|
|||
createAttribute({ name })
|
||||
.then(attributeResp => {
|
||||
attribute = attributeResp;
|
||||
createCategory(name);
|
||||
createCategory({ name });
|
||||
})
|
||||
.then(categoryResp => {
|
||||
category = categoryResp;
|
||||
|
|
|
@ -27,7 +27,9 @@ filterTests({ definedTags: ["all"], version: "3.0.0" }, () => {
|
|||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
deleteCategoriesStartsWith(startsWith);
|
||||
createCategory(name).then(categoryResp => (category = categoryResp));
|
||||
createCategory({ name: startsWith }).then(
|
||||
categoryResp => (category = categoryResp)
|
||||
);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -67,7 +67,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
const updatedName = `${startsWith}${faker.random.number()}`;
|
||||
let updatedCategory;
|
||||
let updatedCollection;
|
||||
createCategory(updatedName)
|
||||
createCategory({ name: updatedName })
|
||||
.then(categoryResp => {
|
||||
updatedCategory = categoryResp;
|
||||
createCollection(updatedName);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { getValueWithDefault } from "./utils/Utils";
|
||||
|
||||
export function createCategory(name, slug = name) {
|
||||
export function createCategory({ name, slug = name, parent }) {
|
||||
const parentLine = getValueWithDefault(parent, `parent:"${parent}"`);
|
||||
const mutation = `mutation{
|
||||
categoryCreate(input:{name:"${name}", slug: "${slug}"}){
|
||||
categoryCreate(input:{name:"${name}", slug: "${slug}"} ${parentLine}){
|
||||
productErrors{
|
||||
field
|
||||
message
|
||||
|
|
|
@ -93,7 +93,7 @@ export function createTypeAttributeAndCategoryForProduct({
|
|||
attributeId: attribute.id
|
||||
});
|
||||
}
|
||||
categoryRequest.createCategory(name);
|
||||
categoryRequest.createCategory({ name });
|
||||
})
|
||||
.then(categoryResp => {
|
||||
category = categoryResp;
|
||||
|
|
|
@ -21,5 +21,7 @@ Cypress.Commands.add("findElementOnTable", (elementName, alias) => {
|
|||
Cypress.Commands.add("searchInTable", query => {
|
||||
cy.get(SHARED_ELEMENTS.searchInput)
|
||||
.type(query)
|
||||
.get(SHARED_ELEMENTS.progressBar)
|
||||
.should("be.visible")
|
||||
.waitForProgressBarToNotExist();
|
||||
});
|
||||
|
|
|
@ -252,6 +252,7 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
|
|||
subcategories={mapEdgesToItems(data?.category?.children)}
|
||||
subcategoryListToolbar={
|
||||
<IconButton
|
||||
data-test-id="delete-icon"
|
||||
variant="secondary"
|
||||
color="primary"
|
||||
onClick={() =>
|
||||
|
|
|
@ -170,6 +170,7 @@ export const CategoryList: React.FC<CategoryListProps> = ({ params }) => {
|
|||
<IconButton
|
||||
variant="secondary"
|
||||
color="primary"
|
||||
data-test-id="delete-icon"
|
||||
onClick={() =>
|
||||
openModal("delete", {
|
||||
ids: listElements
|
||||
|
|
Loading…
Reference in a new issue