@bigbinary/neeto-playwright-commons 1.18.4 → 1.19.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.
package/index.d.ts CHANGED
@@ -990,6 +990,7 @@ declare class ThankYouPage {
990
990
  addRedirectUrl: (customRedirectUrl: string) => Promise<void>;
991
991
  }
992
992
  type EmbedType = "inline" | "floatingPopup" | "elementClick";
993
+ type EmbedTypeV2 = "inline" | "floatingPopup" | "elementPopup";
993
994
  type GetByRoleOptions = {
994
995
  checked?: boolean;
995
996
  disabled?: boolean;
@@ -1029,6 +1030,11 @@ type initializeEmbedPageParams = {
1029
1030
  embedCode: string;
1030
1031
  customElementText?: string;
1031
1032
  };
1033
+ type InitializeEmbedPageParamsV2 = {
1034
+ embedType: EmbedTypeV2;
1035
+ embedCode: string;
1036
+ customElementText?: string;
1037
+ };
1032
1038
  type EmbedBasePageConstructorParams = {
1033
1039
  context: BrowserContext;
1034
1040
  page: Page;
@@ -1042,7 +1048,7 @@ declare class EmbedBase {
1042
1048
  appName: string;
1043
1049
  t: TFunction;
1044
1050
  embedTestPage: Page;
1045
- embedTestPageType: EmbedType;
1051
+ embedTestPageType: EmbedType | EmbedTypeV2;
1046
1052
  embeddedFrame: FrameLocator;
1047
1053
  filePath: string;
1048
1054
  codeBlock: Locator;
@@ -1053,6 +1059,9 @@ declare class EmbedBase {
1053
1059
  neetoPlaywrightUtilities,
1054
1060
  appName
1055
1061
  }: EmbedBasePageConstructorParams);
1062
+ /**
1063
+ * @deprecated This method is deprecated. Use initializeEmbedPageV2 instead.
1064
+ */
1056
1065
  /**
1057
1066
  *
1058
1067
  * Initializes the embed test page. It takes the following parameters:
@@ -1083,6 +1092,36 @@ declare class EmbedBase {
1083
1092
  embedCode,
1084
1093
  customElementText
1085
1094
  }: initializeEmbedPageParams) => Promise<Page>;
1095
+ /**
1096
+ *
1097
+ * Initializes the embed test page. It takes the following parameters:
1098
+ *
1099
+ * embedType: Type of embedded content (inline, floatingPopup, elementPopup).
1100
+ *
1101
+ * embedCode: Embed code.
1102
+ *
1103
+ * customElementText: Custom text for element click type (default: "Click here").
1104
+ *
1105
+ * @example
1106
+ *
1107
+ * await embedBase.initializeEmbedPageV2({
1108
+ * embedType: "inline",
1109
+ * embedCode: "<iframe src='example.com'></iframe>"
1110
+ * });
1111
+ * // OR
1112
+ *
1113
+ * await embedBase.initializeEmbedPageV2({
1114
+ * embedType: "inline",
1115
+ * embedCode: "<iframe src='example.com'></iframe>",
1116
+ * customElementText:"Click here"
1117
+ * });
1118
+ * @endexample
1119
+ */
1120
+ initializeEmbedPageV2: ({
1121
+ embedType,
1122
+ embedCode,
1123
+ customElementText
1124
+ }: InitializeEmbedPageParamsV2) => Promise<Page>;
1086
1125
  /**
1087
1126
  *
1088
1127
  * Closes the embed modal and page.
@@ -1133,8 +1172,13 @@ declare class EmbedBase {
1133
1172
  * selected: true
1134
1173
  * });
1135
1174
  * @endexample
1175
+ * /**
1176
+ *
1136
1177
  */
1137
1178
  clickOnPopupButton: (popUpButtonSelectorOptions: GetByRoleOptions) => Promise<void>;
1179
+ /**
1180
+ * @deprecated This method is deprecated. Use copyEmbedScriptV2 instead.
1181
+ */
1138
1182
  /**
1139
1183
  *
1140
1184
  * Copies the embed script. It takes the following parameters:
@@ -1151,6 +1195,23 @@ declare class EmbedBase {
1151
1195
  }: {
1152
1196
  embedLabel: string;
1153
1197
  }) => Promise<string>;
1198
+ /**
1199
+ *
1200
+ * Copies the embed script. It takes the following parameters:
1201
+ *
1202
+ * embedType: Type of embedded content (inline, floatingPopup, elementPopup).
1203
+ *
1204
+ * @example
1205
+ *
1206
+ * const embedScript = await embedBase.copyEmbedScript("inline");
1207
+ * @endexample
1208
+ * /**
1209
+ *
1210
+ */
1211
+ copyEmbedScriptV2: (embedType: EmbedTypeV2) => Promise<string>;
1212
+ /**
1213
+ * @deprecated This method is deprecated. Use selectEmbedTypeV2 instead.
1214
+ */
1154
1215
  /**
1155
1216
  *
1156
1217
  * Selects the embed type. It takes the following parameters:
@@ -1163,6 +1224,18 @@ declare class EmbedBase {
1163
1224
  * @endexample
1164
1225
  */
1165
1226
  selectEmbedType: (embedLabel: string) => Promise<void>;
1227
+ /**
1228
+ *
1229
+ * Selects the embed type. It takes the following parameters:
1230
+ *
1231
+ * embedType: Type of embedded content (inline, floatingPopup, elementPopup).
1232
+ *
1233
+ * @example
1234
+ *
1235
+ * await embedBase.selectEmbedType("inline");
1236
+ * @endexample
1237
+ */
1238
+ selectEmbedTypeV2: (embedType: EmbedTypeV2) => Promise<void>;
1166
1239
  /**
1167
1240
  *
1168
1241
  * Verifies inline customization of embedded content. It takes the following parameters:
@@ -1187,6 +1260,7 @@ declare class EmbedBase {
1187
1260
  inlineEmbedInterceptParams,
1188
1261
  customizationOptions
1189
1262
  }: VerifyInlineCustomizationParams) => Promise<void>;
1263
+ backToEmbedSelection: () => Promise<void>;
1190
1264
  /**
1191
1265
  *
1192
1266
  * Verifies floating popup customization of embedded content. It takes the following parameters:
@@ -4754,6 +4828,10 @@ declare const FONT_SIZE_SELECTORS: {
4754
4828
  *
4755
4829
  * previewElementPopupButton: Selector for the preview element popup button.
4756
4830
  *
4831
+ * embedSelector: Selector for the embed card to select embed type.
4832
+ *
4833
+ * backToEmbedSelectionButton: Selector for the back button to select embed type.
4834
+ *
4757
4835
  */
4758
4836
  declare const EMBED_SELECTORS: {
4759
4837
  iframe: (appName: string) => string;
@@ -4777,6 +4855,8 @@ declare const EMBED_SELECTORS: {
4777
4855
  showIconCheckbox: string;
4778
4856
  elementIdInput: string;
4779
4857
  previewElementPopupButton: string;
4858
+ embedSelector: (embedType: string) => string;
4859
+ backToEmbedSelectionButton: string;
4780
4860
  };
4781
4861
  /**
4782
4862
  *
package/index.js CHANGED
@@ -389,6 +389,8 @@ const EMBED_SELECTORS = {
389
389
  showIconCheckbox: "show-icon-checkbox",
390
390
  elementIdInput: "element-id-input-field",
391
391
  previewElementPopupButton: "preview-element-popup-button",
392
+ embedSelector: (embedType) => `[data-testid="embed-selector-card-${hyphenize(embedType)}"]`,
393
+ backToEmbedSelectionButton: "back-to-embed-selection-button",
392
394
  };
393
395
 
394
396
  const NEETO_FILTERS_SELECTORS = {
@@ -56992,6 +56994,9 @@ class ThankYouPage {
56992
56994
 
56993
56995
  class EmbedBase {
56994
56996
  constructor({ context, page, neetoPlaywrightUtilities, appName, }) {
56997
+ /**
56998
+ * @deprecated This method is deprecated. Use initializeEmbedPageV2 instead.
56999
+ */
56995
57000
  this.initializeEmbedPage = async ({ embedType, embedCode, customElementText = "Click here", }) => {
56996
57001
  this.embedTestPage = await this.context.newPage();
56997
57002
  this.embedTestPageType = embedType;
@@ -57009,6 +57014,23 @@ class EmbedBase {
57009
57014
  : EMBED_SELECTORS.iframe(this.appName));
57010
57015
  return this.embedTestPage;
57011
57016
  };
57017
+ this.initializeEmbedPageV2 = async ({ embedType, embedCode, customElementText = "Click here", }) => {
57018
+ this.embedTestPage = await this.context.newPage();
57019
+ this.embedTestPageType = embedType;
57020
+ const fileContent = basicHTMLContent(this.embedTestPageType === "elementPopup"
57021
+ ? `${embedCode}<a href='#' id='open-popup-button'>${customElementText}</a>`
57022
+ : embedCode);
57023
+ this.filePath = `tmp/${faker.word.noun()}.html`;
57024
+ writeFileSync$1(this.filePath, fileContent, "utf8");
57025
+ await this.embedTestPage.goto(`file://${Path__default.resolve(this.filePath)}`, {
57026
+ timeout: 20000,
57027
+ });
57028
+ await this.embedTestPage.waitForLoadState("load");
57029
+ this.embeddedFrame = this.embedTestPage.frameLocator(this.embedTestPageType === "inline"
57030
+ ? "iframe"
57031
+ : EMBED_SELECTORS.iframe(this.appName));
57032
+ return this.embedTestPage;
57033
+ };
57012
57034
  this.closeEmbedModalAndPage = async () => {
57013
57035
  if (this.embedTestPageType !== "inline") {
57014
57036
  await this.embedTestPage
@@ -57033,6 +57055,9 @@ class EmbedBase {
57033
57055
  });
57034
57056
  }).toPass({ timeout: 2 * 60 * 1000 });
57035
57057
  };
57058
+ /**
57059
+ * @deprecated This method is deprecated. Use copyEmbedScriptV2 instead.
57060
+ */
57036
57061
  this.copyEmbedScript = async ({ embedLabel }) => {
57037
57062
  await this.page
57038
57063
  .getByTestId(COMMON_SELECTORS.radioLabel(embedLabel))
@@ -57040,12 +57065,24 @@ class EmbedBase {
57040
57065
  await this.page.getByTestId(COMMON_SELECTORS.copyButton).click();
57041
57066
  return await this.page.evaluate(() => navigator.clipboard.readText());
57042
57067
  };
57068
+ this.copyEmbedScriptV2 = async (embedType) => {
57069
+ await this.selectEmbedTypeV2(embedType);
57070
+ await this.page.getByTestId(COMMON_SELECTORS.copyButton).click();
57071
+ return await this.page.evaluate(() => navigator.clipboard.readText());
57072
+ };
57073
+ /**
57074
+ * @deprecated This method is deprecated. Use selectEmbedTypeV2 instead.
57075
+ */
57043
57076
  this.selectEmbedType = async (embedLabel) => {
57044
57077
  await this.page.getByTestId(EMBED_SELECTORS.htmlTab).click();
57045
57078
  await this.page
57046
57079
  .getByTestId(COMMON_SELECTORS.radioLabel(embedLabel))
57047
57080
  .check();
57048
57081
  };
57082
+ this.selectEmbedTypeV2 = async (embedType) => {
57083
+ await this.page.locator(EMBED_SELECTORS.embedSelector(embedType)).click();
57084
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
57085
+ };
57049
57086
  this.verifyInlineCustomization = async ({ headingTestId,
57050
57087
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
57051
57088
  inlineEmbedInterceptParams, customizationOptions, }) => {
@@ -57078,7 +57115,9 @@ class EmbedBase {
57078
57115
  expect(iframeHeight).toStrictEqual(embedHeightPercentage);
57079
57116
  // eslint-disable-next-line playwright/no-standalone-expect
57080
57117
  expect(iframeWidth).toStrictEqual(embedWidthPercentage);
57118
+ await this.backToEmbedSelection();
57081
57119
  };
57120
+ this.backToEmbedSelection = () => this.page.getByTestId(EMBED_SELECTORS.backToEmbedSelectionButton).click();
57082
57121
  this.verifyFloatingPopupCustomization = async (customizationOptions) => {
57083
57122
  await this.page
57084
57123
  .getByTestId(EMBED_SELECTORS.buttonTextInput)
@@ -57145,6 +57184,7 @@ class EmbedBase {
57145
57184
  else if (customizationOptions.showIcon === false) {
57146
57185
  await expect(floatingButtonIcon).toBeHidden();
57147
57186
  }
57187
+ await this.backToEmbedSelection();
57148
57188
  };
57149
57189
  this.verifyElementClickCustomization = async (customizationOptions) => {
57150
57190
  await this.page
@@ -57156,6 +57196,7 @@ class EmbedBase {
57156
57196
  expect(this.page.getByTestId(EMBED_SELECTORS.previewElementPopupButton)).toBeVisible(),
57157
57197
  await expect(this.page.locator(`#${customizationOptions.customId}`)).toBeVisible(),
57158
57198
  ]);
57199
+ await this.backToEmbedSelection();
57159
57200
  };
57160
57201
  this.expectMultipleTextsInCodeblock = async (containTextOptions) => {
57161
57202
  const codeBlock = this.page.getByTestId(EMBED_SELECTORS.codeBlock);
@@ -194650,6 +194691,9 @@ const definePlaywrightConfig = (overrides) => {
194650
194691
  timezoneId: "Asia/Calcutta",
194651
194692
  geolocation: { latitude: 18.553187, longitude: 73.948313 }, // BB Pune office
194652
194693
  permissions: ["geolocation"],
194694
+ launchOptions: {
194695
+ args: ["--js-flags=--max-old-space-size=4096"],
194696
+ },
194653
194697
  ...useOverrides,
194654
194698
  },
194655
194699
  projects: useCustomProjects
@@ -194662,7 +194706,10 @@ const definePlaywrightConfig = (overrides) => {
194662
194706
  },
194663
194707
  {
194664
194708
  name: "chromium",
194665
- use: { ...devices["Desktop Chrome"], storageState: STORAGE_STATE },
194709
+ use: {
194710
+ ...devices["Desktop Chrome"],
194711
+ storageState: STORAGE_STATE,
194712
+ },
194666
194713
  dependencies: ["setup"],
194667
194714
  },
194668
194715
  { name: "cleanup credentials", testMatch: "global.teardown.ts" },