@linzjs/step-ag-grid 7.11.0 → 7.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -1
- package/dist/index.js +39 -25
- package/dist/index.js.map +1 -1
- package/dist/step-ag-grid.esm.js +39 -25
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +6 -1
- package/src/utils/testUtil.ts +12 -8
package/README.md
CHANGED
|
@@ -41,6 +41,8 @@ Storybook demo deployed at: https://linz.github.io/step-ag-grid/
|
|
|
41
41
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
44
|
+
Check `src\stories` for more usage examples
|
|
45
|
+
|
|
44
46
|
```tsx
|
|
45
47
|
import "@linzjs/lui/dist/scss/base.scss";
|
|
46
48
|
import "@linzjs/lui/dist/fonts";
|
|
@@ -133,4 +135,49 @@ const GridDemo = () => {
|
|
|
133
135
|
};
|
|
134
136
|
```
|
|
135
137
|
|
|
136
|
-
|
|
138
|
+
## Writing tests
|
|
139
|
+
|
|
140
|
+
The following testing calls can be imported from step-ag-grid:
|
|
141
|
+
|
|
142
|
+
- findRow
|
|
143
|
+
- queryRow
|
|
144
|
+
- selectRow
|
|
145
|
+
- deselectRow
|
|
146
|
+
- findCell
|
|
147
|
+
- selectCell
|
|
148
|
+
- editCell
|
|
149
|
+
- findOpenMenu
|
|
150
|
+
- queryMenuOption
|
|
151
|
+
- findMenuOption
|
|
152
|
+
- clickMenuOption
|
|
153
|
+
- openAndClickMenuOption
|
|
154
|
+
- getMultiSelectOptions
|
|
155
|
+
- findMultiSelectOption
|
|
156
|
+
- clickMultiSelectOption
|
|
157
|
+
- typeOtherInput
|
|
158
|
+
- typeOtherTextArea
|
|
159
|
+
- closeMenu
|
|
160
|
+
- findActionButton
|
|
161
|
+
- clickActionButton
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import { render, screen } from "@testing-library/react";
|
|
165
|
+
import { waitFor } from "@testing-library/react";
|
|
166
|
+
import { findRow, GridUpdatingContextProvider, openAndClickMenuOption } from "@linzjs/step-ag-grid";
|
|
167
|
+
|
|
168
|
+
const TestComponent = (): JSX.Element => {
|
|
169
|
+
return (
|
|
170
|
+
<GridUpdatingContextProvider>
|
|
171
|
+
<MyGrid />
|
|
172
|
+
</GridUpdatingContextProvider>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
test("click Delete menu option removes row from the table", async () => {
|
|
177
|
+
await render(<TestComponent />);
|
|
178
|
+
await screen.findByText("My component header");
|
|
179
|
+
expect((await findRow(12345)).getAttribute("row-index")).toBe("1");
|
|
180
|
+
await openAndClickMenuOption(12345, "actions", "Delete");
|
|
181
|
+
await waitFor(async () => expect((await queryRow(12345)).not.toBeDefined());
|
|
182
|
+
});
|
|
183
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -2906,7 +2906,7 @@ var Grid = function (params) {
|
|
|
2906
2906
|
sizeColumnsToFit();
|
|
2907
2907
|
}
|
|
2908
2908
|
}, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
|
|
2909
|
-
return (jsxRuntime.jsxs("div", __assign({ "data-testid": params["data-testid"], className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale") }, { children: [params.quickFilter && (jsxRuntime.jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsxRuntime.jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
|
|
2909
|
+
return (jsxRuntime.jsxs("div", __assign({ "data-testid": params["data-testid"], className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale", gridReady && params.rowData && "Grid-ready") }, { children: [params.quickFilter && (jsxRuntime.jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsxRuntime.jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
|
|
2910
2910
|
setInternalQuickFilter(event.target.value);
|
|
2911
2911
|
} }) }))), jsxRuntime.jsx(agGridReact.AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, defaultColDef: params.defaultColDef, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: (_b = params.rowSelection) !== null && _b !== void 0 ? _b : "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_c = params.postSortRows) !== null && _c !== void 0 ? _c : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
|
|
2912
2912
|
};
|
|
@@ -24501,17 +24501,36 @@ var _selectRow = function (select, rowId, within) { return __awaiter(void 0, voi
|
|
|
24501
24501
|
return __generator(this, function (_a) {
|
|
24502
24502
|
switch (_a.label) {
|
|
24503
24503
|
case 0: return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
24504
|
-
var row, isSelected;
|
|
24504
|
+
var row, isSelected, cell;
|
|
24505
24505
|
return __generator(this, function (_a) {
|
|
24506
24506
|
switch (_a.label) {
|
|
24507
24507
|
case 0: return [4 /*yield*/, findRow(rowId, within)];
|
|
24508
24508
|
case 1:
|
|
24509
24509
|
row = _a.sent();
|
|
24510
|
-
isSelected =
|
|
24511
|
-
if (select === "toggle" || (select === "select" && !isSelected) || (select === "deselect" && isSelected))
|
|
24512
|
-
|
|
24513
|
-
|
|
24514
|
-
|
|
24510
|
+
isSelected = row.className.includes("ag-row-selected");
|
|
24511
|
+
if (!(select === "toggle" || (select === "select" && !isSelected) || (select === "deselect" && isSelected))) return [3 /*break*/, 4];
|
|
24512
|
+
return [4 /*yield*/, findCell(rowId, "selection", within)];
|
|
24513
|
+
case 2:
|
|
24514
|
+
cell = _a.sent();
|
|
24515
|
+
userEvent.click(cell);
|
|
24516
|
+
return [4 /*yield*/, waitForWrapper(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
24517
|
+
var row, nowSelected;
|
|
24518
|
+
return __generator(this, function (_a) {
|
|
24519
|
+
switch (_a.label) {
|
|
24520
|
+
case 0: return [4 /*yield*/, findRow(rowId, within)];
|
|
24521
|
+
case 1:
|
|
24522
|
+
row = _a.sent();
|
|
24523
|
+
nowSelected = row.className.includes("ag-row-selected");
|
|
24524
|
+
if (nowSelected == isSelected)
|
|
24525
|
+
throw "Row ".concat(rowId, " won't select");
|
|
24526
|
+
return [2 /*return*/];
|
|
24527
|
+
}
|
|
24528
|
+
});
|
|
24529
|
+
}); })];
|
|
24530
|
+
case 3:
|
|
24531
|
+
_a.sent();
|
|
24532
|
+
_a.label = 4;
|
|
24533
|
+
case 4: return [2 /*return*/];
|
|
24515
24534
|
}
|
|
24516
24535
|
});
|
|
24517
24536
|
}); })];
|
|
@@ -24596,7 +24615,7 @@ var editCell = function (rowId, colId, within) { return __awaiter(void 0, void 0
|
|
|
24596
24615
|
}); })];
|
|
24597
24616
|
case 1:
|
|
24598
24617
|
_a.sent();
|
|
24599
|
-
return [4 /*yield*/, findOpenMenu
|
|
24618
|
+
return [4 /*yield*/, waitForWrapper(findOpenMenu)];
|
|
24600
24619
|
case 2:
|
|
24601
24620
|
_a.sent();
|
|
24602
24621
|
return [2 /*return*/];
|
|
@@ -24638,27 +24657,25 @@ var findMenuOption = function (menuOptionText) { return __awaiter(void 0, void 0
|
|
|
24638
24657
|
return [2 /*return*/, menuOption];
|
|
24639
24658
|
}
|
|
24640
24659
|
});
|
|
24641
|
-
}); }, { timeout:
|
|
24660
|
+
}); }, { timeout: 5000 })];
|
|
24642
24661
|
case 1: return [2 /*return*/, _a.sent()];
|
|
24643
24662
|
}
|
|
24644
24663
|
});
|
|
24645
24664
|
}); };
|
|
24646
24665
|
var clickMenuOption = function (menuOptionText) { return __awaiter(void 0, void 0, void 0, function () {
|
|
24666
|
+
var menuOption;
|
|
24647
24667
|
return __generator(this, function (_a) {
|
|
24648
24668
|
switch (_a.label) {
|
|
24649
|
-
case 0: return [4 /*yield*/,
|
|
24650
|
-
var menuOption;
|
|
24651
|
-
return __generator(this, function (_a) {
|
|
24652
|
-
switch (_a.label) {
|
|
24653
|
-
case 0: return [4 /*yield*/, findMenuOption(menuOptionText)];
|
|
24654
|
-
case 1:
|
|
24655
|
-
menuOption = _a.sent();
|
|
24656
|
-
menuOption && userEvent.click(menuOption);
|
|
24657
|
-
return [2 /*return*/];
|
|
24658
|
-
}
|
|
24659
|
-
});
|
|
24660
|
-
}); })];
|
|
24669
|
+
case 0: return [4 /*yield*/, findMenuOption(menuOptionText)];
|
|
24661
24670
|
case 1:
|
|
24671
|
+
menuOption = _a.sent();
|
|
24672
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
24673
|
+
return __generator(this, function (_a) {
|
|
24674
|
+
userEvent.click(menuOption);
|
|
24675
|
+
return [2 /*return*/];
|
|
24676
|
+
});
|
|
24677
|
+
}); })];
|
|
24678
|
+
case 2:
|
|
24662
24679
|
_a.sent();
|
|
24663
24680
|
return [2 /*return*/];
|
|
24664
24681
|
}
|
|
@@ -24669,12 +24686,9 @@ var openAndClickMenuOption = function (rowId, colId, menuOptionText, within) { r
|
|
|
24669
24686
|
switch (_a.label) {
|
|
24670
24687
|
case 0: return [4 /*yield*/, editCell(rowId, colId, within)];
|
|
24671
24688
|
case 1:
|
|
24672
|
-
_a.sent();
|
|
24673
|
-
return [4 /*yield*/, wait$2(100)];
|
|
24674
|
-
case 2:
|
|
24675
24689
|
_a.sent();
|
|
24676
24690
|
return [4 /*yield*/, clickMenuOption(menuOptionText)];
|
|
24677
|
-
case
|
|
24691
|
+
case 2:
|
|
24678
24692
|
_a.sent();
|
|
24679
24693
|
return [2 /*return*/];
|
|
24680
24694
|
}
|