@bigbinary/neeto-playwright-commons 1.9.2 → 1.9.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.cjs.js CHANGED
@@ -7,12 +7,12 @@ var child_process = require('child_process');
7
7
  var fs$d = require('fs');
8
8
  var ramda = require('ramda');
9
9
  var require$$0$2 = require('util');
10
+ var Path = require('path');
10
11
  var faker = require('@faker-js/faker');
11
12
  var MailosaurClient = require('mailosaur');
12
13
  var dayjs = require('dayjs');
13
14
  var require$$1$1 = require('tty');
14
15
  var require$$0$3 = require('os');
15
- var Path = require('path');
16
16
  var Stream$4 = require('stream');
17
17
  var require$$0$4 = require('events');
18
18
  var playwrightI18nextFixture = require('playwright-i18next-fixture');
@@ -53,11 +53,11 @@ var test__default = /*#__PURE__*/_interopDefaultLegacy(test$1);
53
53
  var fs__namespace = /*#__PURE__*/_interopNamespace(fs$d);
54
54
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$d);
55
55
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
56
+ var Path__default = /*#__PURE__*/_interopDefaultLegacy(Path);
56
57
  var MailosaurClient__default = /*#__PURE__*/_interopDefaultLegacy(MailosaurClient);
57
58
  var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
58
59
  var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
59
60
  var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
60
- var Path__default = /*#__PURE__*/_interopDefaultLegacy(Path);
61
61
  var Stream__default = /*#__PURE__*/_interopDefaultLegacy(Stream$4);
62
62
  var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
63
63
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http$1);
@@ -72,6 +72,58 @@ var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
72
72
  var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4$1);
73
73
  var require$$3__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$3$2);
74
74
 
75
+ const BASE_URL = "/api/v1";
76
+ const NEETO_AUTH_BASE_URL = (subdomain = "app") => `https://${subdomain}.neetoauth.net`;
77
+ const ROUTES = {
78
+ neetoAuthSignup: `${NEETO_AUTH_BASE_URL()}/signups/new`,
79
+ neetoAuth: NEETO_AUTH_BASE_URL(),
80
+ loginLink: "/login",
81
+ profile: "/profile",
82
+ admin: "/admin",
83
+ myProfile: "/my/profile",
84
+ authSettings: "/settings",
85
+ webhooks: "/webhooks",
86
+ login: `${BASE_URL}/login`,
87
+ signup: `${BASE_URL}/signups`,
88
+ subdomainAvailability: `${BASE_URL}/subdomain_availability`,
89
+ countries: `${BASE_URL}/countries`,
90
+ neetoApps: `${BASE_URL}/neeto_apps`,
91
+ directUploads: "/direct_uploads",
92
+ teamMembers: {
93
+ all: "/team_members*/**",
94
+ bulkUpdate: "/team_members/teams/bulk_update",
95
+ index: "/team_members/teams",
96
+ show: (id) => `/team_members/teams/${id}`,
97
+ },
98
+ };
99
+ const API_ROUTES = {
100
+ teamMembers: {
101
+ all: "/team_members*/**",
102
+ bulkUpdate: "/team_members/teams/bulk_update",
103
+ index: "/team_members/teams",
104
+ show: (id) => `/team_members/teams/${id}`,
105
+ },
106
+ integrations: {
107
+ zapier: {
108
+ api_keys: "/neeto_integrations/zapier/api_keys",
109
+ },
110
+ },
111
+ };
112
+ const THIRD_PARTY_ROUTES = {
113
+ webhooks: { site: "https://webhook.site/" },
114
+ slack: {
115
+ loginWithPassword: (workspace) => `https://${workspace}.slack.com/sign_in_with_password`,
116
+ },
117
+ zapier: {
118
+ login: "https://zapier.com/app/login",
119
+ logOut: "https://zapier.com/logout",
120
+ zapEditor: (zapId) => `https://zapier.com/editor/${zapId}`,
121
+ },
122
+ };
123
+ const NEETO_ROUTES = {
124
+ imageUploader: "/neeto_image_uploader_engine",
125
+ };
126
+
75
127
  const NEETO_FILTERS_SELECTORS = {
76
128
  emailSelectContainer: "email-select-container-wrapper",
77
129
  filterPaneHeading: "neeto-filters-pane-header",
@@ -91,6 +143,34 @@ const NEETO_FILTERS_SELECTORS = {
91
143
  searchTermBlock: "neeto-filters-search-term-block",
92
144
  };
93
145
 
146
+ const NEETO_IMAGE_UPLOADER_SELECTORS = {
147
+ imageUploaderWrapper: "image-uploader-wrapper",
148
+ browseText: "neeto-image-uploader-browse-text",
149
+ fileInput: "neeto-image-uploader-file-input",
150
+ uploadedImage: "uploaded-image",
151
+ uploadNewAsset: "upload-new-asset",
152
+ basicImageUploaderRemoveButton: "basic-image-uploader-remove-button",
153
+ removeButton: "image-uploader-remove-button",
154
+ openImageLibraryButton: "image-uploader-open-image-library-button",
155
+ openAssetLibraryButton: "open-asset-library-button",
156
+ imageEditorBackButton: "image-editor-back-button",
157
+ aspectRatioWidthInput: "aspect-ratio-width-input",
158
+ aspectRatioHeightInput: "aspect-ratio-height-input",
159
+ cropSubmitButton: "neeto-image-uploader-crop-submit-button",
160
+ restrictionMessage: "neeto-image-uploader-restriction-message",
161
+ progressBar: "neeto-image-uploader-progress-bar",
162
+ myImagesTab: "neeto-image-uploader-my-images-tab",
163
+ unsplashTab: "neeto-image-uploader-unsplash-tab",
164
+ nthLibraryImage: (index) => `niu-library-image-${index}`,
165
+ nthUnsplashImage: (index) => `niu-unsplash-image-${index}`,
166
+ unsplashSearchInput: "niu-unsplash-image-picker-search-input",
167
+ imageEditorUploadedImage: "image-editor-uploaded-image",
168
+ selectOriginalImageSwitch: "select-original-image-switch",
169
+ lockAspectRatioSwitch: "lock-aspect-ratio-switch",
170
+ widthInputField: "width-input-field",
171
+ heightInputField: "height-input-field",
172
+ };
173
+
94
174
  const ENVIRONMENT = {
95
175
  development: "development",
96
176
  staging: "staging",
@@ -2550,6 +2630,12 @@ var lib$7 = {
2550
2630
 
2551
2631
  var qs$1 = /*@__PURE__*/getDefaultExportFromCjs(lib$7);
2552
2632
 
2633
+ const getImagePathAndName = (localImagePath) => {
2634
+ const imagePath = Path__default["default"].join(__dirname, localImagePath);
2635
+ const imageName = Path__default["default"].basename(localImagePath, Path__default["default"].extname(localImagePath));
2636
+ return { imagePath, imageName };
2637
+ };
2638
+
2553
2639
  class CustomCommands {
2554
2640
  constructor(page, request, baseURL = process.env.BASE_URL) {
2555
2641
  this.interceptMultipleResponses = ({ responseUrl = "", responseStatus = 200, times = 1, baseUrl, customPageContext, timeout = 35000, } = {}) => {
@@ -2664,6 +2750,20 @@ class CustomCommands {
2664
2750
  await test$1.expect(this.page.getByTestId(countSelector)).toContainText(countText);
2665
2751
  }).toPass({ timeout: 15000 });
2666
2752
  };
2753
+ this.uploadImage = async (localImagePath) => {
2754
+ const { imageName, imagePath } = getImagePathAndName(localImagePath);
2755
+ await this.page
2756
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.browseText)
2757
+ .click();
2758
+ const uploadFile = this.interceptMultipleResponses({
2759
+ responseUrl: ROUTES.directUploads,
2760
+ });
2761
+ await this.page
2762
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.fileInput)
2763
+ .setInputFiles(imagePath);
2764
+ await uploadFile;
2765
+ await test$1.expect(this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.uploadedImage)).toHaveAttribute("src", new RegExp(imageName), { timeout: 20000 });
2766
+ };
2667
2767
  this.page = page;
2668
2768
  this.responses = [];
2669
2769
  this.request = request;
@@ -12594,54 +12694,6 @@ class EmbedBase {
12594
12694
  }
12595
12695
  }
12596
12696
 
12597
- const BASE_URL = "/api/v1";
12598
- const NEETO_AUTH_BASE_URL = (subdomain = "app") => `https://${subdomain}.neetoauth.net`;
12599
- const ROUTES = {
12600
- neetoAuthSignup: `${NEETO_AUTH_BASE_URL()}/signups/new`,
12601
- neetoAuth: NEETO_AUTH_BASE_URL(),
12602
- loginLink: "/login",
12603
- profile: "/profile",
12604
- admin: "/admin",
12605
- myProfile: "/my/profile",
12606
- authSettings: "/settings",
12607
- webhooks: "/webhooks",
12608
- login: `${BASE_URL}/login`,
12609
- signup: `${BASE_URL}/signups`,
12610
- subdomainAvailability: `${BASE_URL}/subdomain_availability`,
12611
- countries: `${BASE_URL}/countries`,
12612
- neetoApps: `${BASE_URL}/neeto_apps`,
12613
- teamMembers: {
12614
- all: "/team_members*/**",
12615
- bulkUpdate: "/team_members/teams/bulk_update",
12616
- index: "/team_members/teams",
12617
- show: (id) => `/team_members/teams/${id}`,
12618
- },
12619
- };
12620
- const API_ROUTES = {
12621
- teamMembers: {
12622
- all: "/team_members*/**",
12623
- bulkUpdate: "/team_members/teams/bulk_update",
12624
- index: "/team_members/teams",
12625
- show: (id) => `/team_members/teams/${id}`,
12626
- },
12627
- integrations: {
12628
- zapier: {
12629
- api_keys: "/neeto_integrations/zapier/api_keys",
12630
- },
12631
- },
12632
- };
12633
- const THIRD_PARTY_ROUTES = {
12634
- webhooks: { site: "https://webhook.site/" },
12635
- slack: {
12636
- loginWithPassword: (workspace) => `https://${workspace}.slack.com/sign_in_with_password`,
12637
- },
12638
- zapier: {
12639
- login: "https://zapier.com/app/login",
12640
- logOut: "https://zapier.com/logout",
12641
- zapEditor: (zapId) => `https://zapier.com/editor/${zapId}`,
12642
- },
12643
- };
12644
-
12645
12697
  const CHAT_WIDGET_TEXTS = {
12646
12698
  newConversation: "New Conversation",
12647
12699
  welcomeChatBubble: "Hi! I'm here to assist you with any questions you may have. What can I do for you?",
@@ -13526,6 +13578,147 @@ class ZapierPage extends IntegrationBase {
13526
13578
  }
13527
13579
  }
13528
13580
 
13581
+ class ImageUploader {
13582
+ constructor({ page, neetoPlaywrightUtilities, }) {
13583
+ this.submitCroppedImage = async () => {
13584
+ const cropImage = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13585
+ responseUrl: ROUTES.directUploads,
13586
+ });
13587
+ await this.page
13588
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.cropSubmitButton)
13589
+ .click();
13590
+ await cropImage;
13591
+ };
13592
+ this.removeImage = async () => {
13593
+ await this.page
13594
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.imageUploaderWrapper)
13595
+ .getByTestId(COMMON_SELECTORS.dropdownIcon)
13596
+ .click();
13597
+ await this.page
13598
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.removeButton)
13599
+ .click();
13600
+ await test$1.expect(this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.uploadedImage)).toBeHidden();
13601
+ };
13602
+ this.openImageLibrary = async () => {
13603
+ const fetchImages = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13604
+ responseUrl: NEETO_ROUTES.imageUploader,
13605
+ });
13606
+ await this.page
13607
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.openAssetLibraryButton)
13608
+ .click();
13609
+ await fetchImages;
13610
+ };
13611
+ this.cropImage = async ({ toggleAspectRatioLock = false, width = "100", height = "100", aspectRatioHeight = "9", aspectRatioWidth = "16", } = {}) => {
13612
+ toggleAspectRatioLock &&
13613
+ (await this.page
13614
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.lockAspectRatioSwitch)
13615
+ .click());
13616
+ await this.page
13617
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.aspectRatioHeightInput)
13618
+ .fill(aspectRatioHeight);
13619
+ await this.page
13620
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.aspectRatioWidthInput)
13621
+ .fill(aspectRatioWidth);
13622
+ await this.page
13623
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.widthInputField)
13624
+ .fill(width);
13625
+ await this.page
13626
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.heightInputField)
13627
+ .fill(height);
13628
+ };
13629
+ this.uploadNewImageFromLibrary = async ({ localImagePath, toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", }) => {
13630
+ await this.openImageLibrary();
13631
+ const fileUploaderPromise = this.page.waitForEvent("filechooser");
13632
+ await this.page
13633
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.uploadNewAsset)
13634
+ .click();
13635
+ const fileUploader = await fileUploaderPromise;
13636
+ const { imagePath, imageName } = getImagePathAndName(localImagePath);
13637
+ await fileUploader.setFiles(imagePath);
13638
+ await test$1.expect(this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.imageEditorUploadedImage)).toHaveAttribute("src", new RegExp(imageName), { timeout: 20000 });
13639
+ toggleOrginalImage
13640
+ ? await this.page
13641
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
13642
+ .click()
13643
+ : await this.cropImage({
13644
+ toggleAspectRatioLock,
13645
+ aspectRatioHeight,
13646
+ aspectRatioWidth,
13647
+ width,
13648
+ height,
13649
+ });
13650
+ await this.submitCroppedImage();
13651
+ };
13652
+ this.selectImageFromWeb = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
13653
+ await this.openImageLibrary();
13654
+ const switchImageTab = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13655
+ responseUrl: NEETO_ROUTES.imageUploader,
13656
+ });
13657
+ await this.page
13658
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashTab)
13659
+ .click();
13660
+ await switchImageTab;
13661
+ if (neetoCist.isNotEmpty(searchTerm)) {
13662
+ await this.page
13663
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
13664
+ .fill(searchTerm);
13665
+ await test$1.expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
13666
+ timeout: 10000,
13667
+ });
13668
+ }
13669
+ await this.page
13670
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthUnsplashImage(nthImage))
13671
+ .click();
13672
+ await test$1.expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
13673
+ timeout: 10000,
13674
+ });
13675
+ toggleOrginalImage
13676
+ ? await this.page
13677
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
13678
+ .click()
13679
+ : await this.cropImage({
13680
+ toggleAspectRatioLock,
13681
+ aspectRatioHeight,
13682
+ aspectRatioWidth,
13683
+ width,
13684
+ height,
13685
+ });
13686
+ await this.submitCroppedImage();
13687
+ };
13688
+ this.selectImageFromLibrary = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
13689
+ await this.openImageLibrary();
13690
+ await test$1.expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
13691
+ timeout: 10000,
13692
+ });
13693
+ if (neetoCist.isNotEmpty(searchTerm)) {
13694
+ await this.page
13695
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
13696
+ .fill(searchTerm);
13697
+ await test$1.expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
13698
+ timeout: 10000,
13699
+ });
13700
+ }
13701
+ await this.page
13702
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthLibraryImage(nthImage))
13703
+ .click();
13704
+ toggleOrginalImage
13705
+ ? await this.page
13706
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
13707
+ .click()
13708
+ : await this.cropImage({
13709
+ toggleAspectRatioLock,
13710
+ aspectRatioHeight,
13711
+ aspectRatioWidth,
13712
+ width,
13713
+ height,
13714
+ });
13715
+ await this.submitCroppedImage();
13716
+ };
13717
+ this.page = page;
13718
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
13719
+ }
13720
+ }
13721
+
13529
13722
  const LOGIN_SELECTORS = {
13530
13723
  appleAuthenticationButton: "apple-authentication-button",
13531
13724
  emailTextField: "login-email-text-field",
@@ -147548,6 +147741,7 @@ exports.HelpAndProfilePage = HelpAndProfilePage;
147548
147741
  exports.INTEGRATIONS_TEXTS = INTEGRATIONS_TEXTS;
147549
147742
  exports.INTEGRATION_SELECTORS = INTEGRATION_SELECTORS;
147550
147743
  exports.IS_STAGING_ENV = IS_STAGING_ENV;
147744
+ exports.ImageUploader = ImageUploader;
147551
147745
  exports.IntegrationBase = IntegrationBase;
147552
147746
  exports.KEYBOARD_SHORTCUTS_SELECTORS = KEYBOARD_SHORTCUTS_SELECTORS;
147553
147747
  exports.LOGIN_SELECTORS = LOGIN_SELECTORS;
@@ -147559,6 +147753,8 @@ exports.MailosaurUtils = MailosaurUtils;
147559
147753
  exports.NEETO_AUTH_BASE_URL = NEETO_AUTH_BASE_URL;
147560
147754
  exports.NEETO_EDITOR_SELECTORS = NEETO_EDITOR_SELECTORS;
147561
147755
  exports.NEETO_FILTERS_SELECTORS = NEETO_FILTERS_SELECTORS;
147756
+ exports.NEETO_IMAGE_UPLOADER_SELECTORS = NEETO_IMAGE_UPLOADER_SELECTORS;
147757
+ exports.NEETO_ROUTES = NEETO_ROUTES;
147562
147758
  exports.OTP_EMAIL_PATTERN = OTP_EMAIL_PATTERN;
147563
147759
  exports.OrganizationPage = OrganizationPage;
147564
147760
  exports.PROFILE_SECTION_SELECTORS = PROFILE_SECTION_SELECTORS;
@@ -147596,6 +147792,7 @@ exports.generateRandomBypassEmail = generateRandomBypassEmail;
147596
147792
  exports.generateStagingData = generateStagingData;
147597
147793
  exports.getByDataQA = getByDataQA;
147598
147794
  exports.getGlobalUserState = getGlobalUserState;
147795
+ exports.getImagePathAndName = getImagePathAndName;
147599
147796
  exports.headerUtils = headerUtils;
147600
147797
  exports.hexToRGB = hexToRGB;
147601
147798
  exports.hyphenize = hyphenize;