@atomic-testing/component-driver-mui-x-v8 0.76.0 → 0.77.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.d.mts CHANGED
@@ -184,11 +184,29 @@ declare class DataGridProDriver extends ComponentDriver<typeof parts> {
184
184
  * @returns
185
185
  */
186
186
  getCellText(query: DataGridCellQuery): Promise<string>;
187
+ /**
188
+ * Determine if the pagination footer is currently visible.
189
+ */
187
190
  isFooterVisible(): Promise<boolean>;
191
+ /**
192
+ * Check whether the "previous page" control is enabled.
193
+ */
188
194
  isPreviousPageEnabled(): Promise<boolean>;
195
+ /**
196
+ * Navigate to the previous page using the grid footer control.
197
+ */
189
198
  gotoPreviousPage(): Promise<void>;
199
+ /**
200
+ * Check whether the "next page" control is enabled.
201
+ */
190
202
  isNextPageEnabled(): Promise<boolean>;
203
+ /**
204
+ * Navigate to the next page using the grid footer control.
205
+ */
191
206
  gotoNextPage(): Promise<void>;
207
+ /**
208
+ * Read the textual description of the current pagination state.
209
+ */
192
210
  getPaginationDescription(): Promise<Optional<string>>;
193
211
  get driverName(): string;
194
212
  }
package/dist/index.d.ts CHANGED
@@ -184,11 +184,29 @@ declare class DataGridProDriver extends ComponentDriver<typeof parts> {
184
184
  * @returns
185
185
  */
186
186
  getCellText(query: DataGridCellQuery): Promise<string>;
187
+ /**
188
+ * Determine if the pagination footer is currently visible.
189
+ */
187
190
  isFooterVisible(): Promise<boolean>;
191
+ /**
192
+ * Check whether the "previous page" control is enabled.
193
+ */
188
194
  isPreviousPageEnabled(): Promise<boolean>;
195
+ /**
196
+ * Navigate to the previous page using the grid footer control.
197
+ */
189
198
  gotoPreviousPage(): Promise<void>;
199
+ /**
200
+ * Check whether the "next page" control is enabled.
201
+ */
190
202
  isNextPageEnabled(): Promise<boolean>;
203
+ /**
204
+ * Navigate to the next page using the grid footer control.
205
+ */
191
206
  gotoNextPage(): Promise<void>;
207
+ /**
208
+ * Read the textual description of the current pagination state.
209
+ */
192
210
  getPaginationDescription(): Promise<Optional<string>>;
193
211
  get driverName(): string;
194
212
  }
package/dist/index.js CHANGED
@@ -328,25 +328,43 @@ var DataGridProDriver = class extends __atomic_testing_core.ComponentDriver {
328
328
  }
329
329
  throw new Error(`Cell at row:${query.rowIndex} column:${query.columnIndex ?? query.columnField} does not exist`);
330
330
  }
331
+ /**
332
+ * Determine if the pagination footer is currently visible.
333
+ */
331
334
  isFooterVisible() {
332
335
  return this.parts.footer.isVisible();
333
336
  }
337
+ /**
338
+ * Check whether the "previous page" control is enabled.
339
+ */
334
340
  async isPreviousPageEnabled() {
335
341
  await this.enforcePartExistence("footer");
336
342
  return this.parts.footer.isPreviousPageEnabled();
337
343
  }
344
+ /**
345
+ * Navigate to the previous page using the grid footer control.
346
+ */
338
347
  async gotoPreviousPage() {
339
348
  await this.enforcePartExistence("footer");
340
349
  await this.parts.footer.gotoPreviousPage();
341
350
  }
351
+ /**
352
+ * Check whether the "next page" control is enabled.
353
+ */
342
354
  async isNextPageEnabled() {
343
355
  await this.enforcePartExistence("footer");
344
356
  return this.parts.footer.isNextPageEnabled();
345
357
  }
358
+ /**
359
+ * Navigate to the next page using the grid footer control.
360
+ */
346
361
  async gotoNextPage() {
347
362
  await this.enforcePartExistence("footer");
348
363
  await this.parts.footer.gotoNextPage();
349
364
  }
365
+ /**
366
+ * Read the textual description of the current pagination state.
367
+ */
350
368
  async getPaginationDescription() {
351
369
  await this.enforcePartExistence("footer");
352
370
  return this.parts.footer.getText();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ComponentDriver","HTMLElementDriver","textList: string[]","cellIndexOrField: number | string","driverClass: typeof ComponentDriver","cellLocator: PartLocator","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","parts","HTMLButtonDriver","ComponentDriver","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","parts","HTMLElementDriver","ComponentDriver","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","HTMLElementDriver","ComponentDriver","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","timeoutMs: number","rowIndex: number","query: DataGridCellQuery","driverClass: typeof ComponentDriver"],"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 isFooterVisible(): Promise<boolean> {\n return this.parts.footer.isVisible();\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isPreviousPageEnabled();\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoPreviousPage();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isNextPageEnabled();\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoNextPage();\n }\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,sCAAgB;CAClE,MAAgB,eAAgC;EAC9C,IAAI,QAAQ;AACZ,aAAW,MAAM,KAAK,iCAAW,oBAC/B,MACA,KAAK,gBAAgB,EACrBC,0DACA,oBACD,CACC;AAEF,SAAO;CACR;;;;;;CAOD,MAAM,aAAgC;EACpC,MAAMC,WAAqB,CAAE;AAC7B,aAAW,MAAM,QAAQ,iCAAW,oBAClC,MACA,KAAK,gBAAgB,EACrBD,0DACA,oBACD,EAAE;GACD,MAAM,OAAO,MAAM,KAAK,SAAS;AACjC,YAAS,KAAK,KAAM,MAAM,CAAC;EAC5B;AACD,SAAO;CACR;;;;;;;;CASD,MAAM,QACJE,kBAEAC,cAAsCH,0DACb;EACzB,IAAII;AACJ,aAAW,qBAAqB,SAC9B,eAAc,uCAAY,iBAAiB,iBAAiB,UAAU,CAAC;MAEvE,eAAc,uCAAY,cAAc,iBAAiB;EAE3D,MAAM,UAAU,kCAAY,OAAO,KAAK,SAAS,YAAY;EAC7D,MAAM,aAAa,MAAM,KAAK,WAAW,OAAO,QAAQ;AACxD,MAAI,WAEF,QAAO,IAAI,YAAY,SAAS,KAAK,YAAY,KAAK;AAGxD,SAAO;CACR;AAGF;;;;ACnED,IAAa,wBAAb,cAA2C,sBAAsB;CAC/D,AAAiB;CACjB,YAAYC,SAAsBC,YAAwBC,QAA0C;AAClG,QAAM,SAAS,YAAY;GACzB,GAAG;GACH,OAAO,CAAE;EACV,EAAC;AAEF,OAAK,mBAAmB,kCA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AAS;AAEnD,MAAI,cAAc,KAChB,QAAO;AAGT,MAAI,iBAAiB,MACnB,QAAO,UAAU,QAAQ,MAAM,aAAa,YAAY;AAG1D,SAAO,UAAU,QAAQ,MAAM,aAAa,YAAY;CACzD;;;;;;CAOD,MAAM,YAAYO,OAA2C;EAC3D,MAAM,OAAO,MAAM,KAAK,QAAQ,MAAM;AACtC,MAAI,QAAQ,MAAM;GAChB,MAAM,OAAO,MAAM,KAAK,SAAS;AACjC,UAAO;EACR;AAGD,QAAM,IAAI,OAAO,cAAc,MAAM,SAAS,UAAU,MAAM,eAAe,MAAM,YAAY;CAChG;CAGD,kBAAoC;AAClC,SAAO,KAAK,MAAM,OAAO,WAAW;CACrC;CAED,MAAM,wBAA0C;AAC9C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,uBAAuB;CACjD;CAED,MAAM,mBAAkC;AACtC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,kBAAkB;CAC3C;CAED,MAAM,oBAAsC;AAC1C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,mBAAmB;CAC7C;CAED,MAAM,eAA8B;AAClC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,cAAc;CACvC;CAED,MAAM,2BAAsD;AAC1D,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,SAAS;CACnC;CAGD,IAAa,aAAqB;AAChC,SAAO;CACR;AACF"}
1
+ {"version":3,"file":"index.js","names":["ComponentDriver","HTMLElementDriver","textList: string[]","cellIndexOrField: number | string","driverClass: typeof ComponentDriver","cellLocator: PartLocator","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","parts","HTMLButtonDriver","ComponentDriver","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","parts","HTMLElementDriver","ComponentDriver","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","HTMLElementDriver","ComponentDriver","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","timeoutMs: number","rowIndex: number","query: DataGridCellQuery","driverClass: typeof ComponentDriver"],"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,cAAoDA,sCAAgB;CAClE,MAAgB,eAAgC;EAC9C,IAAI,QAAQ;AACZ,aAAW,MAAM,KAAK,iCAAW,oBAC/B,MACA,KAAK,gBAAgB,EACrBC,0DACA,oBACD,CACC;AAEF,SAAO;CACR;;;;;;CAOD,MAAM,aAAgC;EACpC,MAAMC,WAAqB,CAAE;AAC7B,aAAW,MAAM,QAAQ,iCAAW,oBAClC,MACA,KAAK,gBAAgB,EACrBD,0DACA,oBACD,EAAE;GACD,MAAM,OAAO,MAAM,KAAK,SAAS;AACjC,YAAS,KAAK,KAAM,MAAM,CAAC;EAC5B;AACD,SAAO;CACR;;;;;;;;CASD,MAAM,QACJE,kBAEAC,cAAsCH,0DACb;EACzB,IAAII;AACJ,aAAW,qBAAqB,SAC9B,eAAc,uCAAY,iBAAiB,iBAAiB,UAAU,CAAC;MAEvE,eAAc,uCAAY,cAAc,iBAAiB;EAE3D,MAAM,UAAU,kCAAY,OAAO,KAAK,SAAS,YAAY;EAC7D,MAAM,aAAa,MAAM,KAAK,WAAW,OAAO,QAAQ;AACxD,MAAI,WAEF,QAAO,IAAI,YAAY,SAAS,KAAK,YAAY,KAAK;AAGxD,SAAO;CACR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ComponentDriver {
305
305
  }
306
306
  throw new Error(`Cell at row:${query.rowIndex} column:${query.columnIndex ?? query.columnField} does not exist`);
307
307
  }
308
+ /**
309
+ * Determine if the pagination footer is currently visible.
310
+ */
308
311
  isFooterVisible() {
309
312
  return this.parts.footer.isVisible();
310
313
  }
314
+ /**
315
+ * Check whether the "previous page" control is enabled.
316
+ */
311
317
  async isPreviousPageEnabled() {
312
318
  await this.enforcePartExistence("footer");
313
319
  return this.parts.footer.isPreviousPageEnabled();
314
320
  }
321
+ /**
322
+ * Navigate to the previous page using the grid footer control.
323
+ */
315
324
  async gotoPreviousPage() {
316
325
  await this.enforcePartExistence("footer");
317
326
  await this.parts.footer.gotoPreviousPage();
318
327
  }
328
+ /**
329
+ * Check whether the "next page" control is enabled.
330
+ */
319
331
  async isNextPageEnabled() {
320
332
  await this.enforcePartExistence("footer");
321
333
  return this.parts.footer.isNextPageEnabled();
322
334
  }
335
+ /**
336
+ * Navigate to the next page using the grid footer control.
337
+ */
323
338
  async gotoNextPage() {
324
339
  await this.enforcePartExistence("footer");
325
340
  await this.parts.footer.gotoNextPage();
326
341
  }
342
+ /**
343
+ * Read the textual description of the current pagination state.
344
+ */
327
345
  async getPaginationDescription() {
328
346
  await this.enforcePartExistence("footer");
329
347
  return this.parts.footer.getText();
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["textList: string[]","cellIndexOrField: number | string","driverClass: typeof ComponentDriver","cellLocator: PartLocator","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","parts","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","parts","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","timeoutMs: number","rowIndex: number","query: DataGridCellQuery","driverClass: typeof ComponentDriver"],"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 isFooterVisible(): Promise<boolean> {\n return this.parts.footer.isVisible();\n }\n\n async isPreviousPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isPreviousPageEnabled();\n }\n\n async gotoPreviousPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoPreviousPage();\n }\n\n async isNextPageEnabled(): Promise<boolean> {\n await this.enforcePartExistence('footer');\n return this.parts.footer.isNextPageEnabled();\n }\n\n async gotoNextPage(): Promise<void> {\n await this.enforcePartExistence('footer');\n await this.parts.footer.gotoNextPage();\n }\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":";;;;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AAGD,QAAM,IAAI,OAAO,cAAc,MAAM,SAAS,UAAU,MAAM,eAAe,MAAM,YAAY;CAChG;CAGD,kBAAoC;AAClC,SAAO,KAAK,MAAM,OAAO,WAAW;CACrC;CAED,MAAM,wBAA0C;AAC9C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,uBAAuB;CACjD;CAED,MAAM,mBAAkC;AACtC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,kBAAkB;CAC3C;CAED,MAAM,oBAAsC;AAC1C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,mBAAmB;CAC7C;CAED,MAAM,eAA8B;AAClC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,cAAc;CACvC;CAED,MAAM,2BAAsD;AAC1D,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,SAAS;CACnC;CAGD,IAAa,aAAqB;AAChC,SAAO;CACR;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["textList: string[]","cellIndexOrField: number | string","driverClass: typeof ComponentDriver","cellLocator: PartLocator","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","parts","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","parts","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","locator: PartLocator","interactor: Interactor","option?: Partial<IComponentDriverOption>","timeoutMs: number","rowIndex: number","query: DataGridCellQuery","driverClass: typeof ComponentDriver"],"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 'MuiV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MAAM,KAAK,SAAS;AACjC,UAAO;EACR;AAGD,QAAM,IAAI,OAAO,cAAc,MAAM,SAAS,UAAU,MAAM,eAAe,MAAM,YAAY;CAChG;;;;CAMD,kBAAoC;AAClC,SAAO,KAAK,MAAM,OAAO,WAAW;CACrC;;;;CAKD,MAAM,wBAA0C;AAC9C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,uBAAuB;CACjD;;;;CAKD,MAAM,mBAAkC;AACtC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,kBAAkB;CAC3C;;;;CAKD,MAAM,oBAAsC;AAC1C,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,mBAAmB;CAC7C;;;;CAKD,MAAM,eAA8B;AAClC,QAAM,KAAK,qBAAqB,SAAS;AACzC,QAAM,KAAK,MAAM,OAAO,cAAc;CACvC;;;;CAKD,MAAM,2BAAsD;AAC1D,QAAM,KAAK,qBAAqB,SAAS;AACzC,SAAO,KAAK,MAAM,OAAO,SAAS;CACnC;CAGD,IAAa,aAAqB;AAChC,SAAO;CACR;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomic-testing/component-driver-mui-x-v8",
3
- "version": "0.76.0",
3
+ "version": "0.77.0",
4
4
  "description": "Atomic Testing Component driver to help drive Material UI X V8 components",
5
5
  "main": "dist/index.js",
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/core": "0.76.0",
31
- "@atomic-testing/component-driver-html": "0.76.0",
32
- "@atomic-testing/component-driver-mui-v6": "0.76.0"
30
+ "@atomic-testing/core": "0.77.0",
31
+ "@atomic-testing/component-driver-mui-v6": "0.77.0",
32
+ "@atomic-testing/component-driver-html": "0.77.0"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "tsdown",
@@ -171,30 +171,48 @@ export class DataGridProDriver extends ComponentDriver<typeof parts> {
171
171
  }
172
172
 
173
173
  //#region Footer
174
+ /**
175
+ * Determine if the pagination footer is currently visible.
176
+ */
174
177
  isFooterVisible(): Promise<boolean> {
175
178
  return this.parts.footer.isVisible();
176
179
  }
177
180
 
181
+ /**
182
+ * Check whether the "previous page" control is enabled.
183
+ */
178
184
  async isPreviousPageEnabled(): Promise<boolean> {
179
185
  await this.enforcePartExistence('footer');
180
186
  return this.parts.footer.isPreviousPageEnabled();
181
187
  }
182
188
 
189
+ /**
190
+ * Navigate to the previous page using the grid footer control.
191
+ */
183
192
  async gotoPreviousPage(): Promise<void> {
184
193
  await this.enforcePartExistence('footer');
185
194
  await this.parts.footer.gotoPreviousPage();
186
195
  }
187
196
 
197
+ /**
198
+ * Check whether the "next page" control is enabled.
199
+ */
188
200
  async isNextPageEnabled(): Promise<boolean> {
189
201
  await this.enforcePartExistence('footer');
190
202
  return this.parts.footer.isNextPageEnabled();
191
203
  }
192
204
 
205
+ /**
206
+ * Navigate to the next page using the grid footer control.
207
+ */
193
208
  async gotoNextPage(): Promise<void> {
194
209
  await this.enforcePartExistence('footer');
195
210
  await this.parts.footer.gotoNextPage();
196
211
  }
197
212
 
213
+ /**
214
+ * Read the textual description of the current pagination state.
215
+ */
198
216
  async getPaginationDescription(): Promise<Optional<string>> {
199
217
  await this.enforcePartExistence('footer');
200
218
  return this.parts.footer.getText();