@@ -11,7 +11,7 @@ import {TableHarnessFilters, RowHarnessFilters} from './table-harness-filters';
1111import { MatRowHarness , MatHeaderRowHarness , MatFooterRowHarness } from './row-harness' ;
1212
1313/** Data extracted from a table organized by columns. */
14- export interface MatTableHarnessColumnsData {
14+ export interface MatTableHarnessColumnsText {
1515 [ columnName : string ] : {
1616 text : string [ ] ;
1717 headerText : string ;
@@ -20,7 +20,7 @@ export interface MatTableHarnessColumnsData {
2020}
2121
2222/** Data extracted from a table organized by rows. */
23- export type MatTableHarnessRowsData = {
23+ export type MatTableHarnessRowsText = {
2424 columnName : string ;
2525 text : string ;
2626} [ ] [ ] ;
@@ -54,41 +54,45 @@ export class MatTableHarness extends ComponentHarness {
5454 return this . locatorForAll ( MatFooterRowHarness . with ( filter ) ) ( ) ;
5555 }
5656
57- /** Gets the data inside the entire table organized by rows. */
58- async getRowsData ( ) : Promise < MatTableHarnessRowsData > {
57+ /** Gets the text inside the entire table organized by rows. */
58+ async getRowsText ( ) : Promise < MatTableHarnessRowsText > {
5959 const rows = await this . getRows ( ) ;
60- return Promise . all ( rows . map ( row => row . getData ( ) ) ) ;
60+ return Promise . all ( rows . map ( row => row . getText ( ) ) ) ;
6161 }
6262
63- /** Gets the data inside the entire table organized by columns. */
64- async getColumnsData ( ) : Promise < MatTableHarnessColumnsData > {
65- // Tables can have multiple header rows, but we consider the first one as the "main" row.
66- const headerRow = ( await this . getHeaderRows ( ) ) [ 0 ] ;
67- const footerRow = ( await this . getFooterRows ( ) ) [ 0 ] ;
68- const dataRows = await this . getRows ( ) ;
63+ /** Gets the text inside the entire table organized by columns. */
64+ async getColumnsText ( ) : Promise < MatTableHarnessColumnsText > {
65+ const [ headerRow , footerRow , dataRows ] = await Promise . all ( [
66+ // Tables can have multiple header rows, but we consider the first one as the "main" row.
67+ this . getHeaderRows ( ) . then ( rows => rows [ 0 ] ) ,
68+ this . getFooterRows ( ) . then ( rows => rows [ 0 ] ) ,
69+ this . getRows ( )
70+ ] ) ;
6971
70- const headerData = headerRow ? await headerRow . getData ( ) : [ ] ;
71- const footerData = footerRow ? await footerRow . getData ( ) : [ ] ;
72- const rowsData = await Promise . all ( dataRows . map ( row => row . getData ( ) ) ) ;
73- const data : MatTableHarnessColumnsData = { } ;
72+ const text : MatTableHarnessColumnsText = { } ;
73+ const [ headerData , footerData , rowsData ] = await Promise . all ( [
74+ headerRow ? headerRow . getText ( ) : [ ] ,
75+ footerRow ? footerRow . getText ( ) : [ ] ,
76+ Promise . all ( dataRows . map ( row => row . getText ( ) ) ) ,
77+ ] ) ;
7478
7579 rowsData . forEach ( cells => {
7680 cells . forEach ( cell => {
77- if ( ! data [ cell . columnName ] ) {
81+ if ( ! text [ cell . columnName ] ) {
7882 const headerCell = headerData . find ( header => header . columnName === cell . columnName ) ;
7983 const footerCell = footerData . find ( footer => footer . columnName === cell . columnName ) ;
8084
81- data [ cell . columnName ] = {
85+ text [ cell . columnName ] = {
8286 headerText : headerCell ? headerCell . text : '' ,
8387 footerText : footerCell ? footerCell . text : '' ,
8488 text : [ ]
8589 } ;
8690 }
8791
88- data [ cell . columnName ] . text . push ( cell . text ) ;
92+ text [ cell . columnName ] . text . push ( cell . text ) ;
8993 } ) ;
9094 } ) ;
9195
92- return data ;
96+ return text ;
9397 }
9498}
0 commit comments