@elastic/eui-test-helpers 1.2.0 → 1.3.0

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.
Files changed (45) hide show
  1. package/README.md +3 -0
  2. package/lib/cjs/components/datagrid/selectors.d.ts +36 -0
  3. package/lib/cjs/components/datagrid/selectors.js +50 -0
  4. package/lib/cjs/components/form/super_select/selectors.d.ts +33 -0
  5. package/lib/cjs/components/form/super_select/selectors.js +47 -0
  6. package/lib/cjs/components/toast/selectors.d.ts +12 -0
  7. package/lib/cjs/components/toast/selectors.js +26 -0
  8. package/lib/cjs/index.d.ts +3 -0
  9. package/lib/cjs/index.js +22 -1
  10. package/lib/cjs/playwright/components/datagrid/object.d.ts +51 -0
  11. package/lib/cjs/playwright/components/datagrid/object.js +119 -0
  12. package/lib/cjs/playwright/components/form/super_select/object.d.ts +40 -0
  13. package/lib/cjs/playwright/components/form/super_select/object.js +93 -0
  14. package/lib/cjs/playwright/components/toast/object.d.ts +24 -0
  15. package/lib/cjs/playwright/components/toast/object.js +55 -0
  16. package/lib/cjs/selectors.d.ts +3 -0
  17. package/lib/cjs/selectors.js +22 -1
  18. package/lib/esm/components/datagrid/selectors.d.ts +36 -0
  19. package/lib/esm/components/datagrid/selectors.js +44 -0
  20. package/lib/esm/components/datagrid/selectors.js.map +1 -0
  21. package/lib/esm/components/form/super_select/selectors.d.ts +33 -0
  22. package/lib/esm/components/form/super_select/selectors.js +41 -0
  23. package/lib/esm/components/form/super_select/selectors.js.map +1 -0
  24. package/lib/esm/components/toast/selectors.d.ts +12 -0
  25. package/lib/esm/components/toast/selectors.js +20 -0
  26. package/lib/esm/components/toast/selectors.js.map +1 -0
  27. package/lib/esm/index.d.ts +3 -0
  28. package/lib/esm/index.js +3 -0
  29. package/lib/esm/index.js.map +1 -1
  30. package/lib/esm/playwright/components/datagrid/object.d.ts +51 -0
  31. package/lib/esm/playwright/components/datagrid/object.js +99 -0
  32. package/lib/esm/playwright/components/datagrid/object.js.map +1 -0
  33. package/lib/esm/playwright/components/form/super_select/object.d.ts +40 -0
  34. package/lib/esm/playwright/components/form/super_select/object.js +76 -0
  35. package/lib/esm/playwright/components/form/super_select/object.js.map +1 -0
  36. package/lib/esm/playwright/components/toast/object.d.ts +24 -0
  37. package/lib/esm/playwright/components/toast/object.js +46 -0
  38. package/lib/esm/playwright/components/toast/object.js.map +1 -0
  39. package/lib/esm/selectors.d.ts +3 -0
  40. package/lib/esm/selectors.js +3 -0
  41. package/lib/esm/selectors.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/components/datagrid/README.md +25 -0
  44. package/src/components/form/super_select/README.md +25 -0
  45. package/src/components/toast/README.md +22 -0
package/README.md CHANGED
@@ -47,6 +47,9 @@ their own version at runtime.
47
47
  | Component | Documentation |
48
48
  |---|---|
49
49
  | `EuiComboBoxObject` | [src/components/combo_box/README.md](src/components/combo_box/README.md) |
50
+ | `EuiDataGridObject` | [src/components/datagrid/README.md](src/components/datagrid/README.md) |
51
+ | `EuiSuperSelectObject` | [src/components/form/super_select/README.md](src/components/form/super_select/README.md) |
52
+ | `EuiGlobalToastListObject` | [src/components/toast/README.md](src/components/toast/README.md) |
50
53
 
51
54
  ## Contributing
52
55
 
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Stable selectors for
3
+ * {@link https://eui.elastic.co/docs/components/data-grid|EuiDataGrid}.
4
+ * `*_SELECTOR` values are CSS; `*_TEST_SUBJ` values are `data-test-subj` names.
5
+ */
6
+ export declare const EuiDataGridSelectors: {
7
+ /** Root element (the `.euiDataGrid` div carrying the consumer's `data-test-subj`). */
8
+ ROOT_SELECTOR: string;
9
+ /** Root element only while fullscreen mode is active (state class set synchronously). */
10
+ FULL_SCREEN_ROOT_SELECTOR: string;
11
+ /** A rendered data row. Rows are virtualized — only a window is mounted. */
12
+ ROW_SELECTOR: string;
13
+ /**
14
+ * A rendered data cell. Cells carry `data-gridcell-column-id` (stable column
15
+ * id, unaffected by column order) and `data-gridcell-row-index`. Header cells
16
+ * carry `data-gridcell-column-id` too, so cell queries must include this
17
+ * class to exclude them.
18
+ */
19
+ ROW_CELL_SELECTOR: string;
20
+ /** A column header cell (also carries `data-gridcell-column-id`). */
21
+ HEADER_CELL_SELECTOR: string;
22
+ /** The header cell's actions button, interactable on focus/hover. */
23
+ HEADER_ACTIONS_BUTTON_SELECTOR: string;
24
+ FULL_SCREEN_BUTTON_TEST_SUBJ: string;
25
+ /**
26
+ * A column's header actions menu. It renders in a portal, but EUI names it
27
+ * per column id, which keeps lookups safe when several grids coexist.
28
+ */
29
+ headerActionsMenuFor: (columnId: string) => string;
30
+ /** A rendered data cell addressed by column id and row index. */
31
+ cellFor: (columnId: string, rowIndex: number) => string;
32
+ /** All rendered data cells of a column. */
33
+ columnCellsFor: (columnId: string) => string;
34
+ /** A column's header cell. */
35
+ headerCellFor: (columnId: string) => string;
36
+ };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EuiDataGridSelectors = 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/data-grid|EuiDataGrid}.
18
+ * `*_SELECTOR` values are CSS; `*_TEST_SUBJ` values are `data-test-subj` names.
19
+ */
20
+ const EuiDataGridSelectors = exports.EuiDataGridSelectors = {
21
+ /** Root element (the `.euiDataGrid` div carrying the consumer's `data-test-subj`). */
22
+ ROOT_SELECTOR: '.euiDataGrid',
23
+ /** Root element only while fullscreen mode is active (state class set synchronously). */
24
+ FULL_SCREEN_ROOT_SELECTOR: '.euiDataGrid--fullScreen',
25
+ /** A rendered data row. Rows are virtualized — only a window is mounted. */
26
+ ROW_SELECTOR: '.euiDataGridRow',
27
+ /**
28
+ * A rendered data cell. Cells carry `data-gridcell-column-id` (stable column
29
+ * id, unaffected by column order) and `data-gridcell-row-index`. Header cells
30
+ * carry `data-gridcell-column-id` too, so cell queries must include this
31
+ * class to exclude them.
32
+ */
33
+ ROW_CELL_SELECTOR: '.euiDataGridRowCell',
34
+ /** A column header cell (also carries `data-gridcell-column-id`). */
35
+ HEADER_CELL_SELECTOR: '.euiDataGridHeaderCell',
36
+ /** The header cell's actions button, interactable on focus/hover. */
37
+ HEADER_ACTIONS_BUTTON_SELECTOR: '.euiDataGridHeaderCell__button',
38
+ FULL_SCREEN_BUTTON_TEST_SUBJ: 'dataGridFullScreenButton',
39
+ /**
40
+ * A column's header actions menu. It renders in a portal, but EUI names it
41
+ * per column id, which keeps lookups safe when several grids coexist.
42
+ */
43
+ headerActionsMenuFor: columnId => `[data-test-subj="dataGridHeaderCellActionGroup-${columnId}"]`,
44
+ /** A rendered data cell addressed by column id and row index. */
45
+ cellFor: (columnId, rowIndex) => `.euiDataGridRowCell[data-gridcell-column-id="${columnId}"][data-gridcell-row-index="${rowIndex}"]`,
46
+ /** All rendered data cells of a column. */
47
+ columnCellsFor: columnId => `.euiDataGridRowCell[data-gridcell-column-id="${columnId}"]`,
48
+ /** A column's header cell. */
49
+ headerCellFor: columnId => `.euiDataGridHeaderCell[data-gridcell-column-id="${columnId}"]`
50
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Stable selectors for
3
+ * {@link https://eui.elastic.co/docs/components/forms/selection/super-select/|EuiSuperSelect}.
4
+ * `*_SELECTOR` values are CSS.
5
+ */
6
+ export declare const EuiSuperSelectSelectors: {
7
+ /**
8
+ * Root element (the control `<button>` carrying the consumer's
9
+ * `data-test-subj` — EUI spreads rest props onto it).
10
+ */
11
+ ROOT_SELECTOR: string;
12
+ /**
13
+ * The popover wrapper around the control. The hidden form input holding the
14
+ * committed value is a sibling of the button inside it.
15
+ */
16
+ WRAPPER_SELECTOR: string;
17
+ /**
18
+ * The options listbox. It renders in a popover portal, but EUI keeps at most
19
+ * one super-select dropdown open at a time, so a page-level lookup is safe.
20
+ */
21
+ LISTBOX_SELECTOR: string;
22
+ /**
23
+ * The hidden form input holding the committed `value` — a direct child of
24
+ * the popover wrapper, scoped as such so hidden inputs a consumer might
25
+ * render inside prepend/append content are never matched.
26
+ */
27
+ HIDDEN_INPUT_SELECTOR: string;
28
+ /**
29
+ * An option addressed by its `value` — EUI renders every option with
30
+ * `id={String(value)}`.
31
+ */
32
+ optionByValue: (value: string) => string;
33
+ };
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EuiSuperSelectSelectors = 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/forms/selection/super-select/|EuiSuperSelect}.
18
+ * `*_SELECTOR` values are CSS.
19
+ */
20
+ const EuiSuperSelectSelectors = exports.EuiSuperSelectSelectors = {
21
+ /**
22
+ * Root element (the control `<button>` carrying the consumer's
23
+ * `data-test-subj` — EUI spreads rest props onto it).
24
+ */
25
+ ROOT_SELECTOR: '.euiSuperSelectControl',
26
+ /**
27
+ * The popover wrapper around the control. The hidden form input holding the
28
+ * committed value is a sibling of the button inside it.
29
+ */
30
+ WRAPPER_SELECTOR: '.euiSuperSelect',
31
+ /**
32
+ * The options listbox. It renders in a popover portal, but EUI keeps at most
33
+ * one super-select dropdown open at a time, so a page-level lookup is safe.
34
+ */
35
+ LISTBOX_SELECTOR: '.euiSuperSelect__listbox[role="listbox"]',
36
+ /**
37
+ * The hidden form input holding the committed `value` — a direct child of
38
+ * the popover wrapper, scoped as such so hidden inputs a consumer might
39
+ * render inside prepend/append content are never matched.
40
+ */
41
+ HIDDEN_INPUT_SELECTOR: ':scope > input[type="hidden"]',
42
+ /**
43
+ * An option addressed by its `value` — EUI renders every option with
44
+ * `id={String(value)}`.
45
+ */
46
+ optionByValue: value => `[role="option"][id="${value}"]`
47
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Stable selectors for
3
+ * {@link https://eui.elastic.co/docs/components/display/toast/|EuiGlobalToastList}.
4
+ * `*_SELECTOR` values are CSS; `*_TEST_SUBJ` values are `data-test-subj` names.
5
+ */
6
+ export declare const EuiGlobalToastListSelectors: {
7
+ /** Root element (the list carrying the consumer's `data-test-subj`). */
8
+ ROOT_SELECTOR: string;
9
+ /** A toast inside the list. */
10
+ TOAST_SELECTOR: string;
11
+ CLOSE_BUTTON_TEST_SUBJ: string;
12
+ };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EuiGlobalToastListSelectors = 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/display/toast/|EuiGlobalToastList}.
18
+ * `*_SELECTOR` values are CSS; `*_TEST_SUBJ` values are `data-test-subj` names.
19
+ */
20
+ const EuiGlobalToastListSelectors = exports.EuiGlobalToastListSelectors = {
21
+ /** Root element (the list carrying the consumer's `data-test-subj`). */
22
+ ROOT_SELECTOR: '.euiGlobalToastList',
23
+ /** A toast inside the list. */
24
+ TOAST_SELECTOR: '.euiToast',
25
+ CLOSE_BUTTON_TEST_SUBJ: 'toastCloseButton'
26
+ };
@@ -1,2 +1,5 @@
1
1
  export { BaseObject, type ObjectScope } from './playwright/base_object';
2
2
  export { EuiComboBoxObject } from './playwright/components/combo_box/object';
3
+ export { EuiDataGridObject } from './playwright/components/datagrid/object';
4
+ export { EuiSuperSelectObject } from './playwright/components/form/super_select/object';
5
+ export { EuiGlobalToastListObject } from './playwright/components/toast/object';
package/lib/cjs/index.js CHANGED
@@ -15,5 +15,26 @@ Object.defineProperty(exports, "EuiComboBoxObject", {
15
15
  return _object.EuiComboBoxObject;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "EuiDataGridObject", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _object2.EuiDataGridObject;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "EuiGlobalToastListObject", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _object4.EuiGlobalToastListObject;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "EuiSuperSelectObject", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _object3.EuiSuperSelectObject;
34
+ }
35
+ });
18
36
  var _base_object = require("./playwright/base_object");
19
- var _object = require("./playwright/components/combo_box/object");
37
+ var _object = require("./playwright/components/combo_box/object");
38
+ var _object2 = require("./playwright/components/datagrid/object");
39
+ var _object3 = require("./playwright/components/form/super_select/object");
40
+ var _object4 = require("./playwright/components/toast/object");
@@ -0,0 +1,51 @@
1
+ import type { Locator } from '@playwright/test';
2
+ import { BaseObject, type ObjectScope } from '../../base_object';
3
+ /**
4
+ * Playwright Component Object for {@link
5
+ * https://eui.elastic.co/docs/components/data-grid EuiDataGrid}.
6
+ *
7
+ * `testSubj` must match the `data-test-subj` set by the consumer on the
8
+ * `EuiDataGrid` itself (the component-type guard enforces it) — EUI toggles
9
+ * state classes (fullscreen) on that element. When the subj is not unique on
10
+ * the page (e.g. portal-rendered duplicates), narrow with the `scope`
11
+ * parameter instead of pointing the subj at a wrapper.
12
+ */
13
+ export declare class EuiDataGridObject extends BaseObject {
14
+ constructor(scope: ObjectScope, testSubj: string);
15
+ /**
16
+ * The rows currently mounted in the DOM, as a `Locator` so callers keep
17
+ * Playwright auto-retry for count and content assertions
18
+ * (e.g. `expect(rows).toHaveCount(pageSize)`, `expect(rows).not.toHaveCount(0)`).
19
+ * For a paginated grid this is the current page's rows. Rows are virtualized,
20
+ * so on a grid too tall for its container this is only the visible window —
21
+ * never treat it as the full data set.
22
+ */
23
+ get rows(): Locator;
24
+ /**
25
+ * A single data cell, addressed by row index and column id. Column order and
26
+ * virtualized horizontal scrolling do not affect the column id.
27
+ */
28
+ cell(rowIndex: number, columnId: string): Locator;
29
+ /**
30
+ * All currently rendered data cells of a column. Rows are virtualized, so
31
+ * this is the rendered window, not necessarily every row.
32
+ */
33
+ cells(columnId: string): Locator;
34
+ /**
35
+ * Opens the header actions of a column and clicks the given action.
36
+ * `columnId` is the grid column id (matched verbatim), `actionLabel` is the
37
+ * visible action label (e.g. 'Hide column', 'Sort A-Z').
38
+ */
39
+ doActionOnColumn(columnId: string, actionLabel: string): Promise<void>;
40
+ /** Enters fullscreen mode via the toolbar button. */
41
+ openFullScreenMode(): Promise<void>;
42
+ /** Exits fullscreen mode via the toolbar button. */
43
+ closeFullScreenMode(): Promise<void>;
44
+ /** The grid element only while it carries the fullscreen state class. */
45
+ private get fullScreenGrid();
46
+ /**
47
+ * The fullscreen button sits in a tooltip wrapper and keeps focus after the
48
+ * click, which keeps the tooltip open over the grid — blur it right away.
49
+ */
50
+ private clickFullScreenButton;
51
+ }
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EuiDataGridObject = void 0;
7
+ var _base_object = require("../../base_object");
8
+ var _selectors = require("../../../components/datagrid/selectors");
9
+ /*
10
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
11
+ * or more contributor license agreements. Licensed under the Elastic License
12
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
13
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
14
+ * Side Public License, v 1.
15
+ */
16
+
17
+ /**
18
+ * Playwright Component Object for {@link
19
+ * https://eui.elastic.co/docs/components/data-grid EuiDataGrid}.
20
+ *
21
+ * `testSubj` must match the `data-test-subj` set by the consumer on the
22
+ * `EuiDataGrid` itself (the component-type guard enforces it) — EUI toggles
23
+ * state classes (fullscreen) on that element. When the subj is not unique on
24
+ * the page (e.g. portal-rendered duplicates), narrow with the `scope`
25
+ * parameter instead of pointing the subj at a wrapper.
26
+ */
27
+ class EuiDataGridObject extends _base_object.BaseObject {
28
+ constructor(scope, testSubj) {
29
+ super(scope, testSubj, _selectors.EuiDataGridSelectors.ROOT_SELECTOR);
30
+ }
31
+
32
+ /**
33
+ * The rows currently mounted in the DOM, as a `Locator` so callers keep
34
+ * Playwright auto-retry for count and content assertions
35
+ * (e.g. `expect(rows).toHaveCount(pageSize)`, `expect(rows).not.toHaveCount(0)`).
36
+ * For a paginated grid this is the current page's rows. Rows are virtualized,
37
+ * so on a grid too tall for its container this is only the visible window —
38
+ * never treat it as the full data set.
39
+ */
40
+ get rows() {
41
+ return this.root.locator(_selectors.EuiDataGridSelectors.ROW_SELECTOR);
42
+ }
43
+
44
+ /**
45
+ * A single data cell, addressed by row index and column id. Column order and
46
+ * virtualized horizontal scrolling do not affect the column id.
47
+ */
48
+ cell(rowIndex, columnId) {
49
+ return this.root.locator(_selectors.EuiDataGridSelectors.cellFor(columnId, rowIndex));
50
+ }
51
+
52
+ /**
53
+ * All currently rendered data cells of a column. Rows are virtualized, so
54
+ * this is the rendered window, not necessarily every row.
55
+ */
56
+ cells(columnId) {
57
+ return this.root.locator(_selectors.EuiDataGridSelectors.columnCellsFor(columnId));
58
+ }
59
+
60
+ /**
61
+ * Opens the header actions of a column and clicks the given action.
62
+ * `columnId` is the grid column id (matched verbatim), `actionLabel` is the
63
+ * visible action label (e.g. 'Hide column', 'Sort A-Z').
64
+ */
65
+ async doActionOnColumn(columnId, actionLabel) {
66
+ const headerCell = this.root.locator(_selectors.EuiDataGridSelectors.headerCellFor(columnId));
67
+ // The actions button only becomes interactable when the header cell is
68
+ // focused/hovered and inside the viewport.
69
+ await headerCell.scrollIntoViewIfNeeded();
70
+ await headerCell.focus();
71
+ await headerCell.hover();
72
+ await headerCell.locator(_selectors.EuiDataGridSelectors.HEADER_ACTIONS_BUTTON_SELECTOR).click();
73
+ const actionsMenu = this.root.page().locator(_selectors.EuiDataGridSelectors.headerActionsMenuFor(columnId));
74
+ await actionsMenu.waitFor({
75
+ state: 'visible'
76
+ });
77
+ // Role+name query auto-escapes the label and matches the accessible name
78
+ // (Kibana's lint also forbids getByTitle in favor of role queries).
79
+ await actionsMenu.getByRole('button', {
80
+ name: actionLabel,
81
+ exact: true
82
+ }).click();
83
+ await actionsMenu.waitFor({
84
+ state: 'hidden'
85
+ });
86
+ }
87
+
88
+ /** Enters fullscreen mode via the toolbar button. */
89
+ async openFullScreenMode() {
90
+ await this.clickFullScreenButton();
91
+ await this.fullScreenGrid.waitFor({
92
+ state: 'visible'
93
+ });
94
+ }
95
+
96
+ /** Exits fullscreen mode via the toolbar button. */
97
+ async closeFullScreenMode() {
98
+ await this.clickFullScreenButton();
99
+ await this.fullScreenGrid.waitFor({
100
+ state: 'detached'
101
+ });
102
+ }
103
+
104
+ /** The grid element only while it carries the fullscreen state class. */
105
+ get fullScreenGrid() {
106
+ return this.root.and(this.root.page().locator(_selectors.EuiDataGridSelectors.FULL_SCREEN_ROOT_SELECTOR));
107
+ }
108
+
109
+ /**
110
+ * The fullscreen button sits in a tooltip wrapper and keeps focus after the
111
+ * click, which keeps the tooltip open over the grid — blur it right away.
112
+ */
113
+ async clickFullScreenButton() {
114
+ const button = this.root.getByTestId(_selectors.EuiDataGridSelectors.FULL_SCREEN_BUTTON_TEST_SUBJ);
115
+ await button.click();
116
+ await button.blur();
117
+ }
118
+ }
119
+ exports.EuiDataGridObject = EuiDataGridObject;
@@ -0,0 +1,40 @@
1
+ import { BaseObject, type ObjectScope } from '../../../base_object';
2
+ /**
3
+ * Playwright Component Object for {@link
4
+ * https://eui.elastic.co/docs/components/forms/selection/super-select/ EuiSuperSelect}.
5
+ *
6
+ * `testSubj` must match the `data-test-subj` set by the consumer on the
7
+ * `<EuiSuperSelect>` — EUI spreads it onto the control `<button>`
8
+ * (`.euiSuperSelectControl`).
9
+ */
10
+ export declare class EuiSuperSelectObject extends BaseObject {
11
+ constructor(scope: ObjectScope, testSubj: string);
12
+ /**
13
+ * Selects an option by its `value`. EUI renders every option with
14
+ * `id={String(value)}`, so this works for any EuiSuperSelect without extra
15
+ * test hooks and is the preferred method when the value is a stable code
16
+ * constant.
17
+ */
18
+ selectOptionByValue(value: string): Promise<void>;
19
+ /**
20
+ * Selects an option by its visible label. Use for dynamic, data-driven
21
+ * option content where the value is not known to the test. Note the dropdown
22
+ * shows `dropdownDisplay` when the consumer provides it, which can differ
23
+ * from the committed `inputDisplay` text.
24
+ */
25
+ selectOptionByLabel(label: string): Promise<void>;
26
+ /**
27
+ * The committed selection's `value`, read from the hidden form input EUI
28
+ * renders next to the control (the visible button text shows the label, not
29
+ * the value).
30
+ */
31
+ getSelectedValue(): Promise<string>;
32
+ /** Opens the dropdown if it is not already open. */
33
+ private open;
34
+ private get listbox();
35
+ /**
36
+ * The hidden input is a sibling of the control button; reach it through the
37
+ * `.euiSuperSelect` popover wrapper that contains this instance's button.
38
+ */
39
+ private get hiddenInput();
40
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EuiSuperSelectObject = void 0;
7
+ var _base_object = require("../../../base_object");
8
+ var _selectors = require("../../../../components/form/super_select/selectors");
9
+ /*
10
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
11
+ * or more contributor license agreements. Licensed under the Elastic License
12
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
13
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
14
+ * Side Public License, v 1.
15
+ */
16
+
17
+ /**
18
+ * Playwright Component Object for {@link
19
+ * https://eui.elastic.co/docs/components/forms/selection/super-select/ EuiSuperSelect}.
20
+ *
21
+ * `testSubj` must match the `data-test-subj` set by the consumer on the
22
+ * `<EuiSuperSelect>` — EUI spreads it onto the control `<button>`
23
+ * (`.euiSuperSelectControl`).
24
+ */
25
+ class EuiSuperSelectObject extends _base_object.BaseObject {
26
+ constructor(scope, testSubj) {
27
+ super(scope, testSubj, _selectors.EuiSuperSelectSelectors.ROOT_SELECTOR);
28
+ }
29
+
30
+ /**
31
+ * Selects an option by its `value`. EUI renders every option with
32
+ * `id={String(value)}`, so this works for any EuiSuperSelect without extra
33
+ * test hooks and is the preferred method when the value is a stable code
34
+ * constant.
35
+ */
36
+ async selectOptionByValue(value) {
37
+ await this.open();
38
+ await this.listbox.locator(_selectors.EuiSuperSelectSelectors.optionByValue(value)).click();
39
+ await this.listbox.waitFor({
40
+ state: 'detached'
41
+ });
42
+ }
43
+
44
+ /**
45
+ * Selects an option by its visible label. Use for dynamic, data-driven
46
+ * option content where the value is not known to the test. Note the dropdown
47
+ * shows `dropdownDisplay` when the consumer provides it, which can differ
48
+ * from the committed `inputDisplay` text.
49
+ */
50
+ async selectOptionByLabel(label) {
51
+ await this.open();
52
+ await this.listbox.getByRole('option', {
53
+ name: label
54
+ }).click();
55
+ await this.listbox.waitFor({
56
+ state: 'detached'
57
+ });
58
+ }
59
+
60
+ /**
61
+ * The committed selection's `value`, read from the hidden form input EUI
62
+ * renders next to the control (the visible button text shows the label, not
63
+ * the value).
64
+ */
65
+ async getSelectedValue() {
66
+ return this.hiddenInput.inputValue();
67
+ }
68
+
69
+ /** Opens the dropdown if it is not already open. */
70
+ async open() {
71
+ if (await this.listbox.isVisible()) {
72
+ return;
73
+ }
74
+ await this.root.click();
75
+ await this.listbox.waitFor({
76
+ state: 'visible'
77
+ });
78
+ }
79
+ get listbox() {
80
+ return this.root.page().locator(_selectors.EuiSuperSelectSelectors.LISTBOX_SELECTOR);
81
+ }
82
+
83
+ /**
84
+ * The hidden input is a sibling of the control button; reach it through the
85
+ * `.euiSuperSelect` popover wrapper that contains this instance's button.
86
+ */
87
+ get hiddenInput() {
88
+ return this.scope.locator(_selectors.EuiSuperSelectSelectors.WRAPPER_SELECTOR).filter({
89
+ has: this.root
90
+ }).locator(_selectors.EuiSuperSelectSelectors.HIDDEN_INPUT_SELECTOR);
91
+ }
92
+ }
93
+ exports.EuiSuperSelectObject = EuiSuperSelectObject;
@@ -0,0 +1,24 @@
1
+ import { type Locator } from '@playwright/test';
2
+ import { BaseObject, type ObjectScope } from '../../base_object';
3
+ /**
4
+ * Playwright Component Object for {@link
5
+ * https://eui.elastic.co/docs/components/display/toast/ EuiGlobalToastList}.
6
+ *
7
+ * `testSubj` must match the `data-test-subj` set by the consumer on the
8
+ * `<EuiGlobalToastList>` (the `.euiGlobalToastList` element). Toasts rendered
9
+ * outside the list (inline `EuiToast`) are not covered.
10
+ */
11
+ export declare class EuiGlobalToastListObject extends BaseObject {
12
+ constructor(scope: ObjectScope, testSubj: string);
13
+ /**
14
+ * The toasts currently in the list. Exposed as a `Locator` so callers keep
15
+ * Playwright auto-retry for count and content assertions
16
+ * (e.g. `expect(toasts).toHaveCount(1)`).
17
+ */
18
+ get toasts(): Locator;
19
+ /**
20
+ * Closes every toast in the list and waits until none remain. No-op when the
21
+ * list is empty (dismissing "if present" is a common teardown need).
22
+ */
23
+ closeAll(): Promise<void>;
24
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EuiGlobalToastListObject = void 0;
7
+ var _test = require("@playwright/test");
8
+ var _base_object = require("../../base_object");
9
+ var _selectors = require("../../../components/toast/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/display/toast/ EuiGlobalToastList}.
21
+ *
22
+ * `testSubj` must match the `data-test-subj` set by the consumer on the
23
+ * `<EuiGlobalToastList>` (the `.euiGlobalToastList` element). Toasts rendered
24
+ * outside the list (inline `EuiToast`) are not covered.
25
+ */
26
+ class EuiGlobalToastListObject extends _base_object.BaseObject {
27
+ constructor(scope, testSubj) {
28
+ super(scope, testSubj, _selectors.EuiGlobalToastListSelectors.ROOT_SELECTOR);
29
+ }
30
+
31
+ /**
32
+ * The toasts currently in the list. Exposed as a `Locator` so callers keep
33
+ * Playwright auto-retry for count and content assertions
34
+ * (e.g. `expect(toasts).toHaveCount(1)`).
35
+ */
36
+ get toasts() {
37
+ return this.root.locator(_selectors.EuiGlobalToastListSelectors.TOAST_SELECTOR);
38
+ }
39
+
40
+ /**
41
+ * Closes every toast in the list and waits until none remain. No-op when the
42
+ * list is empty (dismissing "if present" is a common teardown need).
43
+ */
44
+ async closeAll() {
45
+ const closeButtons = await this.root.getByTestId(_selectors.EuiGlobalToastListSelectors.CLOSE_BUTTON_TEST_SUBJ).all();
46
+ for (const closeButton of closeButtons) {
47
+ // A toast may auto-dismiss while iterating; ignore clicks that miss.
48
+ await closeButton.click({
49
+ timeout: 5_000
50
+ }).catch(() => {});
51
+ }
52
+ await (0, _test.expect)(this.toasts).toHaveCount(0);
53
+ }
54
+ }
55
+ exports.EuiGlobalToastListObject = EuiGlobalToastListObject;
@@ -1 +1,4 @@
1
1
  export { EuiComboBoxSelectors } from './components/combo_box/selectors';
2
+ export { EuiDataGridSelectors } from './components/datagrid/selectors';
3
+ export { EuiSuperSelectSelectors } from './components/form/super_select/selectors';
4
+ export { EuiGlobalToastListSelectors } from './components/toast/selectors';