@linzjs/step-ag-grid 7.15.0 → 7.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "7.15.0",
5
+ "version": "7.16.1",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -1,6 +1,7 @@
1
1
  import { act, waitFor, within } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
- import { findQuick, getAllQuick, getMatcher, getQuick, queryQuick } from "./testQuick";
3
+ import { findQuick, getAllQuick, getMatcher, getQuick, IQueryQuick, queryQuick } from "./testQuick";
4
+ import { isEqual } from "lodash-es";
4
5
 
5
6
  export const countRows = async (within?: HTMLElement): Promise<number> => {
6
7
  return getAllQuick({ tagName: `div[row-id]:not(:empty)` }, within).length;
@@ -98,6 +99,17 @@ export const findMenuOption = async (menuOptionText: string | RegExp): Promise<H
98
99
  );
99
100
  };
100
101
 
102
+ export const validateMenuOptions = async (
103
+ rowId: number | string,
104
+ colId: string,
105
+ expectedMenuOptions: Array<string>,
106
+ ): Promise<boolean> => {
107
+ await editCell(rowId, colId);
108
+ const openMenu = await findOpenMenu();
109
+ const actualOptions = (await within(openMenu).findAllByRole("menuitem")).map((menuItem) => menuItem.textContent);
110
+ return isEqual(actualOptions, expectedMenuOptions);
111
+ };
112
+
101
113
  export const clickMenuOption = async (menuOptionText: string | RegExp): Promise<void> => {
102
114
  const menuOption = await findMenuOption(menuOptionText);
103
115
  await act(async () => {
@@ -137,25 +149,38 @@ export const clickMultiSelectOption = async (value: string): Promise<void> => {
137
149
  menuItem.parentElement && userEvent.click(menuItem.parentElement);
138
150
  };
139
151
 
140
- export const typeInput = async (value: string): Promise<void> => {
152
+ const typeInput = async (value: string, filter: IQueryQuick): Promise<void> => {
141
153
  const openMenu = await findOpenMenu();
142
- const input = await findQuick({ child: { tagName: "input[type='text']" } }, openMenu);
154
+ const input = await findQuick(filter, openMenu);
143
155
  userEvent.clear(input);
144
156
  userEvent.type(input, value);
145
157
  };
146
158
 
159
+ export const typeOnlyInput = async (value: string): Promise<void> => {
160
+ typeInput(value, { child: { tagName: "input[type='text']" } });
161
+ };
162
+
163
+ export const typeInputByLabel = async (value: string, labelText: string): Promise<void> => {
164
+ const labels = getAllQuick({ child: { tagName: "label" } }).filter((l) => l.textContent == labelText);
165
+ if (labels.length == 0) {
166
+ throw Error(`Label not found for text: ${labelText}`);
167
+ }
168
+ if (labels.length > 1) {
169
+ throw Error(`Multiple labels found for text: ${labelText}`);
170
+ }
171
+ typeInput(value, { child: { tagName: `input[id='${labels[0].getAttribute("for")}']` } });
172
+ };
173
+
174
+ export const typeInputByPlaceholder = async (value: string, placeholder: string): Promise<void> => {
175
+ typeInput(value, { child: { tagName: `input[placeholder='${placeholder}']` } });
176
+ };
177
+
147
178
  export const typeOtherInput = async (value: string): Promise<void> => {
148
- const openMenu = await findOpenMenu();
149
- const otherInput = await findQuick({ classes: ".subComponent", child: { tagName: "input[type='text']" } }, openMenu);
150
- userEvent.clear(otherInput);
151
- userEvent.type(otherInput, value);
179
+ typeInput(value, { classes: ".subComponent", child: { tagName: "input[type='text']" } });
152
180
  };
153
181
 
154
182
  export const typeOtherTextArea = async (value: string): Promise<void> => {
155
- const openMenu = await findOpenMenu();
156
- const otherTextArea = await findQuick({ classes: ".subComponent", child: { tagName: "textarea" } }, openMenu);
157
- userEvent.clear(otherTextArea);
158
- userEvent.type(otherTextArea, value);
183
+ typeInput(value, { classes: ".subComponent", child: { tagName: "textarea" } });
159
184
  };
160
185
 
161
186
  export const closeMenu = (): void => {