@atomic-testing/component-driver-mui-x-v8 0.80.0 → 0.81.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/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/components/datagrid/DataGridProDriver.ts +4 -4
- package/src/components/datagrid/DataGridRowDriverBase.ts +2 -4
package/dist/index.cjs
CHANGED
|
@@ -293,7 +293,8 @@ var DataGridProDriver = class extends _atomic_testing_core.ComponentDriver {
|
|
|
293
293
|
async getCellText(query) {
|
|
294
294
|
const cell = await this.getCell(query);
|
|
295
295
|
if (cell != null) return await cell.getText();
|
|
296
|
-
|
|
296
|
+
const columnIdentifier = "columnIndex" in query ? query.columnIndex : query.columnField;
|
|
297
|
+
throw new Error(`Cell at row:${query.rowIndex} column:${columnIdentifier} does not exist`);
|
|
297
298
|
}
|
|
298
299
|
/**
|
|
299
300
|
* Determine if the pagination footer is currently visible.
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["ComponentDriver","listHelper","HTMLElementDriver","textList: string[]","cellLocator: PartLocator","locatorUtil","locatorUtil","locatorUtil","parts","HTMLButtonDriver","ComponentDriver","parts","HTMLElementDriver","ComponentDriver","HTMLElementDriver","ComponentDriver","locatorUtil","listHelper"],"sources":["../src/components/datagrid/DataGridRowDriverBase.ts","../src/components/datagrid/DataGridDataRowDriver.ts","../src/components/datagrid/DataGridHeaderRowDriver.ts","../src/components/datagrid/DataGridPaginationActionDriver.ts","../src/components/datagrid/DataGridFooterDriver.ts","../src/components/datagrid/DataGridProDriver.ts"],"sourcesContent":["import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport { byAttribute, ComponentDriver, listHelper, locatorUtil, PartLocator } from '@atomic-testing/core';\n\n// In MUI7, there is an extra div preceding the actual data cells. We need to skip it.\nconst columnStartingIndex = 1;\n\n/**\n * Base class for data grid row\n */\nexport abstract class DataGridRowDriverBase extends ComponentDriver {\n protected async getCellCount(): Promise<number> {\n let count = 0;\n for await (const _ of listHelper.getListItemIterator(\n this,\n this.getCellLocator(),\n HTMLElementDriver,\n columnStartingIndex\n )) {\n count++;\n }\n return count;\n }\n\n /**\n * Get the text of each visible cell in the row.\n * Caveat: Because of virtualization, the text of the cell may not be available until the cell is visible.\n * @returns A promise array of text of each visible cell in the row\n */\n async getRowText(): Promise<string[]> {\n const textList: string[] = [];\n for await (const cell of listHelper.getListItemIterator(\n this,\n this.getCellLocator(),\n HTMLElementDriver,\n columnStartingIndex\n )) {\n const text = await cell.getText();\n textList.push(text!.trim());\n }\n return textList;\n }\n\n /**\n * Get the cell driver at the specified index or data field.\n * Caveat: Because of virtualization, the cell may not be available until the cell is visible.\n * @param cellIndexOrField number: column index, string: column field\n * @param driverClass The driver class of the cell. Default is HTMLElementDriver\n * @returns A promise of the cell driver, or null if the cell is not found\n */\n async getCell<DriverT extends ComponentDriver>(\n cellIndexOrField: number | string, // number: column index, string: column field\n // @ts-ignore\n driverClass: typeof ComponentDriver = HTMLElementDriver\n ): Promise<DriverT | null> {\n let cellLocator: PartLocator;\n if (typeof cellIndexOrField === 'number') {\n cellLocator = byAttribute('data-colindex', cellIndexOrField.toString());\n } else {\n cellLocator = byAttribute('data-field', cellIndexOrField);\n }\n const locator = locatorUtil.append(this.locator, cellLocator);\n const cellExists = await this.interactor.exists(locator);\n if (cellExists) {\n // @ts-ignore\n return new driverClass(locator, this.interactor, this.commutableOption);\n }\n\n return null;\n }\n\n protected abstract getCellLocator(): PartLocator;\n}\n","import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';\n\nimport { DataGridRowDriverBase } from './DataGridRowDriverBase';\n\nexport class DataGridDataRowDriver extends DataGridRowDriverBase {\n private readonly _dataCellLocator: PartLocator;\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts: {},\n });\n\n this._dataCellLocator = locatorUtil.append(locator, byRole('cell'));\n }\n\n protected override getCellLocator(): PartLocator {\n return this._dataCellLocator;\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridDataRowDriver';\n }\n}\n","import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';\n\nimport { DataGridRowDriverBase } from './DataGridRowDriverBase';\n\nexport class DataGridHeaderRowDriver extends DataGridRowDriverBase {\n private readonly _headerCellLocator: PartLocator;\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts: {},\n });\n\n this._headerCellLocator = locatorUtil.append(locator, byRole('columnheader'));\n }\n\n async getColumnCount(): Promise<number> {\n return this.getCellCount();\n }\n\n protected override getCellLocator(): PartLocator {\n return this._headerCellLocator;\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridHeaderRowDriver';\n }\n}\n","import { HTMLButtonDriver } from '@atomic-testing/component-driver-html';\nimport {\n byAttribute,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nconst parts = {\n previousButton: {\n locator: byAttribute('aria-label', 'Go to previous page'),\n driver: HTMLButtonDriver,\n },\n nextButton: {\n locator: byAttribute('aria-label', 'Go to next page'),\n driver: HTMLButtonDriver,\n },\n} satisfies ScenePart;\n\n/**\n * Driver for Material UI v6 DataGridPro component.\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridPaginationActionDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('previousButton');\n const isDisabled = await this.parts.previousButton.isDisabled();\n return !isDisabled;\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('previousButton');\n await this.parts.previousButton.click();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('nextButton');\n const isDisabled = await this.parts.nextButton.isDisabled();\n return !isDisabled;\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('nextButton');\n await this.parts.nextButton.click();\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridPaginationActionDriver';\n }\n}\n","import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport {\n byCssClass,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n Optional,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nimport { DataGridPaginationActionDriver } from './DataGridPaginationActionDriver';\n\nconst parts = {\n paginationAction: {\n locator: byCssClass('MuiTablePagination-actions'),\n driver: DataGridPaginationActionDriver,\n },\n paginationDescription: {\n locator: byCssClass('MuiTablePagination-displayedRows'),\n driver: HTMLElementDriver,\n },\n} satisfies ScenePart;\n\n/**\n * Driver for Material UI v6 DataGridPro component.\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridFooterDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('paginationAction');\n return this.parts.paginationAction.isPreviousPageEnabled();\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('paginationAction');\n await this.parts.paginationAction.gotoPreviousPage();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('paginationAction');\n return this.parts.paginationAction.isNextPageEnabled();\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('paginationAction');\n await this.parts.paginationAction.gotoNextPage();\n }\n\n async getPaginationDescription(): Promise<Optional<string>> {\n await this.enforcePartExistence('paginationDescription');\n return this.parts.paginationDescription.getText();\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridFooterDriver';\n }\n}\n","import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport {\n byCssClass,\n byCssSelector,\n byRole,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n listHelper,\n locatorUtil,\n Optional,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nimport { DataGridCellQuery } from './DataGridCellQuery';\nimport { DataGridFooterDriver } from './DataGridFooterDriver';\nimport { DataGridHeaderRowDriver } from './DataGridHeaderRowDriver';\n\nconst parts = {\n headerRow: {\n locator: byCssClass('MuiDataGrid-columnHeaders').chain(byCssSelector('[role=row]:first-of-type')),\n driver: DataGridHeaderRowDriver,\n },\n loading: {\n locator: byRole('progressbar'),\n driver: HTMLElementDriver,\n },\n skeletonOverlay: {\n locator: byCssClass('MuiDataGrid-main--hasSkeletonLoadingOverlay'),\n driver: HTMLElementDriver,\n },\n footer: {\n locator: byCssClass('MuiDataGrid-footerContainer'),\n driver: DataGridFooterDriver,\n },\n} satisfies ScenePart;\n\nconst dataRowLocator = byCssSelector('[role=row][data-rowindex]');\n\n/**\n * Driver for Material UI v8 DataGridPro component.\n * V8 DataGridPro component does not support data-testid, to use data-testid\n * to locate the component, you need to put the data-testid on the parent element of the grid\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridProDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n /**\n * Checks if the data grid is currently loading.\n * @returns A promise that resolves to a boolean indicating if the data grid is loading.\n */\n async isLoading(): Promise<boolean> {\n const result = await Promise.all([this.parts.skeletonOverlay.isVisible(), this.parts.loading.isVisible()]);\n return result.some(v => v);\n }\n\n /**\n * Waits for the data grid to exit the loading state.\n * @param timeoutMs The maximum time to wait for the load to complete, in milliseconds.\n */\n async waitForLoad(timeoutMs: number = 10000): Promise<void> {\n await this.parts.headerRow.waitUntilComponentState();\n await this.waitUntil({ probeFn: () => this.isLoading(), terminateCondition: false, timeoutMs });\n }\n\n /**\n * The number of columns currently displayed in the data grid, note that data grid pro\n * uses virtualize rendering, therefore the column count heavily depends on the viewport size\n * @returns The number of columns currently displayed in the data grid\n */\n async getColumnCount(): Promise<number> {\n return this.parts.headerRow.getColumnCount();\n }\n\n /**\n * The array text of the header row, note that columns not shown in the viewport may not be included because of virtualize rendering\n * @returns The array of text of the header row\n */\n async getHeaderText(): Promise<string[]> {\n return this.parts.headerRow.getRowText();\n }\n\n /**\n * The number of rows currently displayed in the data grid, note that data grid pro\n * uses virtualize rendering, therefore the row count heavily depends on the viewport size\n * @returns The number of columns currently displayed in the data grid\n */\n async getRowCount(): Promise<number> {\n const gridRowLocator = locatorUtil.append(this.locator, dataRowLocator);\n let count = 0;\n for await (const _ of listHelper.getListItemIterator(this, gridRowLocator, HTMLElementDriver)) {\n count++;\n }\n return count;\n }\n\n /**\n * Return the row driver for the row at the specified index, if the row does not exist, return null\n * @param rowIndex\n * @returns\n */\n async getRow(rowIndex: number): Promise<DataGridHeaderRowDriver | null> {\n const rowLocator = locatorUtil.append(this.locator, byCssSelector(`[role=row][data-rowindex=\"${rowIndex}\"]`));\n const rowExists = await this.interactor.exists(rowLocator);\n if (rowExists) {\n return new DataGridHeaderRowDriver(rowLocator, this.interactor, this.commutableOption);\n }\n\n return null;\n }\n\n /**\n * The array text of the specified row, note that columns not shown in the viewport may not be included because of virtualize rendering\n * @param rowIndex The index of the row\n * @returns The array of text of the specified row\n */\n async getRowText(rowIndex: number): Promise<string[]> {\n const row = await this.getRow(rowIndex);\n if (row != null) {\n return row.getRowText();\n }\n throw new Error(`Row ${rowIndex} does not exist`);\n }\n\n /**\n * Get the cell driver for the cell, if the cell does not exist, return null\n * The cell driver is default to HTMLElementDriver, you can specify a different driver class\n * @param query The query to locate the cell\n * @param driverClass Optional, the driver class to use for the cell, default to HTMLElementDriver\n * @returns\n */\n async getCell<DriverT extends ComponentDriver>(\n query: DataGridCellQuery,\n // @ts-ignore\n driverClass: typeof ComponentDriver = HTMLElementDriver\n ): Promise<DriverT | null> {\n const rowDriver = await this.getRow(query.rowIndex);\n\n if (rowDriver === null) {\n return null;\n }\n\n if ('columnIndex' in query) {\n return rowDriver.getCell(query.columnIndex, driverClass);\n }\n\n return rowDriver.getCell(query.columnField, driverClass);\n }\n\n /**\n * Get the text content of the cell, if the cell does not exist, throw an error\n * @param query The query to locate the cell\n * @returns\n */\n async getCellText(query: DataGridCellQuery): Promise<string> {\n const cell = await this.getCell(query);\n if (cell != null) {\n const text = await cell.getText();\n return text!;\n }\n\n //@ts-ignore\n throw new Error(`Cell at row:${query.rowIndex} column:${query.columnIndex ?? query.columnField} does not exist`);\n }\n\n //#region Footer\n /**\n * Determine if the pagination footer is currently visible.\n */\n isFooterVisible(): Promise<boolean> {\n return this.parts.footer.isVisible();\n }\n\n /**\n * Check whether the \"previous page\" control is enabled.\n */\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isPreviousPageEnabled();\n }\n\n /**\n * Navigate to the previous page using the grid footer control.\n */\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoPreviousPage();\n }\n\n /**\n * Check whether the \"next page\" control is enabled.\n */\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isNextPageEnabled();\n }\n\n /**\n * Navigate to the next page using the grid footer control.\n */\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoNextPage();\n }\n\n /**\n * Read the textual description of the current pagination state.\n */\n async getPaginationDescription(): Promise<Optional<string>> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.getText();\n }\n //#endregion Footer\n\n override get driverName(): string {\n return 'MuiV8DataGridProDriver';\n }\n}\n"],"mappings":";;;;AAIA,MAAM,sBAAsB;;;;AAK5B,IAAsB,wBAAt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,kBAAkB;;;;;CAM5C,MAAM,oBAAsC;AAC1C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,mBAAmB;;;;;CAM9C,MAAM,eAA8B;AAClC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,cAAc;;;;;CAMxC,MAAM,2BAAsD;AAC1D,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,SAAS;;CAIpC,IAAa,aAAqB;AAChC,SAAO"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["ComponentDriver","listHelper","HTMLElementDriver","textList: string[]","cellLocator: PartLocator","locatorUtil","locatorUtil","locatorUtil","parts","HTMLButtonDriver","ComponentDriver","parts","HTMLElementDriver","ComponentDriver","HTMLElementDriver","ComponentDriver","locatorUtil","listHelper"],"sources":["../src/components/datagrid/DataGridRowDriverBase.ts","../src/components/datagrid/DataGridDataRowDriver.ts","../src/components/datagrid/DataGridHeaderRowDriver.ts","../src/components/datagrid/DataGridPaginationActionDriver.ts","../src/components/datagrid/DataGridFooterDriver.ts","../src/components/datagrid/DataGridProDriver.ts"],"sourcesContent":["import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport { byAttribute, ComponentDriver, ComponentDriverCtor, listHelper, locatorUtil, PartLocator } from '@atomic-testing/core';\n\n// In MUI7, there is an extra div preceding the actual data cells. We need to skip it.\nconst columnStartingIndex = 1;\n\n/**\n * Base class for data grid row\n */\nexport abstract class DataGridRowDriverBase extends ComponentDriver {\n protected async getCellCount(): Promise<number> {\n let count = 0;\n for await (const _ of listHelper.getListItemIterator(\n this,\n this.getCellLocator(),\n HTMLElementDriver,\n columnStartingIndex\n )) {\n count++;\n }\n return count;\n }\n\n /**\n * Get the text of each visible cell in the row.\n * Caveat: Because of virtualization, the text of the cell may not be available until the cell is visible.\n * @returns A promise array of text of each visible cell in the row\n */\n async getRowText(): Promise<string[]> {\n const textList: string[] = [];\n for await (const cell of listHelper.getListItemIterator(\n this,\n this.getCellLocator(),\n HTMLElementDriver,\n columnStartingIndex\n )) {\n const text = await cell.getText();\n textList.push(text!.trim());\n }\n return textList;\n }\n\n /**\n * Get the cell driver at the specified index or data field.\n * Caveat: Because of virtualization, the cell may not be available until the cell is visible.\n * @param cellIndexOrField number: column index, string: column field\n * @param driverClass The driver class of the cell. Default is HTMLElementDriver\n * @returns A promise of the cell driver, or null if the cell is not found\n */\n async getCell<DriverT extends ComponentDriver>(\n cellIndexOrField: number | string, // number: column index, string: column field\n driverClass: ComponentDriverCtor<DriverT> = HTMLElementDriver as ComponentDriverCtor<DriverT>\n ): Promise<DriverT | null> {\n let cellLocator: PartLocator;\n if (typeof cellIndexOrField === 'number') {\n cellLocator = byAttribute('data-colindex', cellIndexOrField.toString());\n } else {\n cellLocator = byAttribute('data-field', cellIndexOrField);\n }\n const locator = locatorUtil.append(this.locator, cellLocator);\n const cellExists = await this.interactor.exists(locator);\n if (cellExists) {\n return new driverClass(locator, this.interactor, this.commutableOption);\n }\n\n return null;\n }\n\n protected abstract getCellLocator(): PartLocator;\n}\n","import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';\n\nimport { DataGridRowDriverBase } from './DataGridRowDriverBase';\n\nexport class DataGridDataRowDriver extends DataGridRowDriverBase {\n private readonly _dataCellLocator: PartLocator;\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts: {},\n });\n\n this._dataCellLocator = locatorUtil.append(locator, byRole('cell'));\n }\n\n protected override getCellLocator(): PartLocator {\n return this._dataCellLocator;\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridDataRowDriver';\n }\n}\n","import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';\n\nimport { DataGridRowDriverBase } from './DataGridRowDriverBase';\n\nexport class DataGridHeaderRowDriver extends DataGridRowDriverBase {\n private readonly _headerCellLocator: PartLocator;\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts: {},\n });\n\n this._headerCellLocator = locatorUtil.append(locator, byRole('columnheader'));\n }\n\n async getColumnCount(): Promise<number> {\n return this.getCellCount();\n }\n\n protected override getCellLocator(): PartLocator {\n return this._headerCellLocator;\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridHeaderRowDriver';\n }\n}\n","import { HTMLButtonDriver } from '@atomic-testing/component-driver-html';\nimport {\n byAttribute,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nconst parts = {\n previousButton: {\n locator: byAttribute('aria-label', 'Go to previous page'),\n driver: HTMLButtonDriver,\n },\n nextButton: {\n locator: byAttribute('aria-label', 'Go to next page'),\n driver: HTMLButtonDriver,\n },\n} satisfies ScenePart;\n\n/**\n * Driver for Material UI v6 DataGridPro component.\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridPaginationActionDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('previousButton');\n const isDisabled = await this.parts.previousButton.isDisabled();\n return !isDisabled;\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('previousButton');\n await this.parts.previousButton.click();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('nextButton');\n const isDisabled = await this.parts.nextButton.isDisabled();\n return !isDisabled;\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('nextButton');\n await this.parts.nextButton.click();\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridPaginationActionDriver';\n }\n}\n","import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport {\n byCssClass,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n Optional,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nimport { DataGridPaginationActionDriver } from './DataGridPaginationActionDriver';\n\nconst parts = {\n paginationAction: {\n locator: byCssClass('MuiTablePagination-actions'),\n driver: DataGridPaginationActionDriver,\n },\n paginationDescription: {\n locator: byCssClass('MuiTablePagination-displayedRows'),\n driver: HTMLElementDriver,\n },\n} satisfies ScenePart;\n\n/**\n * Driver for Material UI v6 DataGridPro component.\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridFooterDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('paginationAction');\n return this.parts.paginationAction.isPreviousPageEnabled();\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('paginationAction');\n await this.parts.paginationAction.gotoPreviousPage();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('paginationAction');\n return this.parts.paginationAction.isNextPageEnabled();\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('paginationAction');\n await this.parts.paginationAction.gotoNextPage();\n }\n\n async getPaginationDescription(): Promise<Optional<string>> {\n await this.enforcePartExistence('paginationDescription');\n return this.parts.paginationDescription.getText();\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridFooterDriver';\n }\n}\n","import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport {\n byCssClass,\n byCssSelector,\n byRole,\n ComponentDriver,\n ComponentDriverCtor,\n IComponentDriverOption,\n Interactor,\n listHelper,\n locatorUtil,\n Optional,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nimport { DataGridCellQuery } from './DataGridCellQuery';\nimport { DataGridFooterDriver } from './DataGridFooterDriver';\nimport { DataGridHeaderRowDriver } from './DataGridHeaderRowDriver';\n\nconst parts = {\n headerRow: {\n locator: byCssClass('MuiDataGrid-columnHeaders').chain(byCssSelector('[role=row]:first-of-type')),\n driver: DataGridHeaderRowDriver,\n },\n loading: {\n locator: byRole('progressbar'),\n driver: HTMLElementDriver,\n },\n skeletonOverlay: {\n locator: byCssClass('MuiDataGrid-main--hasSkeletonLoadingOverlay'),\n driver: HTMLElementDriver,\n },\n footer: {\n locator: byCssClass('MuiDataGrid-footerContainer'),\n driver: DataGridFooterDriver,\n },\n} satisfies ScenePart;\n\nconst dataRowLocator = byCssSelector('[role=row][data-rowindex]');\n\n/**\n * Driver for Material UI v8 DataGridPro component.\n * V8 DataGridPro component does not support data-testid, to use data-testid\n * to locate the component, you need to put the data-testid on the parent element of the grid\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridProDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n /**\n * Checks if the data grid is currently loading.\n * @returns A promise that resolves to a boolean indicating if the data grid is loading.\n */\n async isLoading(): Promise<boolean> {\n const result = await Promise.all([this.parts.skeletonOverlay.isVisible(), this.parts.loading.isVisible()]);\n return result.some(v => v);\n }\n\n /**\n * Waits for the data grid to exit the loading state.\n * @param timeoutMs The maximum time to wait for the load to complete, in milliseconds.\n */\n async waitForLoad(timeoutMs: number = 10000): Promise<void> {\n await this.parts.headerRow.waitUntilComponentState();\n await this.waitUntil({ probeFn: () => this.isLoading(), terminateCondition: false, timeoutMs });\n }\n\n /**\n * The number of columns currently displayed in the data grid, note that data grid pro\n * uses virtualize rendering, therefore the column count heavily depends on the viewport size\n * @returns The number of columns currently displayed in the data grid\n */\n async getColumnCount(): Promise<number> {\n return this.parts.headerRow.getColumnCount();\n }\n\n /**\n * The array text of the header row, note that columns not shown in the viewport may not be included because of virtualize rendering\n * @returns The array of text of the header row\n */\n async getHeaderText(): Promise<string[]> {\n return this.parts.headerRow.getRowText();\n }\n\n /**\n * The number of rows currently displayed in the data grid, note that data grid pro\n * uses virtualize rendering, therefore the row count heavily depends on the viewport size\n * @returns The number of columns currently displayed in the data grid\n */\n async getRowCount(): Promise<number> {\n const gridRowLocator = locatorUtil.append(this.locator, dataRowLocator);\n let count = 0;\n for await (const _ of listHelper.getListItemIterator(this, gridRowLocator, HTMLElementDriver)) {\n count++;\n }\n return count;\n }\n\n /**\n * Return the row driver for the row at the specified index, if the row does not exist, return null\n * @param rowIndex\n * @returns\n */\n async getRow(rowIndex: number): Promise<DataGridHeaderRowDriver | null> {\n const rowLocator = locatorUtil.append(this.locator, byCssSelector(`[role=row][data-rowindex=\"${rowIndex}\"]`));\n const rowExists = await this.interactor.exists(rowLocator);\n if (rowExists) {\n return new DataGridHeaderRowDriver(rowLocator, this.interactor, this.commutableOption);\n }\n\n return null;\n }\n\n /**\n * The array text of the specified row, note that columns not shown in the viewport may not be included because of virtualize rendering\n * @param rowIndex The index of the row\n * @returns The array of text of the specified row\n */\n async getRowText(rowIndex: number): Promise<string[]> {\n const row = await this.getRow(rowIndex);\n if (row != null) {\n return row.getRowText();\n }\n throw new Error(`Row ${rowIndex} does not exist`);\n }\n\n /**\n * Get the cell driver for the cell, if the cell does not exist, return null\n * The cell driver is default to HTMLElementDriver, you can specify a different driver class\n * @param query The query to locate the cell\n * @param driverClass Optional, the driver class to use for the cell, default to HTMLElementDriver\n * @returns\n */\n async getCell<DriverT extends ComponentDriver>(\n query: DataGridCellQuery,\n driverClass: ComponentDriverCtor<DriverT> = HTMLElementDriver as ComponentDriverCtor<DriverT>\n ): Promise<DriverT | null> {\n const rowDriver = await this.getRow(query.rowIndex);\n\n if (rowDriver === null) {\n return null;\n }\n\n if ('columnIndex' in query) {\n return rowDriver.getCell(query.columnIndex, driverClass);\n }\n\n return rowDriver.getCell(query.columnField, driverClass);\n }\n\n /**\n * Get the text content of the cell, if the cell does not exist, throw an error\n * @param query The query to locate the cell\n * @returns\n */\n async getCellText(query: DataGridCellQuery): Promise<string> {\n const cell = await this.getCell(query);\n if (cell != null) {\n const text = await cell.getText();\n return text!;\n }\n\n const columnIdentifier = 'columnIndex' in query ? query.columnIndex : query.columnField;\n throw new Error(`Cell at row:${query.rowIndex} column:${columnIdentifier} does not exist`);\n }\n\n //#region Footer\n /**\n * Determine if the pagination footer is currently visible.\n */\n isFooterVisible(): Promise<boolean> {\n return this.parts.footer.isVisible();\n }\n\n /**\n * Check whether the \"previous page\" control is enabled.\n */\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isPreviousPageEnabled();\n }\n\n /**\n * Navigate to the previous page using the grid footer control.\n */\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoPreviousPage();\n }\n\n /**\n * Check whether the \"next page\" control is enabled.\n */\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isNextPageEnabled();\n }\n\n /**\n * Navigate to the next page using the grid footer control.\n */\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoNextPage();\n }\n\n /**\n * Read the textual description of the current pagination state.\n */\n async getPaginationDescription(): Promise<Optional<string>> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.getText();\n }\n //#endregion Footer\n\n override get driverName(): string {\n return 'MuiV8DataGridProDriver';\n }\n}\n"],"mappings":";;;;AAIA,MAAM,sBAAsB;;;;AAK5B,IAAsB,wBAAtB,cAAoDA,qCAAgB;CAClE,MAAgB,eAAgC;EAC9C,IAAI,QAAQ;AACZ,aAAW,MAAM,KAAKC,gCAAW,oBAC/B,MACA,KAAK,gBAAgB,EACrBC,yDACA,oBACD,CACC;AAEF,SAAO;;;;;;;CAQT,MAAM,aAAgC;EACpC,MAAMC,WAAqB,EAAE;AAC7B,aAAW,MAAM,QAAQF,gCAAW,oBAClC,MACA,KAAK,gBAAgB,EACrBC,yDACA,oBACD,EAAE;GACD,MAAM,OAAO,MAAM,KAAK,SAAS;AACjC,YAA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AIpC,IAAa,aAAqB;AAChC,SAAO"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _atomic_testing_core4 from "@atomic-testing/core";
|
|
2
|
-
import { ComponentDriver, IComponentDriverOption, Interactor, Optional, PartLocator } from "@atomic-testing/core";
|
|
2
|
+
import { ComponentDriver, ComponentDriverCtor, IComponentDriverOption, Interactor, Optional, PartLocator } from "@atomic-testing/core";
|
|
3
3
|
import { HTMLButtonDriver, HTMLElementDriver } from "@atomic-testing/component-driver-html";
|
|
4
4
|
|
|
5
5
|
//#region src/components/datagrid/DataGridCellQuery.d.ts
|
|
@@ -34,7 +34,7 @@ declare abstract class DataGridRowDriverBase extends ComponentDriver {
|
|
|
34
34
|
*/
|
|
35
35
|
getCell<DriverT extends ComponentDriver>(cellIndexOrField: number | string,
|
|
36
36
|
// number: column index, string: column field
|
|
37
|
-
driverClass?:
|
|
37
|
+
driverClass?: ComponentDriverCtor<DriverT>): Promise<DriverT | null>;
|
|
38
38
|
protected abstract getCellLocator(): PartLocator;
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
@@ -177,7 +177,7 @@ declare class DataGridProDriver extends ComponentDriver<typeof parts> {
|
|
|
177
177
|
* @param driverClass Optional, the driver class to use for the cell, default to HTMLElementDriver
|
|
178
178
|
* @returns
|
|
179
179
|
*/
|
|
180
|
-
getCell<DriverT extends ComponentDriver>(query: DataGridCellQuery, driverClass?:
|
|
180
|
+
getCell<DriverT extends ComponentDriver>(query: DataGridCellQuery, driverClass?: ComponentDriverCtor<DriverT>): Promise<DriverT | null>;
|
|
181
181
|
/**
|
|
182
182
|
* Get the text content of the cell, if the cell does not exist, throw an error
|
|
183
183
|
* @param query The query to locate the cell
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _atomic_testing_core4 from "@atomic-testing/core";
|
|
2
|
-
import { ComponentDriver, IComponentDriverOption, Interactor, Optional, PartLocator } from "@atomic-testing/core";
|
|
2
|
+
import { ComponentDriver, ComponentDriverCtor, IComponentDriverOption, Interactor, Optional, PartLocator } from "@atomic-testing/core";
|
|
3
3
|
import { HTMLButtonDriver, HTMLElementDriver } from "@atomic-testing/component-driver-html";
|
|
4
4
|
|
|
5
5
|
//#region src/components/datagrid/DataGridCellQuery.d.ts
|
|
@@ -34,7 +34,7 @@ declare abstract class DataGridRowDriverBase extends ComponentDriver {
|
|
|
34
34
|
*/
|
|
35
35
|
getCell<DriverT extends ComponentDriver>(cellIndexOrField: number | string,
|
|
36
36
|
// number: column index, string: column field
|
|
37
|
-
driverClass?:
|
|
37
|
+
driverClass?: ComponentDriverCtor<DriverT>): Promise<DriverT | null>;
|
|
38
38
|
protected abstract getCellLocator(): PartLocator;
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
@@ -177,7 +177,7 @@ declare class DataGridProDriver extends ComponentDriver<typeof parts> {
|
|
|
177
177
|
* @param driverClass Optional, the driver class to use for the cell, default to HTMLElementDriver
|
|
178
178
|
* @returns
|
|
179
179
|
*/
|
|
180
|
-
getCell<DriverT extends ComponentDriver>(query: DataGridCellQuery, driverClass?:
|
|
180
|
+
getCell<DriverT extends ComponentDriver>(query: DataGridCellQuery, driverClass?: ComponentDriverCtor<DriverT>): Promise<DriverT | null>;
|
|
181
181
|
/**
|
|
182
182
|
* Get the text content of the cell, if the cell does not exist, throw an error
|
|
183
183
|
* @param query The query to locate the cell
|
package/dist/index.mjs
CHANGED
|
@@ -293,7 +293,8 @@ var DataGridProDriver = class extends ComponentDriver {
|
|
|
293
293
|
async getCellText(query) {
|
|
294
294
|
const cell = await this.getCell(query);
|
|
295
295
|
if (cell != null) return await cell.getText();
|
|
296
|
-
|
|
296
|
+
const columnIdentifier = "columnIndex" in query ? query.columnIndex : query.columnField;
|
|
297
|
+
throw new Error(`Cell at row:${query.rowIndex} column:${columnIdentifier} does not exist`);
|
|
297
298
|
}
|
|
298
299
|
/**
|
|
299
300
|
* Determine if the pagination footer is currently visible.
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["textList: string[]","cellLocator: PartLocator","parts","parts"],"sources":["../src/components/datagrid/DataGridRowDriverBase.ts","../src/components/datagrid/DataGridDataRowDriver.ts","../src/components/datagrid/DataGridHeaderRowDriver.ts","../src/components/datagrid/DataGridPaginationActionDriver.ts","../src/components/datagrid/DataGridFooterDriver.ts","../src/components/datagrid/DataGridProDriver.ts"],"sourcesContent":["import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport { byAttribute, ComponentDriver, listHelper, locatorUtil, PartLocator } from '@atomic-testing/core';\n\n// In MUI7, there is an extra div preceding the actual data cells. We need to skip it.\nconst columnStartingIndex = 1;\n\n/**\n * Base class for data grid row\n */\nexport abstract class DataGridRowDriverBase extends ComponentDriver {\n protected async getCellCount(): Promise<number> {\n let count = 0;\n for await (const _ of listHelper.getListItemIterator(\n this,\n this.getCellLocator(),\n HTMLElementDriver,\n columnStartingIndex\n )) {\n count++;\n }\n return count;\n }\n\n /**\n * Get the text of each visible cell in the row.\n * Caveat: Because of virtualization, the text of the cell may not be available until the cell is visible.\n * @returns A promise array of text of each visible cell in the row\n */\n async getRowText(): Promise<string[]> {\n const textList: string[] = [];\n for await (const cell of listHelper.getListItemIterator(\n this,\n this.getCellLocator(),\n HTMLElementDriver,\n columnStartingIndex\n )) {\n const text = await cell.getText();\n textList.push(text!.trim());\n }\n return textList;\n }\n\n /**\n * Get the cell driver at the specified index or data field.\n * Caveat: Because of virtualization, the cell may not be available until the cell is visible.\n * @param cellIndexOrField number: column index, string: column field\n * @param driverClass The driver class of the cell. Default is HTMLElementDriver\n * @returns A promise of the cell driver, or null if the cell is not found\n */\n async getCell<DriverT extends ComponentDriver>(\n cellIndexOrField: number | string, // number: column index, string: column field\n // @ts-ignore\n driverClass: typeof ComponentDriver = HTMLElementDriver\n ): Promise<DriverT | null> {\n let cellLocator: PartLocator;\n if (typeof cellIndexOrField === 'number') {\n cellLocator = byAttribute('data-colindex', cellIndexOrField.toString());\n } else {\n cellLocator = byAttribute('data-field', cellIndexOrField);\n }\n const locator = locatorUtil.append(this.locator, cellLocator);\n const cellExists = await this.interactor.exists(locator);\n if (cellExists) {\n // @ts-ignore\n return new driverClass(locator, this.interactor, this.commutableOption);\n }\n\n return null;\n }\n\n protected abstract getCellLocator(): PartLocator;\n}\n","import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';\n\nimport { DataGridRowDriverBase } from './DataGridRowDriverBase';\n\nexport class DataGridDataRowDriver extends DataGridRowDriverBase {\n private readonly _dataCellLocator: PartLocator;\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts: {},\n });\n\n this._dataCellLocator = locatorUtil.append(locator, byRole('cell'));\n }\n\n protected override getCellLocator(): PartLocator {\n return this._dataCellLocator;\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridDataRowDriver';\n }\n}\n","import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';\n\nimport { DataGridRowDriverBase } from './DataGridRowDriverBase';\n\nexport class DataGridHeaderRowDriver extends DataGridRowDriverBase {\n private readonly _headerCellLocator: PartLocator;\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts: {},\n });\n\n this._headerCellLocator = locatorUtil.append(locator, byRole('columnheader'));\n }\n\n async getColumnCount(): Promise<number> {\n return this.getCellCount();\n }\n\n protected override getCellLocator(): PartLocator {\n return this._headerCellLocator;\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridHeaderRowDriver';\n }\n}\n","import { HTMLButtonDriver } from '@atomic-testing/component-driver-html';\nimport {\n byAttribute,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nconst parts = {\n previousButton: {\n locator: byAttribute('aria-label', 'Go to previous page'),\n driver: HTMLButtonDriver,\n },\n nextButton: {\n locator: byAttribute('aria-label', 'Go to next page'),\n driver: HTMLButtonDriver,\n },\n} satisfies ScenePart;\n\n/**\n * Driver for Material UI v6 DataGridPro component.\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridPaginationActionDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('previousButton');\n const isDisabled = await this.parts.previousButton.isDisabled();\n return !isDisabled;\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('previousButton');\n await this.parts.previousButton.click();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('nextButton');\n const isDisabled = await this.parts.nextButton.isDisabled();\n return !isDisabled;\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('nextButton');\n await this.parts.nextButton.click();\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridPaginationActionDriver';\n }\n}\n","import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport {\n byCssClass,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n Optional,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nimport { DataGridPaginationActionDriver } from './DataGridPaginationActionDriver';\n\nconst parts = {\n paginationAction: {\n locator: byCssClass('MuiTablePagination-actions'),\n driver: DataGridPaginationActionDriver,\n },\n paginationDescription: {\n locator: byCssClass('MuiTablePagination-displayedRows'),\n driver: HTMLElementDriver,\n },\n} satisfies ScenePart;\n\n/**\n * Driver for Material UI v6 DataGridPro component.\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridFooterDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('paginationAction');\n return this.parts.paginationAction.isPreviousPageEnabled();\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('paginationAction');\n await this.parts.paginationAction.gotoPreviousPage();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('paginationAction');\n return this.parts.paginationAction.isNextPageEnabled();\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('paginationAction');\n await this.parts.paginationAction.gotoNextPage();\n }\n\n async getPaginationDescription(): Promise<Optional<string>> {\n await this.enforcePartExistence('paginationDescription');\n return this.parts.paginationDescription.getText();\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridFooterDriver';\n }\n}\n","import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport {\n byCssClass,\n byCssSelector,\n byRole,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n listHelper,\n locatorUtil,\n Optional,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nimport { DataGridCellQuery } from './DataGridCellQuery';\nimport { DataGridFooterDriver } from './DataGridFooterDriver';\nimport { DataGridHeaderRowDriver } from './DataGridHeaderRowDriver';\n\nconst parts = {\n headerRow: {\n locator: byCssClass('MuiDataGrid-columnHeaders').chain(byCssSelector('[role=row]:first-of-type')),\n driver: DataGridHeaderRowDriver,\n },\n loading: {\n locator: byRole('progressbar'),\n driver: HTMLElementDriver,\n },\n skeletonOverlay: {\n locator: byCssClass('MuiDataGrid-main--hasSkeletonLoadingOverlay'),\n driver: HTMLElementDriver,\n },\n footer: {\n locator: byCssClass('MuiDataGrid-footerContainer'),\n driver: DataGridFooterDriver,\n },\n} satisfies ScenePart;\n\nconst dataRowLocator = byCssSelector('[role=row][data-rowindex]');\n\n/**\n * Driver for Material UI v8 DataGridPro component.\n * V8 DataGridPro component does not support data-testid, to use data-testid\n * to locate the component, you need to put the data-testid on the parent element of the grid\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridProDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n /**\n * Checks if the data grid is currently loading.\n * @returns A promise that resolves to a boolean indicating if the data grid is loading.\n */\n async isLoading(): Promise<boolean> {\n const result = await Promise.all([this.parts.skeletonOverlay.isVisible(), this.parts.loading.isVisible()]);\n return result.some(v => v);\n }\n\n /**\n * Waits for the data grid to exit the loading state.\n * @param timeoutMs The maximum time to wait for the load to complete, in milliseconds.\n */\n async waitForLoad(timeoutMs: number = 10000): Promise<void> {\n await this.parts.headerRow.waitUntilComponentState();\n await this.waitUntil({ probeFn: () => this.isLoading(), terminateCondition: false, timeoutMs });\n }\n\n /**\n * The number of columns currently displayed in the data grid, note that data grid pro\n * uses virtualize rendering, therefore the column count heavily depends on the viewport size\n * @returns The number of columns currently displayed in the data grid\n */\n async getColumnCount(): Promise<number> {\n return this.parts.headerRow.getColumnCount();\n }\n\n /**\n * The array text of the header row, note that columns not shown in the viewport may not be included because of virtualize rendering\n * @returns The array of text of the header row\n */\n async getHeaderText(): Promise<string[]> {\n return this.parts.headerRow.getRowText();\n }\n\n /**\n * The number of rows currently displayed in the data grid, note that data grid pro\n * uses virtualize rendering, therefore the row count heavily depends on the viewport size\n * @returns The number of columns currently displayed in the data grid\n */\n async getRowCount(): Promise<number> {\n const gridRowLocator = locatorUtil.append(this.locator, dataRowLocator);\n let count = 0;\n for await (const _ of listHelper.getListItemIterator(this, gridRowLocator, HTMLElementDriver)) {\n count++;\n }\n return count;\n }\n\n /**\n * Return the row driver for the row at the specified index, if the row does not exist, return null\n * @param rowIndex\n * @returns\n */\n async getRow(rowIndex: number): Promise<DataGridHeaderRowDriver | null> {\n const rowLocator = locatorUtil.append(this.locator, byCssSelector(`[role=row][data-rowindex=\"${rowIndex}\"]`));\n const rowExists = await this.interactor.exists(rowLocator);\n if (rowExists) {\n return new DataGridHeaderRowDriver(rowLocator, this.interactor, this.commutableOption);\n }\n\n return null;\n }\n\n /**\n * The array text of the specified row, note that columns not shown in the viewport may not be included because of virtualize rendering\n * @param rowIndex The index of the row\n * @returns The array of text of the specified row\n */\n async getRowText(rowIndex: number): Promise<string[]> {\n const row = await this.getRow(rowIndex);\n if (row != null) {\n return row.getRowText();\n }\n throw new Error(`Row ${rowIndex} does not exist`);\n }\n\n /**\n * Get the cell driver for the cell, if the cell does not exist, return null\n * The cell driver is default to HTMLElementDriver, you can specify a different driver class\n * @param query The query to locate the cell\n * @param driverClass Optional, the driver class to use for the cell, default to HTMLElementDriver\n * @returns\n */\n async getCell<DriverT extends ComponentDriver>(\n query: DataGridCellQuery,\n // @ts-ignore\n driverClass: typeof ComponentDriver = HTMLElementDriver\n ): Promise<DriverT | null> {\n const rowDriver = await this.getRow(query.rowIndex);\n\n if (rowDriver === null) {\n return null;\n }\n\n if ('columnIndex' in query) {\n return rowDriver.getCell(query.columnIndex, driverClass);\n }\n\n return rowDriver.getCell(query.columnField, driverClass);\n }\n\n /**\n * Get the text content of the cell, if the cell does not exist, throw an error\n * @param query The query to locate the cell\n * @returns\n */\n async getCellText(query: DataGridCellQuery): Promise<string> {\n const cell = await this.getCell(query);\n if (cell != null) {\n const text = await cell.getText();\n return text!;\n }\n\n //@ts-ignore\n throw new Error(`Cell at row:${query.rowIndex} column:${query.columnIndex ?? query.columnField} does not exist`);\n }\n\n //#region Footer\n /**\n * Determine if the pagination footer is currently visible.\n */\n isFooterVisible(): Promise<boolean> {\n return this.parts.footer.isVisible();\n }\n\n /**\n * Check whether the \"previous page\" control is enabled.\n */\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isPreviousPageEnabled();\n }\n\n /**\n * Navigate to the previous page using the grid footer control.\n */\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoPreviousPage();\n }\n\n /**\n * Check whether the \"next page\" control is enabled.\n */\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isNextPageEnabled();\n }\n\n /**\n * Navigate to the next page using the grid footer control.\n */\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoNextPage();\n }\n\n /**\n * Read the textual description of the current pagination state.\n */\n async getPaginationDescription(): Promise<Optional<string>> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.getText();\n }\n //#endregion Footer\n\n override get driverName(): string {\n return 'MuiV8DataGridProDriver';\n }\n}\n"],"mappings":";;;;AAIA,MAAM,sBAAsB;;;;AAK5B,IAAsB,wBAAtB,cAAoD,gBAAgB;CAClE,MAAgB,eAAgC;EAC9C,IAAI,QAAQ;AACZ,aAAW,MAAM,KAAK,WAAW,oBAC/B,MACA,KAAK,gBAAgB,EACrB,mBACA,oBACD,CACC;AAEF,SAAO;;;;;;;CAQT,MAAM,aAAgC;EACpC,MAAMA,WAAqB,EAAE;AAC7B,aAAW,MAAM,QAAQ,WAAW,oBAClC,MACA,KAAK,gBAAgB,EACrB,mBACA,oBACD,EAAE;GACD,MAAM,OAAO,MAAM,KAAK,SAAS;AACjC,YAAS,KAAK,KAAM,MAAM,CAAC;;AAE7B,SAAO;;;;;;;;;CAUT,MAAM,QACJ,kBAEA,cAAsC,mBACb;EACzB,IAAIC;AACJ,MAAI,OAAO,qBAAqB,SAC9B,eAAc,YAAY,iBAAiB,iBAAiB,UAAU,CAAC;MAEvE,eAAc,YAAY,cAAc,iBAAiB;EAE3D,MAAM,UAAU,YAAY,OAAO,KAAK,SAAS,YAAY;AAE7D,MADmB,MAAM,KAAK,WAAW,OAAO,QAAQ,CAGtD,QAAO,IAAI,YAAY,SAAS,KAAK,YAAY,KAAK,iBAAiB;AAGzE,SAAO;;;;;;AC/DX,IAAa,wBAAb,cAA2C,sBAAsB;CAE/D,YAAY,SAAsB,YAAwB,QAA0C;AAClG,QAAM,SAAS,YAAY;GACzB,GAAG;GACH,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AM,YAAY,OAA2C;EAC3D,MAAM,OAAO,MAAM,KAAK,QAAQ,MAAM;AACtC,MAAI,QAAQ,KAEV,QADa,MAAM,KAAK,SAAS;AAKnC,QAAM,IAAI,MAAM,eAAe,MAAM,SAAS,UAAU,MAAM,eAAe,MAAM,YAAY,iBAAiB;;;;;CAOlH,kBAAoC;AAClC,SAAO,KAAK,MAAM,OAAO,WAAW;;;;;CAMtC,MAAM,wBAA0C;AAC9C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,uBAAuB;;;;;CAMlD,MAAM,mBAAkC;AACtC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,kBAAkB;;;;;CAM5C,MAAM,oBAAsC;AAC1C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,mBAAmB;;;;;CAM9C,MAAM,eAA8B;AAClC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,cAAc;;;;;CAMxC,MAAM,2BAAsD;AAC1D,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,SAAS;;CAIpC,IAAa,aAAqB;AAChC,SAAO"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["textList: string[]","cellLocator: PartLocator","parts","parts"],"sources":["../src/components/datagrid/DataGridRowDriverBase.ts","../src/components/datagrid/DataGridDataRowDriver.ts","../src/components/datagrid/DataGridHeaderRowDriver.ts","../src/components/datagrid/DataGridPaginationActionDriver.ts","../src/components/datagrid/DataGridFooterDriver.ts","../src/components/datagrid/DataGridProDriver.ts"],"sourcesContent":["import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport { byAttribute, ComponentDriver, ComponentDriverCtor, listHelper, locatorUtil, PartLocator } from '@atomic-testing/core';\n\n// In MUI7, there is an extra div preceding the actual data cells. We need to skip it.\nconst columnStartingIndex = 1;\n\n/**\n * Base class for data grid row\n */\nexport abstract class DataGridRowDriverBase extends ComponentDriver {\n protected async getCellCount(): Promise<number> {\n let count = 0;\n for await (const _ of listHelper.getListItemIterator(\n this,\n this.getCellLocator(),\n HTMLElementDriver,\n columnStartingIndex\n )) {\n count++;\n }\n return count;\n }\n\n /**\n * Get the text of each visible cell in the row.\n * Caveat: Because of virtualization, the text of the cell may not be available until the cell is visible.\n * @returns A promise array of text of each visible cell in the row\n */\n async getRowText(): Promise<string[]> {\n const textList: string[] = [];\n for await (const cell of listHelper.getListItemIterator(\n this,\n this.getCellLocator(),\n HTMLElementDriver,\n columnStartingIndex\n )) {\n const text = await cell.getText();\n textList.push(text!.trim());\n }\n return textList;\n }\n\n /**\n * Get the cell driver at the specified index or data field.\n * Caveat: Because of virtualization, the cell may not be available until the cell is visible.\n * @param cellIndexOrField number: column index, string: column field\n * @param driverClass The driver class of the cell. Default is HTMLElementDriver\n * @returns A promise of the cell driver, or null if the cell is not found\n */\n async getCell<DriverT extends ComponentDriver>(\n cellIndexOrField: number | string, // number: column index, string: column field\n driverClass: ComponentDriverCtor<DriverT> = HTMLElementDriver as ComponentDriverCtor<DriverT>\n ): Promise<DriverT | null> {\n let cellLocator: PartLocator;\n if (typeof cellIndexOrField === 'number') {\n cellLocator = byAttribute('data-colindex', cellIndexOrField.toString());\n } else {\n cellLocator = byAttribute('data-field', cellIndexOrField);\n }\n const locator = locatorUtil.append(this.locator, cellLocator);\n const cellExists = await this.interactor.exists(locator);\n if (cellExists) {\n return new driverClass(locator, this.interactor, this.commutableOption);\n }\n\n return null;\n }\n\n protected abstract getCellLocator(): PartLocator;\n}\n","import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';\n\nimport { DataGridRowDriverBase } from './DataGridRowDriverBase';\n\nexport class DataGridDataRowDriver extends DataGridRowDriverBase {\n private readonly _dataCellLocator: PartLocator;\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts: {},\n });\n\n this._dataCellLocator = locatorUtil.append(locator, byRole('cell'));\n }\n\n protected override getCellLocator(): PartLocator {\n return this._dataCellLocator;\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridDataRowDriver';\n }\n}\n","import { byRole, IComponentDriverOption, Interactor, locatorUtil, PartLocator } from '@atomic-testing/core';\n\nimport { DataGridRowDriverBase } from './DataGridRowDriverBase';\n\nexport class DataGridHeaderRowDriver extends DataGridRowDriverBase {\n private readonly _headerCellLocator: PartLocator;\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts: {},\n });\n\n this._headerCellLocator = locatorUtil.append(locator, byRole('columnheader'));\n }\n\n async getColumnCount(): Promise<number> {\n return this.getCellCount();\n }\n\n protected override getCellLocator(): PartLocator {\n return this._headerCellLocator;\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridHeaderRowDriver';\n }\n}\n","import { HTMLButtonDriver } from '@atomic-testing/component-driver-html';\nimport {\n byAttribute,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nconst parts = {\n previousButton: {\n locator: byAttribute('aria-label', 'Go to previous page'),\n driver: HTMLButtonDriver,\n },\n nextButton: {\n locator: byAttribute('aria-label', 'Go to next page'),\n driver: HTMLButtonDriver,\n },\n} satisfies ScenePart;\n\n/**\n * Driver for Material UI v6 DataGridPro component.\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridPaginationActionDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('previousButton');\n const isDisabled = await this.parts.previousButton.isDisabled();\n return !isDisabled;\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('previousButton');\n await this.parts.previousButton.click();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('nextButton');\n const isDisabled = await this.parts.nextButton.isDisabled();\n return !isDisabled;\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('nextButton');\n await this.parts.nextButton.click();\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridPaginationActionDriver';\n }\n}\n","import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport {\n byCssClass,\n ComponentDriver,\n IComponentDriverOption,\n Interactor,\n Optional,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nimport { DataGridPaginationActionDriver } from './DataGridPaginationActionDriver';\n\nconst parts = {\n paginationAction: {\n locator: byCssClass('MuiTablePagination-actions'),\n driver: DataGridPaginationActionDriver,\n },\n paginationDescription: {\n locator: byCssClass('MuiTablePagination-displayedRows'),\n driver: HTMLElementDriver,\n },\n} satisfies ScenePart;\n\n/**\n * Driver for Material UI v6 DataGridPro component.\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridFooterDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('paginationAction');\n return this.parts.paginationAction.isPreviousPageEnabled();\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('paginationAction');\n await this.parts.paginationAction.gotoPreviousPage();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('paginationAction');\n return this.parts.paginationAction.isNextPageEnabled();\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('paginationAction');\n await this.parts.paginationAction.gotoNextPage();\n }\n\n async getPaginationDescription(): Promise<Optional<string>> {\n await this.enforcePartExistence('paginationDescription');\n return this.parts.paginationDescription.getText();\n }\n\n override get driverName(): string {\n return 'MuiV8DataGridFooterDriver';\n }\n}\n","import { HTMLElementDriver } from '@atomic-testing/component-driver-html';\nimport {\n byCssClass,\n byCssSelector,\n byRole,\n ComponentDriver,\n ComponentDriverCtor,\n IComponentDriverOption,\n Interactor,\n listHelper,\n locatorUtil,\n Optional,\n PartLocator,\n ScenePart,\n} from '@atomic-testing/core';\n\nimport { DataGridCellQuery } from './DataGridCellQuery';\nimport { DataGridFooterDriver } from './DataGridFooterDriver';\nimport { DataGridHeaderRowDriver } from './DataGridHeaderRowDriver';\n\nconst parts = {\n headerRow: {\n locator: byCssClass('MuiDataGrid-columnHeaders').chain(byCssSelector('[role=row]:first-of-type')),\n driver: DataGridHeaderRowDriver,\n },\n loading: {\n locator: byRole('progressbar'),\n driver: HTMLElementDriver,\n },\n skeletonOverlay: {\n locator: byCssClass('MuiDataGrid-main--hasSkeletonLoadingOverlay'),\n driver: HTMLElementDriver,\n },\n footer: {\n locator: byCssClass('MuiDataGrid-footerContainer'),\n driver: DataGridFooterDriver,\n },\n} satisfies ScenePart;\n\nconst dataRowLocator = byCssSelector('[role=row][data-rowindex]');\n\n/**\n * Driver for Material UI v8 DataGridPro component.\n * V8 DataGridPro component does not support data-testid, to use data-testid\n * to locate the component, you need to put the data-testid on the parent element of the grid\n * @see https://mui.com/x/react-data-grid/\n */\nexport class DataGridProDriver extends ComponentDriver<typeof parts> {\n constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>) {\n super(locator, interactor, {\n ...option,\n parts,\n });\n }\n\n /**\n * Checks if the data grid is currently loading.\n * @returns A promise that resolves to a boolean indicating if the data grid is loading.\n */\n async isLoading(): Promise<boolean> {\n const result = await Promise.all([this.parts.skeletonOverlay.isVisible(), this.parts.loading.isVisible()]);\n return result.some(v => v);\n }\n\n /**\n * Waits for the data grid to exit the loading state.\n * @param timeoutMs The maximum time to wait for the load to complete, in milliseconds.\n */\n async waitForLoad(timeoutMs: number = 10000): Promise<void> {\n await this.parts.headerRow.waitUntilComponentState();\n await this.waitUntil({ probeFn: () => this.isLoading(), terminateCondition: false, timeoutMs });\n }\n\n /**\n * The number of columns currently displayed in the data grid, note that data grid pro\n * uses virtualize rendering, therefore the column count heavily depends on the viewport size\n * @returns The number of columns currently displayed in the data grid\n */\n async getColumnCount(): Promise<number> {\n return this.parts.headerRow.getColumnCount();\n }\n\n /**\n * The array text of the header row, note that columns not shown in the viewport may not be included because of virtualize rendering\n * @returns The array of text of the header row\n */\n async getHeaderText(): Promise<string[]> {\n return this.parts.headerRow.getRowText();\n }\n\n /**\n * The number of rows currently displayed in the data grid, note that data grid pro\n * uses virtualize rendering, therefore the row count heavily depends on the viewport size\n * @returns The number of columns currently displayed in the data grid\n */\n async getRowCount(): Promise<number> {\n const gridRowLocator = locatorUtil.append(this.locator, dataRowLocator);\n let count = 0;\n for await (const _ of listHelper.getListItemIterator(this, gridRowLocator, HTMLElementDriver)) {\n count++;\n }\n return count;\n }\n\n /**\n * Return the row driver for the row at the specified index, if the row does not exist, return null\n * @param rowIndex\n * @returns\n */\n async getRow(rowIndex: number): Promise<DataGridHeaderRowDriver | null> {\n const rowLocator = locatorUtil.append(this.locator, byCssSelector(`[role=row][data-rowindex=\"${rowIndex}\"]`));\n const rowExists = await this.interactor.exists(rowLocator);\n if (rowExists) {\n return new DataGridHeaderRowDriver(rowLocator, this.interactor, this.commutableOption);\n }\n\n return null;\n }\n\n /**\n * The array text of the specified row, note that columns not shown in the viewport may not be included because of virtualize rendering\n * @param rowIndex The index of the row\n * @returns The array of text of the specified row\n */\n async getRowText(rowIndex: number): Promise<string[]> {\n const row = await this.getRow(rowIndex);\n if (row != null) {\n return row.getRowText();\n }\n throw new Error(`Row ${rowIndex} does not exist`);\n }\n\n /**\n * Get the cell driver for the cell, if the cell does not exist, return null\n * The cell driver is default to HTMLElementDriver, you can specify a different driver class\n * @param query The query to locate the cell\n * @param driverClass Optional, the driver class to use for the cell, default to HTMLElementDriver\n * @returns\n */\n async getCell<DriverT extends ComponentDriver>(\n query: DataGridCellQuery,\n driverClass: ComponentDriverCtor<DriverT> = HTMLElementDriver as ComponentDriverCtor<DriverT>\n ): Promise<DriverT | null> {\n const rowDriver = await this.getRow(query.rowIndex);\n\n if (rowDriver === null) {\n return null;\n }\n\n if ('columnIndex' in query) {\n return rowDriver.getCell(query.columnIndex, driverClass);\n }\n\n return rowDriver.getCell(query.columnField, driverClass);\n }\n\n /**\n * Get the text content of the cell, if the cell does not exist, throw an error\n * @param query The query to locate the cell\n * @returns\n */\n async getCellText(query: DataGridCellQuery): Promise<string> {\n const cell = await this.getCell(query);\n if (cell != null) {\n const text = await cell.getText();\n return text!;\n }\n\n const columnIdentifier = 'columnIndex' in query ? query.columnIndex : query.columnField;\n throw new Error(`Cell at row:${query.rowIndex} column:${columnIdentifier} does not exist`);\n }\n\n //#region Footer\n /**\n * Determine if the pagination footer is currently visible.\n */\n isFooterVisible(): Promise<boolean> {\n return this.parts.footer.isVisible();\n }\n\n /**\n * Check whether the \"previous page\" control is enabled.\n */\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isPreviousPageEnabled();\n }\n\n /**\n * Navigate to the previous page using the grid footer control.\n */\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoPreviousPage();\n }\n\n /**\n * Check whether the \"next page\" control is enabled.\n */\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isNextPageEnabled();\n }\n\n /**\n * Navigate to the next page using the grid footer control.\n */\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoNextPage();\n }\n\n /**\n * Read the textual description of the current pagination state.\n */\n async getPaginationDescription(): Promise<Optional<string>> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.getText();\n }\n //#endregion Footer\n\n override get driverName(): string {\n return 'MuiV8DataGridProDriver';\n }\n}\n"],"mappings":";;;;AAIA,MAAM,sBAAsB;;;;AAK5B,IAAsB,wBAAtB,cAAoD,gBAAgB;CAClE,MAAgB,eAAgC;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ACzC,QAAM,KAAK,MAAM,OAAO,kBAAkB;;;;;CAM5C,MAAM,oBAAsC;AAC1C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,mBAAmB;;;;;CAM9C,MAAM,eAA8B;AAClC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,cAAc;;;;;CAMxC,MAAM,2BAAsD;AAC1D,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,SAAS;;CAIpC,IAAa,aAAqB;AAChC,SAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomic-testing/component-driver-mui-x-v8",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"description": "Atomic Testing Component driver to help drive Material UI X V8 components",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"directory": "packages/component-driver-mui-x-v8"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@atomic-testing/
|
|
31
|
-
"@atomic-testing/component-driver-mui-v6": "0.
|
|
32
|
-
"@atomic-testing/
|
|
30
|
+
"@atomic-testing/component-driver-html": "0.81.0",
|
|
31
|
+
"@atomic-testing/component-driver-mui-v6": "0.81.0",
|
|
32
|
+
"@atomic-testing/core": "0.81.0"
|
|
33
33
|
},
|
|
34
34
|
"exports": {
|
|
35
35
|
".": {
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
byCssSelector,
|
|
5
5
|
byRole,
|
|
6
6
|
ComponentDriver,
|
|
7
|
+
ComponentDriverCtor,
|
|
7
8
|
IComponentDriverOption,
|
|
8
9
|
Interactor,
|
|
9
10
|
listHelper,
|
|
@@ -138,8 +139,7 @@ export class DataGridProDriver extends ComponentDriver<typeof parts> {
|
|
|
138
139
|
*/
|
|
139
140
|
async getCell<DriverT extends ComponentDriver>(
|
|
140
141
|
query: DataGridCellQuery,
|
|
141
|
-
|
|
142
|
-
driverClass: typeof ComponentDriver = HTMLElementDriver
|
|
142
|
+
driverClass: ComponentDriverCtor<DriverT> = HTMLElementDriver as ComponentDriverCtor<DriverT>
|
|
143
143
|
): Promise<DriverT | null> {
|
|
144
144
|
const rowDriver = await this.getRow(query.rowIndex);
|
|
145
145
|
|
|
@@ -166,8 +166,8 @@ export class DataGridProDriver extends ComponentDriver<typeof parts> {
|
|
|
166
166
|
return text!;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
throw new Error(`Cell at row:${query.rowIndex} column:${
|
|
169
|
+
const columnIdentifier = 'columnIndex' in query ? query.columnIndex : query.columnField;
|
|
170
|
+
throw new Error(`Cell at row:${query.rowIndex} column:${columnIdentifier} does not exist`);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
//#region Footer
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTMLElementDriver } from '@atomic-testing/component-driver-html';
|
|
2
|
-
import { byAttribute, ComponentDriver, listHelper, locatorUtil, PartLocator } from '@atomic-testing/core';
|
|
2
|
+
import { byAttribute, ComponentDriver, ComponentDriverCtor, listHelper, locatorUtil, PartLocator } from '@atomic-testing/core';
|
|
3
3
|
|
|
4
4
|
// In MUI7, there is an extra div preceding the actual data cells. We need to skip it.
|
|
5
5
|
const columnStartingIndex = 1;
|
|
@@ -49,8 +49,7 @@ export abstract class DataGridRowDriverBase extends ComponentDriver {
|
|
|
49
49
|
*/
|
|
50
50
|
async getCell<DriverT extends ComponentDriver>(
|
|
51
51
|
cellIndexOrField: number | string, // number: column index, string: column field
|
|
52
|
-
|
|
53
|
-
driverClass: typeof ComponentDriver = HTMLElementDriver
|
|
52
|
+
driverClass: ComponentDriverCtor<DriverT> = HTMLElementDriver as ComponentDriverCtor<DriverT>
|
|
54
53
|
): Promise<DriverT | null> {
|
|
55
54
|
let cellLocator: PartLocator;
|
|
56
55
|
if (typeof cellIndexOrField === 'number') {
|
|
@@ -61,7 +60,6 @@ export abstract class DataGridRowDriverBase extends ComponentDriver {
|
|
|
61
60
|
const locator = locatorUtil.append(this.locator, cellLocator);
|
|
62
61
|
const cellExists = await this.interactor.exists(locator);
|
|
63
62
|
if (cellExists) {
|
|
64
|
-
// @ts-ignore
|
|
65
63
|
return new driverClass(locator, this.interactor, this.commutableOption);
|
|
66
64
|
}
|
|
67
65
|
|