@bigbinary/neeto-playwright-commons 4.11.13 → 4.11.14-beta1
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 +16 -0
- package/index.js +155 -110
- package/package.json +2 -2
- package/scripts/neeto-auth/setup.sh +0 -0
package/index.d.ts
CHANGED
|
@@ -4158,6 +4158,19 @@ declare class EditorPage {
|
|
|
4158
4158
|
highlighterCount: number;
|
|
4159
4159
|
constructor(page: Page, neetoPlaywrightUtilities: CustomCommands, editorWrapper?: Locator | Page);
|
|
4160
4160
|
private cleanString;
|
|
4161
|
+
private toolbarOption;
|
|
4162
|
+
private clickToolbarOption;
|
|
4163
|
+
private dismissToolbarMenu;
|
|
4164
|
+
/**
|
|
4165
|
+
*
|
|
4166
|
+
* Method to move the cursor to bottom of a custom text editor. Before calling this method, please make sure the input field is focused.
|
|
4167
|
+
*
|
|
4168
|
+
* @example
|
|
4169
|
+
*
|
|
4170
|
+
* await neetoPlaywrightUtilities.moveCursorAtBottom();
|
|
4171
|
+
* @endexample
|
|
4172
|
+
*/
|
|
4173
|
+
private moveCursorAtBottom;
|
|
4161
4174
|
private fixedMenuOptions;
|
|
4162
4175
|
private moreMenuOptions;
|
|
4163
4176
|
private verifyFontSize;
|
|
@@ -8072,6 +8085,7 @@ declare const fixedMenuSelector: (selector: string) => string;
|
|
|
8072
8085
|
*/
|
|
8073
8086
|
declare const NEETO_EDITOR_SELECTORS: {
|
|
8074
8087
|
fontSize: string;
|
|
8088
|
+
fontSizeHeadingOptions: RegExp;
|
|
8075
8089
|
boldOption: string;
|
|
8076
8090
|
italicOption: string;
|
|
8077
8091
|
underlineOption: string;
|
|
@@ -8101,6 +8115,7 @@ declare const NEETO_EDITOR_SELECTORS: {
|
|
|
8101
8115
|
cannedResponseOption: string;
|
|
8102
8116
|
cannedResponseSelectContainer: string;
|
|
8103
8117
|
fixedMenuWrapper: string;
|
|
8118
|
+
moreMenuOption: string;
|
|
8104
8119
|
linkOption: string;
|
|
8105
8120
|
addLinkUrlInput: string;
|
|
8106
8121
|
addLinkDoneButton: string;
|
|
@@ -8135,6 +8150,7 @@ declare const NEETO_EDITOR_SELECTORS: {
|
|
|
8135
8150
|
dataEmojiType: (type: string) => string;
|
|
8136
8151
|
calloutContent: string;
|
|
8137
8152
|
calloutTypeOption: string;
|
|
8153
|
+
calloutTypeOptionV2: string;
|
|
8138
8154
|
editorMediaUploaderTab: string;
|
|
8139
8155
|
dynamicVariableSelector: (variable: string) => string;
|
|
8140
8156
|
dynamicVariableList: (variable: string) => string;
|
package/index.js
CHANGED
|
@@ -2409,8 +2409,8 @@ const imageRegex = (imageName) => {
|
|
|
2409
2409
|
};
|
|
2410
2410
|
const minutesAgo = (minutes) => new Date(Date.now() - minutes * 60 * 1000);
|
|
2411
2411
|
const exampleEmail = () => faker.internet.exampleEmail({
|
|
2412
|
-
firstName: faker.
|
|
2413
|
-
lastName: faker.
|
|
2412
|
+
firstName: faker.string.alpha(1),
|
|
2413
|
+
lastName: faker.string.alpha(1),
|
|
2414
2414
|
allowSpecialCharacters: false,
|
|
2415
2415
|
});
|
|
2416
2416
|
|
|
@@ -2418,6 +2418,7 @@ const optionSelector = (option) => `neeto-editor-fixed-menu-${option}-option`;
|
|
|
2418
2418
|
const fixedMenuSelector = (selector) => `neeto-editor-fixed-menu-${selector}`;
|
|
2419
2419
|
const NEETO_EDITOR_SELECTORS = {
|
|
2420
2420
|
fontSize: optionSelector("font-size"),
|
|
2421
|
+
fontSizeHeadingOptions: new RegExp(`^${optionSelector("font-size")}-h[1-5]$`),
|
|
2421
2422
|
boldOption: optionSelector("bold"),
|
|
2422
2423
|
italicOption: optionSelector("italic"),
|
|
2423
2424
|
underlineOption: optionSelector("underline"),
|
|
@@ -2447,6 +2448,7 @@ const NEETO_EDITOR_SELECTORS = {
|
|
|
2447
2448
|
cannedResponseOption: optionSelector("canned-responses"),
|
|
2448
2449
|
cannedResponseSelectContainer: "select-a-canned-response-select-container",
|
|
2449
2450
|
fixedMenuWrapper: fixedMenuSelector("wrapper"),
|
|
2451
|
+
moreMenuOption: optionSelector("more"),
|
|
2450
2452
|
linkOption: optionSelector("link"),
|
|
2451
2453
|
addLinkUrlInput: "neeto-editor-add-link-url-input",
|
|
2452
2454
|
addLinkDoneButton: "neeto-editor-add-link",
|
|
@@ -2483,6 +2485,7 @@ const NEETO_EDITOR_SELECTORS = {
|
|
|
2483
2485
|
calloutContent: ".callout-content",
|
|
2484
2486
|
//Use data-testid once https://github.com/neetozone/neeto-editor/issues/1648 is resolved
|
|
2485
2487
|
calloutTypeOption: ".neeto-editor-callout-dropdown__type-option",
|
|
2488
|
+
calloutTypeOptionV2: "callout-type-option",
|
|
2486
2489
|
editorMediaUploaderTab: "neeto-editor-media-uploader-local-tab",
|
|
2487
2490
|
dynamicVariableSelector: (variable) => `dynamic-variables-list-item-${joinHyphenCase(variable)}`,
|
|
2488
2491
|
dynamicVariableList: (variable) => `dynamic-variables-list-${hyphenate(variable)}`,
|
|
@@ -6589,48 +6592,102 @@ class EditorPage {
|
|
|
6589
6592
|
this.editorWrapper = this.page;
|
|
6590
6593
|
if (editorWrapper)
|
|
6591
6594
|
this.editorWrapper = editorWrapper;
|
|
6592
|
-
this.editorLinkButton = this.
|
|
6595
|
+
this.editorLinkButton = this.toolbarOption(NEETO_EDITOR_SELECTORS.linkOption);
|
|
6593
6596
|
this.attachmentPreview = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.attachmentPreview);
|
|
6594
|
-
this.editorAttachmentsButton = this.
|
|
6597
|
+
this.editorAttachmentsButton = this.toolbarOption(NEETO_EDITOR_SELECTORS.editorAttachmentsButton);
|
|
6595
6598
|
this.imageWrapper = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.imageWrapper);
|
|
6596
6599
|
this.uploadDeleteButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadDeleteButton);
|
|
6597
|
-
this.imageUploadOption = this.
|
|
6598
|
-
this.cannedResponseOption = this.
|
|
6599
|
-
this.videoEmbedOption = this.
|
|
6600
|
+
this.imageUploadOption = this.toolbarOption(NEETO_EDITOR_SELECTORS.imageUploadOption);
|
|
6601
|
+
this.cannedResponseOption = this.toolbarOption(NEETO_EDITOR_SELECTORS.cannedResponseOption);
|
|
6602
|
+
this.videoEmbedOption = this.toolbarOption(NEETO_EDITOR_SELECTORS.videoEmbedOption);
|
|
6600
6603
|
this.videoEmbedInput = this.page.getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedInput);
|
|
6601
6604
|
this.videoWrapperSelector = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.videoWrapper);
|
|
6602
|
-
this.emojiSelector = this.
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6605
|
+
this.emojiSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.emojiOption);
|
|
6606
|
+
const fixedMenuWrapper = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.fixedMenuWrapper);
|
|
6607
|
+
const fixedMenuButtons = fixedMenuWrapper.getByRole("button");
|
|
6608
|
+
const legacyMoreIcon = this.page.getByTestId(COMMON_SELECTORS.dropdownIcon);
|
|
6609
|
+
this.moreMenuSelector = IS_SHADCN_UI
|
|
6610
|
+
? fixedMenuWrapper.getByTestId(NEETO_EDITOR_SELECTORS.moreMenuOption)
|
|
6611
|
+
: fixedMenuButtons
|
|
6612
|
+
.and(legacyMoreIcon)
|
|
6613
|
+
.or(fixedMenuButtons.filter({ has: legacyMoreIcon }));
|
|
6606
6614
|
this.contentField = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.contentField);
|
|
6607
6615
|
this.dynamicVariablesButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.dynamicVariablesButton);
|
|
6608
|
-
this.calloutSelector = this.
|
|
6609
|
-
this.undoSelector = this.
|
|
6610
|
-
this.redoSelector = this.
|
|
6611
|
-
this.tableOption = this.
|
|
6612
|
-
this.videoUploadOption = this.
|
|
6613
|
-
this.todoListSelector = this.
|
|
6614
|
-
this.textColorSelector = this.
|
|
6616
|
+
this.calloutSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.calloutOption);
|
|
6617
|
+
this.undoSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.undoOption);
|
|
6618
|
+
this.redoSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.redoOption);
|
|
6619
|
+
this.tableOption = this.toolbarOption(NEETO_EDITOR_SELECTORS.tableOption);
|
|
6620
|
+
this.videoUploadOption = this.toolbarOption(NEETO_EDITOR_SELECTORS.videoUploadOption);
|
|
6621
|
+
this.todoListSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.todoListOption);
|
|
6622
|
+
this.textColorSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.textColorOption);
|
|
6615
6623
|
}
|
|
6616
6624
|
cleanString = (selector = "") => selector?.replace("neeto-editor-fixed-menu-", "").replace("-option", "") ||
|
|
6617
6625
|
"";
|
|
6626
|
+
// An overflow option is rendered in a menu outside the editor wrapper.
|
|
6627
|
+
toolbarOption = (testId) => this.editorWrapper
|
|
6628
|
+
.getByTestId(testId)
|
|
6629
|
+
.or(this.page
|
|
6630
|
+
.getByTestId(COMMON_SELECTORS.dropdownContainer)
|
|
6631
|
+
.getByTestId(testId));
|
|
6632
|
+
clickToolbarOption = async (option, isButtonInMoreMenu) => {
|
|
6633
|
+
if (isButtonInMoreMenu) {
|
|
6634
|
+
const expanded = await this.moreMenuSelector.getAttribute("aria-expanded");
|
|
6635
|
+
const isMenuOpen = expanded === null ? await option.isVisible() : expanded === "true";
|
|
6636
|
+
if (!isMenuOpen) {
|
|
6637
|
+
// Reopening a menu that is still closing leaves it closed.
|
|
6638
|
+
await expect(option).toBeHidden();
|
|
6639
|
+
await this.moreMenuSelector.click();
|
|
6640
|
+
}
|
|
6641
|
+
}
|
|
6642
|
+
await option.click();
|
|
6643
|
+
};
|
|
6644
|
+
dismissToolbarMenu = async () => {
|
|
6645
|
+
const dropdownContainer = this.page.getByTestId(COMMON_SELECTORS.dropdownContainer);
|
|
6646
|
+
const expandedMenuTrigger = this.editorWrapper
|
|
6647
|
+
.getByTestId(NEETO_EDITOR_SELECTORS.fixedMenuWrapper)
|
|
6648
|
+
.getByRole("button", { expanded: true });
|
|
6649
|
+
// A menu that is already closing stays visible for a moment and can drop
|
|
6650
|
+
// its trigger mid-click, so retry until it is gone.
|
|
6651
|
+
await expect(async () => {
|
|
6652
|
+
if (!(await dropdownContainer.isVisible()))
|
|
6653
|
+
return;
|
|
6654
|
+
if (await expandedMenuTrigger.isVisible()) {
|
|
6655
|
+
await expandedMenuTrigger.click({ timeout: 1_000 });
|
|
6656
|
+
}
|
|
6657
|
+
else if (!IS_SHADCN_UI) {
|
|
6658
|
+
await this.contentField.click();
|
|
6659
|
+
}
|
|
6660
|
+
await expect(dropdownContainer).toBeHidden({ timeout: 1_000 });
|
|
6661
|
+
}).toPass({ timeout: 10_000 });
|
|
6662
|
+
};
|
|
6663
|
+
// A toolbar menu takes focus from the editor and can keep it while closing,
|
|
6664
|
+
// so the keys that move the caret would otherwise miss the editor.
|
|
6665
|
+
moveCursorAtBottom = async () => {
|
|
6666
|
+
await this.dismissToolbarMenu();
|
|
6667
|
+
await this.contentField.focus();
|
|
6668
|
+
await expect(this.contentField).toBeFocused();
|
|
6669
|
+
await this.neetoPlaywrightUtilities.moveCursorAtBottom();
|
|
6670
|
+
};
|
|
6618
6671
|
fixedMenuOptions = async () => {
|
|
6619
6672
|
const fixedMenuButtons = await this.editorWrapper
|
|
6620
6673
|
.getByTestId(NEETO_EDITOR_SELECTORS.fixedMenuWrapper)
|
|
6621
6674
|
.getByRole("button")
|
|
6675
|
+
.filter({ hasNot: this.page.getByTestId(COMMON_SELECTORS.dropdownIcon) })
|
|
6622
6676
|
.all();
|
|
6623
|
-
|
|
6624
|
-
return Promise.all(fixedMenuButtons.map(async (button) => {
|
|
6677
|
+
const options = await Promise.all(fixedMenuButtons.map(async (button) => {
|
|
6625
6678
|
const dataTestid = await button.getAttribute("data-testid");
|
|
6626
6679
|
return this.cleanString(dataTestid);
|
|
6627
6680
|
}));
|
|
6681
|
+
return options.filter(option => option !== "more" && option !== COMMON_SELECTORS.dropdownIcon);
|
|
6628
6682
|
};
|
|
6629
6683
|
moreMenuOptions = async () => {
|
|
6630
6684
|
await this.moreMenuSelector.click();
|
|
6631
6685
|
const dropdownContainer = this.page.getByTestId(COMMON_SELECTORS.dropdownContainer);
|
|
6632
|
-
|
|
6633
|
-
const
|
|
6686
|
+
await expect(dropdownContainer).toBeVisible();
|
|
6687
|
+
const moreMenuButtons = await dropdownContainer
|
|
6688
|
+
.getByRole(IS_SHADCN_UI ? "menuitem" : "button")
|
|
6689
|
+
.all();
|
|
6690
|
+
const moreMenuButtonLocators = await Promise.all(moreMenuButtons.map(async (button) => {
|
|
6634
6691
|
const dataTestid = await button.getAttribute("data-testid");
|
|
6635
6692
|
return this.cleanString(dataTestid);
|
|
6636
6693
|
}));
|
|
@@ -6638,29 +6695,28 @@ class EditorPage {
|
|
|
6638
6695
|
await expect(dropdownContainer).toBeHidden();
|
|
6639
6696
|
return moreMenuButtonLocators;
|
|
6640
6697
|
};
|
|
6641
|
-
verifyFontSize = async () => IS_SHADCN_UI
|
|
6642
|
-
|
|
6698
|
+
verifyFontSize = async (isButtonInMoreMenu = false) => IS_SHADCN_UI
|
|
6699
|
+
? this.verifyFontSizeV2(isButtonInMoreMenu)
|
|
6700
|
+
: this.verifyFontSizeV1(isButtonInMoreMenu);
|
|
6701
|
+
verifyFontSizeV1 = async (isButtonInMoreMenu) => {
|
|
6643
6702
|
const fontsAndTexts = [];
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
.click();
|
|
6703
|
+
const fontSizeDropdown = this.page.getByTestId(NEETO_EDITOR_SELECTORS.fontSize);
|
|
6704
|
+
await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
|
|
6647
6705
|
const headingButtons = await this.page
|
|
6648
|
-
.getByTestId(
|
|
6649
|
-
.getByRole("button")
|
|
6706
|
+
.getByTestId(NEETO_EDITOR_SELECTORS.fontSizeHeadingOptions)
|
|
6707
|
+
.and(this.page.getByRole("button"))
|
|
6650
6708
|
.all();
|
|
6651
6709
|
const headingLevels = (await Promise.all(headingButtons.map(async (button) => {
|
|
6652
6710
|
const dataTestid = await button.getAttribute("data-testid");
|
|
6653
6711
|
const headingLevel = dataTestid?.split("-").pop();
|
|
6654
6712
|
return /^h[1-5]$/.test(headingLevel || "") ? headingLevel : null;
|
|
6655
6713
|
}))).filter(Boolean);
|
|
6656
|
-
|
|
6714
|
+
await this.dismissToolbarMenu();
|
|
6657
6715
|
for (const headingLevel of headingLevels) {
|
|
6658
6716
|
const fontKey = headingLevel;
|
|
6659
6717
|
const randomText = await this.fillRandomText();
|
|
6660
|
-
await
|
|
6661
|
-
await this.
|
|
6662
|
-
.getByTestId(FONT_SIZE_SELECTORS[fontKey])
|
|
6663
|
-
.click();
|
|
6718
|
+
await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
|
|
6719
|
+
await this.page.getByTestId(FONT_SIZE_SELECTORS[fontKey]).click();
|
|
6664
6720
|
await expect(this.contentField.getByRole("heading", {
|
|
6665
6721
|
level: Number(headingLevel?.slice(1)),
|
|
6666
6722
|
name: randomText,
|
|
@@ -6669,28 +6725,25 @@ class EditorPage {
|
|
|
6669
6725
|
}
|
|
6670
6726
|
return fontsAndTexts;
|
|
6671
6727
|
};
|
|
6672
|
-
verifyFontSizeV2 = async () => {
|
|
6728
|
+
verifyFontSizeV2 = async (isButtonInMoreMenu) => {
|
|
6673
6729
|
const fontsAndTexts = [];
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
.getByRole("menuitem")
|
|
6730
|
+
const fontSizeDropdown = this.page.getByTestId(NEETO_EDITOR_SELECTORS.fontSize);
|
|
6731
|
+
await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
|
|
6732
|
+
const headingMenuItems = await this.page
|
|
6733
|
+
.getByTestId(NEETO_EDITOR_SELECTORS.fontSizeHeadingOptions)
|
|
6734
|
+
.and(this.page.getByRole("menuitem"))
|
|
6680
6735
|
.all();
|
|
6681
6736
|
const headingLevels = (await Promise.all(headingMenuItems.map(async (menuItem) => {
|
|
6682
6737
|
const dataTestid = await menuItem.getAttribute("data-testid");
|
|
6683
6738
|
const headingLevel = dataTestid?.split("-").pop();
|
|
6684
6739
|
return /^h[1-5]$/.test(headingLevel || "") ? headingLevel : null;
|
|
6685
6740
|
}))).filter(Boolean);
|
|
6686
|
-
|
|
6687
|
-
await fontSizeDropdown.click();
|
|
6688
|
-
await expect(dropdownContainer).toBeHidden();
|
|
6741
|
+
await this.dismissToolbarMenu();
|
|
6689
6742
|
for (const headingLevel of headingLevels) {
|
|
6690
6743
|
const fontKey = headingLevel;
|
|
6691
6744
|
const randomText = await this.fillRandomText();
|
|
6692
|
-
await
|
|
6693
|
-
await
|
|
6745
|
+
await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
|
|
6746
|
+
await this.page.getByTestId(FONT_SIZE_SELECTORS[fontKey]).click();
|
|
6694
6747
|
await expect(this.contentField.getByRole("heading", {
|
|
6695
6748
|
level: Number(headingLevel?.slice(1)),
|
|
6696
6749
|
name: randomText,
|
|
@@ -6703,39 +6756,34 @@ class EditorPage {
|
|
|
6703
6756
|
const modifierKey = modifier;
|
|
6704
6757
|
const textModifierRole = TEXT_MODIFIER_ROLES[modifierKey];
|
|
6705
6758
|
const randomText = await this.fillRandomText();
|
|
6706
|
-
const textModifierSelector = this.
|
|
6707
|
-
|
|
6708
|
-
await textModifierSelector.click();
|
|
6759
|
+
const textModifierSelector = this.toolbarOption(TEXT_MODIFIER_SELECTORS[modifierKey]);
|
|
6760
|
+
await this.clickToolbarOption(textModifierSelector, isButtonInMoreMenu);
|
|
6709
6761
|
await expect(this.contentField
|
|
6710
6762
|
.getByRole(textModifierRole)
|
|
6711
6763
|
.filter({ hasText: randomText })).toBeVisible();
|
|
6712
|
-
await this.
|
|
6764
|
+
await this.moveCursorAtBottom();
|
|
6713
6765
|
await this.page.keyboard.press("Enter");
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6766
|
+
// The second Enter already leaves a blockquote, so toggling it here would
|
|
6767
|
+
// start a new one and nest everything that follows.
|
|
6768
|
+
if (!["blockquote", "codeBlock"].includes(modifierKey)) {
|
|
6769
|
+
await this.clickToolbarOption(textModifierSelector, isButtonInMoreMenu);
|
|
6717
6770
|
}
|
|
6718
6771
|
return [{ key: modifierKey, value: randomText }];
|
|
6719
6772
|
};
|
|
6720
6773
|
verifyTextDeskModifier = async (modifier, isButtonInMoreMenu) => {
|
|
6721
6774
|
const modifierKey = modifier;
|
|
6722
|
-
const textModifierSelector = this.
|
|
6775
|
+
const textModifierSelector = this.toolbarOption(NEETO_TEXT_MODIFIER_SELECTORS[modifierKey]);
|
|
6723
6776
|
const randomText = await this.fillRandomText();
|
|
6724
|
-
|
|
6725
|
-
await textModifierSelector.click();
|
|
6777
|
+
await this.clickToolbarOption(textModifierSelector, isButtonInMoreMenu);
|
|
6726
6778
|
await expect(this.contentField
|
|
6727
6779
|
.locator(TEXT_MODIFIER_TAGS[modifierKey])
|
|
6728
6780
|
.filter({ hasText: randomText })).toBeVisible();
|
|
6729
|
-
await this.
|
|
6730
|
-
|
|
6731
|
-
await textModifierSelector.click();
|
|
6781
|
+
await this.moveCursorAtBottom();
|
|
6782
|
+
await this.clickToolbarOption(textModifierSelector, isButtonInMoreMenu);
|
|
6732
6783
|
return [{ key: modifierKey, value: randomText }];
|
|
6733
6784
|
};
|
|
6734
6785
|
openHighlighterContainer = (isButtonInMoreMenu) => expect(async () => {
|
|
6735
|
-
|
|
6736
|
-
await this.editorWrapper
|
|
6737
|
-
.getByTestId(NEETO_TEXT_MODIFIER_SELECTORS["highlight"])
|
|
6738
|
-
.click();
|
|
6786
|
+
await this.clickToolbarOption(this.toolbarOption(NEETO_TEXT_MODIFIER_SELECTORS["highlight"]), isButtonInMoreMenu);
|
|
6739
6787
|
await expect(this.page.getByTestId(COMMON_SELECTORS.customDropdownContainer())).toBeVisible({ timeout: 5_000 });
|
|
6740
6788
|
}).toPass({ timeout: 30_000 });
|
|
6741
6789
|
focusText = (textLocator) => expect(async () => {
|
|
@@ -6766,7 +6814,7 @@ class EditorPage {
|
|
|
6766
6814
|
verifyTextHighlighter = async (isButtonInMoreMenu, highlighterCount = this.highlighterCount) => {
|
|
6767
6815
|
const highlightedKeyValuePairs = [];
|
|
6768
6816
|
for (let colorIdx = 1; colorIdx <= highlighterCount; colorIdx++) {
|
|
6769
|
-
await this.
|
|
6817
|
+
await this.moveCursorAtBottom();
|
|
6770
6818
|
const randomText = await this.highlightText(isButtonInMoreMenu, colorIdx);
|
|
6771
6819
|
highlightedKeyValuePairs.push({
|
|
6772
6820
|
key: `highlight-${colorIdx}`,
|
|
@@ -6777,22 +6825,19 @@ class EditorPage {
|
|
|
6777
6825
|
};
|
|
6778
6826
|
verifyListModifiers = async (modifier, isButtonInMoreMenu) => {
|
|
6779
6827
|
const modifierKey = modifier;
|
|
6780
|
-
const listModifierSelector = this.
|
|
6828
|
+
const listModifierSelector = this.toolbarOption(LIST_MODIFIER_SELECTORS[modifierKey]);
|
|
6781
6829
|
const randomText = await this.fillRandomText();
|
|
6782
|
-
|
|
6783
|
-
await listModifierSelector.click();
|
|
6830
|
+
await this.clickToolbarOption(listModifierSelector, isButtonInMoreMenu);
|
|
6784
6831
|
await expect(this.contentField
|
|
6785
6832
|
.locator(LIST_MODIFIER_TAGS[modifierKey])
|
|
6786
6833
|
.filter({ hasText: randomText })).toBeVisible();
|
|
6787
|
-
await this.
|
|
6788
|
-
|
|
6789
|
-
await listModifierSelector.click();
|
|
6834
|
+
await this.moveCursorAtBottom();
|
|
6835
|
+
await this.clickToolbarOption(listModifierSelector, isButtonInMoreMenu);
|
|
6790
6836
|
return [{ key: modifierKey, value: randomText }];
|
|
6791
6837
|
};
|
|
6792
6838
|
verifyEditorLinkButton = async (linkUrl, isButtonInMoreMenu) => {
|
|
6793
6839
|
const randomText = await this.fillRandomText();
|
|
6794
|
-
|
|
6795
|
-
await this.editorLinkButton.click();
|
|
6840
|
+
await this.clickToolbarOption(this.editorLinkButton, isButtonInMoreMenu);
|
|
6796
6841
|
await this.page
|
|
6797
6842
|
.getByTestId(NEETO_EDITOR_SELECTORS.addLinkUrlInput)
|
|
6798
6843
|
.fill(linkUrl);
|
|
@@ -6801,13 +6846,12 @@ class EditorPage {
|
|
|
6801
6846
|
.click();
|
|
6802
6847
|
const linkRole = DESCRIPTION_EDITOR_TEXTS.link;
|
|
6803
6848
|
await expect(this.contentField.getByRole(linkRole)).toBeVisible();
|
|
6804
|
-
await this.
|
|
6849
|
+
await this.moveCursorAtBottom();
|
|
6805
6850
|
return [{ key: "link", value: randomText }];
|
|
6806
6851
|
};
|
|
6807
6852
|
verifyEditorAttachmentsButton = async (filePath, isButtonInMoreMenu, shouldRemoveAttachment = false) => {
|
|
6808
6853
|
const fileUploaderPromise = this.page.waitForEvent("filechooser");
|
|
6809
|
-
|
|
6810
|
-
await this.editorAttachmentsButton.click();
|
|
6854
|
+
await this.clickToolbarOption(this.editorAttachmentsButton, isButtonInMoreMenu);
|
|
6811
6855
|
const fileUploader = await fileUploaderPromise;
|
|
6812
6856
|
const imagePath = path.join(__dirname$3, filePath);
|
|
6813
6857
|
await fileUploader.setFiles(imagePath);
|
|
@@ -6829,8 +6873,7 @@ class EditorPage {
|
|
|
6829
6873
|
return [{ key: "attachments", value: filePath }];
|
|
6830
6874
|
};
|
|
6831
6875
|
verifyImageUploadOption = async ({ filePath, isButtonInMoreMenu, shouldRemoveImage = false, }) => {
|
|
6832
|
-
|
|
6833
|
-
await this.imageUploadOption.click();
|
|
6876
|
+
await this.clickToolbarOption(this.imageUploadOption, isButtonInMoreMenu);
|
|
6834
6877
|
await expect(this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.restrictionMessage)).toBeVisible();
|
|
6835
6878
|
const fileUploaderPromise = this.page.waitForEvent("filechooser");
|
|
6836
6879
|
await this.page
|
|
@@ -6850,8 +6893,7 @@ class EditorPage {
|
|
|
6850
6893
|
return [{ key: "image-upload", value: imagePath }];
|
|
6851
6894
|
};
|
|
6852
6895
|
verifyCannedResponseOption = async (isButtonInMoreMenu, cannedResponseSuccessMessage) => {
|
|
6853
|
-
|
|
6854
|
-
await this.cannedResponseOption.click();
|
|
6896
|
+
await this.clickToolbarOption(this.cannedResponseOption, isButtonInMoreMenu);
|
|
6855
6897
|
await expect(this.page.getByTestId(COMMON_SELECTORS.paneHeader)).toContainText(DESCRIPTION_EDITOR_TEXTS.cannedResponseHeader);
|
|
6856
6898
|
await this.page
|
|
6857
6899
|
.getByTestId(NEETO_EDITOR_SELECTORS.cannedResponseSelectContainer)
|
|
@@ -6868,8 +6910,7 @@ class EditorPage {
|
|
|
6868
6910
|
];
|
|
6869
6911
|
};
|
|
6870
6912
|
verifyVideoEmbedOption = async (videoUrl, isButtonInMoreMenu, shouldRemoveVideo = false) => {
|
|
6871
|
-
|
|
6872
|
-
await this.videoEmbedOption.click();
|
|
6913
|
+
await this.clickToolbarOption(this.videoEmbedOption, isButtonInMoreMenu);
|
|
6873
6914
|
await this.videoEmbedInput.fill(videoUrl);
|
|
6874
6915
|
await this.page
|
|
6875
6916
|
.getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedSubmit)
|
|
@@ -6888,8 +6929,7 @@ class EditorPage {
|
|
|
6888
6929
|
};
|
|
6889
6930
|
verifyEmojiSelector = async (isButtonInMoreMenu) => {
|
|
6890
6931
|
const emoji = "👍";
|
|
6891
|
-
|
|
6892
|
-
await this.emojiSelector.click();
|
|
6932
|
+
await this.clickToolbarOption(this.emojiSelector, isButtonInMoreMenu);
|
|
6893
6933
|
const emojiContainer = this.page.getByTestId(NEETO_EDITOR_SELECTORS.emojiContainer);
|
|
6894
6934
|
await expect(emojiContainer).toBeVisible({ timeout: 10_000 });
|
|
6895
6935
|
await emojiContainer
|
|
@@ -6900,26 +6940,23 @@ class EditorPage {
|
|
|
6900
6940
|
return [{ key: "emoji", value: emoji }];
|
|
6901
6941
|
};
|
|
6902
6942
|
verifyUndoSelector = async (isButtonInMoreMenu) => {
|
|
6903
|
-
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
6904
6943
|
const randomText = await this.fillRandomText();
|
|
6905
6944
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeVisible();
|
|
6906
|
-
await this.undoSelector
|
|
6945
|
+
await this.clickToolbarOption(this.undoSelector, isButtonInMoreMenu);
|
|
6907
6946
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeHidden();
|
|
6908
6947
|
return [{ key: "undo", value: randomText }];
|
|
6909
6948
|
};
|
|
6910
6949
|
verifyRedoSelector = async (isButtonInMoreMenu) => {
|
|
6911
|
-
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
6912
6950
|
const randomText = await this.fillRandomText();
|
|
6913
6951
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeVisible();
|
|
6914
|
-
await this.undoSelector
|
|
6952
|
+
await this.clickToolbarOption(this.undoSelector, isButtonInMoreMenu);
|
|
6915
6953
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeHidden();
|
|
6916
|
-
await this.redoSelector
|
|
6954
|
+
await this.clickToolbarOption(this.redoSelector, isButtonInMoreMenu);
|
|
6917
6955
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeVisible();
|
|
6918
6956
|
return [{ key: "redo", value: randomText }];
|
|
6919
6957
|
};
|
|
6920
6958
|
verifyTableSelector = async (isButtonInMoreMenu) => {
|
|
6921
|
-
|
|
6922
|
-
await this.tableOption.click();
|
|
6959
|
+
await this.clickToolbarOption(this.tableOption, isButtonInMoreMenu);
|
|
6923
6960
|
await this.page
|
|
6924
6961
|
.getByTestId(NEETO_EDITOR_SELECTORS.tableCreateButton)
|
|
6925
6962
|
.click();
|
|
@@ -6937,8 +6974,7 @@ class EditorPage {
|
|
|
6937
6974
|
return [{ key: "table" }];
|
|
6938
6975
|
};
|
|
6939
6976
|
verifyVideoUploadOption = async ({ filePath, isButtonInMoreMenu, shouldRemoveVideo, }) => {
|
|
6940
|
-
|
|
6941
|
-
await this.videoUploadOption.click();
|
|
6977
|
+
await this.clickToolbarOption(this.videoUploadOption, isButtonInMoreMenu);
|
|
6942
6978
|
const fileUploaderPromise = this.page.waitForEvent("filechooser");
|
|
6943
6979
|
await this.page
|
|
6944
6980
|
.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadButton)
|
|
@@ -6962,12 +6998,11 @@ class EditorPage {
|
|
|
6962
6998
|
verifyTodoListSelector = async (isButtonInMoreMenu) => {
|
|
6963
6999
|
const randomText = await this.fillRandomText();
|
|
6964
7000
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeVisible();
|
|
6965
|
-
|
|
6966
|
-
await this.todoListSelector.click();
|
|
7001
|
+
await this.clickToolbarOption(this.todoListSelector, isButtonInMoreMenu);
|
|
6967
7002
|
await expect(this.contentField.locator(NEETO_EDITOR_SELECTORS.todoList, {
|
|
6968
7003
|
hasText: randomText,
|
|
6969
7004
|
})).toBeVisible();
|
|
6970
|
-
await this.
|
|
7005
|
+
await this.moveCursorAtBottom();
|
|
6971
7006
|
return [{ key: "todoList", value: randomText }];
|
|
6972
7007
|
};
|
|
6973
7008
|
verifyDynamicVariables = async (dynamicVariables) => {
|
|
@@ -6986,9 +7021,8 @@ class EditorPage {
|
|
|
6986
7021
|
const colorPickerInput = this.page
|
|
6987
7022
|
.getByTestId(COMMON_SELECTORS.customDropdownContainer())
|
|
6988
7023
|
.getByTestId(COMMON_SELECTORS.inputField);
|
|
6989
|
-
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
6990
7024
|
await expect(async () => {
|
|
6991
|
-
await this.textColorSelector
|
|
7025
|
+
await this.clickToolbarOption(this.textColorSelector, isButtonInMoreMenu);
|
|
6992
7026
|
await expect(colorPickerInput).toBeVisible({ timeout: 5_000 });
|
|
6993
7027
|
await colorPickerInput.fill(EDITOR_VERIFY_TEXT_COLOR);
|
|
6994
7028
|
// Using .first() to target the button rendered by the Formik editor.
|
|
@@ -7004,34 +7038,42 @@ class EditorPage {
|
|
|
7004
7038
|
hasText: randomText,
|
|
7005
7039
|
});
|
|
7006
7040
|
await expect(coloredText).toHaveCSS("color", hexToRGB(EDITOR_VERIFY_TEXT_COLOR));
|
|
7041
|
+
// Otherwise the next option to insert content replaces the selected text.
|
|
7042
|
+
await this.moveCursorAtBottom();
|
|
7007
7043
|
return [{ key: "text-color", value: randomText }];
|
|
7008
7044
|
};
|
|
7009
7045
|
verifyCalloutSelector = async (isButtonInMoreMenu) => {
|
|
7010
|
-
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
7011
7046
|
const calloutTypes = ["default", "info", "warning", "error", "success"];
|
|
7012
7047
|
const calloutContentField = this.contentField.locator(NEETO_EDITOR_SELECTORS.calloutContent);
|
|
7013
|
-
const calloutTypeOption =
|
|
7014
|
-
|
|
7048
|
+
const calloutTypeOption = IS_SHADCN_UI
|
|
7049
|
+
? this.page.getByTestId(NEETO_EDITOR_SELECTORS.calloutTypeOptionV2)
|
|
7050
|
+
: this.page.locator(NEETO_EDITOR_SELECTORS.calloutTypeOption);
|
|
7051
|
+
await this.moveCursorAtBottom();
|
|
7015
7052
|
for (const [index, type] of calloutTypes.entries()) {
|
|
7016
|
-
await this.calloutSelector
|
|
7053
|
+
await this.clickToolbarOption(this.calloutSelector, isButtonInMoreMenu);
|
|
7017
7054
|
const calloutType = calloutTypeOption.filter({ hasText: type });
|
|
7018
7055
|
await expect(calloutType).toBeVisible({ timeout: 10_000 });
|
|
7019
7056
|
await calloutType.click();
|
|
7020
7057
|
await Promise.all([
|
|
7021
|
-
expect(
|
|
7058
|
+
expect(calloutType).toBeHidden(),
|
|
7022
7059
|
expect(this.contentField.locator(NEETO_EDITOR_SELECTORS.dataEmojiType(type))).toBeVisible(),
|
|
7023
7060
|
]);
|
|
7024
7061
|
const randomText = faker.lorem.word(10);
|
|
7025
|
-
|
|
7026
|
-
// The index is important here as it determines which callout content field to interact with
|
|
7062
|
+
// The index identifies the newly inserted callout.
|
|
7027
7063
|
// eslint-disable-next-line playwright/no-nth-methods
|
|
7028
|
-
|
|
7029
|
-
await
|
|
7064
|
+
const currentCalloutContent = calloutContentField.nth(index);
|
|
7065
|
+
await currentCalloutContent.click();
|
|
7066
|
+
await expect(this.contentField).toBeFocused();
|
|
7067
|
+
await this.page.keyboard.type(randomText);
|
|
7068
|
+
await expect(currentCalloutContent).toContainText(randomText);
|
|
7069
|
+
// The editor's ArrowDown command exits a callout at the end of its text.
|
|
7070
|
+
await this.page.keyboard.press("ArrowDown");
|
|
7071
|
+
await this.moveCursorAtBottom();
|
|
7030
7072
|
}
|
|
7031
7073
|
return [{ key: "callout" }];
|
|
7032
7074
|
};
|
|
7033
7075
|
buttonsAndVerifications = {
|
|
7034
|
-
"font-size":
|
|
7076
|
+
"font-size": isButtonInMoreMenu => this.verifyFontSize(isButtonInMoreMenu),
|
|
7035
7077
|
emoji: isButtonInMoreMenu => this.verifyEmojiSelector(isButtonInMoreMenu),
|
|
7036
7078
|
bold: isButtonInMoreMenu => this.verifyTextModifiers("bold", isButtonInMoreMenu),
|
|
7037
7079
|
italic: isButtonInMoreMenu => this.verifyTextModifiers("italic", isButtonInMoreMenu),
|
|
@@ -7068,8 +7110,7 @@ class EditorPage {
|
|
|
7068
7110
|
do {
|
|
7069
7111
|
randomText = faker.lorem.word(10);
|
|
7070
7112
|
} while (this.wordsUsedInEditor.includes(randomText));
|
|
7071
|
-
await this.
|
|
7072
|
-
await this.neetoPlaywrightUtilities.moveCursorAtBottom();
|
|
7113
|
+
await this.moveCursorAtBottom();
|
|
7073
7114
|
await this.page.keyboard.type(randomText);
|
|
7074
7115
|
this.wordsUsedInEditor.push(randomText);
|
|
7075
7116
|
const randomTextLocator = this.contentField.getByText(randomText);
|
|
@@ -7103,7 +7144,11 @@ class EditorPage {
|
|
|
7103
7144
|
})).toBeVisible();
|
|
7104
7145
|
}
|
|
7105
7146
|
if (key === "text-color") {
|
|
7106
|
-
return expect(
|
|
7147
|
+
return expect(
|
|
7148
|
+
// An HTML email styles every ancestor too; the innermost one
|
|
7149
|
+
// carries the colour the text is shown in.
|
|
7150
|
+
// eslint-disable-next-line playwright/no-nth-methods
|
|
7151
|
+
previewLocator.locator("[style]", { hasText: value }).last()).toHaveCSS("color", hexToRGB(EDITOR_VERIFY_TEXT_COLOR));
|
|
7107
7152
|
}
|
|
7108
7153
|
const replacement = elementReplacement?.[key] ?? key;
|
|
7109
7154
|
if (value === undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-playwright-commons",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.14-beta1",
|
|
4
4
|
"description": "A package encapsulating common playwright code across neeto projects.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
|
|
6
6
|
"license": "apache-2.0",
|
|
@@ -106,4 +106,4 @@
|
|
|
106
106
|
"puppeteer-extra-plugin-stealth": "2.11.2"
|
|
107
107
|
},
|
|
108
108
|
"packageManager": "yarn@4.18.1"
|
|
109
|
-
}
|
|
109
|
+
}
|
|
File without changes
|