@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.
Files changed (54) hide show
  1. package/README.md +2 -0
  2. package/lib/cjs/components/color_picker/selectors.d.ts +6 -2
  3. package/lib/cjs/components/color_picker/selectors.js +8 -4
  4. package/lib/cjs/components/pagination/selectors.d.ts +21 -0
  5. package/lib/cjs/components/pagination/selectors.js +35 -0
  6. package/lib/cjs/components/table/selectors.d.ts +15 -0
  7. package/lib/cjs/components/table/selectors.js +29 -0
  8. package/lib/cjs/index.d.ts +2 -0
  9. package/lib/cjs/index.js +22 -8
  10. package/lib/cjs/playwright/base_object.js +6 -4
  11. package/lib/cjs/playwright/components/basic_table/object.d.ts +7 -12
  12. package/lib/cjs/playwright/components/basic_table/object.js +7 -13
  13. package/lib/cjs/playwright/components/color_picker/object.d.ts +25 -4
  14. package/lib/cjs/playwright/components/color_picker/object.js +68 -3
  15. package/lib/cjs/playwright/components/pagination/object.d.ts +37 -0
  16. package/lib/cjs/playwright/components/pagination/object.js +121 -0
  17. package/lib/cjs/playwright/components/table/object.d.ts +28 -0
  18. package/lib/cjs/playwright/components/table/object.js +57 -0
  19. package/lib/cjs/selectors.d.ts +19 -0
  20. package/lib/cjs/selectors.js +18 -14
  21. package/lib/esm/components/color_picker/selectors.d.ts +6 -2
  22. package/lib/esm/components/color_picker/selectors.js +7 -3
  23. package/lib/esm/components/color_picker/selectors.js.map +1 -1
  24. package/lib/esm/components/pagination/selectors.d.ts +21 -0
  25. package/lib/esm/components/pagination/selectors.js +29 -0
  26. package/lib/esm/components/pagination/selectors.js.map +1 -0
  27. package/lib/esm/components/table/selectors.d.ts +15 -0
  28. package/lib/esm/components/table/selectors.js +23 -0
  29. package/lib/esm/components/table/selectors.js.map +1 -0
  30. package/lib/esm/index.d.ts +2 -0
  31. package/lib/esm/index.js +2 -0
  32. package/lib/esm/index.js.map +1 -1
  33. package/lib/esm/playwright/base_object.js +10 -4
  34. package/lib/esm/playwright/base_object.js.map +1 -1
  35. package/lib/esm/playwright/components/basic_table/object.d.ts +7 -12
  36. package/lib/esm/playwright/components/basic_table/object.js +7 -15
  37. package/lib/esm/playwright/components/basic_table/object.js.map +1 -1
  38. package/lib/esm/playwright/components/color_picker/object.d.ts +25 -4
  39. package/lib/esm/playwright/components/color_picker/object.js +65 -3
  40. package/lib/esm/playwright/components/color_picker/object.js.map +1 -1
  41. package/lib/esm/playwright/components/pagination/object.d.ts +37 -0
  42. package/lib/esm/playwright/components/pagination/object.js +118 -0
  43. package/lib/esm/playwright/components/pagination/object.js.map +1 -0
  44. package/lib/esm/playwright/components/table/object.d.ts +28 -0
  45. package/lib/esm/playwright/components/table/object.js +46 -0
  46. package/lib/esm/playwright/components/table/object.js.map +1 -0
  47. package/lib/esm/selectors.d.ts +19 -0
  48. package/lib/esm/selectors.js +4 -0
  49. package/lib/esm/selectors.js.map +1 -1
  50. package/package.json +3 -2
  51. package/src/components/basic_table/README.md +1 -0
  52. package/src/components/color_picker/README.md +7 -5
  53. package/src/components/pagination/README.md +31 -0
  54. package/src/components/table/README.md +31 -0
@@ -0,0 +1,28 @@
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/tabular-content/tables/ EuiTable},
6
+ * the low level table built from `EuiTableHeader`, `EuiTableRow` and
7
+ * `EuiTableRowCell`. `EuiBasicTableObject` extends this for the
8
+ * `EuiBasicTable` and `EuiInMemoryTable` wrappers.
9
+ *
10
+ * `testSubj` must be set on `EuiTable` itself, EUI spreads it onto the
11
+ * `<table>`. Columns are addressed by position since a plain table has no
12
+ * field names.
13
+ */
14
+ export declare class EuiTableObject extends BaseObject {
15
+ constructor(scope: ObjectScope, testSubj: string, componentSelector?: string);
16
+ /** The body rows. */
17
+ get rows(): Locator;
18
+ /** The header cells, in column order. */
19
+ get headerCells(): Locator;
20
+ /**
21
+ * The cells of one column across all body rows, by 0-based position.
22
+ * Direct children only, so a table nested in a cell is not matched. Matches
23
+ * both `<td>` and `<th>`, EUI renders a row header cell as `<th scope="row">`.
24
+ */
25
+ column(index: number): Locator;
26
+ /** One body cell by 0-based row and column position. */
27
+ cell(row: number, column: number): Locator;
28
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EuiTableObject = void 0;
7
+ var _base_object = require("../../base_object");
8
+ var _selectors = require("../../../components/table/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/tabular-content/tables/ EuiTable},
20
+ * the low level table built from `EuiTableHeader`, `EuiTableRow` and
21
+ * `EuiTableRowCell`. `EuiBasicTableObject` extends this for the
22
+ * `EuiBasicTable` and `EuiInMemoryTable` wrappers.
23
+ *
24
+ * `testSubj` must be set on `EuiTable` itself, EUI spreads it onto the
25
+ * `<table>`. Columns are addressed by position since a plain table has no
26
+ * field names.
27
+ */
28
+ class EuiTableObject extends _base_object.BaseObject {
29
+ constructor(scope, testSubj, componentSelector = _selectors.EuiTableSelectors.ROOT_SELECTOR) {
30
+ super(scope, testSubj, componentSelector);
31
+ }
32
+
33
+ /** The body rows. */
34
+ get rows() {
35
+ return this.root.locator(_selectors.EuiTableSelectors.ROW_SELECTOR);
36
+ }
37
+
38
+ /** The header cells, in column order. */
39
+ get headerCells() {
40
+ return this.root.locator(_selectors.EuiTableSelectors.HEADER_CELL_SELECTOR);
41
+ }
42
+
43
+ /**
44
+ * The cells of one column across all body rows, by 0-based position.
45
+ * Direct children only, so a table nested in a cell is not matched. Matches
46
+ * both `<td>` and `<th>`, EUI renders a row header cell as `<th scope="row">`.
47
+ */
48
+ column(index) {
49
+ return this.rows.locator(`> :is(td, th):nth-child(${index + 1})`);
50
+ }
51
+
52
+ /** One body cell by 0-based row and column position. */
53
+ cell(row, column) {
54
+ return this.rows.nth(row).locator(`> :is(td, th):nth-child(${column + 1})`);
55
+ }
56
+ }
57
+ exports.EuiTableObject = EuiTableObject;
@@ -16,9 +16,11 @@ export declare const selectors: {
16
16
  HEADER_CELL_SELECTOR_PREFIX: string;
17
17
  };
18
18
  readonly colorPicker: {
19
+ ANCHOR_TEST_SUBJ: string;
19
20
  ANCHOR_SELECTOR: string;
20
21
  PANEL_SELECTOR: string;
21
22
  SWATCH_SELECTOR: string;
23
+ SECONDARY_INPUT_SELECTOR: string;
22
24
  };
23
25
  readonly comboBox: {
24
26
  ROOT_SELECTOR: string;
@@ -69,6 +71,17 @@ export declare const selectors: {
69
71
  ROOT_SELECTOR: string;
70
72
  CLOSE_BUTTON_SELECTOR: string;
71
73
  };
74
+ readonly pagination: {
75
+ ROOT_SELECTOR: string;
76
+ PAGE_BUTTON_SELECTOR: string;
77
+ ACTIVE_PAGE_BUTTON_SELECTOR: string;
78
+ COMPRESSED_TEXT_SELECTOR: string;
79
+ PAGE_BUTTON_TEST_SUBJ_PREFIX: string;
80
+ FIRST_BUTTON_TEST_SUBJ: string;
81
+ PREVIOUS_BUTTON_TEST_SUBJ: string;
82
+ NEXT_BUTTON_TEST_SUBJ: string;
83
+ LAST_BUTTON_TEST_SUBJ: string;
84
+ };
72
85
  readonly popover: {
73
86
  TOGGLE_SELECTOR: string;
74
87
  panelFor: (id: string) => string;
@@ -88,6 +101,12 @@ export declare const selectors: {
88
101
  HIDDEN_INPUT_SELECTOR: string;
89
102
  optionByValue: (value: string) => string;
90
103
  };
104
+ readonly table: {
105
+ ROOT_SELECTOR: string;
106
+ ROW_SELECTOR: string;
107
+ ROW_CELL_SELECTOR: string;
108
+ HEADER_CELL_SELECTOR: string;
109
+ };
91
110
  readonly globalToastList: {
92
111
  ROOT_SELECTOR: string;
93
112
  TOAST_SELECTOR: string;
@@ -14,13 +14,15 @@ var _selectors7 = require("./components/drag_and_drop/selectors");
14
14
  var _selectors8 = require("./components/filter_button/selectors");
15
15
  var _selectors9 = require("./components/flyout/selectors");
16
16
  var _selectors10 = require("./components/modal/selectors");
17
- var _selectors11 = require("./components/popover/selectors");
18
- var _selectors12 = require("./components/form/range/selectors");
19
- var _selectors13 = require("./components/selectable/selectors");
20
- var _selectors14 = require("./components/form/super_select/selectors");
21
- var _selectors15 = require("./components/toast/selectors");
22
- var _selectors16 = require("./components/tool_tip/selectors");
23
- var _selectors17 = require("./components/tree_view/selectors");
17
+ var _selectors11 = require("./components/pagination/selectors");
18
+ var _selectors12 = require("./components/popover/selectors");
19
+ var _selectors13 = require("./components/form/range/selectors");
20
+ var _selectors14 = require("./components/selectable/selectors");
21
+ var _selectors15 = require("./components/form/super_select/selectors");
22
+ var _selectors16 = require("./components/table/selectors");
23
+ var _selectors17 = require("./components/toast/selectors");
24
+ var _selectors18 = require("./components/tool_tip/selectors");
25
+ var _selectors19 = require("./components/tree_view/selectors");
24
26
  /*
25
27
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
26
28
  * or more contributor license agreements. Licensed under the Elastic License
@@ -46,11 +48,13 @@ const selectors = exports.selectors = {
46
48
  filterButton: _selectors8.EuiFilterButtonSelectors,
47
49
  flyout: _selectors9.EuiFlyoutSelectors,
48
50
  modal: _selectors10.EuiModalSelectors,
49
- popover: _selectors11.EuiPopoverSelectors,
50
- range: _selectors12.EuiRangeSelectors,
51
- selectable: _selectors13.EuiSelectableSelectors,
52
- superSelect: _selectors14.EuiSuperSelectSelectors,
53
- globalToastList: _selectors15.EuiGlobalToastListSelectors,
54
- toolTip: _selectors16.EuiToolTipSelectors,
55
- treeView: _selectors17.EuiTreeViewSelectors
51
+ pagination: _selectors11.EuiPaginationSelectors,
52
+ popover: _selectors12.EuiPopoverSelectors,
53
+ range: _selectors13.EuiRangeSelectors,
54
+ selectable: _selectors14.EuiSelectableSelectors,
55
+ superSelect: _selectors15.EuiSuperSelectSelectors,
56
+ table: _selectors16.EuiTableSelectors,
57
+ globalToastList: _selectors17.EuiGlobalToastListSelectors,
58
+ toolTip: _selectors18.EuiToolTipSelectors,
59
+ treeView: _selectors19.EuiTreeViewSelectors
56
60
  };
@@ -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
- /** The default text-input anchor. A custom `button` prop has no class of its own. */
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
  };
@@ -8,14 +8,18 @@
8
8
  /**
9
9
  * Stable selectors for
10
10
  * {@link https://eui.elastic.co/docs/components/forms/color-picker/|EuiColorPicker}.
11
- * `*_SELECTOR` values are CSS.
11
+ * `*_SELECTOR` values are CSS, `*_TEST_SUBJ` values are `data-test-subj` names EUI sets itself.
12
12
  */
13
13
  export const EuiColorPickerSelectors = {
14
- /** The default text-input anchor. A custom `button` prop has no class of its own. */
15
- ANCHOR_SELECTOR: '.euiColorPicker__input',
14
+ /** Token EUI adds to the anchor's `data-test-subj`, on the default input and on a custom `button` alike. */
15
+ ANCHOR_TEST_SUBJ: 'euiColorPickerAnchor',
16
+ /** The anchor, whether the default text input or a custom `button`. */
17
+ ANCHOR_SELECTOR: '[data-test-subj~="euiColorPickerAnchor"]',
16
18
  /** The popover panel, rendered in a portal and only while open. */
17
19
  PANEL_SELECTOR: '[data-popover-panel].euiColorPicker__popoverPanel',
18
20
  /** A swatch button inside the panel. */
19
21
  SWATCH_SELECTOR: '.euiColorPickerSwatch',
22
+ /** The hex input inside the panel. Present only when `secondaryInputDisplay` is `top` or `bottom`. */
23
+ SECONDARY_INPUT_SELECTOR: '[data-test-subj^="euiColorPickerInput_"]',
20
24
  };
21
25
  //# sourceMappingURL=selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../../src/components/color_picker/selectors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,qFAAqF;IACrF,eAAe,EAAE,wBAAwB;IAEzC,mEAAmE;IACnE,cAAc,EAAE,mDAAmD;IAEnE,wCAAwC;IACxC,eAAe,EAAE,uBAAuB;CACzC,CAAC"}
1
+ {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../../src/components/color_picker/selectors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,4GAA4G;IAC5G,gBAAgB,EAAE,sBAAsB;IAExC,uEAAuE;IACvE,eAAe,EAAE,0CAA0C;IAE3D,mEAAmE;IACnE,cAAc,EAAE,mDAAmD;IAEnE,wCAAwC;IACxC,eAAe,EAAE,uBAAuB;IAExC,sGAAsG;IACtG,wBAAwB,EAAE,0CAA0C;CACrE,CAAC"}
@@ -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,29 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ /**
9
+ * Stable selectors for
10
+ * {@link https://eui.elastic.co/docs/components/navigation/pagination/|EuiPagination}.
11
+ * `*_SELECTOR` values are CSS, `*_TEST_SUBJ` values are `data-test-subj` names EUI sets itself.
12
+ */
13
+ export const EuiPaginationSelectors = {
14
+ /** The `<nav>` root carrying the consumer's `data-test-subj`. */
15
+ ROOT_SELECTOR: '.euiPagination',
16
+ /** A numbered page button. Not rendered in the compressed variant. */
17
+ PAGE_BUTTON_SELECTOR: '.euiPaginationButton',
18
+ /** The numbered page button of the active page. */
19
+ ACTIVE_PAGE_BUTTON_SELECTOR: '.euiPaginationButton[aria-current="page"]',
20
+ /** The "page of total" text of the compressed variant, with one `<span>` per number. */
21
+ COMPRESSED_TEXT_SELECTOR: '.euiPagination__compressedText',
22
+ /** Prefix of a page button's test subj, followed by the 0-based page index. */
23
+ PAGE_BUTTON_TEST_SUBJ_PREFIX: 'pagination-button-',
24
+ FIRST_BUTTON_TEST_SUBJ: 'pagination-button-first',
25
+ PREVIOUS_BUTTON_TEST_SUBJ: 'pagination-button-previous',
26
+ NEXT_BUTTON_TEST_SUBJ: 'pagination-button-next',
27
+ LAST_BUTTON_TEST_SUBJ: 'pagination-button-last',
28
+ };
29
+ //# sourceMappingURL=selectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../../src/components/pagination/selectors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,iEAAiE;IACjE,aAAa,EAAE,gBAAgB;IAE/B,sEAAsE;IACtE,oBAAoB,EAAE,sBAAsB;IAE5C,mDAAmD;IACnD,2BAA2B,EAAE,2CAA2C;IAExE,wFAAwF;IACxF,wBAAwB,EAAE,gCAAgC;IAE1D,+EAA+E;IAC/E,4BAA4B,EAAE,oBAAoB;IAElD,sBAAsB,EAAE,yBAAyB;IACjD,yBAAyB,EAAE,4BAA4B;IACvD,qBAAqB,EAAE,wBAAwB;IAC/C,qBAAqB,EAAE,wBAAwB;CAChD,CAAC"}
@@ -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,23 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ /**
9
+ * Stable selectors for
10
+ * {@link https://eui.elastic.co/docs/components/tabular-content/tables/|EuiTable}.
11
+ * `*_SELECTOR` values are CSS.
12
+ */
13
+ export const EuiTableSelectors = {
14
+ /** The `<table>` element carrying the consumer's `data-test-subj`. */
15
+ ROOT_SELECTOR: '.euiTable',
16
+ /** A body row. Also matches EUI's own empty/error message row, callers must exclude those. */
17
+ ROW_SELECTOR: '.euiTableRow',
18
+ /** A body cell. */
19
+ ROW_CELL_SELECTOR: '.euiTableRowCell',
20
+ /** A header cell, including the selection checkbox cell which has its own class. */
21
+ HEADER_CELL_SELECTOR: 'thead > tr > :is(th, td)',
22
+ };
23
+ //# sourceMappingURL=selectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../../src/components/table/selectors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,sEAAsE;IACtE,aAAa,EAAE,WAAW;IAE1B,8FAA8F;IAC9F,YAAY,EAAE,cAAc;IAE5B,mBAAmB;IACnB,iBAAiB,EAAE,kBAAkB;IAErC,oFAAoF;IACpF,oBAAoB,EAAE,0BAA0B;CACjD,CAAC"}
@@ -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/esm/index.js CHANGED
@@ -19,6 +19,8 @@ export { EuiFlyoutObject } from './playwright/components/flyout/object';
19
19
  export { EuiAccordionObject } from './playwright/components/accordion/object';
20
20
  export { EuiContextMenuObject } from './playwright/components/context_menu/object';
21
21
  export { EuiModalObject } from './playwright/components/modal/object';
22
+ export { EuiTableObject } from './playwright/components/table/object';
23
+ export { EuiPaginationObject } from './playwright/components/pagination/object';
22
24
  export { EuiBasicTableObject } from './playwright/components/basic_table/object';
23
25
  export { EuiColorPickerObject } from './playwright/components/color_picker/object';
24
26
  export { EuiTreeViewObject } from './playwright/components/tree_view/object';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAoB,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9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C;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -6,11 +6,17 @@
6
6
  * Side Public License, v 1.
7
7
  */
8
8
  /**
9
- * Matches one space-separated token in `data-test-subj`, not the whole
10
- * attribute value. `getByTestId` does an exact match and misses components
11
- * like `EuiColorPicker` that add their own token to the consumer's subj.
9
+ * Matches space-separated tokens in `data-test-subj`, not the whole attribute
10
+ * value. `getByTestId` does an exact match and misses components like
11
+ * `EuiColorPicker` that add their own token to the consumer's subj. A
12
+ * `testSubj` with spaces (`colorEditorColorPicker 0`, a Kibana convention) is
13
+ * split so every token must be present, in any order.
12
14
  */
13
- const testSubjSelector = (testSubj) => `[data-test-subj~="${testSubj.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"]`;
15
+ const testSubjSelector = (testSubj) => testSubj
16
+ .trim()
17
+ .split(/\s+/)
18
+ .map((token) => `[data-test-subj~="${token.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"]`)
19
+ .join('');
14
20
  /**
15
21
  * Base class for Playwright Component Objects — semantic wrappers around a
16
22
  * single root `Locator` resolved from a `data-test-subj` inside the given
@@ -1 +1 @@
1
- {"version":3,"file":"base_object.js","sourceRoot":"","sources":["../../../src/playwright/base_object.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAU,EAAE,CACpD,qBAAqB,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE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;QAC7B,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACtD,OAAO;QACT,CAAC;QACD,4EAA4E;QAC5E,8EAA8E;QAC9E,yEAAyE;QACzE,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,OAAO;QACT,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI;aAC5B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;aAC/C,KAAK,EAAE,CAAC;QACX,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,6CAA6C,IAAI,CAAC,QAAQ,eAAe,IAAI,CAAC,iBAAiB,KAAK;gBAClG,6EAA6E,CAChF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;CACF"}
@@ -1,5 +1,6 @@
1
1
  import type { Locator } from '@playwright/test';
2
- import { BaseObject, type ObjectScope } from '../../base_object';
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). See the package README for what's deliberately excluded from v1.
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 BaseObject {
15
+ export declare class EuiBasicTableObject extends EuiTableObject {
14
16
  constructor(scope: ObjectScope, testSubj: string);
15
17
  /**
16
- * The table's data rows, as a `Locator` so callers keep Playwright auto-retry
17
- * for count and content assertions (e.g. `expect(table.rows).toHaveCount(3)`).
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
  /**
@@ -5,7 +5,7 @@
5
5
  * in compliance with, at your election, the Elastic License 2.0 or the Server
6
6
  * Side Public License, v 1.
7
7
  */
8
- import { BaseObject } from '../../base_object';
8
+ import { EuiTableObject } from '../table/object';
9
9
  import { EuiBasicTableSelectors } from '../../../components/basic_table/selectors';
10
10
  /**
11
11
  * Playwright Component Object for {@link
@@ -15,27 +15,19 @@ import { EuiBasicTableSelectors } from '../../../components/basic_table/selector
15
15
  *
16
16
  * `testSubj` must match the `data-test-subj` set by the consumer on the
17
17
  * `<EuiBasicTable>`/`<EuiInMemoryTable>` (EUI spreads it onto the `.euiBasicTable`
18
- * root). See the package README for what's deliberately excluded from v1.
18
+ * root). Extends `EuiTableObject`, so `rows`, `headerCells`, `column` and `cell`
19
+ * are available too. See the package README for what's deliberately excluded.
19
20
  */
20
- export class EuiBasicTableObject extends BaseObject {
21
+ export class EuiBasicTableObject extends EuiTableObject {
21
22
  constructor(scope, testSubj) {
22
23
  super(scope, testSubj, EuiBasicTableSelectors.ROOT_SELECTOR);
23
24
  }
24
25
  /**
25
- * The table's data rows, as a `Locator` so callers keep Playwright auto-retry
26
- * for count and content assertions (e.g. `expect(table.rows).toHaveCount(3)`).
27
- *
28
- * Excludes EUI's own "no items found" (and error-message) row: when the table
29
- * is empty, EUI still renders a single `.euiTableRow` whose one cell spans
30
- * every column (`colSpan` on `EuiTableRowCell`, the `td[colspan]` HTML
31
- * attribute). Real data rows don't set `colspan` on their cells, so filtering
32
- * it out is what keeps `toHaveCount(0)` correct on an empty table instead of
33
- * reading `1`.
26
+ * The data rows. Excludes EUI's own "no items found" row, whose single cell
27
+ * spans every column with `colspan`. Basic table data rows never set it.
34
28
  */
35
29
  get rows() {
36
- return this.root
37
- .locator(EuiBasicTableSelectors.ROW_SELECTOR)
38
- .filter({ hasNot: this.root.page().locator('td[colspan]') });
30
+ return super.rows.filter({ hasNot: this.root.page().locator('td[colspan]') });
39
31
  }
40
32
  /**
41
33
  * The cells of the given field-data column, one per row, as a `Locator` for
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../../src/playwright/components/basic_table/object.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAEnF;;;;;;;;;GASG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IACjD,YAAY,KAAkB,EAAE,QAAgB;QAC9C,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI;aACb,OAAO,CAAC,sBAAsB,CAAC,YAAY,CAAC;aAC5C,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,KAAK,CAAC,KAAa;QACvB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAA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AAG,CAAC,CAAC;IACtE,CAAC;CACF"}
@@ -1,12 +1,12 @@
1
- import type { Locator } from '@playwright/test';
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. Covers only the default
8
- * text-input anchor, not a custom `button` prop. See the package README for
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
  }
@@ -5,15 +5,16 @@
5
5
  * in compliance with, at your election, the Elastic License 2.0 or the Server
6
6
  * Side Public License, v 1.
7
7
  */
8
+ import { expect } from '@playwright/test';
8
9
  import { BaseObject } from '../../base_object';
9
10
  import { EuiColorPickerSelectors } from '../../../components/color_picker/selectors';
10
11
  /**
11
12
  * Playwright Component Object for {@link
12
13
  * https://eui.elastic.co/docs/components/forms/color-picker/ EuiColorPicker}.
13
14
  *
14
- * `testSubj` must be set on `EuiColorPicker` itself. Covers only the default
15
- * text-input anchor, not a custom `button` prop. See the package README for
16
- * what this does not cover.
15
+ * `testSubj` must be set on `EuiColorPicker` itself. `locator` is the anchor:
16
+ * the default text input, or the element passed as the `button` prop. See the
17
+ * package README for what this does not cover.
17
18
  */
18
19
  export class EuiColorPickerObject extends BaseObject {
19
20
  constructor(scope, testSubj) {
@@ -30,5 +31,66 @@ export class EuiColorPickerObject extends BaseObject {
30
31
  get swatches() {
31
32
  return this.panel.locator(EuiColorPickerSelectors.SWATCH_SELECTOR);
32
33
  }
34
+ /**
35
+ * Type `color` into the hex input and verify it was accepted. With the
36
+ * default anchor that input is the anchor itself. With a custom `button`
37
+ * the input lives inside the panel, so the picker is opened, filled and
38
+ * closed again. Throws if the panel has no input
39
+ * (`secondaryInputDisplay="none"`).
40
+ */
41
+ async setColor(color) {
42
+ // EUI echoes the value back uppercased.
43
+ const expected = color.toUpperCase();
44
+ if (await this.isInputAnchor()) {
45
+ await this.root.fill(color);
46
+ await expect(this.root).toHaveValue(expected);
47
+ await this.root.blur();
48
+ return;
49
+ }
50
+ await this.toggle();
51
+ const input = await this.secondaryInput();
52
+ await input.fill(color);
53
+ await expect(input).toHaveValue(expected);
54
+ await this.toggle();
55
+ }
56
+ /**
57
+ * The color shown in the hex input, uppercased. With a custom `button` the
58
+ * picker is opened to read it and closed again.
59
+ */
60
+ async getColor() {
61
+ if (await this.isInputAnchor()) {
62
+ return this.root.inputValue();
63
+ }
64
+ await this.toggle();
65
+ const value = await (await this.secondaryInput()).inputValue();
66
+ await this.toggle();
67
+ return value;
68
+ }
69
+ async isInputAnchor() {
70
+ return this.root.evaluate((el) => el.tagName === 'INPUT');
71
+ }
72
+ /**
73
+ * Click a custom `button` anchor, which toggles the panel, and wait for the
74
+ * panel to follow. Only used with a custom `button`: the default input
75
+ * anchor opens on click but does not close on a second one.
76
+ */
77
+ async toggle() {
78
+ const wasOpen = (await this.panel.count()) > 0;
79
+ await this.root.click();
80
+ if (wasOpen) {
81
+ await this.panel.waitFor({ state: 'detached' });
82
+ }
83
+ else {
84
+ await expect(this.panel).toHaveAttribute('data-popover-open', 'true');
85
+ }
86
+ }
87
+ async secondaryInput() {
88
+ const input = this.panel.locator(EuiColorPickerSelectors.SECONDARY_INPUT_SELECTOR);
89
+ if ((await input.count()) === 0) {
90
+ throw new Error(`EuiColorPicker "${this.testSubj}" uses a custom button and its panel has no hex input. ` +
91
+ `Set secondaryInputDisplay to "top" or "bottom" to read or set its color.`);
92
+ }
93
+ return input;
94
+ }
33
95
  }
34
96
  //# sourceMappingURL=object.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../../src/playwright/components/color_picker/object.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAErF;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAClD,YAAY,KAAkB,EAAE,QAAgB;QAC9C,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC;IAClE,CAAC;IAED;;;OAGG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;IAC1E,CAAC;IAED,+CAA+C;IAC/C,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC;IACrE,CAAC;CACF"}
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../../src/playwright/components/color_picker/object.ts"],"names":[],"mappings":"AAAA;;;;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