@bigbinary/neeto-playwright-commons 2.1.4 → 2.1.5
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 +59 -42
- package/index.cjs.js.map +1 -1
- package/index.d.ts +15 -0
- package/index.js +59 -42
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -3510,6 +3510,21 @@ declare class EditorPage {
|
|
|
3510
3510
|
private verifyCalloutSelector;
|
|
3511
3511
|
private buttonsAndVerifications;
|
|
3512
3512
|
private fillRandomText;
|
|
3513
|
+
/**
|
|
3514
|
+
*
|
|
3515
|
+
* Used to assert that rendered preview HTML matches the key–value pairs produced by the editor (for example, the return value of verifyDescriptionEditor). Each pair is checked against previewLocator using the appropriate selector for that formatting type.
|
|
3516
|
+
*
|
|
3517
|
+
* previewLocator (required): A Playwright Locator or Page that wraps the preview output (read-only HTML), not the editable editor surface.
|
|
3518
|
+
*
|
|
3519
|
+
* keyValuePairs (required): An array of { key, value } objects. Supported keys include editor formatting types such as bold, italic, underline, link, strike, bulletList, orderedList, codeBlock, emoji, todoList, image-upload, heading keys, and highlight-<index> for highlighter styles. When value is undefined, the assertion only checks that the corresponding element exists (first match for that tag).
|
|
3520
|
+
*
|
|
3521
|
+
* @example
|
|
3522
|
+
*
|
|
3523
|
+
* const keysAndValues = await editorPage.verifyDescriptionEditor();
|
|
3524
|
+
* await editorPage.verifyDescriptionPreview(previewSection, keysAndValues);
|
|
3525
|
+
* @endexample
|
|
3526
|
+
*/
|
|
3527
|
+
verifyDescriptionPreview: (previewLocator: Locator | Page, keyValuePairs: KeyValuePair[]) => Promise<void[]>;
|
|
3513
3528
|
/**
|
|
3514
3529
|
*
|
|
3515
3530
|
* Used to verify description editor functionality.
|
package/index.js
CHANGED
|
@@ -6246,17 +6246,14 @@ class CustomCommands {
|
|
|
6246
6246
|
await expect(locator).toBeChecked({ checked: shouldBeChecked });
|
|
6247
6247
|
}).toPass({ timeout: 15_000 });
|
|
6248
6248
|
moveCursorAtBottom = async () => {
|
|
6249
|
-
const
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
await this.page.keyboard.press("End");
|
|
6256
|
-
await this.page.keyboard.press("PageDown");
|
|
6257
|
-
}
|
|
6249
|
+
const isMacOS = require$$0$5.platform() === "darwin";
|
|
6250
|
+
const rightArrowKey = isMacOS ? "Meta+ArrowRight" : "End";
|
|
6251
|
+
const downArrowKey = isMacOS ? "Meta+ArrowDown" : "PageDown";
|
|
6252
|
+
await this.page.keyboard.press(rightArrowKey);
|
|
6253
|
+
await this.page.keyboard.press(rightArrowKey);
|
|
6254
|
+
await this.page.keyboard.press(downArrowKey);
|
|
6258
6255
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
|
6259
|
-
await this.page.waitForTimeout(
|
|
6256
|
+
await this.page.waitForTimeout(150); // Adding some delay for DOM to react
|
|
6260
6257
|
await this.page.keyboard.press("Enter");
|
|
6261
6258
|
};
|
|
6262
6259
|
}
|
|
@@ -118856,7 +118853,7 @@ class HelpAndProfilePage {
|
|
|
118856
118853
|
expect(bodyElement).not.toHaveClass(THEMES_TEXTS.lightThemeClass),
|
|
118857
118854
|
]);
|
|
118858
118855
|
await expect(this.page.getByTestId(COMMON_SELECTORS.dropdownContainer).filter({
|
|
118859
|
-
has: this.page.getByTestId(PROFILE_SECTION_SELECTORS.
|
|
118856
|
+
has: this.page.getByTestId(PROFILE_SECTION_SELECTORS.profileExpandMenuBtn),
|
|
118860
118857
|
})).toHaveScreenshot(expectedScreenshot, { maxDiffPixelRatio: 0.1 });
|
|
118861
118858
|
});
|
|
118862
118859
|
};
|
|
@@ -119879,7 +119876,7 @@ class EditorPage {
|
|
|
119879
119876
|
calloutSelector;
|
|
119880
119877
|
videoUploadOption;
|
|
119881
119878
|
todoListSelector;
|
|
119882
|
-
filePath = "../../../e2e/assets/images/
|
|
119879
|
+
filePath = "../../../e2e/assets/images/sample.png";
|
|
119883
119880
|
videoPath = "../../../e2e/assets/files/sample.mp4";
|
|
119884
119881
|
linkUrl = faker.internet.url();
|
|
119885
119882
|
imageUrl = "https://picsum.photos/200/300";
|
|
@@ -119944,10 +119941,9 @@ class EditorPage {
|
|
|
119944
119941
|
};
|
|
119945
119942
|
verifyFontSize = async () => {
|
|
119946
119943
|
const fontsAndTexts = [];
|
|
119947
|
-
|
|
119948
|
-
|
|
119949
|
-
|
|
119950
|
-
await fontSizeDropdownButton.click();
|
|
119944
|
+
await this.page
|
|
119945
|
+
.getByTestId(NEETO_EDITOR_SELECTORS.neetoEditorFixedMenuFontSize)
|
|
119946
|
+
.click();
|
|
119951
119947
|
const headingButtons = await this.page
|
|
119952
119948
|
.getByTestId(COMMON_SELECTORS.dropdownContainer)
|
|
119953
119949
|
.getByRole("button")
|
|
@@ -119969,10 +119965,7 @@ class EditorPage {
|
|
|
119969
119965
|
level: Number(headingLevel?.slice(1)),
|
|
119970
119966
|
name: randomText,
|
|
119971
119967
|
})).toBeVisible();
|
|
119972
|
-
fontsAndTexts.push({
|
|
119973
|
-
key: fontKey,
|
|
119974
|
-
value: randomText,
|
|
119975
|
-
});
|
|
119968
|
+
fontsAndTexts.push({ key: fontKey, value: randomText });
|
|
119976
119969
|
}
|
|
119977
119970
|
return fontsAndTexts;
|
|
119978
119971
|
};
|
|
@@ -120015,18 +120008,13 @@ class EditorPage {
|
|
|
120015
120008
|
.click();
|
|
120016
120009
|
await expect(this.page.getByTestId(COMMON_SELECTORS.customDropdownContainer())).toBeVisible({ timeout: 5_000 });
|
|
120017
120010
|
}).toPass({ timeout: 30_000 });
|
|
120018
|
-
focusText = (textLocator) => {
|
|
120019
|
-
|
|
120020
|
-
|
|
120021
|
-
|
|
120022
|
-
|
|
120023
|
-
|
|
120024
|
-
|
|
120025
|
-
await expect(textLocator.locator("..")).toHaveClass(/has-focus/, {
|
|
120026
|
-
timeout: 5_000,
|
|
120027
|
-
});
|
|
120028
|
-
}).toPass({ timeout: 20_000 });
|
|
120029
|
-
};
|
|
120011
|
+
focusText = (textLocator) => expect(async () => {
|
|
120012
|
+
await textLocator.click();
|
|
120013
|
+
await this.page.keyboard.press(require$$0$5.platform() === "darwin" ? "Meta+ArrowRight" : "End");
|
|
120014
|
+
await expect(textLocator.locator("..")).toHaveClass(/has-focus/, {
|
|
120015
|
+
timeout: 5_000,
|
|
120016
|
+
});
|
|
120017
|
+
}).toPass({ timeout: 20_000 });
|
|
120030
120018
|
highlightText = async (isButtonInMoreMenu, colorIndex) => {
|
|
120031
120019
|
const randomText = await this.fillRandomText();
|
|
120032
120020
|
await this.openHighlighterContainer(isButtonInMoreMenu);
|
|
@@ -120125,9 +120113,7 @@ class EditorPage {
|
|
|
120125
120113
|
.getByTestId(COMMON_SELECTORS.dropdownIcon)
|
|
120126
120114
|
.click();
|
|
120127
120115
|
await this.uploadDeleteButton.click();
|
|
120128
|
-
await expect(this.imageWrapper).toBeHidden({
|
|
120129
|
-
timeout: 15_000,
|
|
120130
|
-
});
|
|
120116
|
+
await expect(this.imageWrapper).toBeHidden({ timeout: 15_000 });
|
|
120131
120117
|
}
|
|
120132
120118
|
return [{ key: "image-upload", value: imagePath }];
|
|
120133
120119
|
};
|
|
@@ -120173,9 +120159,7 @@ class EditorPage {
|
|
|
120173
120159
|
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
120174
120160
|
await this.emojiSelector.click();
|
|
120175
120161
|
const emojiContainer = this.page.getByTestId(NEETO_EDITOR_SELECTORS.emojiContainer);
|
|
120176
|
-
await expect(emojiContainer).toBeVisible({
|
|
120177
|
-
timeout: 10_000,
|
|
120178
|
-
});
|
|
120162
|
+
await expect(emojiContainer).toBeVisible({ timeout: 10_000 });
|
|
120179
120163
|
await emojiContainer
|
|
120180
120164
|
.getByPlaceholder(DESCRIPTION_EDITOR_TEXTS.search)
|
|
120181
120165
|
.fill(EMOJI_LABEL);
|
|
@@ -120239,9 +120223,7 @@ class EditorPage {
|
|
|
120239
120223
|
.getByTestId(COMMON_SELECTORS.dropdownIcon)
|
|
120240
120224
|
.click();
|
|
120241
120225
|
await this.uploadDeleteButton.click();
|
|
120242
|
-
await expect(this.imageWrapper).toBeHidden({
|
|
120243
|
-
timeout: 15_000,
|
|
120244
|
-
});
|
|
120226
|
+
await expect(this.imageWrapper).toBeHidden({ timeout: 15_000 });
|
|
120245
120227
|
}
|
|
120246
120228
|
return [{ key: "video-upload", value: this.videoPath }];
|
|
120247
120229
|
};
|
|
@@ -120334,9 +120316,44 @@ class EditorPage {
|
|
|
120334
120316
|
this.wordsUsedInEditor.push(randomText);
|
|
120335
120317
|
const randomTextLocator = this.contentField.getByText(randomText);
|
|
120336
120318
|
await randomTextLocator.scrollIntoViewIfNeeded();
|
|
120337
|
-
await randomTextLocator.
|
|
120319
|
+
const box = await randomTextLocator.boundingBox();
|
|
120320
|
+
await randomTextLocator.click({
|
|
120321
|
+
clickCount: 3,
|
|
120322
|
+
...(box && { position: { x: box.width * 0.99, y: box.height / 2 } }),
|
|
120323
|
+
});
|
|
120338
120324
|
return randomText;
|
|
120339
120325
|
};
|
|
120326
|
+
verifyDescriptionPreview = (previewLocator, keyValuePairs) => Promise.all(keyValuePairs.flatMap(({ key, value }) => {
|
|
120327
|
+
const elementReplacement = {
|
|
120328
|
+
bold: "strong",
|
|
120329
|
+
italic: "em",
|
|
120330
|
+
underline: "u",
|
|
120331
|
+
link: "a",
|
|
120332
|
+
strike: "s",
|
|
120333
|
+
bulletList: "ul li",
|
|
120334
|
+
orderedList: "ol li",
|
|
120335
|
+
codeBlock: "pre",
|
|
120336
|
+
emoji: "span",
|
|
120337
|
+
};
|
|
120338
|
+
if (key.includes("highlight")) {
|
|
120339
|
+
const highlightIndex = key.split("-")[1];
|
|
120340
|
+
return expect(previewLocator.locator(`span[style*="background-color: var(${NEETO_EDITOR_SELECTORS.highlightBg(Number(highlightIndex))})"][style*="color: var(${NEETO_EDITOR_SELECTORS.highlightText(Number(highlightIndex))})"]`, { hasText: value })).toBeVisible();
|
|
120341
|
+
}
|
|
120342
|
+
if (key === "todoList") {
|
|
120343
|
+
return expect(previewLocator.locator(NEETO_EDITOR_SELECTORS.todoList, {
|
|
120344
|
+
hasText: value,
|
|
120345
|
+
})).toBeVisible();
|
|
120346
|
+
}
|
|
120347
|
+
const replacement = elementReplacement?.[key] ?? key;
|
|
120348
|
+
if (value === undefined) {
|
|
120349
|
+
return expect(
|
|
120350
|
+
// eslint-disable-next-line playwright/no-nth-methods
|
|
120351
|
+
previewLocator.locator(replacement).first()).toBeVisible();
|
|
120352
|
+
}
|
|
120353
|
+
return expect(previewLocator.locator(key === "image-upload"
|
|
120354
|
+
? `img[src*="sample"]`
|
|
120355
|
+
: `${replacement}:has-text("${value}")`)).toBeVisible();
|
|
120356
|
+
}));
|
|
120340
120357
|
verifyDescriptionEditor = async ({ dynamicVariables, linkUrl, videoPath, filePath, imageUrl, videoUrl, highlighterCount, cannedResponseSuccessMessage, } = {}) => {
|
|
120341
120358
|
this.linkUrl = linkUrl || this.linkUrl;
|
|
120342
120359
|
this.filePath = filePath || this.filePath;
|