@atomic-testing/component-driver-mui-x-v8 0.58.0

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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -0
  3. package/dist/components/datagrid/DataGridCellQuery.d.ts +9 -0
  4. package/dist/components/datagrid/DataGridCellQuery.js +3 -0
  5. package/dist/components/datagrid/DataGridCellQuery.js.map +1 -0
  6. package/dist/components/datagrid/DataGridDataRowDriver.d.ts +8 -0
  7. package/dist/components/datagrid/DataGridDataRowDriver.js +19 -0
  8. package/dist/components/datagrid/DataGridDataRowDriver.js.map +1 -0
  9. package/dist/components/datagrid/DataGridFooterDriver.d.ts +27 -0
  10. package/dist/components/datagrid/DataGridFooterDriver.js +69 -0
  11. package/dist/components/datagrid/DataGridFooterDriver.js.map +1 -0
  12. package/dist/components/datagrid/DataGridHeaderRowDriver.d.ts +9 -0
  13. package/dist/components/datagrid/DataGridHeaderRowDriver.js +33 -0
  14. package/dist/components/datagrid/DataGridHeaderRowDriver.js.map +1 -0
  15. package/dist/components/datagrid/DataGridPaginationActionDriver.d.ts +25 -0
  16. package/dist/components/datagrid/DataGridPaginationActionDriver.js +64 -0
  17. package/dist/components/datagrid/DataGridPaginationActionDriver.js.map +1 -0
  18. package/dist/components/datagrid/DataGridProDriver.d.ts +93 -0
  19. package/dist/components/datagrid/DataGridProDriver.js +227 -0
  20. package/dist/components/datagrid/DataGridProDriver.js.map +1 -0
  21. package/dist/components/datagrid/DataGridRowDriverBase.d.ts +23 -0
  22. package/dist/components/datagrid/DataGridRowDriverBase.js +107 -0
  23. package/dist/components/datagrid/DataGridRowDriverBase.js.map +1 -0
  24. package/dist/components/datagrid/index.d.ts +4 -0
  25. package/dist/components/datagrid/index.js +25 -0
  26. package/dist/components/datagrid/index.js.map +1 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +18 -0
  29. package/dist/index.js.map +1 -0
  30. package/package.json +48 -0
  31. package/src/components/datagrid/DataGridCellQuery.ts +11 -0
  32. package/src/components/datagrid/DataGridDataRowDriver.ts +23 -0
  33. package/src/components/datagrid/DataGridFooterDriver.ts +65 -0
  34. package/src/components/datagrid/DataGridHeaderRowDriver.ts +27 -0
  35. package/src/components/datagrid/DataGridPaginationActionDriver.ts +59 -0
  36. package/src/components/datagrid/DataGridProDriver.ts +207 -0
  37. package/src/components/datagrid/DataGridRowDriverBase.ts +72 -0
  38. package/src/components/datagrid/index.ts +4 -0
  39. package/src/index.ts +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGridProDriver.js","sourceRoot":"","sources":["../../../src/components/datagrid/DataGridProDriver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,iFAA0E;AAC1E,+CAY8B;AAG9B,iEAA8D;AAC9D,uEAAoE;AAEpE,MAAM,KAAK,GAAG;IACZ,SAAS,EAAE;QACT,OAAO,EAAE,IAAA,iBAAU,EAAC,2BAA2B,CAAC,CAAC,KAAK,CAAC,IAAA,oBAAa,EAAC,0BAA0B,CAAC,CAAC;QACjG,MAAM,EAAE,iDAAuB;KAChC;IACD,OAAO,EAAE;QACP,OAAO,EAAE,IAAA,aAAM,EAAC,aAAa,CAAC;QAC9B,MAAM,EAAE,yCAAiB;KAC1B;IACD,eAAe,EAAE;QACf,OAAO,EAAE,IAAA,iBAAU,EAAC,6CAA6C,CAAC;QAClE,MAAM,EAAE,yCAAiB;KAC1B;IACD,MAAM,EAAE;QACN,OAAO,EAAE,IAAA,iBAAU,EAAC,6BAA6B,CAAC;QAClD,MAAM,EAAE,2CAAoB;KAC7B;CACkB,CAAC;AAEtB,MAAM,cAAc,GAAG,IAAA,oBAAa,EAAC,2BAA2B,CAAC,CAAC;AAElE;;;;;GAKG;AACH,MAAa,iBAAkB,SAAQ,sBAA6B;IAClE,YAAY,OAAoB,EAAE,UAAsB,EAAE,MAAwC;QAChG,KAAK,CAAC,OAAO,EAAE,UAAU,kCACpB,MAA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Q,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACrC,CAAC;KAAA;IACD,mBAAmB;IAEnB,IAAa,UAAU;QACrB,OAAO,wBAAwB,CAAC;IAClC,CAAC;CACF;AAhKD,8CAgKC"}
@@ -0,0 +1,23 @@
1
+ import { ComponentDriver, PartLocator } from '@atomic-testing/core';
2
+ /**
3
+ * Base class for data grid row
4
+ */
5
+ export declare abstract class DataGridRowDriverBase extends ComponentDriver {
6
+ protected getCellCount(): Promise<number>;
7
+ /**
8
+ * Get the text of each visible cell in the row.
9
+ * Caveat: Because of virtualization, the text of the cell may not be available until the cell is visible.
10
+ * @returns A promise array of text of each visible cell in the row
11
+ */
12
+ getRowText(): Promise<string[]>;
13
+ /**
14
+ * Get the cell driver at the specified index or data field.
15
+ * Caveat: Because of virtualization, the cell may not be available until the cell is visible.
16
+ * @param cellIndexOrField number: column index, string: column field
17
+ * @param driverClass The driver class of the cell. Default is HTMLElementDriver
18
+ * @returns A promise of the cell driver, or null if the cell is not found
19
+ */
20
+ getCell<DriverT extends ComponentDriver>(cellIndexOrField: number | string, // number: column index, string: column field
21
+ driverClass?: typeof ComponentDriver): Promise<DriverT | null>;
22
+ protected abstract getCellLocator(): PartLocator;
23
+ }
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
12
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
+ var m = o[Symbol.asyncIterator], i;
14
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.DataGridRowDriverBase = void 0;
20
+ const component_driver_html_1 = require("@atomic-testing/component-driver-html");
21
+ const core_1 = require("@atomic-testing/core");
22
+ // In MUI7, there is an extra div preceding the actual data cells. We need to skip it.
23
+ const columnStartingIndex = 1;
24
+ /**
25
+ * Base class for data grid row
26
+ */
27
+ class DataGridRowDriverBase extends core_1.ComponentDriver {
28
+ getCellCount() {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ var _a, e_1, _b, _c;
31
+ let count = 0;
32
+ try {
33
+ for (var _d = true, _e = __asyncValues(core_1.listHelper.getListItemIterator(this, this.getCellLocator(), component_driver_html_1.HTMLElementDriver, columnStartingIndex)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
34
+ _c = _f.value;
35
+ _d = false;
36
+ const _ = _c;
37
+ count++;
38
+ }
39
+ }
40
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
41
+ finally {
42
+ try {
43
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
44
+ }
45
+ finally { if (e_1) throw e_1.error; }
46
+ }
47
+ return count;
48
+ });
49
+ }
50
+ /**
51
+ * Get the text of each visible cell in the row.
52
+ * Caveat: Because of virtualization, the text of the cell may not be available until the cell is visible.
53
+ * @returns A promise array of text of each visible cell in the row
54
+ */
55
+ getRowText() {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ var _a, e_2, _b, _c;
58
+ const textList = [];
59
+ try {
60
+ for (var _d = true, _e = __asyncValues(core_1.listHelper.getListItemIterator(this, this.getCellLocator(), component_driver_html_1.HTMLElementDriver, columnStartingIndex)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
61
+ _c = _f.value;
62
+ _d = false;
63
+ const cell = _c;
64
+ const text = yield cell.getText();
65
+ textList.push(text.trim());
66
+ }
67
+ }
68
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
69
+ finally {
70
+ try {
71
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
72
+ }
73
+ finally { if (e_2) throw e_2.error; }
74
+ }
75
+ return textList;
76
+ });
77
+ }
78
+ /**
79
+ * Get the cell driver at the specified index or data field.
80
+ * Caveat: Because of virtualization, the cell may not be available until the cell is visible.
81
+ * @param cellIndexOrField number: column index, string: column field
82
+ * @param driverClass The driver class of the cell. Default is HTMLElementDriver
83
+ * @returns A promise of the cell driver, or null if the cell is not found
84
+ */
85
+ getCell(cellIndexOrField_1) {
86
+ return __awaiter(this, arguments, void 0, function* (cellIndexOrField, // number: column index, string: column field
87
+ // @ts-ignore
88
+ driverClass = component_driver_html_1.HTMLElementDriver) {
89
+ let cellLocator;
90
+ if (typeof cellIndexOrField === 'number') {
91
+ cellLocator = (0, core_1.byAttribute)('data-colindex', cellIndexOrField.toString());
92
+ }
93
+ else {
94
+ cellLocator = (0, core_1.byAttribute)('data-field', cellIndexOrField);
95
+ }
96
+ const locator = core_1.locatorUtil.append(this.locator, cellLocator);
97
+ const cellExists = yield this.interactor.exists(locator);
98
+ if (cellExists) {
99
+ // @ts-ignore
100
+ return new driverClass(locator, this.interactor, this.commutableOption);
101
+ }
102
+ return null;
103
+ });
104
+ }
105
+ }
106
+ exports.DataGridRowDriverBase = DataGridRowDriverBase;
107
+ //# sourceMappingURL=DataGridRowDriverBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGridRowDriverBase.js","sourceRoot":"","s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,kBAAW,EAAC,eAAe,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,WAAW,GAAG,IAAA,kBAAW,EAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;YAC5D,CAAC;YACD,MAAM,OAAO,GAAG,kBAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC9D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACzD,IAAI,UAAU,EAAE,CAAC;gBACf,aAAa;gBACb,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC1E,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CAGF;AA9DD,sDA8DC"}
@@ -0,0 +1,4 @@
1
+ export * from './DataGridCellQuery';
2
+ export { DataGridDataRowDriver } from './DataGridDataRowDriver';
3
+ export { DataGridHeaderRowDriver } from './DataGridHeaderRowDriver';
4
+ export { DataGridProDriver } from './DataGridProDriver';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.DataGridProDriver = exports.DataGridHeaderRowDriver = exports.DataGridDataRowDriver = void 0;
18
+ __exportStar(require("./DataGridCellQuery"), exports);
19
+ var DataGridDataRowDriver_1 = require("./DataGridDataRowDriver");
20
+ Object.defineProperty(exports, "DataGridDataRowDriver", { enumerable: true, get: function () { return DataGridDataRowDriver_1.DataGridDataRowDriver; } });
21
+ var DataGridHeaderRowDriver_1 = require("./DataGridHeaderRowDriver");
22
+ Object.defineProperty(exports, "DataGridHeaderRowDriver", { enumerable: true, get: function () { return DataGridHeaderRowDriver_1.DataGridHeaderRowDriver; } });
23
+ var DataGridProDriver_1 = require("./DataGridProDriver");
24
+ Object.defineProperty(exports, "DataGridProDriver", { enumerable: true, get: function () { return DataGridProDriver_1.DataGridProDriver; } });
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/datagrid/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA"}
@@ -0,0 +1 @@
1
+ export * from './components/datagrid';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./components/datagrid"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@atomic-testing/component-driver-mui-x-v8",
3
+ "version": "0.58.0",
4
+ "description": "Atomic Testing Component driver to help drive Material UI X V8 components",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "src"
10
+ ],
11
+ "author": "Tianzhen Lin <tangent@usa.net>",
12
+ "keywords": [
13
+ "testing",
14
+ "react",
15
+ "unit",
16
+ "integration",
17
+ "mui",
18
+ "material-ui",
19
+ "v6",
20
+ "integration-driver"
21
+ ],
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/atomic-testing/atomic-testing.git",
26
+ "directory": "packages/component-driver-mui-x-v8"
27
+ },
28
+ "dependencies": {
29
+ "dayjs": "^1.11.13",
30
+ "@atomic-testing/core": "0.58.0",
31
+ "@atomic-testing/component-driver-mui-v6": "0.58.0",
32
+ "@atomic-testing/component-driver-html": "0.58.0"
33
+ },
34
+ "devDependencies": {
35
+ "@testing-library/dom": "^10.4.0",
36
+ "@testing-library/user-event": "^14.6.1",
37
+ "@types/jest": "^29.5.5",
38
+ "@types/node": "^22.15.30",
39
+ "jest": "^29.7.0",
40
+ "jest-environment-jsdom": "^29.7.0",
41
+ "typescript": "^5.8.3"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc",
45
+ "postbuild": "node ../../scripts/postBuild.mjs",
46
+ "test": "jest --maxConcurrency=1"
47
+ }
48
+ }
@@ -0,0 +1,11 @@
1
+ export interface CellQueryByColumnIndex {
2
+ rowIndex: number;
3
+ columnIndex: number;
4
+ }
5
+
6
+ export interface CellQueryByColumnField {
7
+ rowIndex: number;
8
+ columnField: string;
9
+ }
10
+
11
+ export type DataGridCellQuery = CellQueryByColumnIndex | CellQueryByColumnField;
@@ -0,0 +1,23 @@
1
+ import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';
2
+
3
+ import { DataGridRowDriverBase } from './DataGridRowDriverBase';
4
+
5
+ export class DataGridDataRowDriver extends DataGridRowDriverBase {
6
+ private readonly _dataCellLocator: PartLocator;
7
+ constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {
8
+ super(locator, interactor, {
9
+ ...option,
10
+ parts: {},
11
+ });
12
+
13
+ this._dataCellLocator = locatorUtil.append(locator, byRole('cell'));
14
+ }
15
+
16
+ protected override getCellLocator(): PartLocator {
17
+ return this._dataCellLocator;
18
+ }
19
+
20
+ override get driverName(): string {
21
+ return 'MuiV8DataGridDataRowDriver';
22
+ }
23
+ }
@@ -0,0 +1,65 @@
1
+ import { HTMLElementDriver } from '@atomic-testing/component-driver-html';
2
+ import {
3
+ byCssClass,
4
+ ComponentDriver,
5
+ IComponentDriverOption,
6
+ Interactor,
7
+ Optional,
8
+ PartLocator,
9
+ ScenePart,
10
+ } from '@atomic-testing/core';
11
+
12
+ import { DataGridPaginationActionDriver } from './DataGridPaginationActionDriver';
13
+
14
+ const parts = {
15
+ paginationAction: {
16
+ locator: byCssClass('MuiTablePagination-actions'),
17
+ driver: DataGridPaginationActionDriver,
18
+ },
19
+ paginationDescription: {
20
+ locator: byCssClass('MuiTablePagination-displayedRows'),
21
+ driver: HTMLElementDriver,
22
+ },
23
+ } satisfies ScenePart;
24
+
25
+ /**
26
+ * Driver for Material UI v6 DataGridPro component.
27
+ * @see https://mui.com/x/react-data-grid/
28
+ */
29
+ export class DataGridFooterDriver extends ComponentDriver<typeof parts> {
30
+ constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {
31
+ super(locator, interactor, {
32
+ ...option,
33
+ parts,
34
+ });
35
+ }
36
+
37
+ async isPreviousPageEnabled(): Promise<boolean> {
38
+ await this.enforcePartExistence('paginationAction');
39
+ return this.parts.paginationAction.isPreviousPageEnabled();
40
+ }
41
+
42
+ async gotoPreviousPage(): Promise<void> {
43
+ await this.enforcePartExistence('paginationAction');
44
+ await this.parts.paginationAction.gotoPreviousPage();
45
+ }
46
+
47
+ async isNextPageEnabled(): Promise<boolean> {
48
+ await this.enforcePartExistence('paginationAction');
49
+ return this.parts.paginationAction.isNextPageEnabled();
50
+ }
51
+
52
+ async gotoNextPage(): Promise<void> {
53
+ await this.enforcePartExistence('paginationAction');
54
+ await this.parts.paginationAction.gotoNextPage();
55
+ }
56
+
57
+ async getPaginationDescription(): Promise<Optional<string>> {
58
+ await this.enforcePartExistence('paginationDescription');
59
+ return this.parts.paginationDescription.getText();
60
+ }
61
+
62
+ override get driverName(): string {
63
+ return 'MuiV8DataGridFooterDriver';
64
+ }
65
+ }
@@ -0,0 +1,27 @@
1
+ import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';
2
+
3
+ import { DataGridRowDriverBase } from './DataGridRowDriverBase';
4
+
5
+ export class DataGridHeaderRowDriver extends DataGridRowDriverBase {
6
+ private readonly _headerCellLocator: PartLocator;
7
+ constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {
8
+ super(locator, interactor, {
9
+ ...option,
10
+ parts: {},
11
+ });
12
+
13
+ this._headerCellLocator = locatorUtil.append(locator, byRole('columnheader'));
14
+ }
15
+
16
+ async getColumnCount(): Promise<number> {
17
+ return this.getCellCount();
18
+ }
19
+
20
+ protected override getCellLocator(): PartLocator {
21
+ return this._headerCellLocator;
22
+ }
23
+
24
+ override get driverName(): string {
25
+ return 'MuiV8DataGridHeaderRowDriver';
26
+ }
27
+ }
@@ -0,0 +1,59 @@
1
+ import { HTMLButtonDriver } from '@atomic-testing/component-driver-html';
2
+ import {
3
+ byAttribute,
4
+ ComponentDriver,
5
+ IComponentDriverOption,
6
+ Interactor,
7
+ PartLocator,
8
+ ScenePart,
9
+ } from '@atomic-testing/core';
10
+
11
+ const parts = {
12
+ previousButton: {
13
+ locator: byAttribute('aria-label', 'Go to previous page'),
14
+ driver: HTMLButtonDriver,
15
+ },
16
+ nextButton: {
17
+ locator: byAttribute('aria-label', 'Go to next page'),
18
+ driver: HTMLButtonDriver,
19
+ },
20
+ } satisfies ScenePart;
21
+
22
+ /**
23
+ * Driver for Material UI v6 DataGridPro component.
24
+ * @see https://mui.com/x/react-data-grid/
25
+ */
26
+ export class DataGridPaginationActionDriver extends ComponentDriver<typeof parts> {
27
+ constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {
28
+ super(locator, interactor, {
29
+ ...option,
30
+ parts,
31
+ });
32
+ }
33
+
34
+ async isPreviousPageEnabled(): Promise<boolean> {
35
+ await this.enforcePartExistence('previousButton');
36
+ const isDisabled = await this.parts.previousButton.isDisabled();
37
+ return !isDisabled;
38
+ }
39
+
40
+ async gotoPreviousPage(): Promise<void> {
41
+ await this.enforcePartExistence('previousButton');
42
+ await this.parts.previousButton.click();
43
+ }
44
+
45
+ async isNextPageEnabled(): Promise<boolean> {
46
+ await this.enforcePartExistence('nextButton');
47
+ const isDisabled = await this.parts.nextButton.isDisabled();
48
+ return !isDisabled;
49
+ }
50
+
51
+ async gotoNextPage(): Promise<void> {
52
+ await this.enforcePartExistence('nextButton');
53
+ await this.parts.nextButton.click();
54
+ }
55
+
56
+ override get driverName(): string {
57
+ return 'MuiV8DataGridPaginationActionDriver';
58
+ }
59
+ }
@@ -0,0 +1,207 @@
1
+ import { HTMLElementDriver } from '@atomic-testing/component-driver-html';
2
+ import {
3
+ byCssClass,
4
+ byCssSelector,
5
+ byRole,
6
+ ComponentDriver,
7
+ IComponentDriverOption,
8
+ Interactor,
9
+ listHelper,
10
+ locatorUtil,
11
+ Optional,
12
+ PartLocator,
13
+ ScenePart,
14
+ } from '@atomic-testing/core';
15
+
16
+ import { DataGridCellQuery } from './DataGridCellQuery';
17
+ import { DataGridFooterDriver } from './DataGridFooterDriver';
18
+ import { DataGridHeaderRowDriver } from './DataGridHeaderRowDriver';
19
+
20
+ const parts = {
21
+ headerRow: {
22
+ locator: byCssClass('MuiDataGrid-columnHeaders').chain(byCssSelector('[role=row]:first-of-type')),
23
+ driver: DataGridHeaderRowDriver,
24
+ },
25
+ loading: {
26
+ locator: byRole('progressbar'),
27
+ driver: HTMLElementDriver,
28
+ },
29
+ skeletonOverlay: {
30
+ locator: byCssClass('MuiDataGrid-main--hasSkeletonLoadingOverlay'),
31
+ driver: HTMLElementDriver,
32
+ },
33
+ footer: {
34
+ locator: byCssClass('MuiDataGrid-footerContainer'),
35
+ driver: DataGridFooterDriver,
36
+ },
37
+ } satisfies ScenePart;
38
+
39
+ const dataRowLocator = byCssSelector('[role=row][data-rowindex]');
40
+
41
+ /**
42
+ * Driver for Material UI v8 DataGridPro component.
43
+ * V8 DataGridPro component does not support data-testid, to use data-testid
44
+ * to locate the component, you need to put the data-testid on the parent element of the grid
45
+ * @see https://mui.com/x/react-data-grid/
46
+ */
47
+ export class DataGridProDriver extends ComponentDriver<typeof parts> {
48
+ constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {
49
+ super(locator, interactor, {
50
+ ...option,
51
+ parts,
52
+ });
53
+ }
54
+
55
+ /**
56
+ * Checks if the data grid is currently loading.
57
+ * @returns A promise that resolves to a boolean indicating if the data grid is loading.
58
+ */
59
+ async isLoading(): Promise<boolean> {
60
+ const result = await Promise.all([this.parts.skeletonOverlay.isVisible(), this.parts.loading.isVisible()]);
61
+ return result.some(v => v);
62
+ }
63
+
64
+ /**
65
+ * Waits for the data grid to exit the loading state.
66
+ * @param timeoutMs The maximum time to wait for the load to complete, in milliseconds.
67
+ */
68
+ async waitForLoad(timeoutMs: number = 10000): Promise<void> {
69
+ await this.parts.headerRow.waitUntilComponentState();
70
+ await this.waitUntil({ probeFn: () => this.isLoading(), terminateCondition: false, timeoutMs });
71
+ }
72
+
73
+ /**
74
+ * The number of columns currently displayed in the data grid, note that data grid pro
75
+ * uses virtualize rendering, therefore the column count heavily depends on the viewport size
76
+ * @returns The number of columns currently displayed in the data grid
77
+ */
78
+ async getColumnCount(): Promise<number> {
79
+ return this.parts.headerRow.getColumnCount();
80
+ }
81
+
82
+ /**
83
+ * The array text of the header row, note that columns not shown in the viewport may not be included because of virtualize rendering
84
+ * @returns The array of text of the header row
85
+ */
86
+ async getHeaderText(): Promise<string[]> {
87
+ return this.parts.headerRow.getRowText();
88
+ }
89
+
90
+ /**
91
+ * The number of rows currently displayed in the data grid, note that data grid pro
92
+ * uses virtualize rendering, therefore the row count heavily depends on the viewport size
93
+ * @returns The number of columns currently displayed in the data grid
94
+ */
95
+ async getRowCount(): Promise<number> {
96
+ const gridRowLocator = locatorUtil.append(this.locator, dataRowLocator);
97
+ let count = 0;
98
+ for await (const _ of listHelper.getListItemIterator(this, gridRowLocator, HTMLElementDriver)) {
99
+ count++;
100
+ }
101
+ return count;
102
+ }
103
+
104
+ /**
105
+ * Return the row driver for the row at the specified index, if the row does not exist, return null
106
+ * @param rowIndex
107
+ * @returns
108
+ */
109
+ async getRow(rowIndex: number): Promise<DataGridHeaderRowDriver | null> {
110
+ const rowLocator = locatorUtil.append(this.locator, byCssSelector(`[role=row][data-rowindex="${rowIndex}"]`));
111
+ const rowExists = await this.interactor.exists(rowLocator);
112
+ if (rowExists) {
113
+ return new DataGridHeaderRowDriver(rowLocator, this.interactor, this.commutableOption);
114
+ }
115
+
116
+ return null;
117
+ }
118
+
119
+ /**
120
+ * The array text of the specified row, note that columns not shown in the viewport may not be included because of virtualize rendering
121
+ * @param rowIndex The index of the row
122
+ * @returns The array of text of the specified row
123
+ */
124
+ async getRowText(rowIndex: number): Promise<string[]> {
125
+ const row = await this.getRow(rowIndex);
126
+ if (row != null) {
127
+ return row.getRowText();
128
+ }
129
+ throw new Error(`Row ${rowIndex} does not exist`);
130
+ }
131
+
132
+ /**
133
+ * Get the cell driver for the cell, if the cell does not exist, return null
134
+ * The cell driver is default to HTMLElementDriver, you can specify a different driver class
135
+ * @param query The query to locate the cell
136
+ * @param driverClass Optional, the driver class to use for the cell, default to HTMLElementDriver
137
+ * @returns
138
+ */
139
+ async getCell<DriverT extends ComponentDriver>(
140
+ query: DataGridCellQuery,
141
+ // @ts-ignore
142
+ driverClass: typeof ComponentDriver = HTMLElementDriver
143
+ ): Promise<DriverT | null> {
144
+ const rowDriver = await this.getRow(query.rowIndex);
145
+
146
+ if (rowDriver === null) {
147
+ return null;
148
+ }
149
+
150
+ if ('columnIndex' in query) {
151
+ return rowDriver.getCell(query.columnIndex, driverClass);
152
+ }
153
+
154
+ return rowDriver.getCell(query.columnField, driverClass);
155
+ }
156
+
157
+ /**
158
+ * Get the text content of the cell, if the cell does not exist, throw an error
159
+ * @param query The query to locate the cell
160
+ * @returns
161
+ */
162
+ async getCellText(query: DataGridCellQuery): Promise<string> {
163
+ const cell = await this.getCell(query);
164
+ if (cell != null) {
165
+ const text = await cell.getText();
166
+ return text!;
167
+ }
168
+
169
+ //@ts-ignore
170
+ throw new Error(`Cell at row:${query.rowIndex} column:${query.columnIndex ?? query.columnField} does not exist`);
171
+ }
172
+
173
+ //#region Footer
174
+ isFooterVisible(): Promise<boolean> {
175
+ return this.parts.footer.isVisible();
176
+ }
177
+
178
+ async isPreviousPageEnabled(): Promise<boolean> {
179
+ await this.enforcePartExistence('footer');
180
+ return this.parts.footer.isPreviousPageEnabled();
181
+ }
182
+
183
+ async gotoPreviousPage(): Promise<void> {
184
+ await this.enforcePartExistence('footer');
185
+ await this.parts.footer.gotoPreviousPage();
186
+ }
187
+
188
+ async isNextPageEnabled(): Promise<boolean> {
189
+ await this.enforcePartExistence('footer');
190
+ return this.parts.footer.isNextPageEnabled();
191
+ }
192
+
193
+ async gotoNextPage(): Promise<void> {
194
+ await this.enforcePartExistence('footer');
195
+ await this.parts.footer.gotoNextPage();
196
+ }
197
+
198
+ async getPaginationDescription(): Promise<Optional<string>> {
199
+ await this.enforcePartExistence('footer');
200
+ return this.parts.footer.getText();
201
+ }
202
+ //#endregion Footer
203
+
204
+ override get driverName(): string {
205
+ return 'MuiV8DataGridProDriver';
206
+ }
207
+ }