@bigbinary/neeto-playwright-commons 4.11.12 → 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 +181 -117
- 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)}`,
|
|
@@ -6220,6 +6223,8 @@ class ZapierPage extends IntegrationBase {
|
|
|
6220
6223
|
};
|
|
6221
6224
|
}
|
|
6222
6225
|
|
|
6226
|
+
const MEMBER_PAGE_SIZE = 200;
|
|
6227
|
+
const NAME_SYNC_WAIT = 5_000;
|
|
6223
6228
|
class Member {
|
|
6224
6229
|
memberApis;
|
|
6225
6230
|
constructor(neetoPlaywrightUtilities) {
|
|
@@ -6255,19 +6260,36 @@ class Member {
|
|
|
6255
6260
|
.toBe(true);
|
|
6256
6261
|
};
|
|
6257
6262
|
editMemberViaRequest = async ({ email, newEmail, firstName, lastName, newRole, subscriptionPlan, }) => {
|
|
6258
|
-
const
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6263
|
+
const findMember = async (isRequestedMember) => {
|
|
6264
|
+
for (let page = 1;; page++) {
|
|
6265
|
+
const { members } = (await this.memberApis
|
|
6266
|
+
.fetch({ page, page_size: MEMBER_PAGE_SIZE })
|
|
6267
|
+
.then(response => response?.json()));
|
|
6268
|
+
const member = members.find(isRequestedMember);
|
|
6269
|
+
if (member || members.length < MEMBER_PAGE_SIZE)
|
|
6270
|
+
return member;
|
|
6271
|
+
}
|
|
6272
|
+
};
|
|
6273
|
+
const memberDetails = await findMember(member => member.email.toLowerCase() === email.toLowerCase());
|
|
6274
|
+
if (!memberDetails)
|
|
6275
|
+
throw new Error(`Member ${email} was not found`);
|
|
6276
|
+
await expect(async () => {
|
|
6277
|
+
await this.memberApis.update(memberDetails.id, keysToSnakeCase({
|
|
6264
6278
|
active: true,
|
|
6265
6279
|
firstName,
|
|
6266
6280
|
lastName,
|
|
6267
6281
|
organizationRole: newRole,
|
|
6268
6282
|
email: newEmail,
|
|
6269
6283
|
subscriptionPlan,
|
|
6270
|
-
}))
|
|
6284
|
+
}));
|
|
6285
|
+
if (!firstName && !lastName)
|
|
6286
|
+
return;
|
|
6287
|
+
await new Promise(resolve => setTimeout(resolve, NAME_SYNC_WAIT));
|
|
6288
|
+
const updatedMember = await findMember(({ id }) => id === memberDetails.id);
|
|
6289
|
+
expect(updatedMember, `Member ${email} was not found`).toBeDefined();
|
|
6290
|
+
firstName && expect(updatedMember?.first_name).toBe(firstName);
|
|
6291
|
+
lastName && expect(updatedMember?.last_name).toBe(lastName);
|
|
6292
|
+
}).toPass({ timeout: 60_000 });
|
|
6271
6293
|
};
|
|
6272
6294
|
deactivateMemberViaRequest = (email) => this.memberApis.bulkUpdate({ active: false, emails: [email] });
|
|
6273
6295
|
generateRandomTeamMembers = ({ count = 1, role = "standard" }) => dynamicArray(count, () => ({
|
|
@@ -6570,48 +6592,102 @@ class EditorPage {
|
|
|
6570
6592
|
this.editorWrapper = this.page;
|
|
6571
6593
|
if (editorWrapper)
|
|
6572
6594
|
this.editorWrapper = editorWrapper;
|
|
6573
|
-
this.editorLinkButton = this.
|
|
6595
|
+
this.editorLinkButton = this.toolbarOption(NEETO_EDITOR_SELECTORS.linkOption);
|
|
6574
6596
|
this.attachmentPreview = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.attachmentPreview);
|
|
6575
|
-
this.editorAttachmentsButton = this.
|
|
6597
|
+
this.editorAttachmentsButton = this.toolbarOption(NEETO_EDITOR_SELECTORS.editorAttachmentsButton);
|
|
6576
6598
|
this.imageWrapper = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.imageWrapper);
|
|
6577
6599
|
this.uploadDeleteButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadDeleteButton);
|
|
6578
|
-
this.imageUploadOption = this.
|
|
6579
|
-
this.cannedResponseOption = this.
|
|
6580
|
-
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);
|
|
6581
6603
|
this.videoEmbedInput = this.page.getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedInput);
|
|
6582
6604
|
this.videoWrapperSelector = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.videoWrapper);
|
|
6583
|
-
this.emojiSelector = this.
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
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 }));
|
|
6587
6614
|
this.contentField = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.contentField);
|
|
6588
6615
|
this.dynamicVariablesButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.dynamicVariablesButton);
|
|
6589
|
-
this.calloutSelector = this.
|
|
6590
|
-
this.undoSelector = this.
|
|
6591
|
-
this.redoSelector = this.
|
|
6592
|
-
this.tableOption = this.
|
|
6593
|
-
this.videoUploadOption = this.
|
|
6594
|
-
this.todoListSelector = this.
|
|
6595
|
-
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);
|
|
6596
6623
|
}
|
|
6597
6624
|
cleanString = (selector = "") => selector?.replace("neeto-editor-fixed-menu-", "").replace("-option", "") ||
|
|
6598
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
|
+
};
|
|
6599
6671
|
fixedMenuOptions = async () => {
|
|
6600
6672
|
const fixedMenuButtons = await this.editorWrapper
|
|
6601
6673
|
.getByTestId(NEETO_EDITOR_SELECTORS.fixedMenuWrapper)
|
|
6602
6674
|
.getByRole("button")
|
|
6675
|
+
.filter({ hasNot: this.page.getByTestId(COMMON_SELECTORS.dropdownIcon) })
|
|
6603
6676
|
.all();
|
|
6604
|
-
|
|
6605
|
-
return Promise.all(fixedMenuButtons.map(async (button) => {
|
|
6677
|
+
const options = await Promise.all(fixedMenuButtons.map(async (button) => {
|
|
6606
6678
|
const dataTestid = await button.getAttribute("data-testid");
|
|
6607
6679
|
return this.cleanString(dataTestid);
|
|
6608
6680
|
}));
|
|
6681
|
+
return options.filter(option => option !== "more" && option !== COMMON_SELECTORS.dropdownIcon);
|
|
6609
6682
|
};
|
|
6610
6683
|
moreMenuOptions = async () => {
|
|
6611
6684
|
await this.moreMenuSelector.click();
|
|
6612
6685
|
const dropdownContainer = this.page.getByTestId(COMMON_SELECTORS.dropdownContainer);
|
|
6613
|
-
|
|
6614
|
-
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) => {
|
|
6615
6691
|
const dataTestid = await button.getAttribute("data-testid");
|
|
6616
6692
|
return this.cleanString(dataTestid);
|
|
6617
6693
|
}));
|
|
@@ -6619,29 +6695,28 @@ class EditorPage {
|
|
|
6619
6695
|
await expect(dropdownContainer).toBeHidden();
|
|
6620
6696
|
return moreMenuButtonLocators;
|
|
6621
6697
|
};
|
|
6622
|
-
verifyFontSize = async () => IS_SHADCN_UI
|
|
6623
|
-
|
|
6698
|
+
verifyFontSize = async (isButtonInMoreMenu = false) => IS_SHADCN_UI
|
|
6699
|
+
? this.verifyFontSizeV2(isButtonInMoreMenu)
|
|
6700
|
+
: this.verifyFontSizeV1(isButtonInMoreMenu);
|
|
6701
|
+
verifyFontSizeV1 = async (isButtonInMoreMenu) => {
|
|
6624
6702
|
const fontsAndTexts = [];
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
.click();
|
|
6703
|
+
const fontSizeDropdown = this.page.getByTestId(NEETO_EDITOR_SELECTORS.fontSize);
|
|
6704
|
+
await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
|
|
6628
6705
|
const headingButtons = await this.page
|
|
6629
|
-
.getByTestId(
|
|
6630
|
-
.getByRole("button")
|
|
6706
|
+
.getByTestId(NEETO_EDITOR_SELECTORS.fontSizeHeadingOptions)
|
|
6707
|
+
.and(this.page.getByRole("button"))
|
|
6631
6708
|
.all();
|
|
6632
6709
|
const headingLevels = (await Promise.all(headingButtons.map(async (button) => {
|
|
6633
6710
|
const dataTestid = await button.getAttribute("data-testid");
|
|
6634
6711
|
const headingLevel = dataTestid?.split("-").pop();
|
|
6635
6712
|
return /^h[1-5]$/.test(headingLevel || "") ? headingLevel : null;
|
|
6636
6713
|
}))).filter(Boolean);
|
|
6637
|
-
|
|
6714
|
+
await this.dismissToolbarMenu();
|
|
6638
6715
|
for (const headingLevel of headingLevels) {
|
|
6639
6716
|
const fontKey = headingLevel;
|
|
6640
6717
|
const randomText = await this.fillRandomText();
|
|
6641
|
-
await
|
|
6642
|
-
await this.
|
|
6643
|
-
.getByTestId(FONT_SIZE_SELECTORS[fontKey])
|
|
6644
|
-
.click();
|
|
6718
|
+
await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
|
|
6719
|
+
await this.page.getByTestId(FONT_SIZE_SELECTORS[fontKey]).click();
|
|
6645
6720
|
await expect(this.contentField.getByRole("heading", {
|
|
6646
6721
|
level: Number(headingLevel?.slice(1)),
|
|
6647
6722
|
name: randomText,
|
|
@@ -6650,28 +6725,25 @@ class EditorPage {
|
|
|
6650
6725
|
}
|
|
6651
6726
|
return fontsAndTexts;
|
|
6652
6727
|
};
|
|
6653
|
-
verifyFontSizeV2 = async () => {
|
|
6728
|
+
verifyFontSizeV2 = async (isButtonInMoreMenu) => {
|
|
6654
6729
|
const fontsAndTexts = [];
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
.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"))
|
|
6661
6735
|
.all();
|
|
6662
6736
|
const headingLevels = (await Promise.all(headingMenuItems.map(async (menuItem) => {
|
|
6663
6737
|
const dataTestid = await menuItem.getAttribute("data-testid");
|
|
6664
6738
|
const headingLevel = dataTestid?.split("-").pop();
|
|
6665
6739
|
return /^h[1-5]$/.test(headingLevel || "") ? headingLevel : null;
|
|
6666
6740
|
}))).filter(Boolean);
|
|
6667
|
-
|
|
6668
|
-
await fontSizeDropdown.click();
|
|
6669
|
-
await expect(dropdownContainer).toBeHidden();
|
|
6741
|
+
await this.dismissToolbarMenu();
|
|
6670
6742
|
for (const headingLevel of headingLevels) {
|
|
6671
6743
|
const fontKey = headingLevel;
|
|
6672
6744
|
const randomText = await this.fillRandomText();
|
|
6673
|
-
await
|
|
6674
|
-
await
|
|
6745
|
+
await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
|
|
6746
|
+
await this.page.getByTestId(FONT_SIZE_SELECTORS[fontKey]).click();
|
|
6675
6747
|
await expect(this.contentField.getByRole("heading", {
|
|
6676
6748
|
level: Number(headingLevel?.slice(1)),
|
|
6677
6749
|
name: randomText,
|
|
@@ -6684,39 +6756,34 @@ class EditorPage {
|
|
|
6684
6756
|
const modifierKey = modifier;
|
|
6685
6757
|
const textModifierRole = TEXT_MODIFIER_ROLES[modifierKey];
|
|
6686
6758
|
const randomText = await this.fillRandomText();
|
|
6687
|
-
const textModifierSelector = this.
|
|
6688
|
-
|
|
6689
|
-
await textModifierSelector.click();
|
|
6759
|
+
const textModifierSelector = this.toolbarOption(TEXT_MODIFIER_SELECTORS[modifierKey]);
|
|
6760
|
+
await this.clickToolbarOption(textModifierSelector, isButtonInMoreMenu);
|
|
6690
6761
|
await expect(this.contentField
|
|
6691
6762
|
.getByRole(textModifierRole)
|
|
6692
6763
|
.filter({ hasText: randomText })).toBeVisible();
|
|
6693
|
-
await this.
|
|
6764
|
+
await this.moveCursorAtBottom();
|
|
6694
6765
|
await this.page.keyboard.press("Enter");
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
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);
|
|
6698
6770
|
}
|
|
6699
6771
|
return [{ key: modifierKey, value: randomText }];
|
|
6700
6772
|
};
|
|
6701
6773
|
verifyTextDeskModifier = async (modifier, isButtonInMoreMenu) => {
|
|
6702
6774
|
const modifierKey = modifier;
|
|
6703
|
-
const textModifierSelector = this.
|
|
6775
|
+
const textModifierSelector = this.toolbarOption(NEETO_TEXT_MODIFIER_SELECTORS[modifierKey]);
|
|
6704
6776
|
const randomText = await this.fillRandomText();
|
|
6705
|
-
|
|
6706
|
-
await textModifierSelector.click();
|
|
6777
|
+
await this.clickToolbarOption(textModifierSelector, isButtonInMoreMenu);
|
|
6707
6778
|
await expect(this.contentField
|
|
6708
6779
|
.locator(TEXT_MODIFIER_TAGS[modifierKey])
|
|
6709
6780
|
.filter({ hasText: randomText })).toBeVisible();
|
|
6710
|
-
await this.
|
|
6711
|
-
|
|
6712
|
-
await textModifierSelector.click();
|
|
6781
|
+
await this.moveCursorAtBottom();
|
|
6782
|
+
await this.clickToolbarOption(textModifierSelector, isButtonInMoreMenu);
|
|
6713
6783
|
return [{ key: modifierKey, value: randomText }];
|
|
6714
6784
|
};
|
|
6715
6785
|
openHighlighterContainer = (isButtonInMoreMenu) => expect(async () => {
|
|
6716
|
-
|
|
6717
|
-
await this.editorWrapper
|
|
6718
|
-
.getByTestId(NEETO_TEXT_MODIFIER_SELECTORS["highlight"])
|
|
6719
|
-
.click();
|
|
6786
|
+
await this.clickToolbarOption(this.toolbarOption(NEETO_TEXT_MODIFIER_SELECTORS["highlight"]), isButtonInMoreMenu);
|
|
6720
6787
|
await expect(this.page.getByTestId(COMMON_SELECTORS.customDropdownContainer())).toBeVisible({ timeout: 5_000 });
|
|
6721
6788
|
}).toPass({ timeout: 30_000 });
|
|
6722
6789
|
focusText = (textLocator) => expect(async () => {
|
|
@@ -6747,7 +6814,7 @@ class EditorPage {
|
|
|
6747
6814
|
verifyTextHighlighter = async (isButtonInMoreMenu, highlighterCount = this.highlighterCount) => {
|
|
6748
6815
|
const highlightedKeyValuePairs = [];
|
|
6749
6816
|
for (let colorIdx = 1; colorIdx <= highlighterCount; colorIdx++) {
|
|
6750
|
-
await this.
|
|
6817
|
+
await this.moveCursorAtBottom();
|
|
6751
6818
|
const randomText = await this.highlightText(isButtonInMoreMenu, colorIdx);
|
|
6752
6819
|
highlightedKeyValuePairs.push({
|
|
6753
6820
|
key: `highlight-${colorIdx}`,
|
|
@@ -6758,22 +6825,19 @@ class EditorPage {
|
|
|
6758
6825
|
};
|
|
6759
6826
|
verifyListModifiers = async (modifier, isButtonInMoreMenu) => {
|
|
6760
6827
|
const modifierKey = modifier;
|
|
6761
|
-
const listModifierSelector = this.
|
|
6828
|
+
const listModifierSelector = this.toolbarOption(LIST_MODIFIER_SELECTORS[modifierKey]);
|
|
6762
6829
|
const randomText = await this.fillRandomText();
|
|
6763
|
-
|
|
6764
|
-
await listModifierSelector.click();
|
|
6830
|
+
await this.clickToolbarOption(listModifierSelector, isButtonInMoreMenu);
|
|
6765
6831
|
await expect(this.contentField
|
|
6766
6832
|
.locator(LIST_MODIFIER_TAGS[modifierKey])
|
|
6767
6833
|
.filter({ hasText: randomText })).toBeVisible();
|
|
6768
|
-
await this.
|
|
6769
|
-
|
|
6770
|
-
await listModifierSelector.click();
|
|
6834
|
+
await this.moveCursorAtBottom();
|
|
6835
|
+
await this.clickToolbarOption(listModifierSelector, isButtonInMoreMenu);
|
|
6771
6836
|
return [{ key: modifierKey, value: randomText }];
|
|
6772
6837
|
};
|
|
6773
6838
|
verifyEditorLinkButton = async (linkUrl, isButtonInMoreMenu) => {
|
|
6774
6839
|
const randomText = await this.fillRandomText();
|
|
6775
|
-
|
|
6776
|
-
await this.editorLinkButton.click();
|
|
6840
|
+
await this.clickToolbarOption(this.editorLinkButton, isButtonInMoreMenu);
|
|
6777
6841
|
await this.page
|
|
6778
6842
|
.getByTestId(NEETO_EDITOR_SELECTORS.addLinkUrlInput)
|
|
6779
6843
|
.fill(linkUrl);
|
|
@@ -6782,13 +6846,12 @@ class EditorPage {
|
|
|
6782
6846
|
.click();
|
|
6783
6847
|
const linkRole = DESCRIPTION_EDITOR_TEXTS.link;
|
|
6784
6848
|
await expect(this.contentField.getByRole(linkRole)).toBeVisible();
|
|
6785
|
-
await this.
|
|
6849
|
+
await this.moveCursorAtBottom();
|
|
6786
6850
|
return [{ key: "link", value: randomText }];
|
|
6787
6851
|
};
|
|
6788
6852
|
verifyEditorAttachmentsButton = async (filePath, isButtonInMoreMenu, shouldRemoveAttachment = false) => {
|
|
6789
6853
|
const fileUploaderPromise = this.page.waitForEvent("filechooser");
|
|
6790
|
-
|
|
6791
|
-
await this.editorAttachmentsButton.click();
|
|
6854
|
+
await this.clickToolbarOption(this.editorAttachmentsButton, isButtonInMoreMenu);
|
|
6792
6855
|
const fileUploader = await fileUploaderPromise;
|
|
6793
6856
|
const imagePath = path.join(__dirname$3, filePath);
|
|
6794
6857
|
await fileUploader.setFiles(imagePath);
|
|
@@ -6810,8 +6873,7 @@ class EditorPage {
|
|
|
6810
6873
|
return [{ key: "attachments", value: filePath }];
|
|
6811
6874
|
};
|
|
6812
6875
|
verifyImageUploadOption = async ({ filePath, isButtonInMoreMenu, shouldRemoveImage = false, }) => {
|
|
6813
|
-
|
|
6814
|
-
await this.imageUploadOption.click();
|
|
6876
|
+
await this.clickToolbarOption(this.imageUploadOption, isButtonInMoreMenu);
|
|
6815
6877
|
await expect(this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.restrictionMessage)).toBeVisible();
|
|
6816
6878
|
const fileUploaderPromise = this.page.waitForEvent("filechooser");
|
|
6817
6879
|
await this.page
|
|
@@ -6831,8 +6893,7 @@ class EditorPage {
|
|
|
6831
6893
|
return [{ key: "image-upload", value: imagePath }];
|
|
6832
6894
|
};
|
|
6833
6895
|
verifyCannedResponseOption = async (isButtonInMoreMenu, cannedResponseSuccessMessage) => {
|
|
6834
|
-
|
|
6835
|
-
await this.cannedResponseOption.click();
|
|
6896
|
+
await this.clickToolbarOption(this.cannedResponseOption, isButtonInMoreMenu);
|
|
6836
6897
|
await expect(this.page.getByTestId(COMMON_SELECTORS.paneHeader)).toContainText(DESCRIPTION_EDITOR_TEXTS.cannedResponseHeader);
|
|
6837
6898
|
await this.page
|
|
6838
6899
|
.getByTestId(NEETO_EDITOR_SELECTORS.cannedResponseSelectContainer)
|
|
@@ -6849,8 +6910,7 @@ class EditorPage {
|
|
|
6849
6910
|
];
|
|
6850
6911
|
};
|
|
6851
6912
|
verifyVideoEmbedOption = async (videoUrl, isButtonInMoreMenu, shouldRemoveVideo = false) => {
|
|
6852
|
-
|
|
6853
|
-
await this.videoEmbedOption.click();
|
|
6913
|
+
await this.clickToolbarOption(this.videoEmbedOption, isButtonInMoreMenu);
|
|
6854
6914
|
await this.videoEmbedInput.fill(videoUrl);
|
|
6855
6915
|
await this.page
|
|
6856
6916
|
.getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedSubmit)
|
|
@@ -6869,8 +6929,7 @@ class EditorPage {
|
|
|
6869
6929
|
};
|
|
6870
6930
|
verifyEmojiSelector = async (isButtonInMoreMenu) => {
|
|
6871
6931
|
const emoji = "👍";
|
|
6872
|
-
|
|
6873
|
-
await this.emojiSelector.click();
|
|
6932
|
+
await this.clickToolbarOption(this.emojiSelector, isButtonInMoreMenu);
|
|
6874
6933
|
const emojiContainer = this.page.getByTestId(NEETO_EDITOR_SELECTORS.emojiContainer);
|
|
6875
6934
|
await expect(emojiContainer).toBeVisible({ timeout: 10_000 });
|
|
6876
6935
|
await emojiContainer
|
|
@@ -6881,26 +6940,23 @@ class EditorPage {
|
|
|
6881
6940
|
return [{ key: "emoji", value: emoji }];
|
|
6882
6941
|
};
|
|
6883
6942
|
verifyUndoSelector = async (isButtonInMoreMenu) => {
|
|
6884
|
-
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
6885
6943
|
const randomText = await this.fillRandomText();
|
|
6886
6944
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeVisible();
|
|
6887
|
-
await this.undoSelector
|
|
6945
|
+
await this.clickToolbarOption(this.undoSelector, isButtonInMoreMenu);
|
|
6888
6946
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeHidden();
|
|
6889
6947
|
return [{ key: "undo", value: randomText }];
|
|
6890
6948
|
};
|
|
6891
6949
|
verifyRedoSelector = async (isButtonInMoreMenu) => {
|
|
6892
|
-
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
6893
6950
|
const randomText = await this.fillRandomText();
|
|
6894
6951
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeVisible();
|
|
6895
|
-
await this.undoSelector
|
|
6952
|
+
await this.clickToolbarOption(this.undoSelector, isButtonInMoreMenu);
|
|
6896
6953
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeHidden();
|
|
6897
|
-
await this.redoSelector
|
|
6954
|
+
await this.clickToolbarOption(this.redoSelector, isButtonInMoreMenu);
|
|
6898
6955
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeVisible();
|
|
6899
6956
|
return [{ key: "redo", value: randomText }];
|
|
6900
6957
|
};
|
|
6901
6958
|
verifyTableSelector = async (isButtonInMoreMenu) => {
|
|
6902
|
-
|
|
6903
|
-
await this.tableOption.click();
|
|
6959
|
+
await this.clickToolbarOption(this.tableOption, isButtonInMoreMenu);
|
|
6904
6960
|
await this.page
|
|
6905
6961
|
.getByTestId(NEETO_EDITOR_SELECTORS.tableCreateButton)
|
|
6906
6962
|
.click();
|
|
@@ -6918,8 +6974,7 @@ class EditorPage {
|
|
|
6918
6974
|
return [{ key: "table" }];
|
|
6919
6975
|
};
|
|
6920
6976
|
verifyVideoUploadOption = async ({ filePath, isButtonInMoreMenu, shouldRemoveVideo, }) => {
|
|
6921
|
-
|
|
6922
|
-
await this.videoUploadOption.click();
|
|
6977
|
+
await this.clickToolbarOption(this.videoUploadOption, isButtonInMoreMenu);
|
|
6923
6978
|
const fileUploaderPromise = this.page.waitForEvent("filechooser");
|
|
6924
6979
|
await this.page
|
|
6925
6980
|
.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadButton)
|
|
@@ -6943,12 +6998,11 @@ class EditorPage {
|
|
|
6943
6998
|
verifyTodoListSelector = async (isButtonInMoreMenu) => {
|
|
6944
6999
|
const randomText = await this.fillRandomText();
|
|
6945
7000
|
await expect(this.contentField.getByText(randomText, { exact: true })).toBeVisible();
|
|
6946
|
-
|
|
6947
|
-
await this.todoListSelector.click();
|
|
7001
|
+
await this.clickToolbarOption(this.todoListSelector, isButtonInMoreMenu);
|
|
6948
7002
|
await expect(this.contentField.locator(NEETO_EDITOR_SELECTORS.todoList, {
|
|
6949
7003
|
hasText: randomText,
|
|
6950
7004
|
})).toBeVisible();
|
|
6951
|
-
await this.
|
|
7005
|
+
await this.moveCursorAtBottom();
|
|
6952
7006
|
return [{ key: "todoList", value: randomText }];
|
|
6953
7007
|
};
|
|
6954
7008
|
verifyDynamicVariables = async (dynamicVariables) => {
|
|
@@ -6967,9 +7021,8 @@ class EditorPage {
|
|
|
6967
7021
|
const colorPickerInput = this.page
|
|
6968
7022
|
.getByTestId(COMMON_SELECTORS.customDropdownContainer())
|
|
6969
7023
|
.getByTestId(COMMON_SELECTORS.inputField);
|
|
6970
|
-
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
6971
7024
|
await expect(async () => {
|
|
6972
|
-
await this.textColorSelector
|
|
7025
|
+
await this.clickToolbarOption(this.textColorSelector, isButtonInMoreMenu);
|
|
6973
7026
|
await expect(colorPickerInput).toBeVisible({ timeout: 5_000 });
|
|
6974
7027
|
await colorPickerInput.fill(EDITOR_VERIFY_TEXT_COLOR);
|
|
6975
7028
|
// Using .first() to target the button rendered by the Formik editor.
|
|
@@ -6985,34 +7038,42 @@ class EditorPage {
|
|
|
6985
7038
|
hasText: randomText,
|
|
6986
7039
|
});
|
|
6987
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();
|
|
6988
7043
|
return [{ key: "text-color", value: randomText }];
|
|
6989
7044
|
};
|
|
6990
7045
|
verifyCalloutSelector = async (isButtonInMoreMenu) => {
|
|
6991
|
-
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
6992
7046
|
const calloutTypes = ["default", "info", "warning", "error", "success"];
|
|
6993
7047
|
const calloutContentField = this.contentField.locator(NEETO_EDITOR_SELECTORS.calloutContent);
|
|
6994
|
-
const calloutTypeOption =
|
|
6995
|
-
|
|
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();
|
|
6996
7052
|
for (const [index, type] of calloutTypes.entries()) {
|
|
6997
|
-
await this.calloutSelector
|
|
7053
|
+
await this.clickToolbarOption(this.calloutSelector, isButtonInMoreMenu);
|
|
6998
7054
|
const calloutType = calloutTypeOption.filter({ hasText: type });
|
|
6999
7055
|
await expect(calloutType).toBeVisible({ timeout: 10_000 });
|
|
7000
7056
|
await calloutType.click();
|
|
7001
7057
|
await Promise.all([
|
|
7002
|
-
expect(
|
|
7058
|
+
expect(calloutType).toBeHidden(),
|
|
7003
7059
|
expect(this.contentField.locator(NEETO_EDITOR_SELECTORS.dataEmojiType(type))).toBeVisible(),
|
|
7004
7060
|
]);
|
|
7005
7061
|
const randomText = faker.lorem.word(10);
|
|
7006
|
-
|
|
7007
|
-
// The index is important here as it determines which callout content field to interact with
|
|
7062
|
+
// The index identifies the newly inserted callout.
|
|
7008
7063
|
// eslint-disable-next-line playwright/no-nth-methods
|
|
7009
|
-
|
|
7010
|
-
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();
|
|
7011
7072
|
}
|
|
7012
7073
|
return [{ key: "callout" }];
|
|
7013
7074
|
};
|
|
7014
7075
|
buttonsAndVerifications = {
|
|
7015
|
-
"font-size":
|
|
7076
|
+
"font-size": isButtonInMoreMenu => this.verifyFontSize(isButtonInMoreMenu),
|
|
7016
7077
|
emoji: isButtonInMoreMenu => this.verifyEmojiSelector(isButtonInMoreMenu),
|
|
7017
7078
|
bold: isButtonInMoreMenu => this.verifyTextModifiers("bold", isButtonInMoreMenu),
|
|
7018
7079
|
italic: isButtonInMoreMenu => this.verifyTextModifiers("italic", isButtonInMoreMenu),
|
|
@@ -7049,8 +7110,7 @@ class EditorPage {
|
|
|
7049
7110
|
do {
|
|
7050
7111
|
randomText = faker.lorem.word(10);
|
|
7051
7112
|
} while (this.wordsUsedInEditor.includes(randomText));
|
|
7052
|
-
await this.
|
|
7053
|
-
await this.neetoPlaywrightUtilities.moveCursorAtBottom();
|
|
7113
|
+
await this.moveCursorAtBottom();
|
|
7054
7114
|
await this.page.keyboard.type(randomText);
|
|
7055
7115
|
this.wordsUsedInEditor.push(randomText);
|
|
7056
7116
|
const randomTextLocator = this.contentField.getByText(randomText);
|
|
@@ -7084,7 +7144,11 @@ class EditorPage {
|
|
|
7084
7144
|
})).toBeVisible();
|
|
7085
7145
|
}
|
|
7086
7146
|
if (key === "text-color") {
|
|
7087
|
-
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));
|
|
7088
7152
|
}
|
|
7089
7153
|
const replacement = elementReplacement?.[key] ?? key;
|
|
7090
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
|