@bigbinary/neeto-playwright-commons 1.10.2 → 1.10.3

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.js CHANGED
@@ -13740,49 +13740,54 @@ const LIST_MODIFIER_TAGS = {
13740
13740
  orderedListOption: "ol",
13741
13741
  };
13742
13742
 
13743
+ const optionSelector = (option) => `neeto-editor-fixed-menu-${option}-option`;
13744
+ const fixedMenuSelector = (selector) => `neeto-editor-fixed-menu-${selector}`;
13745
+
13743
13746
  const NEETO_EDITOR_SELECTORS = {
13744
- boldOption: "neeto-editor-fixed-menu-bold-option",
13745
- italicOption: "neeto-editor-fixed-menu-italic-option",
13746
- underlineOption: "neeto-editor-fixed-menu-underline-option",
13747
- strikeOption: "neeto-editor-fixed-menu-strike-option",
13748
- codeBlockOption: "neeto-editor-fixed-menu-code-option",
13749
- highlightOption: "neeto-editor-fixed-menu-highlight-option",
13750
- linkInput: "neeto-editor-fixed-menu-link-option-input",
13751
- linkSubmitButton: "neeto-editor-fixed-menu-link-option-link-button",
13747
+ boldOption: optionSelector("bold"),
13748
+ italicOption: optionSelector("italic"),
13749
+ underlineOption: optionSelector("underline"),
13750
+ strikeOption: optionSelector("strike"),
13751
+ codeBlockOption: optionSelector("code"),
13752
+ highlightOption: optionSelector("highlight"),
13753
+ emojiOption: optionSelector("emoji"),
13754
+ emojiDropdownIcon: "emoji-dropdown-icon",
13755
+ linkInput: fixedMenuSelector("link-option-input"),
13756
+ linkSubmitButton: fixedMenuSelector("link-option-link-button"),
13752
13757
  commandList: (index) => `neeto-editor-command-list-item-${index}`,
13753
13758
  imageUploadUrlSubmitButton: "neeto-editor-media-upload-url-submit",
13754
13759
  imageUploadUrlInputTextField: "neeto-editor-media-upload-url-input",
13755
13760
  uploadInput: "neeto-editor-media-uploader-input",
13756
- editorMenuBarWrapper: "neeto-editor-fixed-menu-wrapper",
13757
- undoOption: "neeto-editor-fixed-menu-undo-option",
13758
- redoOption: "neeto-editor-fixed-menu-redo-option",
13761
+ editorMenuBarWrapper: fixedMenuSelector("wrapper"),
13762
+ undoOption: optionSelector("undo"),
13763
+ redoOption: optionSelector("redo"),
13759
13764
  imageWrapper: "neeto-editor-image-wrapper",
13760
13765
  contentField: "neeto-editor-content",
13761
- addLinkButton: "neeto-editor-fixed-menu-link-option",
13766
+ addLinkButton: optionSelector("link"),
13762
13767
  addLinkTextField: "neeto-editor-add-link-text-input",
13763
13768
  addURLTextField: "neeto-editor-add-link-url-input",
13764
13769
  submitLinkButton: "neeto-editor-add-link",
13765
13770
  fontSizeDropdown: (currentOption) => `${joinHyphenCase(currentOption)}-dropdown-icon`,
13766
- fixedMenuArrow: "neeto-editor-fixed-menu-arrow",
13767
- cannedResponseOption: "neeto-editor-fixed-menu-canned-responses-option",
13771
+ fixedMenuArrow: fixedMenuSelector("arrow"),
13772
+ cannedResponseOption: optionSelector("canned-responses"),
13768
13773
  cannedResponseSelectContainer: "select-a-canned-response-select-container",
13769
- fixedMenuWrapper: "neeto-editor-fixed-menu-wrapper",
13770
- linkOption: "neeto-editor-fixed-menu-link-option",
13774
+ fixedMenuWrapper: optionSelector("wrapper"),
13775
+ linkOption: optionSelector("link"),
13771
13776
  addLinkUrlInput: "neeto-editor-add-link-url-input",
13772
13777
  addLinkDoneButton: "neeto-editor-add-link",
13773
13778
  unlinkButton: "neeto-editor-link-popover-unlink",
13774
- editorAttachmentsButton: "neeto-editor-fixed-menu-attachments-option",
13779
+ editorAttachmentsButton: optionSelector("attachments"),
13775
13780
  attachmentPreviewDeleteButton: "neeto-editor-preview-delete-button",
13776
- imageUploadOption: "neeto-editor-fixed-menu-image-upload-option",
13781
+ imageUploadOption: optionSelector("image-upload"),
13777
13782
  imageUploadLinkInput: "neeto-editor-media-upload-url-input",
13778
13783
  imageUploadButton: "neeto-editor-media-uploader-dnd",
13779
13784
  imageUploadLinkSubmitButton: "neeto-editor-media-upload-url-submit",
13780
13785
  applyButton: "apply-button",
13781
- videoEmbedOption: "neeto-editor-fixed-menu-video-embed-option",
13786
+ videoEmbedOption: optionSelector("video-embed"),
13782
13787
  videoEmbedInput: "neeto-editor-embed-input",
13783
13788
  videoEmbedSubmit: "neeto-editor-embed-cancel",
13784
13789
  videoWrapper: "neeto-editor-video-wrapper",
13785
- paragraphOption: "neeto-editor-fixed-menu-font-size-option-body2",
13790
+ paragraphOption: fixedMenuSelector("font-size-option-body2"),
13786
13791
  attachmentPreview: "ne-attachments-wrapper",
13787
13792
  imageUploadLinkButton: "neeto-editor-media-uploader-link-tab",
13788
13793
  errorText: "neeto-editor-error-text",
@@ -13793,256 +13798,266 @@ const NEETO_EDITOR_SELECTORS = {
13793
13798
  dynamicVariableSelector: (variable) => `dynamic-variables-list-item-${hyphenate(variable)}`,
13794
13799
  };
13795
13800
  const NEETO_TEXT_MODIFIER_SELECTORS = {
13796
- strikeOption: "neeto-editor-fixed-menu-strike-option",
13797
- underlineOption: "neeto-editor-fixed-menu-underline-option",
13798
- highlightOption: "neeto-editor-fixed-menu-highlight-option",
13801
+ strikeOption: optionSelector("strike"),
13802
+ underlineOption: optionSelector("underline"),
13803
+ highlightOption: optionSelector("highlight"),
13799
13804
  };
13800
13805
  const TEXT_MODIFIER_SELECTORS = {
13801
- boldOption: "neeto-editor-fixed-menu-bold-option",
13802
- italicsOption: "neeto-editor-fixed-menu-italic-option",
13803
- codeOption: "neeto-editor-fixed-menu-code-option",
13804
- blockquoteOption: "neeto-editor-fixed-menu-blockquote-option",
13805
- codeblockOption: "neeto-editor-fixed-menu-code-block-option",
13806
+ boldOption: optionSelector("bold"),
13807
+ italicsOption: optionSelector("italic"),
13808
+ codeOption: optionSelector("code"),
13809
+ blockquoteOption: optionSelector("blockquote"),
13810
+ codeblockOption: optionSelector("codeBlock"),
13806
13811
  };
13807
13812
  const LIST_MODIFIER_SELECTORS = {
13808
- bulletListOption: "neeto-editor-fixed-menu-bullet-list-option",
13809
- orderedListOption: "neeto-editor-fixed-menu-ordered-list-option",
13813
+ bulletListOption: optionSelector("bulletList"),
13814
+ orderedListOption: optionSelector("orderedList"),
13810
13815
  };
13811
13816
  const FONT_SIZE_SELECTORS = {
13812
- h1: "neeto-editor-fixed-menu-font-size-option-h1",
13813
- h2: "neeto-editor-fixed-menu-font-size-option-h2",
13814
- h3: "neeto-editor-fixed-menu-font-size-option-h3",
13815
- h4: "neeto-editor-fixed-menu-font-size-option-h4",
13816
- h5: "neeto-editor-fixed-menu-font-size-option-h5",
13817
+ h1: fixedMenuSelector("font-size-option-h1"),
13818
+ h2: fixedMenuSelector("font-size-option-h2"),
13819
+ h3: fixedMenuSelector("font-size-option-h3"),
13820
+ h4: fixedMenuSelector("font-size-option-h4"),
13821
+ h5: fixedMenuSelector("font-size-option-h5"),
13817
13822
  };
13818
13823
 
13819
- /* eslint-disable playwright/no-nth-methods */
13820
13824
  class EditorPage {
13821
- constructor(page, neetoPlaywrightUtilities) {
13822
- this.verifyDescriptionEditor = async ({ text, editorWrapper, dynamicVariables, defaultFontSizeOption = "Paragraph", linkUrl = faker.internet.url(), filePath = "../../../e2e/assets/images/BigBinary.png", imageUrl = "https://picsum.photos/200/300", videoUrl = "https://youtu.be/jNQXAC9IVRw", cannedResponseSuccessMessage, }) => {
13823
- if (!editorWrapper)
13824
- editorWrapper = this.page;
13825
- await editorWrapper
13826
- .getByTestId(NEETO_EDITOR_SELECTORS.contentField)
13827
- .fill(text);
13828
- await editorWrapper
13825
+ constructor(page, neetoPlaywrightUtilities, editorWrapper) {
13826
+ this.assertOptionVisibility = async (optionLocator) => {
13827
+ if (await optionLocator.isVisible())
13828
+ return true;
13829
+ (await this.moreMenuSelector.isVisible()) &&
13830
+ (await this.moreMenuSelector.click());
13831
+ return optionLocator.isVisible();
13832
+ };
13833
+ this.verifyFontSize = async (defaultFontSizeOption) => {
13834
+ await this.editorWrapper
13829
13835
  .getByTestId(NEETO_EDITOR_SELECTORS.fontSizeDropdown(defaultFontSizeOption))
13830
13836
  .click();
13831
13837
  const fontSize = Object.keys(FONT_SIZE_SELECTORS);
13832
13838
  for (const font of fontSize) {
13833
13839
  const fontKey = font;
13834
- await editorWrapper.getByTestId(FONT_SIZE_SELECTORS[fontKey]).click();
13835
- await expect(editorWrapper
13836
- .getByTestId(NEETO_EDITOR_SELECTORS.contentField)
13837
- .getByRole("heading", { level: Number(font.slice(1)) })).toBeVisible();
13838
- await editorWrapper
13840
+ await this.editorWrapper
13841
+ .getByTestId(FONT_SIZE_SELECTORS[fontKey])
13842
+ .click();
13843
+ await expect(this.contentField.getByRole("heading", { level: Number(font.slice(1)) })).toBeVisible();
13844
+ await this.editorWrapper
13839
13845
  .getByTestId(NEETO_EDITOR_SELECTORS.fontSizeDropdown(EXPANDED_FONT_SIZE[fontKey]))
13840
13846
  .click();
13841
13847
  }
13842
- if (await this.paragraphSelector.isVisible()) {
13843
- await this.paragraphSelector.click();
13844
- const paragraphRole = DESCRIPTION_EDITOR_TEXTS.paragraphOption;
13845
- await expect(editorWrapper
13846
- .getByTestId(NEETO_EDITOR_SELECTORS.contentField)
13847
- .getByRole(paragraphRole)).toBeVisible();
13848
- }
13849
- (await this.fixedMenuArrowSelector.isVisible()) &&
13850
- (await this.fixedMenuArrowSelector.click());
13851
- await editorWrapper.getByText(text).click({ clickCount: 3 });
13848
+ };
13849
+ this.verifyTextModifiers = async () => {
13852
13850
  const textModifier = Object.keys(TEXT_MODIFIER_SELECTORS);
13853
13851
  for (const modifier of textModifier) {
13854
13852
  const modifierKey = modifier;
13855
13853
  const textModifierRole = TEXT_MODIFIER_ROLES[modifierKey];
13856
- const textModifierSelector = editorWrapper.getByTestId(TEXT_MODIFIER_SELECTORS[modifierKey]);
13857
- if (await textModifierSelector.isVisible()) {
13854
+ const textModifierSelector = this.editorWrapper.getByTestId(TEXT_MODIFIER_SELECTORS[modifierKey]);
13855
+ if (await this.assertOptionVisibility(textModifierSelector)) {
13858
13856
  await textModifierSelector.click();
13859
- await expect(editorWrapper
13860
- .getByTestId(NEETO_EDITOR_SELECTORS.contentField)
13861
- .getByRole(textModifierRole)).toBeVisible();
13857
+ await expect(this.contentField.getByRole(textModifierRole)).toBeVisible();
13862
13858
  await textModifierSelector.click();
13863
13859
  }
13864
13860
  }
13861
+ };
13862
+ this.verifyTextDeskModifier = async () => {
13865
13863
  const textDeskModifier = Object.keys(NEETO_TEXT_MODIFIER_SELECTORS);
13866
13864
  for (const modifier of textDeskModifier) {
13867
13865
  const modifierKey = modifier;
13868
- const textModifierSelector = editorWrapper.getByTestId(NEETO_TEXT_MODIFIER_SELECTORS[modifierKey]);
13869
- if (await textModifierSelector.isVisible()) {
13866
+ const textModifierSelector = this.editorWrapper.getByTestId(NEETO_TEXT_MODIFIER_SELECTORS[modifierKey]);
13867
+ if (await this.assertOptionVisibility(textModifierSelector)) {
13870
13868
  await textModifierSelector.click();
13871
- await expect(editorWrapper
13872
- .getByTestId(NEETO_EDITOR_SELECTORS.contentField)
13873
- .locator(TEXT_MODIFIER_TAGS[modifierKey])).toBeVisible();
13869
+ await expect(this.contentField.locator(TEXT_MODIFIER_TAGS[modifierKey])).toBeVisible();
13874
13870
  await textModifierSelector.click();
13875
13871
  }
13876
13872
  }
13873
+ };
13874
+ this.verifyListModifiers = async () => {
13877
13875
  const listModifier = Object.keys(LIST_MODIFIER_SELECTORS);
13878
13876
  for (const modifier of listModifier) {
13879
13877
  const modifierKey = modifier;
13880
- const listModifierSelector = editorWrapper.getByTestId(LIST_MODIFIER_SELECTORS[modifierKey]);
13881
- if (await listModifierSelector.isVisible()) {
13878
+ const listModifierSelector = this.editorWrapper.getByTestId(LIST_MODIFIER_SELECTORS[modifierKey]);
13879
+ if (await this.assertOptionVisibility(listModifierSelector)) {
13882
13880
  await listModifierSelector.click();
13883
- await expect(editorWrapper
13884
- .getByTestId(NEETO_EDITOR_SELECTORS.contentField)
13885
- .locator(LIST_MODIFIER_TAGS[modifierKey])).toBeVisible();
13881
+ await expect(this.contentField.locator(LIST_MODIFIER_TAGS[modifierKey])).toBeVisible();
13886
13882
  await listModifierSelector.click();
13887
13883
  }
13888
13884
  }
13889
- if (await this.editorLinkButton.isVisible()) {
13890
- await this.editorLinkButton.click();
13891
- await this.page
13892
- .getByTestId(NEETO_EDITOR_SELECTORS.addLinkUrlInput)
13893
- .fill(linkUrl);
13894
- await this.page
13895
- .getByTestId(NEETO_EDITOR_SELECTORS.addLinkDoneButton)
13896
- .click();
13897
- const linkRole = DESCRIPTION_EDITOR_TEXTS.link;
13898
- await expect(editorWrapper
13899
- .getByTestId(NEETO_EDITOR_SELECTORS.contentField)
13900
- .getByRole(linkRole)).toBeVisible();
13901
- await this.page.getByTestId(NEETO_EDITOR_SELECTORS.unlinkButton).click();
13902
- }
13903
- if (await this.editorAttachmentsButton.isVisible()) {
13904
- const fileUploaderPromise = this.page.waitForEvent("filechooser");
13905
- await this.editorAttachmentsButton.click();
13906
- const fileUploader = await fileUploaderPromise;
13907
- const imagePath = Path.join(__dirname, filePath);
13908
- await fileUploader.setFiles(imagePath);
13909
- await this.neetoPlaywrightUtilities.interceptMultipleResponses({
13910
- responseUrl: ROUTES.attachment,
13911
- });
13912
- await this.neetoPlaywrightUtilities.verifyToast();
13913
- await expect(this.attachmentPreview).toBeVisible();
13914
- await this.attachmentPreview
13915
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
13916
- .click();
13917
- await this.page
13918
- .getByTestId(NEETO_EDITOR_SELECTORS.attachmentPreviewDeleteButton)
13919
- .click();
13920
- await this.page
13921
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
13922
- .click();
13923
- await this.neetoPlaywrightUtilities.verifyToast({
13924
- message: ATTACHMENT_DELETION_TOASTR_MESSAGE,
13925
- });
13926
- }
13927
- if (await this.imageUploadOption.isVisible()) {
13928
- await this.imageUploadOption.click();
13929
- const fileUploaderPromise = this.page.waitForEvent("filechooser");
13930
- await this.page
13931
- .getByTestId(NEETO_EDITOR_SELECTORS.imageUploadButton)
13932
- .click();
13933
- const fileUploader = await fileUploaderPromise;
13934
- const imagePath = Path.join(__dirname, filePath);
13935
- await fileUploader.setFiles(imagePath);
13936
- await expect(this.imageWrapper).toBeVisible({ timeout: 15000 });
13937
- await this.imageWrapper
13938
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
13939
- .click();
13940
- await this.imageUploadDeleteButton.click();
13941
- await expect(this.imageWrapper).toBeHidden({
13942
- timeout: 15000,
13943
- });
13944
- await this.imageUploadOption.click();
13945
- await this.page
13946
- .getByTestId(NEETO_EDITOR_SELECTORS.imageUploadLinkButton)
13947
- .click();
13948
- await this.page
13949
- .getByTestId(NEETO_EDITOR_SELECTORS.imageUploadLinkInput)
13950
- .fill(imageUrl);
13951
- await this.page
13952
- .getByTestId(NEETO_EDITOR_SELECTORS.imageUploadLinkSubmitButton)
13953
- .click();
13954
- await expect(this.imageWrapper).toBeVisible({ timeout: 15000 });
13955
- await this.imageWrapper
13956
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
13957
- .click();
13958
- await this.imageUploadDeleteButton.click();
13959
- await expect(this.imageWrapper).toBeHidden({
13960
- timeout: 15000,
13961
- });
13962
- }
13963
- if (await this.cannedResponseOption.isVisible()) {
13964
- await this.cannedResponseOption.click();
13965
- await expect(this.page.getByTestId(COMMON_SELECTORS.paneHeader)).toContainText(DESCRIPTION_EDITOR_TEXTS.cannedResponseHeader);
13966
- await this.page
13967
- .getByTestId(NEETO_EDITOR_SELECTORS.cannedResponseSelectContainer)
13968
- .fill(this.t("neetoRules.labels.feedback"));
13969
- await this.page
13970
- .getByTestId(COMMON_SELECTORS.selectOption(this.t("neetoRules.labels.feedback")))
13971
- .click();
13972
- await this.page.getByTestId(NEETO_EDITOR_SELECTORS.applyButton).click();
13973
- await this.neetoPlaywrightUtilities.verifyToast({
13974
- message: cannedResponseSuccessMessage,
13975
- });
13976
- }
13977
- if (await editorWrapper
13978
- .getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedOption)
13979
- .isVisible()) {
13980
- await this.videoEmbedOption.click();
13981
- await this.videoEmbedInput.fill(videoUrl);
13982
- await this.page
13983
- .getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedSubmit)
13984
- .click();
13985
- await expect(this.videoWrapperSelector).toBeVisible({ timeout: 15000 });
13986
- await this.videoWrapperSelector
13987
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
13988
- .click();
13989
- await this.imageUploadDeleteButton.click();
13990
- await expect(this.videoWrapperSelector).toBeHidden({
13991
- timeout: 15000,
13992
- });
13993
- }
13994
- if (await this.emojiDropdownIcon.isVisible()) {
13995
- await this.emojiDropdownIcon.click();
13885
+ };
13886
+ this.verifyEditorLinkButton = async (linkUrl) => {
13887
+ await this.editorLinkButton.click();
13888
+ await this.page
13889
+ .getByTestId(NEETO_EDITOR_SELECTORS.addLinkUrlInput)
13890
+ .fill(linkUrl);
13891
+ await this.page
13892
+ .getByTestId(NEETO_EDITOR_SELECTORS.addLinkDoneButton)
13893
+ .click();
13894
+ const linkRole = DESCRIPTION_EDITOR_TEXTS.link;
13895
+ await expect(this.contentField.getByRole(linkRole)).toBeVisible();
13896
+ await this.page.getByTestId(NEETO_EDITOR_SELECTORS.unlinkButton).click();
13897
+ };
13898
+ this.verifyEditorAttachmentsButton = async (filePath) => {
13899
+ const fileUploaderPromise = this.page.waitForEvent("filechooser");
13900
+ await this.editorAttachmentsButton.click();
13901
+ const fileUploader = await fileUploaderPromise;
13902
+ const imagePath = Path.join(__dirname, filePath);
13903
+ await fileUploader.setFiles(imagePath);
13904
+ await this.neetoPlaywrightUtilities.interceptMultipleResponses({
13905
+ responseUrl: ROUTES.attachment,
13906
+ });
13907
+ await this.neetoPlaywrightUtilities.verifyToast();
13908
+ await expect(this.attachmentPreview).toBeVisible();
13909
+ await this.attachmentPreview
13910
+ .getByTestId(COMMON_SELECTORS.dropdownIcon)
13911
+ .click();
13912
+ await this.page
13913
+ .getByTestId(NEETO_EDITOR_SELECTORS.attachmentPreviewDeleteButton)
13914
+ .click();
13915
+ await this.page
13916
+ .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
13917
+ .click();
13918
+ await this.neetoPlaywrightUtilities.verifyToast({
13919
+ message: ATTACHMENT_DELETION_TOASTR_MESSAGE,
13920
+ });
13921
+ };
13922
+ this.verifyImageUploadOption = async ({ imageUrl, filePath, }) => {
13923
+ await this.imageUploadOption.click();
13924
+ const fileUploaderPromise = this.page.waitForEvent("filechooser");
13925
+ await this.page
13926
+ .getByTestId(NEETO_EDITOR_SELECTORS.imageUploadButton)
13927
+ .click();
13928
+ const fileUploader = await fileUploaderPromise;
13929
+ const imagePath = Path.join(__dirname, filePath);
13930
+ await fileUploader.setFiles(imagePath);
13931
+ await expect(this.imageWrapper).toBeVisible({ timeout: 15000 });
13932
+ await this.imageWrapper.getByTestId(COMMON_SELECTORS.dropdownIcon).click();
13933
+ await this.imageUploadDeleteButton.click();
13934
+ await expect(this.imageWrapper).toBeHidden({
13935
+ timeout: 15000,
13936
+ });
13937
+ await this.imageUploadOption.click();
13938
+ await this.page
13939
+ .getByTestId(NEETO_EDITOR_SELECTORS.imageUploadLinkButton)
13940
+ .click();
13941
+ await this.page
13942
+ .getByTestId(NEETO_EDITOR_SELECTORS.imageUploadLinkInput)
13943
+ .fill(imageUrl);
13944
+ await this.page
13945
+ .getByTestId(NEETO_EDITOR_SELECTORS.imageUploadLinkSubmitButton)
13946
+ .click();
13947
+ await expect(this.imageWrapper).toBeVisible({ timeout: 15000 });
13948
+ await this.imageWrapper.getByTestId(COMMON_SELECTORS.dropdownIcon).click();
13949
+ await this.imageUploadDeleteButton.click();
13950
+ await expect(this.imageWrapper).toBeHidden({
13951
+ timeout: 15000,
13952
+ });
13953
+ };
13954
+ this.verifyCannedResponseOption = async (cannedResponseSuccessMessage) => {
13955
+ await this.cannedResponseOption.click();
13956
+ await expect(this.page.getByTestId(COMMON_SELECTORS.paneHeader)).toContainText(DESCRIPTION_EDITOR_TEXTS.cannedResponseHeader);
13957
+ await this.page
13958
+ .getByTestId(NEETO_EDITOR_SELECTORS.cannedResponseSelectContainer)
13959
+ .fill(this.t("neetoRules.labels.feedback"));
13960
+ await this.page
13961
+ .getByTestId(COMMON_SELECTORS.selectOption(this.t("neetoRules.labels.feedback")))
13962
+ .click();
13963
+ await this.page.getByTestId(NEETO_EDITOR_SELECTORS.applyButton).click();
13964
+ await this.neetoPlaywrightUtilities.verifyToast({
13965
+ message: cannedResponseSuccessMessage,
13966
+ });
13967
+ };
13968
+ this.verifyVideoEmbedOption = async (videoUrl) => {
13969
+ await this.videoEmbedOption.click();
13970
+ await this.videoEmbedInput.fill(videoUrl);
13971
+ await this.page
13972
+ .getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedSubmit)
13973
+ .click();
13974
+ await expect(this.videoWrapperSelector).toBeVisible({ timeout: 15000 });
13975
+ await this.videoWrapperSelector
13976
+ .getByTestId(COMMON_SELECTORS.dropdownIcon)
13977
+ .click();
13978
+ await this.imageUploadDeleteButton.click();
13979
+ await expect(this.videoWrapperSelector).toBeHidden({
13980
+ timeout: 15000,
13981
+ });
13982
+ };
13983
+ this.verifyEmojiSelector = async () => {
13984
+ await this.emojiSelector.click();
13985
+ const emojiContainer = this.page.getByTestId(NEETO_EDITOR_SELECTORS.emojiContainer);
13986
+ await expect(emojiContainer).toBeVisible({
13987
+ timeout: 10000,
13988
+ });
13989
+ await emojiContainer
13990
+ .getByPlaceholder(DESCRIPTION_EDITOR_TEXTS.search)
13991
+ .fill(EMOJI_LABEL);
13992
+ await this.page.keyboard.press("Enter");
13993
+ await expect(this.contentField).toContainText("👍");
13994
+ await this.page.keyboard.press("Escape");
13995
+ };
13996
+ this.verifyDynamicVariables = async (dynamicVariables) => {
13997
+ for (const dynamicVariable of dynamicVariables) {
13998
+ await this.dynamicVariablesButton.click();
13999
+ await expect(this.page.getByTestId(COMMON_SELECTORS.dropdownContainer)).toBeVisible();
13996
14000
  await this.page
13997
- .getByRole("button", { name: DESCRIPTION_EDITOR_TEXTS.emoji })
14001
+ .getByTestId(NEETO_EDITOR_SELECTORS.dynamicVariableSelector(dynamicVariable))
13998
14002
  .click();
13999
- await expect(this.page.getByTestId(NEETO_EDITOR_SELECTORS.emojiContainer)).toBeVisible({
14000
- timeout: 10000,
14001
- });
14002
- await this.page
14003
- .getByTestId(NEETO_EDITOR_SELECTORS.emojiContainer)
14004
- .getByPlaceholder(DESCRIPTION_EDITOR_TEXTS.search)
14005
- .fill(EMOJI_LABEL);
14006
- await this.page.keyboard.press("Enter");
14007
- await expect(editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.contentField)).toContainText("👍");
14008
- await this.page.keyboard.press("Escape");
14003
+ await expect(this.contentField.getByText(dynamicVariable)).toBeVisible();
14009
14004
  }
14010
- if (dynamicVariables &&
14011
- (await editorWrapper
14012
- .getByTestId(NEETO_EDITOR_SELECTORS.dynamicVariablesButton)
14013
- .isVisible())) {
14014
- for (const dynamicVariable of dynamicVariables) {
14015
- await editorWrapper
14016
- .getByTestId(NEETO_EDITOR_SELECTORS.dynamicVariablesButton)
14017
- .click();
14018
- await expect(this.page.getByTestId(COMMON_SELECTORS.dropdownContainer)).toBeVisible();
14019
- await this.page
14020
- .getByTestId(NEETO_EDITOR_SELECTORS.dynamicVariableSelector(dynamicVariable))
14021
- .click();
14022
- await expect(editorWrapper
14023
- .getByTestId(NEETO_EDITOR_SELECTORS.contentField)
14024
- .getByText(dynamicVariable)).toBeVisible();
14025
- }
14005
+ };
14006
+ this.verifyDescriptionEditor = async ({ text, dynamicVariables, defaultFontSizeOption = "Paragraph", linkUrl = faker.internet.url(), filePath = "../../../e2e/assets/images/BigBinary.png", imageUrl = "https://picsum.photos/200/300", videoUrl = "https://youtu.be/jNQXAC9IVRw", cannedResponseSuccessMessage, }) => {
14007
+ await this.contentField.fill(text);
14008
+ await this.verifyFontSize(defaultFontSizeOption);
14009
+ if (await this.assertOptionVisibility(this.paragraphSelector)) {
14010
+ await this.paragraphSelector.click();
14011
+ const paragraphRole = DESCRIPTION_EDITOR_TEXTS.paragraphOption;
14012
+ await expect(this.contentField.getByRole(paragraphRole)).toBeVisible();
14026
14013
  }
14014
+ (await this.fixedMenuArrowSelector.isVisible()) &&
14015
+ (await this.fixedMenuArrowSelector.click());
14016
+ await this.editorWrapper.getByText(text).click({ clickCount: 3 });
14017
+ await this.verifyTextModifiers();
14018
+ await this.verifyTextDeskModifier();
14019
+ await this.verifyListModifiers();
14020
+ (await this.assertOptionVisibility(this.editorLinkButton)) &&
14021
+ (await this.verifyEditorLinkButton(linkUrl));
14022
+ (await this.assertOptionVisibility(this.editorAttachmentsButton)) &&
14023
+ (await this.verifyEditorAttachmentsButton(filePath));
14024
+ (await this.assertOptionVisibility(this.imageUploadOption)) &&
14025
+ (await this.verifyImageUploadOption({
14026
+ imageUrl,
14027
+ filePath,
14028
+ }));
14029
+ (await this.assertOptionVisibility(this.cannedResponseOption)) &&
14030
+ (await this.verifyCannedResponseOption(cannedResponseSuccessMessage));
14031
+ (await this.assertOptionVisibility(this.videoEmbedOption)) &&
14032
+ (await this.verifyVideoEmbedOption(videoUrl));
14033
+ (await this.assertOptionVisibility(this.emojiSelector)) &&
14034
+ (await this.verifyEmojiSelector());
14035
+ dynamicVariables &&
14036
+ (await this.assertOptionVisibility(this.dynamicVariablesButton)) &&
14037
+ (await this.verifyDynamicVariables(dynamicVariables));
14027
14038
  };
14028
14039
  this.page = page;
14029
14040
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
14030
14041
  this.t = getI18nInstance().t;
14031
- this.paragraphSelector = this.page.getByTestId(NEETO_EDITOR_SELECTORS.paragraphOption);
14032
- this.fixedMenuArrowSelector = this.page.getByTestId(NEETO_EDITOR_SELECTORS.fixedMenuArrow);
14033
- this.editorLinkButton = this.page.getByTestId(NEETO_EDITOR_SELECTORS.linkOption);
14034
- this.attachmentPreview = this.page.getByTestId(NEETO_EDITOR_SELECTORS.attachmentPreview);
14035
- this.editorAttachmentsButton = this.page.getByTestId(NEETO_EDITOR_SELECTORS.editorAttachmentsButton);
14036
- this.imageWrapper = this.page.getByTestId(NEETO_EDITOR_SELECTORS.imageWrapper);
14037
- this.imageUploadDeleteButton = this.page.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadDeleteButton);
14038
- this.imageUploadOption = this.page.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadOption);
14039
- this.cannedResponseOption = this.page.getByTestId(NEETO_EDITOR_SELECTORS.cannedResponseOption);
14040
- this.videoEmbedOption = this.page.getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedOption);
14042
+ this.editorWrapper = this.page;
14043
+ if (editorWrapper)
14044
+ this.editorWrapper = editorWrapper;
14045
+ this.paragraphSelector = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.paragraphOption);
14046
+ this.fixedMenuArrowSelector = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.fixedMenuArrow);
14047
+ this.editorLinkButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.linkOption);
14048
+ this.attachmentPreview = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.attachmentPreview);
14049
+ this.editorAttachmentsButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.editorAttachmentsButton);
14050
+ this.imageWrapper = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.imageWrapper);
14051
+ this.imageUploadDeleteButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadDeleteButton);
14052
+ this.imageUploadOption = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadOption);
14053
+ this.cannedResponseOption = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.cannedResponseOption);
14054
+ this.videoEmbedOption = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedOption);
14041
14055
  this.videoEmbedInput = this.page.getByTestId(NEETO_EDITOR_SELECTORS.videoEmbedInput);
14042
- this.videoWrapperSelector = this.page.getByTestId(NEETO_EDITOR_SELECTORS.videoWrapper);
14043
- this.emojiDropdownIcon = this.page
14044
- .getByTestId(NEETO_EDITOR_SELECTORS.fixedMenuWrapper)
14045
- .getByTestId(COMMON_SELECTORS.dropdownIcon);
14056
+ this.videoWrapperSelector = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.videoWrapper);
14057
+ this.emojiSelector = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.emojiOption);
14058
+ this.moreMenuSelector = this.editorWrapper.getByTestId(COMMON_SELECTORS.dropdownIcon);
14059
+ this.contentField = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.contentField);
14060
+ this.dynamicVariablesButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.dynamicVariablesButton);
14046
14061
  }
14047
14062
  }
14048
14063