@linzjs/step-ag-grid 7.16.0 → 7.16.2

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.16.0",
5
+ "version": "7.16.2",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -1,6 +1,6 @@
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
4
  import { isEqual } from "lodash-es";
5
5
 
6
6
  export const countRows = async (within?: HTMLElement): Promise<number> => {
@@ -149,25 +149,40 @@ export const clickMultiSelectOption = async (value: string): Promise<void> => {
149
149
  menuItem.parentElement && userEvent.click(menuItem.parentElement);
150
150
  };
151
151
 
152
- export const typeInput = async (value: string): Promise<void> => {
153
- const openMenu = await findOpenMenu();
154
- const input = await findQuick({ child: { tagName: "input[type='text']" } }, openMenu);
155
- userEvent.clear(input);
156
- userEvent.type(input, value);
152
+ const typeInput = async (value: string, filter: IQueryQuick): Promise<void> => {
153
+ await act(async () => {
154
+ const openMenu = await findOpenMenu();
155
+ const input = await findQuick(filter, openMenu);
156
+ userEvent.clear(input);
157
+ userEvent.type(input, value);
158
+ });
159
+ };
160
+
161
+ export const typeOnlyInput = async (value: string): Promise<void> => {
162
+ typeInput(value, { child: { tagName: "input[type='text']" } });
163
+ };
164
+
165
+ export const typeInputByLabel = async (value: string, labelText: string): Promise<void> => {
166
+ const labels = getAllQuick({ child: { tagName: "label" } }).filter((l) => l.textContent == labelText);
167
+ if (labels.length == 0) {
168
+ throw Error(`Label not found for text: ${labelText}`);
169
+ }
170
+ if (labels.length > 1) {
171
+ throw Error(`Multiple labels found for text: ${labelText}`);
172
+ }
173
+ typeInput(value, { child: { tagName: `input[id='${labels[0].getAttribute("for")}']` } });
174
+ };
175
+
176
+ export const typeInputByPlaceholder = async (value: string, placeholder: string): Promise<void> => {
177
+ typeInput(value, { child: { tagName: `input[placeholder='${placeholder}']` } });
157
178
  };
158
179
 
159
180
  export const typeOtherInput = async (value: string): Promise<void> => {
160
- const openMenu = await findOpenMenu();
161
- const otherInput = await findQuick({ classes: ".subComponent", child: { tagName: "input[type='text']" } }, openMenu);
162
- userEvent.clear(otherInput);
163
- userEvent.type(otherInput, value);
181
+ typeInput(value, { classes: ".subComponent", child: { tagName: "input[type='text']" } });
164
182
  };
165
183
 
166
184
  export const typeOtherTextArea = async (value: string): Promise<void> => {
167
- const openMenu = await findOpenMenu();
168
- const otherTextArea = await findQuick({ classes: ".subComponent", child: { tagName: "textarea" } }, openMenu);
169
- userEvent.clear(otherTextArea);
170
- userEvent.type(otherTextArea, value);
185
+ typeInput(value, { classes: ".subComponent", child: { tagName: "textarea" } });
171
186
  };
172
187
 
173
188
  export const closeMenu = (): void => {