@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
@@ -0,0 +1,25 @@
1
+ # EuiDataGridObject
2
+
3
+ Playwright Component Object for [EuiDataGrid](https://eui.elastic.co/docs/components/data-grid).
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import { EuiDataGridObject } from '@elastic/eui-test-helpers';
9
+
10
+ const dataGrid = new EuiDataGridObject(page, 'myDataGrid');
11
+ await expect(dataGrid.rows).toHaveCount(10);
12
+ await expect(dataGrid.cells('name').filter({ hasText: 'my-rule' })).toBeVisible();
13
+ ```
14
+
15
+ Set `data-test-subj` on the `<EuiDataGrid>` itself — EUI spreads it onto the `.euiDataGrid` element, and the Component Object verifies that (the component-type guard throws otherwise). EUI also toggles state classes such as fullscreen on that element, so a wrapper subj would not work. When the subj is not unique on the page (e.g. portal-rendered duplicates), narrow with the `scope` constructor parameter instead of pointing the subj at a wrapper.
16
+
17
+ ## API
18
+
19
+ | Member | Description |
20
+ |---|---|
21
+ | `rows` | `Locator` for the rendered rows, keeping Playwright auto-retry for count/content assertions. For a paginated grid this is the current page. Rows are virtualized: on a grid too tall for its container this is only the visible window, never the full data set. |
22
+ | `cell(rowIndex, columnId)` | `Locator` for a single data cell. The column id is stable against column reordering and horizontal virtualization. |
23
+ | `cells(columnId)` | `Locator` for every rendered data cell of a column (excludes the header cell). |
24
+ | `doActionOnColumn(columnId, actionLabel)` | Opens the column's header actions and clicks the action with the given visible label (e.g. `'Hide column'`). Handles the hover/focus dance the actions button requires and the portal-rendered menu (scoped per column id, safe with multiple grids). |
25
+ | `openFullScreenMode()` / `closeFullScreenMode()` | Toggles fullscreen via the toolbar button and settles on the synchronously-set state class. Blurs the button afterwards so its tooltip does not cover the grid. |
@@ -0,0 +1,25 @@
1
+ # EuiSuperSelectObject
2
+
3
+ Playwright Component Object for [EuiSuperSelect](https://eui.elastic.co/docs/components/forms/selection/super-select/).
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import { EuiSuperSelectObject } from '@elastic/eui-test-helpers';
9
+
10
+ const superSelect = new EuiSuperSelectObject(page, 'mySuperSelect');
11
+ await superSelect.selectOptionByValue('warning');
12
+ expect(await superSelect.getSelectedValue()).toBe('warning');
13
+ ```
14
+
15
+ Set `data-test-subj` on the `<EuiSuperSelect>` — EUI spreads it onto the control `<button>` (`.euiSuperSelectControl`), which the component-type guard verifies.
16
+
17
+ ## API
18
+
19
+ | Method | Description |
20
+ |---|---|
21
+ | `selectOptionByValue(value)` | Selects the option whose `value` matches. Works on any EuiSuperSelect without extra test hooks (EUI renders each option with `id={String(value)}`) and is the preferred method when the value is a stable code constant — it is immune to i18n and display changes. |
22
+ | `selectOptionByLabel(label)` | Selects the option by its visible label. Use for dynamic, data-driven option content where the test cannot know the value. Note the dropdown shows `dropdownDisplay` when the consumer provides it, which can differ from the committed `inputDisplay` text. |
23
+ | `getSelectedValue()` | The committed selection's `value`, read from the hidden form input EUI renders next to the control (the visible button text shows the label, not the value). |
24
+
25
+ Both select methods open the dropdown if needed and wait for it to close after the click.
@@ -0,0 +1,22 @@
1
+ # EuiGlobalToastListObject
2
+
3
+ Playwright Component Object for [EuiGlobalToastList](https://eui.elastic.co/docs/components/display/toast/).
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import { EuiGlobalToastListObject } from '@elastic/eui-test-helpers';
9
+
10
+ const toastList = new EuiGlobalToastListObject(page, 'globalToastList');
11
+ await expect(toastList.toasts).toHaveCount(1);
12
+ await toastList.closeAll();
13
+ ```
14
+
15
+ Set `data-test-subj` on the `<EuiGlobalToastList>` (EUI spreads it onto the `.euiGlobalToastList` element, which the component-type guard verifies). Toasts rendered outside the list (inline `EuiToast`) are not covered.
16
+
17
+ ## API
18
+
19
+ | Member | Description |
20
+ |---|---|
21
+ | `toasts` | `Locator` for the toasts currently in the list, keeping Playwright auto-retry for count and content assertions (e.g. `expect(toasts).toHaveCount(1)`, `expect(toasts).toContainText('Saved')`). |
22
+ | `closeAll()` | Clicks every toast's close button and waits until none remain. No-op when the list is already empty, so it doubles as a "dismiss if present" teardown helper. Tolerates toasts auto-dismissing mid-iteration. |