@vuu-ui/vuu-playwright-helpers 3.5.10 → 3.5.12
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 +23 -5
- package/types/PwTable.d.ts +43 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.5.
|
|
2
|
+
"version": "3.5.12",
|
|
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.12"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@playwright/test": "^1.62.1"
|
package/src/PwTable.js
CHANGED
|
@@ -7,6 +7,11 @@ const xpathStringLiteral = (value)=>{
|
|
|
7
7
|
if (!value.includes('"')) return `"${value}"`;
|
|
8
8
|
return `concat('${value.split("'").join("', \"'\", '")}')`;
|
|
9
9
|
};
|
|
10
|
+
const cssAttributeValue = (value)=>Array.from(value, (character)=>{
|
|
11
|
+
const code = character.charCodeAt(0);
|
|
12
|
+
return '"' === character || "\\" === character || code < 32 || 127 === code ? `\\${code.toString(16)} ` : character;
|
|
13
|
+
}).join("");
|
|
14
|
+
const byDataIcon = (iconName)=>`[data-icon="${cssAttributeValue(iconName)}"]`;
|
|
10
15
|
class PwTable extends PlaywrightPageObject {
|
|
11
16
|
cssSelector;
|
|
12
17
|
defaultCssSelector = ".vuuTable";
|
|
@@ -36,12 +41,25 @@ class PwTable extends PlaywrightPageObject {
|
|
|
36
41
|
await expect(textbox).toHaveValue(value);
|
|
37
42
|
await textbox.press("commit" === action ? "Enter" : "Escape");
|
|
38
43
|
}
|
|
44
|
+
async columnNames() {
|
|
45
|
+
return this.#locator.locator(".vuuTableHeaderCell .vuuTableHeaderCell-label").allTextContents();
|
|
46
|
+
}
|
|
47
|
+
async rowCount() {
|
|
48
|
+
const ariaRowCount = await this.#locator.getByRole("table").getAttribute("aria-rowcount");
|
|
49
|
+
if (null === ariaRowCount) throw Error("PwTable, rowCount, table does not have an aria-rowcount");
|
|
50
|
+
return parseInt(ariaRowCount, 10);
|
|
51
|
+
}
|
|
52
|
+
async cellIcon(columnName, ariaRowIndex, iconName) {
|
|
53
|
+
const cell = await this.cell(columnName, ariaRowIndex);
|
|
54
|
+
return cell.locator(byDataIcon(iconName));
|
|
55
|
+
}
|
|
56
|
+
cellsWithIcon(iconName) {
|
|
57
|
+
return this.#locator.getByRole("cell").filter({
|
|
58
|
+
has: this.page.locator(byDataIcon(iconName))
|
|
59
|
+
});
|
|
60
|
+
}
|
|
39
61
|
headerCell(columnName) {
|
|
40
|
-
|
|
41
|
-
const code = character.charCodeAt(0);
|
|
42
|
-
return '"' === character || "\\" === character || code < 32 || 127 === code ? `\\${code.toString(16)} ` : character;
|
|
43
|
-
}).join("");
|
|
44
|
-
return new PwTableHeaderCell(this.page, `${this.cssSelector ?? this.defaultCssSelector} >> .vuuTableHeaderCell[data-column-name="${escapedColumnName}"]`);
|
|
62
|
+
return new PwTableHeaderCell(this.page, `${this.cssSelector ?? this.defaultCssSelector} >> .vuuTableHeaderCell[data-column-name="${cssAttributeValue(columnName)}"]`);
|
|
45
63
|
}
|
|
46
64
|
locateCell(rowOrText, column) {
|
|
47
65
|
if ("number" == typeof rowOrText && "number" == typeof column) return this.#locator.locator(`[aria-rowindex="${rowOrText}"] > [aria-colindex="${column}"]`);
|
package/types/PwTable.d.ts
CHANGED
|
@@ -23,6 +23,49 @@ export declare class PwTable extends PlaywrightPageObject {
|
|
|
23
23
|
*/
|
|
24
24
|
cell(colName: string, ariaRowIndex: number): Promise<Locator>;
|
|
25
25
|
editCell(columnName: string, ariaRowIndex: number, value: string, action?: "commit" | "cancel"): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* The labels displayed in the column headers, in rendered order.
|
|
28
|
+
* Header cells without a label (e.g. the checkbox selection column) are omitted.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* test("renders expected columns", async ({ page }) => {
|
|
32
|
+
* const table = new PwTable(page);
|
|
33
|
+
* expect(await table.columnNames()).toEqual(["Ccy", "Exchange", "Price"]);
|
|
34
|
+
* });
|
|
35
|
+
*/
|
|
36
|
+
columnNames(): Promise<string[]>;
|
|
37
|
+
/**
|
|
38
|
+
* The total row count, read from aria-rowcount on the element with role="table".
|
|
39
|
+
* This is the dataSource size, not the number of rendered rows.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* test("loads all instruments", async ({ page }) => {
|
|
43
|
+
* const table = new PwTable(page);
|
|
44
|
+
* expect(await table.rowCount()).toEqual(1000);
|
|
45
|
+
* });
|
|
46
|
+
*/
|
|
47
|
+
rowCount(): Promise<number>;
|
|
48
|
+
/**
|
|
49
|
+
* Locate the icon with the given data-icon name within a cell.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* test("flags stale prices", async ({ page }) => {
|
|
53
|
+
* const table = new PwTable(page);
|
|
54
|
+
* await expect(await table.cellIcon("status", 3, "warning")).toBeVisible();
|
|
55
|
+
* });
|
|
56
|
+
*/
|
|
57
|
+
cellIcon(columnName: string, ariaRowIndex: number, iconName: string): Promise<Locator>;
|
|
58
|
+
/**
|
|
59
|
+
* Locate all rendered (non header) cells containing an icon with the given
|
|
60
|
+
* data-icon name. Each matching cell is counted once, however many such icons it holds.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* test("flags stale prices", async ({ page }) => {
|
|
64
|
+
* const table = new PwTable(page);
|
|
65
|
+
* await expect(table.cellsWithIcon("warning")).toHaveCount(4);
|
|
66
|
+
* });
|
|
67
|
+
*/
|
|
68
|
+
cellsWithIcon(iconName: string): Locator;
|
|
26
69
|
headerCell(columnName: string): PwTableHeaderCell;
|
|
27
70
|
/**
|
|
28
71
|
* Locate cell by cell contents
|