Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category listing datagrid #3760

Merged
merged 25 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f214d2a
Category list datagrid init
poulch Jun 13, 2023
4889a00
Handle selection and bulk delete
poulch Jun 14, 2023
584ea72
Add pagination
poulch Jun 14, 2023
ccb1eac
Use datagrid in category update page in subcategories list
poulch Jun 14, 2023
f49e4f1
Datagrid in category product list
poulch Jun 14, 2023
6849542
Update stories props
poulch Jun 14, 2023
338b252
Put delete button inside datagrid, fix datagrid anchor
poulch Jun 15, 2023
5daa1e4
Add column pickers
poulch Jun 15, 2023
23c98c4
Improve filter presets updating and deleting
poulch Jun 15, 2023
315d3a3
Refactor and move some logic to hooks
poulch Jun 15, 2023
9974c51
Refactor CategoryDetails page
poulch Jun 15, 2023
add813f
Remove props from story
poulch Jun 15, 2023
1dc2ba2
Fix loading state in storybook fro CategoryList page
poulch Jun 15, 2023
6ceadd8
Extract messages
poulch Jun 15, 2023
a37b7a6
Last improvments
poulch Jun 16, 2023
775d85c
Merge branch 'main' into 3755-category-listing-datagrid
poulch Jun 23, 2023
c0a9075
Add ts ignore comment
poulch Jun 23, 2023
dbf8c7f
Merge branch 'main' into 3755-category-listing-datagrid
poulch Jun 27, 2023
5960b73
Add changeset
poulch Jun 27, 2023
2231118
Change from patch to minor in changeset
poulch Jun 27, 2023
76d0a34
test - test scenarios update according to grid
wojteknowacki Jul 3, 2023
e53be45
Merge branch 'main' into 3755-category-listing-datagrid
poulch Jul 3, 2023
37a52de
Refactor to useFilterPresets
poulch Jul 3, 2023
6307aa9
Remove useTabs
poulch Jul 3, 2023
3797d06
Fix lint
poulch Jul 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strange-carrots-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

Introduce datagrid on category listing page
107 changes: 64 additions & 43 deletions cypress/e2e/catalog/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

import faker from "faker";

import {
CATEGORIES_LIST_SELECTORS,
categoryRow,
} from "../../elements/catalog/categories/categories-list";
import { CATEGORIES_LIST_SELECTORS } from "../../elements/catalog/categories/categories-list";
import { CATEGORY_DETAILS_SELECTORS } from "../../elements/catalog/categories/category-details";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
Expand All @@ -17,6 +14,7 @@ import {
} from "../../support/api/requests/Category";
import * as channelsUtils from "../../support/api/utils/channelsUtils";
import * as productsUtils from "../../support/api/utils/products/productsUtils";
import { ensureCanvasStatic } from "../../support/customCommands/sharedElementsOperations/canvas";
import {
createCategory,
updateCategory,
Expand Down Expand Up @@ -109,9 +107,13 @@ describe("As an admin I want to manage categories", () => {
.click();
createCategory({ name: categoryName, description: categoryName })
.visit(categoryDetailsUrl(category.id))
.contains(CATEGORY_DETAILS_SELECTORS.categoryChildrenRow, categoryName)
.scrollIntoView()
.should("be.visible");
.get(SHARED_ELEMENTS.dataGridTable)
.scrollIntoView();
ensureCanvasStatic(SHARED_ELEMENTS.dataGridTable);

cy.contains(SHARED_ELEMENTS.dataGridTable, categoryName).should(
"be.visible",
);
getCategory(category.id).then(categoryResp => {
expect(categoryResp.children.edges[0].node.name).to.eq(categoryName);
});
Expand All @@ -136,19 +138,22 @@ describe("As an admin I want to manage categories", () => {
"should be able to remove product from category. TC: SALEOR_0204",
{ tags: ["@category", "@allEnv", "@stable"] },
() => {
cy.addAliasToGraphRequest("productBulkDelete");
cy.visit(categoryDetailsUrl(category.id))
.get(CATEGORY_DETAILS_SELECTORS.productsTab)
.click();
cy.contains(CATEGORY_DETAILS_SELECTORS.productRow, product.name)
.find(BUTTON_SELECTORS.checkbox)
ensureCanvasStatic(SHARED_ELEMENTS.dataGridTable);
cy.contains(SHARED_ELEMENTS.dataGridTable, product.name).should(
"be.visible",
);
// selects first row
cy.clickGridCell(0, 0);
cy.get(CATEGORY_DETAILS_SELECTORS.deleteCategoriesButton)
.click()
.get(BUTTON_SELECTORS.deleteIcon)
.click()
.addAliasToGraphRequest("productBulkDelete")
.get(BUTTON_SELECTORS.submit)
.click()
.confirmationMessageShouldDisappear();
cy.contains(CATEGORY_DETAILS_SELECTORS.productRow, product.name)
cy.contains(SHARED_ELEMENTS.dataGridTable, product.name)
.should("not.exist")
.waitForRequestAndCheckIfNoErrors("@productBulkDelete");
getCategory(category.id).then(categoryResp => {
Expand All @@ -164,7 +169,12 @@ describe("As an admin I want to manage categories", () => {
cy.visit(urlList.categories)
.get(SHARED_ELEMENTS.searchInput)
.type(category.name);
cy.contains(SHARED_ELEMENTS.tableRow, category.name).click();
ensureCanvasStatic(SHARED_ELEMENTS.dataGridTable);
cy.contains(SHARED_ELEMENTS.dataGridTable, category.name).should(
"be.visible",
);
// opens first row details
cy.clickGridCell(1, 0);
cy.contains(SHARED_ELEMENTS.header, category.name).should("be.visible");
},
);
Expand All @@ -174,14 +184,14 @@ describe("As an admin I want to manage categories", () => {
{ tags: ["@category", "@allEnv", "@stable"] },
() => {
const categoryName = `${startsWith}${faker.datatype.number()}`;
cy.addAliasToGraphRequest("CategoryDelete");

createCategoryRequest({
name: categoryName,
}).then(categoryResp => {
cy.visit(categoryDetailsUrl(categoryResp.id))
.get(BUTTON_SELECTORS.deleteButton)
.click()
.addAliasToGraphRequest("CategoryDelete")
.get(BUTTON_SELECTORS.submit)
.click()
.waitForRequestAndCheckIfNoErrors("@CategoryDelete");
Expand Down Expand Up @@ -222,35 +232,43 @@ describe("As an admin I want to manage categories", () => {
() => {
const firstCategoryName = `${startsWith}${faker.datatype.number()}`;
const secondCategoryName = `${startsWith}${faker.datatype.number()}`;
let firstCategory;
let secondCategory;
cy.addAliasToGraphRequest("CategoryBulkDelete");

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");
cy.get(categoryRow(firstCategory.id)).should("not.exist");
cy.get(categoryRow(secondCategory.id)).should("not.exist");
}).then(() => {
cy.visit(urlList.categories).searchInTable(startsWith);
ensureCanvasStatic(SHARED_ELEMENTS.dataGridTable);
cy.get(SHARED_ELEMENTS.firstRowDataGrid)
.invoke("text")
.then(firstOnListCategoryName => {
cy.get(SHARED_ELEMENTS.secondRowDataGrid)
.invoke("text")
.then(secondOnListCategoryName => {
// deletes two first rows from categories list view
cy.clickGridCell(0, 0);
cy.clickGridCell(0, 1);

cy.get(CATEGORY_DETAILS_SELECTORS.deleteCategoriesButton)
.click()
.get(BUTTON_SELECTORS.submit)
.click()
.waitForRequestAndCheckIfNoErrors("@CategoryBulkDelete");
ensureCanvasStatic(SHARED_ELEMENTS.dataGridTable);

cy.contains(
SHARED_ELEMENTS.dataGridTable,
firstOnListCategoryName,
).should("not.exist");
cy.contains(
SHARED_ELEMENTS.dataGridTable,
secondOnListCategoryName,
).should("not.exist");
});
});
});
},
);
Expand All @@ -263,6 +281,7 @@ describe("As an admin I want to manage categories", () => {
const mainCategoryName = `${startsWith}${faker.datatype.number()}`;
let subCategory;
let mainCategory;
cy.addAliasToGraphRequest("CategoryBulkDelete");

createCategoryRequest({
name: mainCategoryName,
Expand All @@ -277,14 +296,16 @@ describe("As an admin I want to manage categories", () => {
.then(categoryResp => {
subCategory = categoryResp;
cy.visit(categoryDetailsUrl(mainCategory.id))
.get(categoryRow(subCategory.id))
.find(BUTTON_SELECTORS.checkbox)
.click()
.get(BUTTON_SELECTORS.deleteIcon)
.get(SHARED_ELEMENTS.dataGridTable)
.scrollIntoView();
ensureCanvasStatic(SHARED_ELEMENTS.dataGridTable);
// selects first row of subcategories
cy.clickGridCell(0, 0);
cy.get(CATEGORY_DETAILS_SELECTORS.deleteCategoriesButton)
.click()
.addAliasToGraphRequest("CategoryBulkDelete")
.get(BUTTON_SELECTORS.submit)
.click()
.confirmationMessageShouldDisappear()
.waitForRequestAndCheckIfNoErrors("@CategoryBulkDelete");
getCategory(subCategory.id).should("be.null");
getCategory(mainCategory.id);
Expand Down
1 change: 1 addition & 0 deletions cypress/elements/catalog/categories/category-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export const CATEGORY_DETAILS_SELECTORS = {
productsTab: '[data-test-id="products-tab"]',
addProducts: '[data-test-id="add-products"]',
productRow: '[data-test-id="product-row"]',
deleteCategoriesButton: '[data-test-id="delete-categories-button"]',
};
2 changes: 2 additions & 0 deletions cypress/elements/shared/sharedElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export const SHARED_ELEMENTS = {
dataGridTable: "[data-testid='data-grid-canvas']",
skeleton: '[data-test-id="skeleton"]',
table: 'table[class*="Table"]',
firstRowDataGrid: "[data-testid='glide-cell-1-0']",
secondRowDataGrid: "[id='glide-cell-1-1']",
tableRow: '[data-test-id*="id"], [class*="MuiTableRow"]',
notificationSuccess:
'[data-test-id="notification"][data-test-type="success"]',
Expand Down
9 changes: 4 additions & 5 deletions cypress/support/pages/catalog/categoriesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ export function updateCategory({ name, description }) {

export function fillUpCategoryGeneralInfo({ name, description }) {
return cy
.get(CATEGORY_DETAILS_SELECTORS.nameInput)
.clearAndType(name)
.get(CATEGORY_DETAILS_SELECTORS.descriptionInput)
.find(SHARED_ELEMENTS.contentEditable)
.should("be.visible")

.get(CATEGORY_DETAILS_SELECTORS.descriptionInput)
.click()
.get(CATEGORY_DETAILS_SELECTORS.descriptionInput)
.find(SHARED_ELEMENTS.contentEditable)
.get(CATEGORY_DETAILS_SELECTORS.descriptionInput)
.clearAndType(description)
.get(CATEGORY_DETAILS_SELECTORS.nameInput)
.clearAndType(name);
.clearAndType(description);
}

export function saveCategory(alias = "CategoryCreate") {
Expand Down
46 changes: 24 additions & 22 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@
"context": "product variants, title",
"string": "Variants"
},
"1X6HtI": {
"string": "All Categories"
},
"1div9r": {
"string": "Search Attribute"
},
Expand Down Expand Up @@ -1775,10 +1778,6 @@
"context": "webhooks and events section name",
"string": "Webhooks & Events"
},
"BHQrgz": {
"context": "number of subcategories",
"string": "Subcategories"
},
"BJtUQI": {
"context": "button",
"string": "Add"
Expand Down Expand Up @@ -2320,6 +2319,9 @@
"context": "Webhook details objects",
"string": "Objects"
},
"F7DxHw": {
"string": "Subcategories"
},
"F8gsds": {
"context": "unpublish page, button",
"string": "Unpublish"
Expand Down Expand Up @@ -3048,9 +3050,6 @@
"context": "dialog search placeholder",
"string": "Search by collection name, etc..."
},
"JiXNEV": {
"string": "Search Category"
},
"Jj0de8": {
"context": "voucher status",
"string": "Scheduled"
Expand Down Expand Up @@ -4291,6 +4290,9 @@
"context": "header",
"string": "Create Variant"
},
"T83iU7": {
"string": "Search categories..."
},
"T8rvXs": {
"context": "order subtotal price",
"string": "Subtotal"
Expand Down Expand Up @@ -4644,10 +4646,6 @@
"VOiUXQ": {
"string": "Used to calculate rates for shipping for products of this product type, when specific weight is not given"
},
"VQLIXd": {
"context": "product",
"string": "Name"
},
"VSj89H": {
"context": "fulfill button label",
"string": "Fulfill anyway"
Expand Down Expand Up @@ -5232,6 +5230,9 @@
"ZMy18J": {
"string": "You have reached your channel limit, you will be no longer able to add channels to your store. If you would like to up your limit, contact your administration staff about raising your limits."
},
"ZN5IZl": {
"string": "Bulk categories delete"
},
"ZPOyI1": {
"context": "fulfilled fulfillment, section header",
"string": "Fulfilled from {warehouseName}"
Expand Down Expand Up @@ -5650,6 +5651,9 @@
"context": "product attribute type",
"string": "Multiple Select"
},
"cLcy6F": {
"string": "Number of products"
},
"cMFlOp": {
"context": "input label",
"string": "New Password"
Expand Down Expand Up @@ -5750,6 +5754,9 @@
"context": "config type section title",
"string": "Configuration Type"
},
"cxOmce": {
"string": "Bulk products delete"
},
"cy8sV7": {
"context": "volume units types",
"string": "Volume"
Expand Down Expand Up @@ -6577,10 +6584,6 @@
"context": "tooltip content when product is in preorder",
"string": "This product is still in preorder. You will be able to fulfill it after it reaches it’s release date"
},
"k8ZJ5L": {
"context": "number of products",
"string": "No. of Products"
},
"k8bltk": {
"string": "No Results"
},
Expand Down Expand Up @@ -6682,6 +6685,9 @@
"context": "balance amound missing error message",
"string": "Balance amount is missing"
},
"kgVqk1": {
"string": "Category name"
},
"ki7Mr8": {
"context": "product export to csv file, header",
"string": "Export Settings"
Expand Down Expand Up @@ -7415,6 +7421,9 @@
"context": "order line total price",
"string": "Total"
},
"qU/z0Q": {
"string": "Bulk category delete"
},
"qZHHed": {
"context": "stock exceeded dialog title",
"string": "Not enough stock"
Expand Down Expand Up @@ -7584,9 +7593,6 @@
"context": "header",
"string": "Top Products"
},
"rrbzZt": {
"string": "No subcategories found"
},
"rs815i": {
"context": "text field label",
"string": "Group name"
Expand Down Expand Up @@ -8192,10 +8198,6 @@
"context": "draft order",
"string": "Created"
},
"vy7fjd": {
"context": "tab name",
"string": "All Categories"
},
"vzce9B": {
"context": "customer gift cards card subtitle",
"string": "Only five newest gift cards are shown here"
Expand Down
Loading