@bigbinary/neeto-playwright-commons 1.8.26 → 1.8.27

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/index.d.ts CHANGED
@@ -44,6 +44,16 @@ interface FieldValue {
44
44
  value: string;
45
45
  }
46
46
  type VerifyFieldValue = (values: FieldValue | FieldValue[]) => Promise<void> | Promise<void[]>;
47
+ interface SelectOptionFromDropdownParams {
48
+ selectValueContainer: string;
49
+ selectMenu: string;
50
+ value: string;
51
+ options?: Partial<{
52
+ visiblityTimeout: number;
53
+ textAssertionTimeout: number;
54
+ retryTimeout: number;
55
+ }>;
56
+ }
47
57
  declare class CustomCommands {
48
58
  page: Page;
49
59
  responses: string[];
@@ -56,6 +66,7 @@ declare class CustomCommands {
56
66
  verifySuccessToast: ({ message, closeAfterVerification, }?: Partial<VerifySuccessToastParams>) => Promise<void>;
57
67
  reloadAndWait: (requestCount: number, customPageContext?: Page, interceptMultipleResponsesProps?: Partial<Omit<InterceptMultipleResponsesParams, "times">>) => Promise<void>;
58
68
  apiRequest: ApiRequest;
69
+ selectOptionFromDropdown: ({ selectValueContainer, selectMenu, value, options, }: SelectOptionFromDropdownParams) => Promise<void>;
59
70
  verifyFieldValue: VerifyFieldValue;
60
71
  }
61
72
 
package/index.js CHANGED
@@ -2503,6 +2503,21 @@ class CustomCommands {
2503
2503
  })}`;
2504
2504
  return await this.request[method](formattedUrl, requestOptions);
2505
2505
  };
2506
+ this.selectOptionFromDropdown = async ({ selectValueContainer, selectMenu, value, options = {}, }) => {
2507
+ Object.assign({
2508
+ visiblityTimeout: 2000,
2509
+ textAssertionTimeout: 1000,
2510
+ retryTimeout: 20000,
2511
+ }, options);
2512
+ await expect(async () => {
2513
+ await this.page.getByTestId(selectValueContainer).click();
2514
+ await expect(this.page.getByTestId(selectMenu)).toBeVisible({
2515
+ timeout: options.visiblityTimeout,
2516
+ });
2517
+ await this.page.getByTestId(selectMenu).getByText(value).click();
2518
+ await expect(this.page.getByTestId(selectValueContainer)).toContainText(value, { timeout: options.textAssertionTimeout });
2519
+ }).toPass({ timeout: options.retryTimeout });
2520
+ };
2506
2521
  this.verifyFieldValue = values => {
2507
2522
  const verifyEachFieldValue = ({ field, value, }) => expect(this.page.getByTestId(field)).toHaveValue(value);
2508
2523
  return Array.isArray(values)