-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtable-column-formatted-text.pageobject.ts
46 lines (40 loc) · 1.6 KB
/
table-column-formatted-text.pageobject.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type { TablePageObject } from '../../table/testing/table.pageobject';
import type { TableRecord } from '../../table/types';
/**
* Page object for table columns that format their text for display.
*/
export abstract class TableColumnFormattedTextPageObject<
T extends TableRecord
> {
// When text is localized to different languages, the space character
// can get changed to a different unicode variant. This regular expression
// matches both known unicode variants so we can change them back to a
// regular space to perform consistent checks for testing purposes.
private readonly spaceUnicodeCharsRegEx = /\u202f|\u00a0/g;
public constructor(
protected readonly tablePageObject: TablePageObject<T>
) {}
public getRenderedCellContent(
rowIndex: number,
columnIndex: number
): string {
return this.tablePageObject
.getRenderedCellTextContent(rowIndex, columnIndex)
.replace(this.spaceUnicodeCharsRegEx, ' ');
}
public getRenderedGroupHeaderContent(groupRowIndex: number): string {
return this.tablePageObject
.getRenderedGroupHeaderTextContent(groupRowIndex)
.replace(this.spaceUnicodeCharsRegEx, ' ');
}
public getCellTitle(rowIndex: number, columnIndex: number): string {
this.verifyCellType(rowIndex, columnIndex);
return this.tablePageObject
.getCellTitle(rowIndex, columnIndex)
.replace(this.spaceUnicodeCharsRegEx, ' ');
}
protected abstract verifyCellType(
rowIndex: number,
columnIndex: number
): void;
}