@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.
- package/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/components/datagrid/DataGridCellQuery.d.ts +9 -0
- package/dist/components/datagrid/DataGridCellQuery.js +3 -0
- package/dist/components/datagrid/DataGridCellQuery.js.map +1 -0
- package/dist/components/datagrid/DataGridDataRowDriver.d.ts +8 -0
- package/dist/components/datagrid/DataGridDataRowDriver.js +19 -0
- package/dist/components/datagrid/DataGridDataRowDriver.js.map +1 -0
- package/dist/components/datagrid/DataGridFooterDriver.d.ts +27 -0
- package/dist/components/datagrid/DataGridFooterDriver.js +69 -0
- package/dist/components/datagrid/DataGridFooterDriver.js.map +1 -0
- package/dist/components/datagrid/DataGridHeaderRowDriver.d.ts +9 -0
- package/dist/components/datagrid/DataGridHeaderRowDriver.js +33 -0
- package/dist/components/datagrid/DataGridHeaderRowDriver.js.map +1 -0
- package/dist/components/datagrid/DataGridPaginationActionDriver.d.ts +25 -0
- package/dist/components/datagrid/DataGridPaginationActionDriver.js +64 -0
- package/dist/components/datagrid/DataGridPaginationActionDriver.js.map +1 -0
- package/dist/components/datagrid/DataGridProDriver.d.ts +93 -0
- package/dist/components/datagrid/DataGridProDriver.js +227 -0
- package/dist/components/datagrid/DataGridProDriver.js.map +1 -0
- package/dist/components/datagrid/DataGridRowDriverBase.d.ts +23 -0
- package/dist/components/datagrid/DataGridRowDriverBase.js +107 -0
- package/dist/components/datagrid/DataGridRowDriverBase.js.map +1 -0
- package/dist/components/datagrid/index.d.ts +4 -0
- package/dist/components/datagrid/index.js +25 -0
- package/dist/components/datagrid/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
- package/src/components/datagrid/DataGridCellQuery.ts +11 -0
- package/src/components/datagrid/DataGridDataRowDriver.ts +23 -0
- package/src/components/datagrid/DataGridFooterDriver.ts +65 -0
- package/src/components/datagrid/DataGridHeaderRowDriver.ts +27 -0
- package/src/components/datagrid/DataGridPaginationActionDriver.ts +59 -0
- package/src/components/datagrid/DataGridProDriver.ts +207 -0
- package/src/components/datagrid/DataGridRowDriverBase.ts +72 -0
- package/src/components/datagrid/index.ts +4 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { HTMLElementDriver } from '@atomic-testing/component-driver-html';
|
|
2
|
+
import { byAttribute, ComponentDriver, listHelper, locatorUtil, PartLocator } from '@atomic-testing/core';
|
|
3
|
+
|
|
4
|
+
// In MUI7, there is an extra div preceding the actual data cells. We need to skip it.
|
|
5
|
+
const columnStartingIndex = 1;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base class for data grid row
|
|
9
|
+
*/
|
|
10
|
+
export abstract class DataGridRowDriverBase extends ComponentDriver {
|
|
11
|
+
protected async getCellCount(): Promise<number> {
|
|
12
|
+
let count = 0;
|
|
13
|
+
for await (const _ of listHelper.getListItemIterator(
|
|
14
|
+
this,
|
|
15
|
+
this.getCellLocator(),
|
|
16
|
+
HTMLElementDriver,
|
|
17
|
+
columnStartingIndex
|
|
18
|
+
)) {
|
|
19
|
+
count++;
|
|
20
|
+
}
|
|
21
|
+
return count;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the text of each visible cell in the row.
|
|
26
|
+
* Caveat: Because of virtualization, the text of the cell may not be available until the cell is visible.
|
|
27
|
+
* @returns A promise array of text of each visible cell in the row
|
|
28
|
+
*/
|
|
29
|
+
async getRowText(): Promise<string[]> {
|
|
30
|
+
const textList: string[] = [];
|
|
31
|
+
for await (const cell of listHelper.getListItemIterator(
|
|
32
|
+
this,
|
|
33
|
+
this.getCellLocator(),
|
|
34
|
+
HTMLElementDriver,
|
|
35
|
+
columnStartingIndex
|
|
36
|
+
)) {
|
|
37
|
+
const text = await cell.getText();
|
|
38
|
+
textList.push(text!.trim());
|
|
39
|
+
}
|
|
40
|
+
return textList;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the cell driver at the specified index or data field.
|
|
45
|
+
* Caveat: Because of virtualization, the cell may not be available until the cell is visible.
|
|
46
|
+
* @param cellIndexOrField number: column index, string: column field
|
|
47
|
+
* @param driverClass The driver class of the cell. Default is HTMLElementDriver
|
|
48
|
+
* @returns A promise of the cell driver, or null if the cell is not found
|
|
49
|
+
*/
|
|
50
|
+
async getCell<DriverT extends ComponentDriver>(
|
|
51
|
+
cellIndexOrField: number | string, // number: column index, string: column field
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
driverClass: typeof ComponentDriver = HTMLElementDriver
|
|
54
|
+
): Promise<DriverT | null> {
|
|
55
|
+
let cellLocator: PartLocator;
|
|
56
|
+
if (typeof cellIndexOrField === 'number') {
|
|
57
|
+
cellLocator = byAttribute('data-colindex', cellIndexOrField.toString());
|
|
58
|
+
} else {
|
|
59
|
+
cellLocator = byAttribute('data-field', cellIndexOrField);
|
|
60
|
+
}
|
|
61
|
+
const locator = locatorUtil.append(this.locator, cellLocator);
|
|
62
|
+
const cellExists = await this.interactor.exists(locator);
|
|
63
|
+
if (cellExists) {
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
return new driverClass(locator, this.interactor, this.commutableOption);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected abstract getCellLocator(): PartLocator;
|
|
72
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/datagrid';
|