UNPKG

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

Version:

Atomic Testing Component driver to help drive Material UI X V8 components

215 lines (214 loc) 8.46 kB
import * as _atomic_testing_core5 from "@atomic-testing/core"; import { ComponentDriver, IComponentDriverOption, Interactor, Optional, PartLocator } from "@atomic-testing/core"; import { HTMLButtonDriver, HTMLElementDriver } from "@atomic-testing/component-driver-html"; //#region src/components/datagrid/DataGridCellQuery.d.ts interface CellQueryByColumnIndex { rowIndex: number; columnIndex: number; } interface CellQueryByColumnField { rowIndex: number; columnField: string; } type DataGridCellQuery = CellQueryByColumnIndex | CellQueryByColumnField; //#endregion //#region src/components/datagrid/DataGridRowDriverBase.d.ts /** * Base class for data grid row */ declare abstract class DataGridRowDriverBase extends ComponentDriver { protected getCellCount(): Promise<number>; /** * Get the text of each visible cell in the row. * Caveat: Because of virtualization, the text of the cell may not be available until the cell is visible. * @returns A promise array of text of each visible cell in the row */ getRowText(): Promise<string[]>; /** * Get the cell driver at the specified index or data field. * Caveat: Because of virtualization, the cell may not be available until the cell is visible. * @param cellIndexOrField number: column index, string: column field * @param driverClass The driver class of the cell. Default is HTMLElementDriver * @returns A promise of the cell driver, or null if the cell is not found */ getCell<DriverT extends ComponentDriver>(cellIndexOrField: number | string, // number: column index, string: column field driverClass?: typeof ComponentDriver): Promise<DriverT | null>; protected abstract getCellLocator(): PartLocator; } //#endregion //#region src/components/datagrid/DataGridDataRowDriver.d.ts declare class DataGridDataRowDriver extends DataGridRowDriverBase { private readonly _dataCellLocator; constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>); protected getCellLocator(): PartLocator; get driverName(): string; } //#endregion //#region src/components/datagrid/DataGridHeaderRowDriver.d.ts declare class DataGridHeaderRowDriver extends DataGridRowDriverBase { private readonly _headerCellLocator; constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>); getColumnCount(): Promise<number>; protected getCellLocator(): PartLocator; get driverName(): string; } //#endregion //#region src/components/datagrid/DataGridPaginationActionDriver.d.ts declare const parts$2: { previousButton: { locator: _atomic_testing_core5.CssLocator; driver: typeof HTMLButtonDriver; }; nextButton: { locator: _atomic_testing_core5.CssLocator; driver: typeof HTMLButtonDriver; }; }; /** * Driver for Material UI v6 DataGridPro component. * @see https://mui.com/x/react-data-grid/ */ declare class DataGridPaginationActionDriver extends ComponentDriver<typeof parts$2> { constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>); isPreviousPageEnabled(): Promise<boolean>; gotoPreviousPage(): Promise<void>; isNextPageEnabled(): Promise<boolean>; gotoNextPage(): Promise<void>; get driverName(): string; } //#endregion //#region src/components/datagrid/DataGridFooterDriver.d.ts declare const parts$1: { paginationAction: { locator: _atomic_testing_core5.CssLocator; driver: typeof DataGridPaginationActionDriver; }; paginationDescription: { locator: _atomic_testing_core5.CssLocator; driver: typeof HTMLElementDriver; }; }; /** * Driver for Material UI v6 DataGridPro component. * @see https://mui.com/x/react-data-grid/ */ declare class DataGridFooterDriver extends ComponentDriver<typeof parts$1> { constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>); isPreviousPageEnabled(): Promise<boolean>; gotoPreviousPage(): Promise<void>; isNextPageEnabled(): Promise<boolean>; gotoNextPage(): Promise<void>; getPaginationDescription(): Promise<Optional<string>>; get driverName(): string; } //#endregion //#region src/components/datagrid/DataGridProDriver.d.ts declare const parts: { headerRow: { locator: PartLocator; driver: typeof DataGridHeaderRowDriver; }; loading: { locator: _atomic_testing_core5.CssLocator; driver: typeof HTMLElementDriver; }; skeletonOverlay: { locator: _atomic_testing_core5.CssLocator; driver: typeof HTMLElementDriver; }; footer: { locator: _atomic_testing_core5.CssLocator; driver: typeof DataGridFooterDriver; }; }; /** * Driver for Material UI v8 DataGridPro component. * V8 DataGridPro component does not support data-testid, to use data-testid * to locate the component, you need to put the data-testid on the parent element of the grid * @see https://mui.com/x/react-data-grid/ */ declare class DataGridProDriver extends ComponentDriver<typeof parts> { constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>); /** * Checks if the data grid is currently loading. * @returns A promise that resolves to a boolean indicating if the data grid is loading. */ isLoading(): Promise<boolean>; /** * Waits for the data grid to exit the loading state. * @param timeoutMs The maximum time to wait for the load to complete, in milliseconds. */ waitForLoad(timeoutMs?: number): Promise<void>; /** * The number of columns currently displayed in the data grid, note that data grid pro * uses virtualize rendering, therefore the column count heavily depends on the viewport size * @returns The number of columns currently displayed in the data grid */ getColumnCount(): Promise<number>; /** * The array text of the header row, note that columns not shown in the viewport may not be included because of virtualize rendering * @returns The array of text of the header row */ getHeaderText(): Promise<string[]>; /** * The number of rows currently displayed in the data grid, note that data grid pro * uses virtualize rendering, therefore the row count heavily depends on the viewport size * @returns The number of columns currently displayed in the data grid */ getRowCount(): Promise<number>; /** * Return the row driver for the row at the specified index, if the row does not exist, return null * @param rowIndex * @returns */ getRow(rowIndex: number): Promise<DataGridHeaderRowDriver | null>; /** * The array text of the specified row, note that columns not shown in the viewport may not be included because of virtualize rendering * @param rowIndex The index of the row * @returns The array of text of the specified row */ getRowText(rowIndex: number): Promise<string[]>; /** * Get the cell driver for the cell, if the cell does not exist, return null * The cell driver is default to HTMLElementDriver, you can specify a different driver class * @param query The query to locate the cell * @param driverClass Optional, the driver class to use for the cell, default to HTMLElementDriver * @returns */ getCell<DriverT extends ComponentDriver>(query: DataGridCellQuery, driverClass?: typeof ComponentDriver): Promise<DriverT | null>; /** * Get the text content of the cell, if the cell does not exist, throw an error * @param query The query to locate the cell * @returns */ getCellText(query: DataGridCellQuery): Promise<string>; /** * Determine if the pagination footer is currently visible. */ isFooterVisible(): Promise<boolean>; /** * Check whether the "previous page" control is enabled. */ isPreviousPageEnabled(): Promise<boolean>; /** * Navigate to the previous page using the grid footer control. */ gotoPreviousPage(): Promise<void>; /** * Check whether the "next page" control is enabled. */ isNextPageEnabled(): Promise<boolean>; /** * Navigate to the next page using the grid footer control. */ gotoNextPage(): Promise<void>; /** * Read the textual description of the current pagination state. */ getPaginationDescription(): Promise<Optional<string>>; get driverName(): string; } //#endregion export { CellQueryByColumnField, CellQueryByColumnIndex, DataGridCellQuery, DataGridDataRowDriver, DataGridHeaderRowDriver, DataGridProDriver }; //# sourceMappingURL=index.d.ts.map