@bigbinary/neeto-playwright-commons 1.10.11 → 1.10.13

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
@@ -73,6 +73,12 @@ interface SearchAndVerifyProps {
73
73
  searchInputSelector?: string;
74
74
  countText: string;
75
75
  }
76
+ interface UploadFileViaDispatchProps {
77
+ fileNameWithType: string;
78
+ assetsPath?: string;
79
+ dispatchEvent?: string;
80
+ droppableZone?: Locator;
81
+ }
76
82
  declare class CustomCommands {
77
83
  page: Page;
78
84
  responses: string[];
@@ -323,6 +329,33 @@ declare class CustomCommands {
323
329
  * @endexample
324
330
  */
325
331
  uploadImage: (localImagePath: string) => Promise<void>;
332
+ /**
333
+ *
334
+ * Function to upload a file by simulating a drop event onto a specified droppable zone on the page.
335
+ *
336
+ * React-dropzone, by default, uses File System API to upload files. Due to this we cannot use directly use waitForEvent("filechooser"). Ref: https://github.com/microsoft/playwright/issues/8850
337
+ *
338
+ * fileNameWithType: The name of the file to upload including its type extension (e.g., "images/example.png").
339
+ *
340
+ * assetsPath: The relative path to the assets directory where the file is located. Defaults to ../../../e2e/assets/.
341
+ *
342
+ * dispatchEvent: The type of event to dispatch to the droppable zone. Defaults to drop.
343
+ *
344
+ * droppableZone: The droppable zone element where the file will be dropped. Defaults to this.page.getByTestId("file-upload-body").
345
+ *
346
+ * @example
347
+ *
348
+ * await uploadFileViaDispatch({
349
+ * fileNameWithType: "files/sample.pdf",
350
+ * });
351
+ * @endexample
352
+ */
353
+ uploadFileViaDispatch: ({
354
+ fileNameWithType,
355
+ assetsPath,
356
+ dispatchEvent,
357
+ droppableZone
358
+ }: UploadFileViaDispatchProps) => Promise<void>;
326
359
  verifyTooltip: ({
327
360
  triggerElement,
328
361
  content
@@ -1144,6 +1177,7 @@ interface WebhooksPageParams {
1144
1177
  type CallbackFunction = (args: Record<string, unknown>) => void;
1145
1178
  interface VerifyWebhookResponseParams extends Record<string, unknown> {
1146
1179
  callback?: CallbackFunction;
1180
+ parseFullResponseContent?: boolean;
1147
1181
  webhookToken: string;
1148
1182
  }
1149
1183
  interface VerifyWebhookDeliveriesParams extends Record<string, unknown> {
@@ -1204,6 +1238,8 @@ declare class WebhooksPage {
1204
1238
  *
1205
1239
  * webhookToken: Token of the webhook.
1206
1240
  *
1241
+ * parseFullResponseContent: Option to pass the full response content to the callback function. Defaults to false.
1242
+ *
1207
1243
  * Other parameters to be passed to the callback function.
1208
1244
  *
1209
1245
  * @example
@@ -1217,6 +1253,7 @@ declare class WebhooksPage {
1217
1253
  verifyLatestWebhookResponse: ({
1218
1254
  callback,
1219
1255
  webhookToken,
1256
+ parseFullResponseContent,
1220
1257
  ...otherParams
1221
1258
  }: VerifyWebhookResponseParams) => Promise<void>;
1222
1259
  /**
@@ -1391,7 +1428,6 @@ declare class ZapierPage extends IntegrationBase {
1391
1428
  interface VerifyDescriptionEditorParams {
1392
1429
  text: string;
1393
1430
  dynamicVariables?: string[];
1394
- defaultFontSizeOption?: string;
1395
1431
  linkUrl?: string;
1396
1432
  filePath?: string;
1397
1433
  imageUrl?: string;
@@ -1463,7 +1499,6 @@ declare class EditorPage {
1463
1499
  verifyDescriptionEditor: ({
1464
1500
  text,
1465
1501
  dynamicVariables,
1466
- defaultFontSizeOption,
1467
1502
  linkUrl,
1468
1503
  filePath,
1469
1504
  imageUrl,
@@ -2993,6 +3028,7 @@ declare const COMMON_SELECTORS: {
2993
3028
  submitButton: string;
2994
3029
  tableRow: string;
2995
3030
  navigationHeaderLeftBlock: string;
3031
+ fileUploadBody: string;
2996
3032
  };
2997
3033
  /**
2998
3034
  *
@@ -3050,6 +3086,7 @@ declare const COMMON_SELECTORS: {
3050
3086
  *
3051
3087
  */
3052
3088
  declare const NEETO_EDITOR_SELECTORS: {
3089
+ fontSize: string;
3053
3090
  boldOption: string;
3054
3091
  italicOption: string;
3055
3092
  underlineOption: string;
@@ -3073,7 +3110,6 @@ declare const NEETO_EDITOR_SELECTORS: {
3073
3110
  addLinkTextField: string;
3074
3111
  addURLTextField: string;
3075
3112
  submitLinkButton: string;
3076
- fontSizeDropdown: (currentOption: string) => string;
3077
3113
  fixedMenuArrow: string;
3078
3114
  cannedResponseOption: string;
3079
3115
  cannedResponseSelectContainer: string;
package/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { execSync } from 'child_process';
2
1
  import * as fs$d from 'fs';
3
- import fs__default, { writeFileSync as writeFileSync$1, unlinkSync, readFileSync } from 'fs';
2
+ import fs__default, { readFileSync, writeFileSync as writeFileSync$1, unlinkSync } from 'fs';
3
+ import * as Path from 'path';
4
+ import Path__default from 'path';
5
+ import { execSync } from 'child_process';
4
6
  import test$1, { expect, test as test$2, defineConfig, devices } from '@playwright/test';
5
7
  import { curry, not, isEmpty as isEmpty$1, isNil, isNotNil, mergeDeepLeft, mergeAll } from 'ramda';
6
8
  import require$$0$1 from 'util';
7
- import * as Path from 'path';
8
- import Path__default from 'path';
9
9
  import { faker } from '@faker-js/faker';
10
10
  import MailosaurClient from 'mailosaur';
11
11
  import dayjs from 'dayjs';
@@ -331,6 +331,7 @@ const COMMON_SELECTORS = {
331
331
  submitButton: "submit-button",
332
332
  tableRow: ".ant-table-row",
333
333
  navigationHeaderLeftBlock: "navigation-header-left-block",
334
+ fileUploadBody: "file-upload-body",
334
335
  };
335
336
 
336
337
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -3579,9 +3580,25 @@ class CustomCommands {
3579
3580
  await uploadFile;
3580
3581
  await expect(this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.uploadedImage)).toHaveAttribute("src", new RegExp(imageName), { timeout: 20000 });
3581
3582
  };
3583
+ this.uploadFileViaDispatch = async ({ fileNameWithType, assetsPath = "../../../e2e/assets/", dispatchEvent = "drop", droppableZone = this.page.getByTestId(COMMON_SELECTORS.fileUploadBody), }) => {
3584
+ const filePath = Path__default.join(__dirname, `${assetsPath}/${fileNameWithType}`);
3585
+ const buffer = readFileSync(filePath).toString("base64");
3586
+ const dataTransfer = await droppableZone.evaluateHandle((_, { buffer, fileNameWithType }) => {
3587
+ var _a;
3588
+ const dataTransfer = new DataTransfer();
3589
+ const fileName = (_a = fileNameWithType.split("/")) === null || _a === void 0 ? void 0 : _a[1];
3590
+ const hexString = Uint8Array.from(atob(buffer), c => c.charCodeAt(0));
3591
+ const file = new File([hexString], fileName);
3592
+ dataTransfer.items.add(file);
3593
+ return dataTransfer;
3594
+ }, { buffer, fileNameWithType });
3595
+ await droppableZone.dispatchEvent(dispatchEvent, { dataTransfer });
3596
+ };
3582
3597
  this.verifyTooltip = async ({ triggerElement, content, }) => {
3583
3598
  await triggerElement.hover();
3584
3599
  await expect(this.page.getByTestId(COMMON_SELECTORS.tooltip)).toContainText(content);
3600
+ await this.page.mouse.move(0, 0);
3601
+ await expect(this.page.getByTestId(COMMON_SELECTORS.tooltip)).toBeHidden();
3585
3602
  };
3586
3603
  this.page = page;
3587
3604
  this.responses = [];
@@ -13469,14 +13486,16 @@ class WebhooksPage {
13469
13486
  await addWebhook;
13470
13487
  await expect(this.page.getByRole("row", { name: webhookSiteURL })).toBeVisible();
13471
13488
  };
13472
- this.verifyLatestWebhookResponse = async ({ callback = () => { }, webhookToken, ...otherParams }) => {
13489
+ this.verifyLatestWebhookResponse = async ({ callback = () => { }, webhookToken, parseFullResponseContent = false, ...otherParams }) => {
13473
13490
  let response;
13474
13491
  await expect(async () => {
13475
13492
  response = await this.request.get(`https://webhook.site/token/${webhookToken}/request/latest`);
13476
13493
  expect(response.status()).toBe(200);
13477
13494
  if (response.status() === 200) {
13478
13495
  const { content } = await response.json();
13479
- const parsedResponse = JSON.parse(content).webhook;
13496
+ const parsedResponse = parseFullResponseContent
13497
+ ? JSON.parse(content)
13498
+ : JSON.parse(content).webhook;
13480
13499
  callback({ parsedResponse, ...otherParams });
13481
13500
  }
13482
13501
  }).toPass({ timeout: 20000 });
@@ -13769,6 +13788,7 @@ const optionSelector = (option) => `neeto-editor-fixed-menu-${option}-option`;
13769
13788
  const fixedMenuSelector = (selector) => `neeto-editor-fixed-menu-${selector}`;
13770
13789
 
13771
13790
  const NEETO_EDITOR_SELECTORS = {
13791
+ fontSize: optionSelector("font-size"),
13772
13792
  boldOption: optionSelector("bold"),
13773
13793
  italicOption: optionSelector("italic"),
13774
13794
  underlineOption: optionSelector("underline"),
@@ -13792,7 +13812,6 @@ const NEETO_EDITOR_SELECTORS = {
13792
13812
  addLinkTextField: "neeto-editor-add-link-text-input",
13793
13813
  addURLTextField: "neeto-editor-add-link-url-input",
13794
13814
  submitLinkButton: "neeto-editor-add-link",
13795
- fontSizeDropdown: (currentOption) => `${joinHyphenCase(currentOption)}-dropdown-icon`,
13796
13815
  fixedMenuArrow: fixedMenuSelector("arrow"),
13797
13816
  cannedResponseOption: optionSelector("canned-responses"),
13798
13817
  cannedResponseSelectContainer: "select-a-canned-response-select-container",
@@ -13855,10 +13874,9 @@ class EditorPage {
13855
13874
  (await this.moreMenuSelector.click());
13856
13875
  return optionLocator.isVisible();
13857
13876
  };
13858
- this.verifyFontSize = async (defaultFontSizeOption) => {
13859
- await this.editorWrapper
13860
- .getByTestId(NEETO_EDITOR_SELECTORS.fontSizeDropdown(defaultFontSizeOption))
13861
- .click();
13877
+ this.verifyFontSize = async () => {
13878
+ const fontSizeDropdown = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.fontSize);
13879
+ await fontSizeDropdown.click();
13862
13880
  const fontSize = Object.keys(FONT_SIZE_SELECTORS);
13863
13881
  for (const font of fontSize) {
13864
13882
  const fontKey = font;
@@ -13866,9 +13884,7 @@ class EditorPage {
13866
13884
  .getByTestId(FONT_SIZE_SELECTORS[fontKey])
13867
13885
  .click();
13868
13886
  await expect(this.contentField.getByRole("heading", { level: Number(font.slice(1)) })).toBeVisible();
13869
- await this.editorWrapper
13870
- .getByTestId(NEETO_EDITOR_SELECTORS.fontSizeDropdown(EXPANDED_FONT_SIZE[fontKey]))
13871
- .click();
13887
+ await fontSizeDropdown.click();
13872
13888
  }
13873
13889
  };
13874
13890
  this.verifyTextModifiers = async () => {
@@ -14028,9 +14044,9 @@ class EditorPage {
14028
14044
  await expect(this.contentField.getByText(dynamicVariable)).toBeVisible();
14029
14045
  }
14030
14046
  };
14031
- this.verifyDescriptionEditor = async ({ text, dynamicVariables, defaultFontSizeOption = "Paragraph", linkUrl = faker.internet.url(), filePath = "../../../e2e/assets/images/BigBinary.png", imageUrl = "https://picsum.photos/200/300", videoUrl = "https://youtu.be/jNQXAC9IVRw", cannedResponseSuccessMessage, }) => {
14047
+ this.verifyDescriptionEditor = async ({ text, dynamicVariables, linkUrl = faker.internet.url(), filePath = "../../../e2e/assets/images/BigBinary.png", imageUrl = "https://picsum.photos/200/300", videoUrl = "https://youtu.be/jNQXAC9IVRw", cannedResponseSuccessMessage, }) => {
14032
14048
  await this.contentField.fill(text);
14033
- await this.verifyFontSize(defaultFontSizeOption);
14049
+ await this.verifyFontSize();
14034
14050
  if (await this.assertOptionVisibility(this.paragraphSelector)) {
14035
14051
  await this.paragraphSelector.click();
14036
14052
  const paragraphRole = DESCRIPTION_EDITOR_TEXTS.paragraphOption;