@vuu-ui/vuu-playwright-helpers 3.5.20 → 3.5.21
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/package.json +2 -2
- package/src/PwTable.js +14 -0
- package/types/PwTable.d.ts +26 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.5.
|
|
2
|
+
"version": "3.5.21",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./src/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@vuu-ui/vuu-protocol-types": "3.5.
|
|
12
|
+
"@vuu-ui/vuu-protocol-types": "3.5.21"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@playwright/test": "^1.62.1"
|
package/src/PwTable.js
CHANGED
|
@@ -39,6 +39,20 @@ class PwTable extends PwComponent {
|
|
|
39
39
|
if (null === ariaRowCount) throw Error("PwTable, rowCount, table does not have an aria-rowcount");
|
|
40
40
|
return parseInt(ariaRowCount, 10);
|
|
41
41
|
}
|
|
42
|
+
get dataLoaded() {
|
|
43
|
+
return expect.poll(()=>this.rowCount()).toBeGreaterThan(0);
|
|
44
|
+
}
|
|
45
|
+
async columnValues(columnName) {
|
|
46
|
+
const headerCell = this.locator.locator(`xpath=.//*[@role='columnheader' and @data-column-name=${xpathStringLiteral(columnName)}]`).first();
|
|
47
|
+
const ariaColIndex = await headerCell.getAttribute("aria-colindex");
|
|
48
|
+
if (null === ariaColIndex) throw Error(`PwTable, columnValues, column "${columnName}" does not have an aria-colindex`);
|
|
49
|
+
const cells = this.locator.locator(`[role="row"] > [role="cell"][aria-colindex="${ariaColIndex}"]`);
|
|
50
|
+
const values = await cells.evaluateAll((elements)=>elements.map((cell)=>({
|
|
51
|
+
rowIndex: Number(cell.parentElement?.getAttribute("aria-rowindex")),
|
|
52
|
+
text: cell.textContent ?? ""
|
|
53
|
+
})));
|
|
54
|
+
return values.sort((v1, v2)=>v1.rowIndex - v2.rowIndex).map(({ text })=>text);
|
|
55
|
+
}
|
|
42
56
|
async cellIcon(columnName, ariaRowIndex, iconName) {
|
|
43
57
|
const cell = await this.cell(columnName, ariaRowIndex);
|
|
44
58
|
return cell.locator(byDataIcon(iconName));
|
package/types/PwTable.d.ts
CHANGED
|
@@ -100,6 +100,32 @@ export declare class PwTable extends PwComponent {
|
|
|
100
100
|
* });
|
|
101
101
|
*/
|
|
102
102
|
rowCount(): Promise<number>;
|
|
103
|
+
/**
|
|
104
|
+
* Wait until the table has loaded data, i.e. rowCount is greater than zero.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* test("table loads", async ({ mount, page }) => {
|
|
108
|
+
* await mount("Filters/FilterContainer/FilterContainerWithTable");
|
|
109
|
+
* const table = new PwTable(page);
|
|
110
|
+
* await table.dataLoaded;
|
|
111
|
+
* });
|
|
112
|
+
*/
|
|
113
|
+
get dataLoaded(): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* The text content of the data cells in a column, exactly as formatted in
|
|
116
|
+
* the table, in row order. These are the cells in data rows with the same
|
|
117
|
+
* aria-colindex as the column header. The table is virtualised, so only
|
|
118
|
+
* rendered rows are included.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* test("filter on currency", async ({ page }) => {
|
|
122
|
+
* const table = new PwTable(page);
|
|
123
|
+
* await expect
|
|
124
|
+
* .poll(async () => new Set(await table.columnValues("currency")))
|
|
125
|
+
* .toEqual(new Set(["GBP"]));
|
|
126
|
+
* });
|
|
127
|
+
*/
|
|
128
|
+
columnValues(columnName: string): Promise<string[]>;
|
|
103
129
|
/**
|
|
104
130
|
* Locate the icon with the given data-icon name within a cell.
|
|
105
131
|
*
|