@elastic/eui-test-helpers 2.0.0 → 2.1.0-snapshot.1792553816977
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/README.md +2 -0
- package/lib/cjs/components/color_picker/selectors.d.ts +6 -2
- package/lib/cjs/components/color_picker/selectors.js +8 -4
- package/lib/cjs/components/pagination/selectors.d.ts +21 -0
- package/lib/cjs/components/pagination/selectors.js +35 -0
- package/lib/cjs/components/table/selectors.d.ts +15 -0
- package/lib/cjs/components/table/selectors.js +29 -0
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +22 -8
- package/lib/cjs/playwright/base_object.js +6 -4
- package/lib/cjs/playwright/components/basic_table/object.d.ts +7 -12
- package/lib/cjs/playwright/components/basic_table/object.js +7 -13
- package/lib/cjs/playwright/components/color_picker/object.d.ts +25 -4
- package/lib/cjs/playwright/components/color_picker/object.js +68 -3
- package/lib/cjs/playwright/components/pagination/object.d.ts +37 -0
- package/lib/cjs/playwright/components/pagination/object.js +121 -0
- package/lib/cjs/playwright/components/table/object.d.ts +28 -0
- package/lib/cjs/playwright/components/table/object.js +57 -0
- package/lib/cjs/selectors.d.ts +19 -0
- package/lib/cjs/selectors.js +18 -14
- package/lib/esm/components/color_picker/selectors.d.ts +6 -2
- package/lib/esm/components/color_picker/selectors.js +7 -3
- package/lib/esm/components/color_picker/selectors.js.map +1 -1
- package/lib/esm/components/pagination/selectors.d.ts +21 -0
- package/lib/esm/components/pagination/selectors.js +29 -0
- package/lib/esm/components/pagination/selectors.js.map +1 -0
- package/lib/esm/components/table/selectors.d.ts +15 -0
- package/lib/esm/components/table/selectors.js +23 -0
- package/lib/esm/components/table/selectors.js.map +1 -0
- package/lib/esm/index.d.ts +2 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/playwright/base_object.js +10 -4
- package/lib/esm/playwright/base_object.js.map +1 -1
- package/lib/esm/playwright/components/basic_table/object.d.ts +7 -12
- package/lib/esm/playwright/components/basic_table/object.js +7 -15
- package/lib/esm/playwright/components/basic_table/object.js.map +1 -1
- package/lib/esm/playwright/components/color_picker/object.d.ts +25 -4
- package/lib/esm/playwright/components/color_picker/object.js +65 -3
- package/lib/esm/playwright/components/color_picker/object.js.map +1 -1
- package/lib/esm/playwright/components/pagination/object.d.ts +37 -0
- package/lib/esm/playwright/components/pagination/object.js +118 -0
- package/lib/esm/playwright/components/pagination/object.js.map +1 -0
- package/lib/esm/playwright/components/table/object.d.ts +28 -0
- package/lib/esm/playwright/components/table/object.js +46 -0
- package/lib/esm/playwright/components/table/object.js.map +1 -0
- package/lib/esm/selectors.d.ts +19 -0
- package/lib/esm/selectors.js +4 -0
- package/lib/esm/selectors.js.map +1 -1
- package/package.json +3 -2
- package/src/components/basic_table/README.md +1 -0
- package/src/components/color_picker/README.md +7 -5
- package/src/components/pagination/README.md +31 -0
- package/src/components/table/README.md +31 -0
package/README.md
CHANGED
|
@@ -59,6 +59,8 @@ their own version at runtime.
|
|
|
59
59
|
| `EuiAccordionObject` | [src/components/accordion/README.md](src/components/accordion/README.md) |
|
|
60
60
|
| `EuiContextMenuObject` | [src/components/context_menu/README.md](src/components/context_menu/README.md) |
|
|
61
61
|
| `EuiModalObject` | [src/components/modal/README.md](src/components/modal/README.md) |
|
|
62
|
+
| `EuiTableObject` | [src/components/table/README.md](src/components/table/README.md) |
|
|
63
|
+
| `EuiPaginationObject` | [src/components/pagination/README.md](src/components/pagination/README.md) |
|
|
62
64
|
| `EuiBasicTableObject` | [src/components/basic_table/README.md](src/components/basic_table/README.md) |
|
|
63
65
|
| `EuiColorPickerObject` | [src/components/color_picker/README.md](src/components/color_picker/README.md) |
|
|
64
66
|
| `EuiTreeViewObject` | [src/components/tree_view/README.md](src/components/tree_view/README.md) |
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stable selectors for
|
|
3
3
|
* {@link https://eui.elastic.co/docs/components/forms/color-picker/|EuiColorPicker}.
|
|
4
|
-
* `*_SELECTOR` values are CSS.
|
|
4
|
+
* `*_SELECTOR` values are CSS, `*_TEST_SUBJ` values are `data-test-subj` names EUI sets itself.
|
|
5
5
|
*/
|
|
6
6
|
export declare const EuiColorPickerSelectors: {
|
|
7
|
-
/**
|
|
7
|
+
/** Token EUI adds to the anchor's `data-test-subj`, on the default input and on a custom `button` alike. */
|
|
8
|
+
ANCHOR_TEST_SUBJ: string;
|
|
9
|
+
/** The anchor, whether the default text input or a custom `button`. */
|
|
8
10
|
ANCHOR_SELECTOR: string;
|
|
9
11
|
/** The popover panel, rendered in a portal and only while open. */
|
|
10
12
|
PANEL_SELECTOR: string;
|
|
11
13
|
/** A swatch button inside the panel. */
|
|
12
14
|
SWATCH_SELECTOR: string;
|
|
15
|
+
/** The hex input inside the panel. Present only when `secondaryInputDisplay` is `top` or `bottom`. */
|
|
16
|
+
SECONDARY_INPUT_SELECTOR: string;
|
|
13
17
|
};
|
|
@@ -15,13 +15,17 @@ exports.EuiColorPickerSelectors = void 0;
|
|
|
15
15
|
/**
|
|
16
16
|
* Stable selectors for
|
|
17
17
|
* {@link https://eui.elastic.co/docs/components/forms/color-picker/|EuiColorPicker}.
|
|
18
|
-
* `*_SELECTOR` values are CSS.
|
|
18
|
+
* `*_SELECTOR` values are CSS, `*_TEST_SUBJ` values are `data-test-subj` names EUI sets itself.
|
|
19
19
|
*/
|
|
20
20
|
const EuiColorPickerSelectors = exports.EuiColorPickerSelectors = {
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/** Token EUI adds to the anchor's `data-test-subj`, on the default input and on a custom `button` alike. */
|
|
22
|
+
ANCHOR_TEST_SUBJ: 'euiColorPickerAnchor',
|
|
23
|
+
/** The anchor, whether the default text input or a custom `button`. */
|
|
24
|
+
ANCHOR_SELECTOR: '[data-test-subj~="euiColorPickerAnchor"]',
|
|
23
25
|
/** The popover panel, rendered in a portal and only while open. */
|
|
24
26
|
PANEL_SELECTOR: '[data-popover-panel].euiColorPicker__popoverPanel',
|
|
25
27
|
/** A swatch button inside the panel. */
|
|
26
|
-
SWATCH_SELECTOR: '.euiColorPickerSwatch'
|
|
28
|
+
SWATCH_SELECTOR: '.euiColorPickerSwatch',
|
|
29
|
+
/** The hex input inside the panel. Present only when `secondaryInputDisplay` is `top` or `bottom`. */
|
|
30
|
+
SECONDARY_INPUT_SELECTOR: '[data-test-subj^="euiColorPickerInput_"]'
|
|
27
31
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable selectors for
|
|
3
|
+
* {@link https://eui.elastic.co/docs/components/navigation/pagination/|EuiPagination}.
|
|
4
|
+
* `*_SELECTOR` values are CSS, `*_TEST_SUBJ` values are `data-test-subj` names EUI sets itself.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EuiPaginationSelectors: {
|
|
7
|
+
/** The `<nav>` root carrying the consumer's `data-test-subj`. */
|
|
8
|
+
ROOT_SELECTOR: string;
|
|
9
|
+
/** A numbered page button. Not rendered in the compressed variant. */
|
|
10
|
+
PAGE_BUTTON_SELECTOR: string;
|
|
11
|
+
/** The numbered page button of the active page. */
|
|
12
|
+
ACTIVE_PAGE_BUTTON_SELECTOR: string;
|
|
13
|
+
/** The "page of total" text of the compressed variant, with one `<span>` per number. */
|
|
14
|
+
COMPRESSED_TEXT_SELECTOR: string;
|
|
15
|
+
/** Prefix of a page button's test subj, followed by the 0-based page index. */
|
|
16
|
+
PAGE_BUTTON_TEST_SUBJ_PREFIX: string;
|
|
17
|
+
FIRST_BUTTON_TEST_SUBJ: string;
|
|
18
|
+
PREVIOUS_BUTTON_TEST_SUBJ: string;
|
|
19
|
+
NEXT_BUTTON_TEST_SUBJ: string;
|
|
20
|
+
LAST_BUTTON_TEST_SUBJ: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EuiPaginationSelectors = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
9
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
10
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
11
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
12
|
+
* Side Public License, v 1.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Stable selectors for
|
|
17
|
+
* {@link https://eui.elastic.co/docs/components/navigation/pagination/|EuiPagination}.
|
|
18
|
+
* `*_SELECTOR` values are CSS, `*_TEST_SUBJ` values are `data-test-subj` names EUI sets itself.
|
|
19
|
+
*/
|
|
20
|
+
const EuiPaginationSelectors = exports.EuiPaginationSelectors = {
|
|
21
|
+
/** The `<nav>` root carrying the consumer's `data-test-subj`. */
|
|
22
|
+
ROOT_SELECTOR: '.euiPagination',
|
|
23
|
+
/** A numbered page button. Not rendered in the compressed variant. */
|
|
24
|
+
PAGE_BUTTON_SELECTOR: '.euiPaginationButton',
|
|
25
|
+
/** The numbered page button of the active page. */
|
|
26
|
+
ACTIVE_PAGE_BUTTON_SELECTOR: '.euiPaginationButton[aria-current="page"]',
|
|
27
|
+
/** The "page of total" text of the compressed variant, with one `<span>` per number. */
|
|
28
|
+
COMPRESSED_TEXT_SELECTOR: '.euiPagination__compressedText',
|
|
29
|
+
/** Prefix of a page button's test subj, followed by the 0-based page index. */
|
|
30
|
+
PAGE_BUTTON_TEST_SUBJ_PREFIX: 'pagination-button-',
|
|
31
|
+
FIRST_BUTTON_TEST_SUBJ: 'pagination-button-first',
|
|
32
|
+
PREVIOUS_BUTTON_TEST_SUBJ: 'pagination-button-previous',
|
|
33
|
+
NEXT_BUTTON_TEST_SUBJ: 'pagination-button-next',
|
|
34
|
+
LAST_BUTTON_TEST_SUBJ: 'pagination-button-last'
|
|
35
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable selectors for
|
|
3
|
+
* {@link https://eui.elastic.co/docs/components/tabular-content/tables/|EuiTable}.
|
|
4
|
+
* `*_SELECTOR` values are CSS.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EuiTableSelectors: {
|
|
7
|
+
/** The `<table>` element carrying the consumer's `data-test-subj`. */
|
|
8
|
+
ROOT_SELECTOR: string;
|
|
9
|
+
/** A body row. Also matches EUI's own empty/error message row, callers must exclude those. */
|
|
10
|
+
ROW_SELECTOR: string;
|
|
11
|
+
/** A body cell. */
|
|
12
|
+
ROW_CELL_SELECTOR: string;
|
|
13
|
+
/** A header cell, including the selection checkbox cell which has its own class. */
|
|
14
|
+
HEADER_CELL_SELECTOR: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EuiTableSelectors = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
9
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
10
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
11
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
12
|
+
* Side Public License, v 1.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Stable selectors for
|
|
17
|
+
* {@link https://eui.elastic.co/docs/components/tabular-content/tables/|EuiTable}.
|
|
18
|
+
* `*_SELECTOR` values are CSS.
|
|
19
|
+
*/
|
|
20
|
+
const EuiTableSelectors = exports.EuiTableSelectors = {
|
|
21
|
+
/** The `<table>` element carrying the consumer's `data-test-subj`. */
|
|
22
|
+
ROOT_SELECTOR: '.euiTable',
|
|
23
|
+
/** A body row. Also matches EUI's own empty/error message row, callers must exclude those. */
|
|
24
|
+
ROW_SELECTOR: '.euiTableRow',
|
|
25
|
+
/** A body cell. */
|
|
26
|
+
ROW_CELL_SELECTOR: '.euiTableRowCell',
|
|
27
|
+
/** A header cell, including the selection checkbox cell which has its own class. */
|
|
28
|
+
HEADER_CELL_SELECTOR: 'thead > tr > :is(th, td)'
|
|
29
|
+
};
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export { EuiFlyoutObject } from './playwright/components/flyout/object';
|
|
|
12
12
|
export { EuiAccordionObject } from './playwright/components/accordion/object';
|
|
13
13
|
export { EuiContextMenuObject } from './playwright/components/context_menu/object';
|
|
14
14
|
export { EuiModalObject } from './playwright/components/modal/object';
|
|
15
|
+
export { EuiTableObject } from './playwright/components/table/object';
|
|
16
|
+
export { EuiPaginationObject } from './playwright/components/pagination/object';
|
|
15
17
|
export { EuiBasicTableObject } from './playwright/components/basic_table/object';
|
|
16
18
|
export { EuiColorPickerObject } from './playwright/components/color_picker/object';
|
|
17
19
|
export { EuiTreeViewObject } from './playwright/components/tree_view/object';
|
package/lib/cjs/index.js
CHANGED
|
@@ -18,13 +18,13 @@ Object.defineProperty(exports, "EuiAccordionObject", {
|
|
|
18
18
|
Object.defineProperty(exports, "EuiBasicTableObject", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _object16.EuiBasicTableObject;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "EuiColorPickerObject", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
27
|
+
return _object17.EuiColorPickerObject;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "EuiComboBoxObject", {
|
|
@@ -75,6 +75,12 @@ Object.defineProperty(exports, "EuiModalObject", {
|
|
|
75
75
|
return _object13.EuiModalObject;
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
+
Object.defineProperty(exports, "EuiPaginationObject", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _object15.EuiPaginationObject;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
78
84
|
Object.defineProperty(exports, "EuiPopoverObject", {
|
|
79
85
|
enumerable: true,
|
|
80
86
|
get: function () {
|
|
@@ -99,16 +105,22 @@ Object.defineProperty(exports, "EuiSuperSelectObject", {
|
|
|
99
105
|
return _object3.EuiSuperSelectObject;
|
|
100
106
|
}
|
|
101
107
|
});
|
|
108
|
+
Object.defineProperty(exports, "EuiTableObject", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () {
|
|
111
|
+
return _object14.EuiTableObject;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
102
114
|
Object.defineProperty(exports, "EuiToolTipObject", {
|
|
103
115
|
enumerable: true,
|
|
104
116
|
get: function () {
|
|
105
|
-
return
|
|
117
|
+
return _object19.EuiToolTipObject;
|
|
106
118
|
}
|
|
107
119
|
});
|
|
108
120
|
Object.defineProperty(exports, "EuiTreeViewObject", {
|
|
109
121
|
enumerable: true,
|
|
110
122
|
get: function () {
|
|
111
|
-
return
|
|
123
|
+
return _object18.EuiTreeViewObject;
|
|
112
124
|
}
|
|
113
125
|
});
|
|
114
126
|
Object.defineProperty(exports, "selectors", {
|
|
@@ -131,8 +143,10 @@ var _object10 = require("./playwright/components/flyout/object");
|
|
|
131
143
|
var _object11 = require("./playwright/components/accordion/object");
|
|
132
144
|
var _object12 = require("./playwright/components/context_menu/object");
|
|
133
145
|
var _object13 = require("./playwright/components/modal/object");
|
|
134
|
-
var _object14 = require("./playwright/components/
|
|
135
|
-
var _object15 = require("./playwright/components/
|
|
136
|
-
var _object16 = require("./playwright/components/
|
|
137
|
-
var _object17 = require("./playwright/components/
|
|
146
|
+
var _object14 = require("./playwright/components/table/object");
|
|
147
|
+
var _object15 = require("./playwright/components/pagination/object");
|
|
148
|
+
var _object16 = require("./playwright/components/basic_table/object");
|
|
149
|
+
var _object17 = require("./playwright/components/color_picker/object");
|
|
150
|
+
var _object18 = require("./playwright/components/tree_view/object");
|
|
151
|
+
var _object19 = require("./playwright/components/tool_tip/object");
|
|
138
152
|
var _selectors = require("./selectors");
|
|
@@ -13,11 +13,13 @@ exports.BaseObject = void 0;
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Matches
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* Matches space-separated tokens in `data-test-subj`, not the whole attribute
|
|
17
|
+
* value. `getByTestId` does an exact match and misses components like
|
|
18
|
+
* `EuiColorPicker` that add their own token to the consumer's subj. A
|
|
19
|
+
* `testSubj` with spaces (`colorEditorColorPicker 0`, a Kibana convention) is
|
|
20
|
+
* split so every token must be present, in any order.
|
|
19
21
|
*/
|
|
20
|
-
const testSubjSelector = testSubj => `[data-test-subj~="${
|
|
22
|
+
const testSubjSelector = testSubj => testSubj.trim().split(/\s+/).map(token => `[data-test-subj~="${token.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"]`).join('');
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* Base class for Playwright Component Objects — semantic wrappers around a
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Locator } from '@playwright/test';
|
|
2
|
-
import {
|
|
2
|
+
import type { ObjectScope } from '../../base_object';
|
|
3
|
+
import { EuiTableObject } from '../table/object';
|
|
3
4
|
/**
|
|
4
5
|
* Playwright Component Object for {@link
|
|
5
6
|
* https://eui.elastic.co/docs/components/tabular-content/tables/ EuiBasicTable}
|
|
@@ -8,20 +9,14 @@ import { BaseObject, type ObjectScope } from '../../base_object';
|
|
|
8
9
|
*
|
|
9
10
|
* `testSubj` must match the `data-test-subj` set by the consumer on the
|
|
10
11
|
* `<EuiBasicTable>`/`<EuiInMemoryTable>` (EUI spreads it onto the `.euiBasicTable`
|
|
11
|
-
* root).
|
|
12
|
+
* root). Extends `EuiTableObject`, so `rows`, `headerCells`, `column` and `cell`
|
|
13
|
+
* are available too. See the package README for what's deliberately excluded.
|
|
12
14
|
*/
|
|
13
|
-
export declare class EuiBasicTableObject extends
|
|
15
|
+
export declare class EuiBasicTableObject extends EuiTableObject {
|
|
14
16
|
constructor(scope: ObjectScope, testSubj: string);
|
|
15
17
|
/**
|
|
16
|
-
* The
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Excludes EUI's own "no items found" (and error-message) row: when the table
|
|
20
|
-
* is empty, EUI still renders a single `.euiTableRow` whose one cell spans
|
|
21
|
-
* every column (`colSpan` on `EuiTableRowCell`, the `td[colspan]` HTML
|
|
22
|
-
* attribute). Real data rows don't set `colspan` on their cells, so filtering
|
|
23
|
-
* it out is what keeps `toHaveCount(0)` correct on an empty table instead of
|
|
24
|
-
* reading `1`.
|
|
18
|
+
* The data rows. Excludes EUI's own "no items found" row, whose single cell
|
|
19
|
+
* spans every column with `colspan`. Basic table data rows never set it.
|
|
25
20
|
*/
|
|
26
21
|
get rows(): Locator;
|
|
27
22
|
/**
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EuiBasicTableObject = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _object = require("../table/object");
|
|
8
8
|
var _selectors = require("../../../components/basic_table/selectors");
|
|
9
9
|
/*
|
|
10
10
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -22,26 +22,20 @@ var _selectors = require("../../../components/basic_table/selectors");
|
|
|
22
22
|
*
|
|
23
23
|
* `testSubj` must match the `data-test-subj` set by the consumer on the
|
|
24
24
|
* `<EuiBasicTable>`/`<EuiInMemoryTable>` (EUI spreads it onto the `.euiBasicTable`
|
|
25
|
-
* root).
|
|
25
|
+
* root). Extends `EuiTableObject`, so `rows`, `headerCells`, `column` and `cell`
|
|
26
|
+
* are available too. See the package README for what's deliberately excluded.
|
|
26
27
|
*/
|
|
27
|
-
class EuiBasicTableObject extends
|
|
28
|
+
class EuiBasicTableObject extends _object.EuiTableObject {
|
|
28
29
|
constructor(scope, testSubj) {
|
|
29
30
|
super(scope, testSubj, _selectors.EuiBasicTableSelectors.ROOT_SELECTOR);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
* The
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* Excludes EUI's own "no items found" (and error-message) row: when the table
|
|
37
|
-
* is empty, EUI still renders a single `.euiTableRow` whose one cell spans
|
|
38
|
-
* every column (`colSpan` on `EuiTableRowCell`, the `td[colspan]` HTML
|
|
39
|
-
* attribute). Real data rows don't set `colspan` on their cells, so filtering
|
|
40
|
-
* it out is what keeps `toHaveCount(0)` correct on an empty table instead of
|
|
41
|
-
* reading `1`.
|
|
34
|
+
* The data rows. Excludes EUI's own "no items found" row, whose single cell
|
|
35
|
+
* spans every column with `colspan`. Basic table data rows never set it.
|
|
42
36
|
*/
|
|
43
37
|
get rows() {
|
|
44
|
-
return
|
|
38
|
+
return super.rows.filter({
|
|
45
39
|
hasNot: this.root.page().locator('td[colspan]')
|
|
46
40
|
});
|
|
47
41
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Locator } from '@playwright/test';
|
|
2
2
|
import { BaseObject, type ObjectScope } from '../../base_object';
|
|
3
3
|
/**
|
|
4
4
|
* Playwright Component Object for {@link
|
|
5
5
|
* https://eui.elastic.co/docs/components/forms/color-picker/ EuiColorPicker}.
|
|
6
6
|
*
|
|
7
|
-
* `testSubj` must be set on `EuiColorPicker` itself.
|
|
8
|
-
* text
|
|
9
|
-
* what this does not cover.
|
|
7
|
+
* `testSubj` must be set on `EuiColorPicker` itself. `locator` is the anchor:
|
|
8
|
+
* the default text input, or the element passed as the `button` prop. See the
|
|
9
|
+
* package README for what this does not cover.
|
|
10
10
|
*/
|
|
11
11
|
export declare class EuiColorPickerObject extends BaseObject {
|
|
12
12
|
constructor(scope: ObjectScope, testSubj: string);
|
|
@@ -17,4 +17,25 @@ export declare class EuiColorPickerObject extends BaseObject {
|
|
|
17
17
|
get panel(): Locator;
|
|
18
18
|
/** The swatch buttons inside {@link panel}. */
|
|
19
19
|
get swatches(): Locator;
|
|
20
|
+
/**
|
|
21
|
+
* Type `color` into the hex input and verify it was accepted. With the
|
|
22
|
+
* default anchor that input is the anchor itself. With a custom `button`
|
|
23
|
+
* the input lives inside the panel, so the picker is opened, filled and
|
|
24
|
+
* closed again. Throws if the panel has no input
|
|
25
|
+
* (`secondaryInputDisplay="none"`).
|
|
26
|
+
*/
|
|
27
|
+
setColor(color: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* The color shown in the hex input, uppercased. With a custom `button` the
|
|
30
|
+
* picker is opened to read it and closed again.
|
|
31
|
+
*/
|
|
32
|
+
getColor(): Promise<string>;
|
|
33
|
+
private isInputAnchor;
|
|
34
|
+
/**
|
|
35
|
+
* Click a custom `button` anchor, which toggles the panel, and wait for the
|
|
36
|
+
* panel to follow. Only used with a custom `button`: the default input
|
|
37
|
+
* anchor opens on click but does not close on a second one.
|
|
38
|
+
*/
|
|
39
|
+
private toggle;
|
|
40
|
+
private secondaryInput;
|
|
20
41
|
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EuiColorPickerObject = void 0;
|
|
7
|
+
var _test = require("@playwright/test");
|
|
7
8
|
var _base_object = require("../../base_object");
|
|
8
9
|
var _selectors = require("../../../components/color_picker/selectors");
|
|
9
10
|
/*
|
|
@@ -18,9 +19,9 @@ var _selectors = require("../../../components/color_picker/selectors");
|
|
|
18
19
|
* Playwright Component Object for {@link
|
|
19
20
|
* https://eui.elastic.co/docs/components/forms/color-picker/ EuiColorPicker}.
|
|
20
21
|
*
|
|
21
|
-
* `testSubj` must be set on `EuiColorPicker` itself.
|
|
22
|
-
* text
|
|
23
|
-
* what this does not cover.
|
|
22
|
+
* `testSubj` must be set on `EuiColorPicker` itself. `locator` is the anchor:
|
|
23
|
+
* the default text input, or the element passed as the `button` prop. See the
|
|
24
|
+
* package README for what this does not cover.
|
|
24
25
|
*/
|
|
25
26
|
class EuiColorPickerObject extends _base_object.BaseObject {
|
|
26
27
|
constructor(scope, testSubj) {
|
|
@@ -39,5 +40,69 @@ class EuiColorPickerObject extends _base_object.BaseObject {
|
|
|
39
40
|
get swatches() {
|
|
40
41
|
return this.panel.locator(_selectors.EuiColorPickerSelectors.SWATCH_SELECTOR);
|
|
41
42
|
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Type `color` into the hex input and verify it was accepted. With the
|
|
46
|
+
* default anchor that input is the anchor itself. With a custom `button`
|
|
47
|
+
* the input lives inside the panel, so the picker is opened, filled and
|
|
48
|
+
* closed again. Throws if the panel has no input
|
|
49
|
+
* (`secondaryInputDisplay="none"`).
|
|
50
|
+
*/
|
|
51
|
+
async setColor(color) {
|
|
52
|
+
// EUI echoes the value back uppercased.
|
|
53
|
+
const expected = color.toUpperCase();
|
|
54
|
+
if (await this.isInputAnchor()) {
|
|
55
|
+
await this.root.fill(color);
|
|
56
|
+
await (0, _test.expect)(this.root).toHaveValue(expected);
|
|
57
|
+
await this.root.blur();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
await this.toggle();
|
|
61
|
+
const input = await this.secondaryInput();
|
|
62
|
+
await input.fill(color);
|
|
63
|
+
await (0, _test.expect)(input).toHaveValue(expected);
|
|
64
|
+
await this.toggle();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The color shown in the hex input, uppercased. With a custom `button` the
|
|
69
|
+
* picker is opened to read it and closed again.
|
|
70
|
+
*/
|
|
71
|
+
async getColor() {
|
|
72
|
+
if (await this.isInputAnchor()) {
|
|
73
|
+
return this.root.inputValue();
|
|
74
|
+
}
|
|
75
|
+
await this.toggle();
|
|
76
|
+
const value = await (await this.secondaryInput()).inputValue();
|
|
77
|
+
await this.toggle();
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
async isInputAnchor() {
|
|
81
|
+
return this.root.evaluate(el => el.tagName === 'INPUT');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Click a custom `button` anchor, which toggles the panel, and wait for the
|
|
86
|
+
* panel to follow. Only used with a custom `button`: the default input
|
|
87
|
+
* anchor opens on click but does not close on a second one.
|
|
88
|
+
*/
|
|
89
|
+
async toggle() {
|
|
90
|
+
const wasOpen = (await this.panel.count()) > 0;
|
|
91
|
+
await this.root.click();
|
|
92
|
+
if (wasOpen) {
|
|
93
|
+
await this.panel.waitFor({
|
|
94
|
+
state: 'detached'
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
await (0, _test.expect)(this.panel).toHaveAttribute('data-popover-open', 'true');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async secondaryInput() {
|
|
101
|
+
const input = this.panel.locator(_selectors.EuiColorPickerSelectors.SECONDARY_INPUT_SELECTOR);
|
|
102
|
+
if ((await input.count()) === 0) {
|
|
103
|
+
throw new Error(`EuiColorPicker "${this.testSubj}" uses a custom button and its panel has no hex input. ` + `Set secondaryInputDisplay to "top" or "bottom" to read or set its color.`);
|
|
104
|
+
}
|
|
105
|
+
return input;
|
|
106
|
+
}
|
|
42
107
|
}
|
|
43
108
|
exports.EuiColorPickerObject = EuiColorPickerObject;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseObject, type ObjectScope } from '../../base_object';
|
|
2
|
+
/**
|
|
3
|
+
* Playwright Component Object for {@link
|
|
4
|
+
* https://eui.elastic.co/docs/components/navigation/pagination/ EuiPagination}.
|
|
5
|
+
*
|
|
6
|
+
* `testSubj` must be set on `EuiPagination` itself, EUI spreads it onto the
|
|
7
|
+
* `<nav>`. Page indexes are 0-based, matching EUI's `activePage` and the
|
|
8
|
+
* `pagination-button-<index>` test subjs. Covers the numbered and the
|
|
9
|
+
* compressed variant.
|
|
10
|
+
*/
|
|
11
|
+
export declare class EuiPaginationObject extends BaseObject {
|
|
12
|
+
constructor(scope: ObjectScope, testSubj: string);
|
|
13
|
+
/** The 0-based index of the active page. */
|
|
14
|
+
getActivePage(): Promise<number>;
|
|
15
|
+
/** The total number of pages. */
|
|
16
|
+
getPageCount(): Promise<number>;
|
|
17
|
+
/**
|
|
18
|
+
* Go to the page at the 0-based `index` and wait for it to become active.
|
|
19
|
+
* Clicks the page button when EUI renders it, otherwise steps through
|
|
20
|
+
* next or previous until it does. A no-op if already active. Throws if
|
|
21
|
+
* `index` is not a page, or the page never becomes active.
|
|
22
|
+
*/
|
|
23
|
+
goToPage(index: number): Promise<void>;
|
|
24
|
+
/** Click the next arrow and wait for the active page to advance. */
|
|
25
|
+
next(): Promise<void>;
|
|
26
|
+
/** Click the previous arrow and wait for the active page to go back. */
|
|
27
|
+
previous(): Promise<void>;
|
|
28
|
+
private pageButton;
|
|
29
|
+
private arrow;
|
|
30
|
+
private isCompressed;
|
|
31
|
+
/**
|
|
32
|
+
* The compressed "page of total" numbers as [page, total]. Translations may
|
|
33
|
+
* order the two the other way round, and the page is never above the total,
|
|
34
|
+
* so the smaller one is the page.
|
|
35
|
+
*/
|
|
36
|
+
private compressedNumbers;
|
|
37
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EuiPaginationObject = void 0;
|
|
7
|
+
var _test = require("@playwright/test");
|
|
8
|
+
var _base_object = require("../../base_object");
|
|
9
|
+
var _selectors = require("../../../components/pagination/selectors");
|
|
10
|
+
/*
|
|
11
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
12
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
13
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
14
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
15
|
+
* Side Public License, v 1.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Playwright Component Object for {@link
|
|
20
|
+
* https://eui.elastic.co/docs/components/navigation/pagination/ EuiPagination}.
|
|
21
|
+
*
|
|
22
|
+
* `testSubj` must be set on `EuiPagination` itself, EUI spreads it onto the
|
|
23
|
+
* `<nav>`. Page indexes are 0-based, matching EUI's `activePage` and the
|
|
24
|
+
* `pagination-button-<index>` test subjs. Covers the numbered and the
|
|
25
|
+
* compressed variant.
|
|
26
|
+
*/
|
|
27
|
+
class EuiPaginationObject extends _base_object.BaseObject {
|
|
28
|
+
constructor(scope, testSubj) {
|
|
29
|
+
super(scope, testSubj, _selectors.EuiPaginationSelectors.ROOT_SELECTOR);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The 0-based index of the active page. */
|
|
33
|
+
async getActivePage() {
|
|
34
|
+
if (await this.isCompressed()) {
|
|
35
|
+
const [page] = await this.compressedNumbers();
|
|
36
|
+
return page - 1;
|
|
37
|
+
}
|
|
38
|
+
const text = await this.root.locator(_selectors.EuiPaginationSelectors.ACTIVE_PAGE_BUTTON_SELECTOR).innerText();
|
|
39
|
+
return Number(text) - 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The total number of pages. */
|
|
43
|
+
async getPageCount() {
|
|
44
|
+
if (await this.isCompressed()) {
|
|
45
|
+
const [, total] = await this.compressedNumbers();
|
|
46
|
+
return total;
|
|
47
|
+
}
|
|
48
|
+
// EUI always renders the last page's button, so its label is the count.
|
|
49
|
+
return Number(await this.root.locator(_selectors.EuiPaginationSelectors.PAGE_BUTTON_SELECTOR).last().innerText());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Go to the page at the 0-based `index` and wait for it to become active.
|
|
54
|
+
* Clicks the page button when EUI renders it, otherwise steps through
|
|
55
|
+
* next or previous until it does. A no-op if already active. Throws if
|
|
56
|
+
* `index` is not a page, or the page never becomes active.
|
|
57
|
+
*/
|
|
58
|
+
async goToPage(index) {
|
|
59
|
+
const pageCount = await this.getPageCount();
|
|
60
|
+
if (!Number.isInteger(index) || index < 0 || index >= pageCount) {
|
|
61
|
+
throw new Error(`EuiPagination "${this.testSubj}" has ${pageCount} pages, page index ${index} is out of range.`);
|
|
62
|
+
}
|
|
63
|
+
for (let step = 0; step < pageCount; step++) {
|
|
64
|
+
const active = await this.getActivePage();
|
|
65
|
+
if (active === index) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const button = this.pageButton(index);
|
|
69
|
+
if ((await button.count()) > 0) {
|
|
70
|
+
await button.click();
|
|
71
|
+
} else if (index > active) {
|
|
72
|
+
await this.arrow(_selectors.EuiPaginationSelectors.NEXT_BUTTON_TEST_SUBJ).click();
|
|
73
|
+
} else {
|
|
74
|
+
await this.arrow(_selectors.EuiPaginationSelectors.PREVIOUS_BUTTON_TEST_SUBJ).click();
|
|
75
|
+
}
|
|
76
|
+
await _test.expect.poll(() => this.getActivePage()).not.toBe(active);
|
|
77
|
+
}
|
|
78
|
+
if ((await this.getActivePage()) !== index) {
|
|
79
|
+
throw new Error(`EuiPagination "${this.testSubj}" did not reach page index ${index} after ${pageCount} steps.`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Click the next arrow and wait for the active page to advance. */
|
|
84
|
+
async next() {
|
|
85
|
+
const active = await this.getActivePage();
|
|
86
|
+
await this.arrow(_selectors.EuiPaginationSelectors.NEXT_BUTTON_TEST_SUBJ).click();
|
|
87
|
+
await _test.expect.poll(() => this.getActivePage()).toBe(active + 1);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Click the previous arrow and wait for the active page to go back. */
|
|
91
|
+
async previous() {
|
|
92
|
+
const active = await this.getActivePage();
|
|
93
|
+
await this.arrow(_selectors.EuiPaginationSelectors.PREVIOUS_BUTTON_TEST_SUBJ).click();
|
|
94
|
+
await _test.expect.poll(() => this.getActivePage()).toBe(active - 1);
|
|
95
|
+
}
|
|
96
|
+
pageButton(index) {
|
|
97
|
+
return this.root.getByTestId(`${_selectors.EuiPaginationSelectors.PAGE_BUTTON_TEST_SUBJ_PREFIX}${index}`);
|
|
98
|
+
}
|
|
99
|
+
arrow(testSubj) {
|
|
100
|
+
return this.root.getByTestId(testSubj);
|
|
101
|
+
}
|
|
102
|
+
async isCompressed() {
|
|
103
|
+
// count() does not wait, so make sure the nav has rendered first.
|
|
104
|
+
await this.root.waitFor({
|
|
105
|
+
state: 'visible'
|
|
106
|
+
});
|
|
107
|
+
return (await this.root.locator(_selectors.EuiPaginationSelectors.COMPRESSED_TEXT_SELECTOR).count()) > 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The compressed "page of total" numbers as [page, total]. Translations may
|
|
112
|
+
* order the two the other way round, and the page is never above the total,
|
|
113
|
+
* so the smaller one is the page.
|
|
114
|
+
*/
|
|
115
|
+
async compressedNumbers() {
|
|
116
|
+
const texts = await this.root.locator(_selectors.EuiPaginationSelectors.COMPRESSED_TEXT_SELECTOR).locator('span').allInnerTexts();
|
|
117
|
+
const numbers = texts.map(Number);
|
|
118
|
+
return [Math.min(...numbers), Math.max(...numbers)];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.EuiPaginationObject = EuiPaginationObject;
|