@bigbinary/neeto-playwright-commons 1.8.34 → 1.8.36
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.cjs.js +210 -1
- package/index.cjs.js.map +1 -1
- package/index.d.ts +77 -2
- package/index.js +210 -3
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -171,8 +171,10 @@ const skipTest = {
|
|
|
171
171
|
const shouldSkipSetupAndTeardown = () => { var _a; return ((_a = getGlobalUserState()) === null || _a === void 0 ? void 0 : _a.isLoggedIn) && process.env.SKIP_SETUP === "true"; };
|
|
172
172
|
// trims and replaces multiple whitespace characters in a string with a single space
|
|
173
173
|
const squish = (text) => text.trim().replace(/\s+/g, " ");
|
|
174
|
+
const toCamelCase = (string) => string.toLowerCase().replace(/( \w)/g, letter => letter[1].toUpperCase());
|
|
174
175
|
|
|
175
176
|
const COMMON_SELECTORS = {
|
|
177
|
+
copyButton: "copy-button",
|
|
176
178
|
spinner: ".neeto-ui-spinner",
|
|
177
179
|
subheaderText: "subheader-left",
|
|
178
180
|
alertTitle: "alert-title",
|
|
@@ -187,6 +189,7 @@ const COMMON_SELECTORS = {
|
|
|
187
189
|
paneHeader: "pane-header",
|
|
188
190
|
profileSidebar: "profile-section",
|
|
189
191
|
selectOption: (label) => `${hyphenize(label)}-select-option`,
|
|
192
|
+
radioLabel: (embedLabel) => `${hyphenize(embedLabel)}-radio-label`,
|
|
190
193
|
toastMessage: "toastr-message-container",
|
|
191
194
|
toastCloseButton: "toastr-close-button",
|
|
192
195
|
windowAlert: "#alert-box",
|
|
@@ -230,7 +233,7 @@ const COMMON_SELECTORS = {
|
|
|
230
233
|
homeButton: "home-button",
|
|
231
234
|
neetoUiSwitch: "nui-switch",
|
|
232
235
|
floatingActionMenuButton: "floating-action-menu-container",
|
|
233
|
-
columnsDropdownContainer: "columns-dropdown-container",
|
|
236
|
+
columnsDropdownContainer: "show/hide-columns-dropdown-container",
|
|
234
237
|
columnsDropdownButton: "columns-dropdown-button",
|
|
235
238
|
breadcrumbHeader: "header-breadcrumb",
|
|
236
239
|
};
|
|
@@ -12293,6 +12296,210 @@ const i18nFixture = {
|
|
|
12293
12296
|
},
|
|
12294
12297
|
};
|
|
12295
12298
|
|
|
12299
|
+
const EMBED_SELECTORS = {
|
|
12300
|
+
iframe: (appName) => `#${appName}-iframe`,
|
|
12301
|
+
modal: (appName) => `#${appName}-modal`,
|
|
12302
|
+
close: (appName) => `#close-${appName}`,
|
|
12303
|
+
loader: (appName) => `#${appName}-loader`,
|
|
12304
|
+
inlineHeightInput: "inline-height-input-field",
|
|
12305
|
+
inlineWidthInput: "inline-width-input-field",
|
|
12306
|
+
inlineElementIdInput: "inline-element-id-input-field",
|
|
12307
|
+
codeBlock: "code-block",
|
|
12308
|
+
previewTab: "preview-tab",
|
|
12309
|
+
htmlTab: "html-tab",
|
|
12310
|
+
buttonTextInput: "button-text-input-field",
|
|
12311
|
+
buttonPositionSelectContainer: "button-position-select-value-container",
|
|
12312
|
+
buttonPositionSelectMenu: "button-position-select-menu",
|
|
12313
|
+
buttonColorLabel: "button-color-label",
|
|
12314
|
+
buttonTextColorLabel: "button-text-color-label",
|
|
12315
|
+
colorPickerTarget: "color-picker-target",
|
|
12316
|
+
colorpickerEditableInput: "colorpicker-editable-input",
|
|
12317
|
+
showIconCheckbox: "show-icon-checkbox",
|
|
12318
|
+
elementIdInput: "element-id-input-field",
|
|
12319
|
+
previewElementPopupButton: "preview-element-popup-button",
|
|
12320
|
+
};
|
|
12321
|
+
|
|
12322
|
+
const basicHTMLContent = (content) => `
|
|
12323
|
+
<!DOCTYPE html>
|
|
12324
|
+
<html lang="en">
|
|
12325
|
+
<head>
|
|
12326
|
+
<meta charset="UTF-8" />
|
|
12327
|
+
<meta name="viewport" content="width=device-width" />
|
|
12328
|
+
</head>
|
|
12329
|
+
<body>
|
|
12330
|
+
${content}
|
|
12331
|
+
</body>
|
|
12332
|
+
</html>`;
|
|
12333
|
+
const hexToRGB = (hex) => {
|
|
12334
|
+
let r = "", g = "", b = "";
|
|
12335
|
+
if (hex.length === 4) {
|
|
12336
|
+
r = `0x${hex[1]}${hex[1]}`;
|
|
12337
|
+
g = `0x${hex[2]}${hex[2]}`;
|
|
12338
|
+
b = `0x${hex[3]}${hex[3]}`;
|
|
12339
|
+
}
|
|
12340
|
+
else if (hex.length === 7) {
|
|
12341
|
+
r = `0x${hex[1]}${hex[2]}`;
|
|
12342
|
+
g = `0x${hex[3]}${hex[4]}`;
|
|
12343
|
+
b = `0x${hex[5]}${hex[6]}`;
|
|
12344
|
+
}
|
|
12345
|
+
return `rgb(${Number(r)}, ${Number(g)}, ${Number(b)})`;
|
|
12346
|
+
};
|
|
12347
|
+
|
|
12348
|
+
class EmbedBase {
|
|
12349
|
+
constructor({ context, page, neetoPlaywrightUtilities, appName, }) {
|
|
12350
|
+
this.initializeEmbedPage = async ({ embedType, embedCode, customElementText = "Click here", }) => {
|
|
12351
|
+
this.embedTestPage = await this.context.newPage();
|
|
12352
|
+
this.embedTestPageType = embedType;
|
|
12353
|
+
const fileContent = basicHTMLContent(this.embedTestPageType === "elementClick"
|
|
12354
|
+
? `${embedCode}<a href='#' id='open-popup-button'>${customElementText}</a>`
|
|
12355
|
+
: embedCode);
|
|
12356
|
+
this.filePath = `tmp/${faker.faker.word.noun()}.html`;
|
|
12357
|
+
fs$d.writeFileSync(this.filePath, fileContent, "utf8");
|
|
12358
|
+
await this.embedTestPage.goto(`file://${Path__default["default"].resolve(this.filePath)}`);
|
|
12359
|
+
await this.embedTestPage.waitForLoadState("load");
|
|
12360
|
+
this.embeddedFrame = this.embedTestPage.frameLocator(this.embedTestPageType === "inline"
|
|
12361
|
+
? "iframe"
|
|
12362
|
+
: EMBED_SELECTORS.iframe(this.appName));
|
|
12363
|
+
return this.embedTestPage;
|
|
12364
|
+
};
|
|
12365
|
+
this.closeEmbedModalAndPage = async () => {
|
|
12366
|
+
if (this.embedTestPageType !== "inline") {
|
|
12367
|
+
await this.embedTestPage
|
|
12368
|
+
.locator(EMBED_SELECTORS.close(this.appName))
|
|
12369
|
+
.click();
|
|
12370
|
+
await test$1.expect(this.embedTestPage.locator(EMBED_SELECTORS.modal(this.appName))).toBeHidden();
|
|
12371
|
+
}
|
|
12372
|
+
await this.embedTestPage.close();
|
|
12373
|
+
await this.context.close();
|
|
12374
|
+
fs$d.unlinkSync(this.filePath);
|
|
12375
|
+
};
|
|
12376
|
+
this.clickOnPopupButton = async (popUpButtonSelectorOptions) => {
|
|
12377
|
+
const popUpButton = this.embedTestPage.getByRole(this.embedTestPageType === "floatingPopup" ? "button" : "link", popUpButtonSelectorOptions);
|
|
12378
|
+
await test$1.expect(popUpButton).toBeVisible();
|
|
12379
|
+
await popUpButton.click();
|
|
12380
|
+
await test$1.expect(this.embedTestPage.locator(EMBED_SELECTORS.loader(this.appName))).toBeHidden({
|
|
12381
|
+
timeout: 10000,
|
|
12382
|
+
});
|
|
12383
|
+
};
|
|
12384
|
+
this.copyEmbedScript = async ({ embedLabel }) => {
|
|
12385
|
+
await this.page
|
|
12386
|
+
.getByTestId(COMMON_SELECTORS.radioLabel(embedLabel))
|
|
12387
|
+
.check();
|
|
12388
|
+
await this.page.getByTestId(COMMON_SELECTORS.copyButton).click();
|
|
12389
|
+
return await this.page.evaluate(() => navigator.clipboard.readText());
|
|
12390
|
+
};
|
|
12391
|
+
this.selectEmbedType = async (embedLabel) => {
|
|
12392
|
+
await this.page.getByTestId(EMBED_SELECTORS.htmlTab).click();
|
|
12393
|
+
await this.page
|
|
12394
|
+
.getByTestId(COMMON_SELECTORS.radioLabel(embedLabel))
|
|
12395
|
+
.check();
|
|
12396
|
+
};
|
|
12397
|
+
this.verifyInlineCustomization = async ({ headingTestId, inlineEmbedInterceptParams, customizationOptions, }) => {
|
|
12398
|
+
const embedHeightPercentage = `${customizationOptions.embedHeight}%`;
|
|
12399
|
+
const embedWidthPercentage = `${customizationOptions.embedWidth}%`;
|
|
12400
|
+
await this.page
|
|
12401
|
+
.getByTestId(EMBED_SELECTORS.inlineHeightInput)
|
|
12402
|
+
.fill(customizationOptions.embedHeight);
|
|
12403
|
+
await this.page
|
|
12404
|
+
.getByTestId(EMBED_SELECTORS.inlineWidthInput)
|
|
12405
|
+
.fill(customizationOptions.embedWidth);
|
|
12406
|
+
await this.page
|
|
12407
|
+
.getByTestId(EMBED_SELECTORS.inlineElementIdInput)
|
|
12408
|
+
.fill(customizationOptions.embedDivContainerId);
|
|
12409
|
+
await this.expectMultipleTextsInCodeblock([
|
|
12410
|
+
RegExp(`<div .* id="${customizationOptions.embedDivContainerId}">`),
|
|
12411
|
+
`elementSelector: "#${customizationOptions.embedDivContainerId}"`,
|
|
12412
|
+
`height: "${embedHeightPercentage}"`,
|
|
12413
|
+
`width: "${embedWidthPercentage}"`,
|
|
12414
|
+
]);
|
|
12415
|
+
const inlineEmbedPromise = this.neetoPlaywrightUtilities.interceptMultipleResponses(inlineEmbedInterceptParams);
|
|
12416
|
+
await this.previewTab.click();
|
|
12417
|
+
await inlineEmbedPromise;
|
|
12418
|
+
const iframe = this.page.locator("iframe");
|
|
12419
|
+
await iframe.waitFor({ state: "visible" });
|
|
12420
|
+
await test$1.expect(this.page.frameLocator("iframe").getByTestId(headingTestId)).toBeVisible({ timeout: 10000 });
|
|
12421
|
+
const iframeHeight = await iframe.evaluate(node => node.getAttribute("height"));
|
|
12422
|
+
const iframeWidth = await iframe.evaluate(node => node.getAttribute("width"));
|
|
12423
|
+
test$1.expect(iframeHeight).toStrictEqual(embedHeightPercentage);
|
|
12424
|
+
test$1.expect(iframeWidth).toStrictEqual(embedWidthPercentage);
|
|
12425
|
+
};
|
|
12426
|
+
this.verifyFloatingPopupCustomization = async (customizationOptions) => {
|
|
12427
|
+
await this.page
|
|
12428
|
+
.getByTestId(EMBED_SELECTORS.buttonTextInput)
|
|
12429
|
+
.fill(customizationOptions.buttonText);
|
|
12430
|
+
await this.page
|
|
12431
|
+
.getByTestId(EMBED_SELECTORS.buttonPositionSelectContainer)
|
|
12432
|
+
.click();
|
|
12433
|
+
await this.page
|
|
12434
|
+
.getByTestId(EMBED_SELECTORS.buttonPositionSelectMenu)
|
|
12435
|
+
.getByText(customizationOptions.buttonPosition)
|
|
12436
|
+
.click();
|
|
12437
|
+
await test$1.expect(this.page.getByTestId(EMBED_SELECTORS.buttonPositionSelectContainer)).toContainText(customizationOptions.buttonPosition);
|
|
12438
|
+
const buttonColorLabel = this.page.getByTestId(EMBED_SELECTORS.buttonColorLabel);
|
|
12439
|
+
await buttonColorLabel
|
|
12440
|
+
.getByTestId(EMBED_SELECTORS.colorPickerTarget)
|
|
12441
|
+
.click();
|
|
12442
|
+
await this.page
|
|
12443
|
+
.getByTestId(EMBED_SELECTORS.colorpickerEditableInput)
|
|
12444
|
+
.getByRole("textbox")
|
|
12445
|
+
.fill(customizationOptions.buttonColorHex);
|
|
12446
|
+
const buttonTextColorLabel = this.page.getByTestId(EMBED_SELECTORS.buttonTextColorLabel);
|
|
12447
|
+
// This additional click is to close the previously opened color picker for buttonColor.
|
|
12448
|
+
await buttonTextColorLabel
|
|
12449
|
+
.getByTestId(EMBED_SELECTORS.colorPickerTarget)
|
|
12450
|
+
.click();
|
|
12451
|
+
await buttonTextColorLabel
|
|
12452
|
+
.getByTestId(EMBED_SELECTORS.colorPickerTarget)
|
|
12453
|
+
.click();
|
|
12454
|
+
await this.page
|
|
12455
|
+
.getByTestId(EMBED_SELECTORS.colorpickerEditableInput)
|
|
12456
|
+
.getByRole("textbox")
|
|
12457
|
+
.fill(customizationOptions.buttonTextColorHex);
|
|
12458
|
+
await this.page.getByTestId(EMBED_SELECTORS.showIconCheckbox).click();
|
|
12459
|
+
await this.expectMultipleTextsInCodeblock([
|
|
12460
|
+
`btnColor: "${customizationOptions.buttonColorHex}"`,
|
|
12461
|
+
`btnTextColor: "${customizationOptions.buttonTextColorHex}"`,
|
|
12462
|
+
`btnPosition: "${toCamelCase(customizationOptions.buttonPosition)}"`,
|
|
12463
|
+
`btnText: "${customizationOptions.buttonText}"`,
|
|
12464
|
+
"showIcon: false",
|
|
12465
|
+
]);
|
|
12466
|
+
await this.previewTab.click();
|
|
12467
|
+
const floatingButton = this.page.getByRole("button", {
|
|
12468
|
+
name: customizationOptions.buttonText,
|
|
12469
|
+
});
|
|
12470
|
+
await test$1.expect(floatingButton).toHaveCSS("color", hexToRGB(customizationOptions.buttonTextColorHex));
|
|
12471
|
+
await test$1.expect(floatingButton).toHaveCSS("background-color", hexToRGB(customizationOptions.buttonColorHex));
|
|
12472
|
+
const classRegExp = customizationOptions.buttonPosition
|
|
12473
|
+
.toLocaleLowerCase()
|
|
12474
|
+
.replace(" ", ".*");
|
|
12475
|
+
await test$1.expect(floatingButton).toHaveClass(RegExp(classRegExp));
|
|
12476
|
+
await test$1.expect(floatingButton.locator("svg")).toBeHidden();
|
|
12477
|
+
};
|
|
12478
|
+
this.verifyElementClickCustomization = async (customizationOptions) => {
|
|
12479
|
+
await this.page
|
|
12480
|
+
.getByTestId(EMBED_SELECTORS.elementIdInput)
|
|
12481
|
+
.fill(customizationOptions.customId);
|
|
12482
|
+
await test$1.expect(this.codeBlock).toContainText(`elementSelector: "#${customizationOptions.customId}"`);
|
|
12483
|
+
await this.previewTab.click();
|
|
12484
|
+
await test$1.expect(this.page.getByTestId(EMBED_SELECTORS.previewElementPopupButton)).toBeVisible();
|
|
12485
|
+
await test$1.expect(this.page.locator(`#${customizationOptions.customId}`)).toBeVisible();
|
|
12486
|
+
};
|
|
12487
|
+
this.expectMultipleTextsInCodeblock = async (containTextOptions) => {
|
|
12488
|
+
const codeBlock = this.page.getByTestId(EMBED_SELECTORS.codeBlock);
|
|
12489
|
+
for (const containTextOption of containTextOptions) {
|
|
12490
|
+
await test$1.expect(codeBlock).toContainText(containTextOption);
|
|
12491
|
+
}
|
|
12492
|
+
};
|
|
12493
|
+
this.context = context;
|
|
12494
|
+
this.page = page;
|
|
12495
|
+
this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
|
|
12496
|
+
this.appName = appName;
|
|
12497
|
+
this.t = playwrightI18nextFixture.getI18nInstance().t;
|
|
12498
|
+
this.codeBlock = this.page.getByTestId(EMBED_SELECTORS.codeBlock);
|
|
12499
|
+
this.previewTab = this.page.getByTestId(EMBED_SELECTORS.previewTab);
|
|
12500
|
+
}
|
|
12501
|
+
}
|
|
12502
|
+
|
|
12296
12503
|
const BASE_URL = "/api/v1";
|
|
12297
12504
|
const NEETO_AUTH_BASE_URL = (subdomain = "app") => `https://${subdomain}.neetoauth.net`;
|
|
12298
12505
|
const ROUTES = {
|
|
@@ -146687,6 +146894,7 @@ exports.COMMON_SELECTORS = COMMON_SELECTORS;
|
|
|
146687
146894
|
exports.CREDENTIALS = CREDENTIALS;
|
|
146688
146895
|
exports.CustomCommands = CustomCommands;
|
|
146689
146896
|
exports.ENVIRONMENT = ENVIRONMENT;
|
|
146897
|
+
exports.EmbedBase = EmbedBase;
|
|
146690
146898
|
exports.GLOBAL_TRANSLATIONS_PATTERN = GLOBAL_TRANSLATIONS_PATTERN;
|
|
146691
146899
|
exports.HELP_CENTER_SELECTORS = HELP_CENTER_SELECTORS;
|
|
146692
146900
|
exports.HelpAndProfilePage = HelpAndProfilePage;
|
|
@@ -146748,6 +146956,7 @@ exports.skipTest = skipTest;
|
|
|
146748
146956
|
exports.squish = squish;
|
|
146749
146957
|
exports.stealthTest = stealth;
|
|
146750
146958
|
exports.tableUtils = tableUtils;
|
|
146959
|
+
exports.toCamelCase = toCamelCase;
|
|
146751
146960
|
exports.updateCredentials = updateCredentials;
|
|
146752
146961
|
exports.writeDataToFile = writeDataToFile;
|
|
146753
146962
|
//# sourceMappingURL=index.cjs.js.map
|