@bigbinary/neeto-playwright-commons 3.0.1 → 3.0.2

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
@@ -253,12 +253,10 @@ class NeetoEmailDeliveryApi {
253
253
  constructor(neetoPlaywrightUtilities) {
254
254
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
255
255
  }
256
- connect = (payload) => this.neetoPlaywrightUtilities.apiRequest({
256
+ connect = ({ ownerId, ...payload }) => this.neetoPlaywrightUtilities.apiRequest({
257
257
  method: "post",
258
258
  url: `${NEETO_EMAIL_DELIVERY_TESTING_BASE_URL}/connect`,
259
- body: {
260
- connect: neetoCist.keysToSnakeCase(payload),
261
- },
259
+ body: neetoCist.keysToSnakeCase({ ownerId, connect: payload }),
262
260
  });
263
261
  verifyEmail = (params) => this.neetoPlaywrightUtilities.apiRequest({
264
262
  url: `${NEETO_EMAIL_DELIVERY_TESTING_BASE_URL}/verify_email`,
@@ -121483,70 +121481,6 @@ class TagsPage {
121483
121481
  };
121484
121482
  }
121485
121483
 
121486
- const REFRESH_TOKEN_ENV_KEYS = {
121487
- gmail: "EMAIL_DELIVERY_GMAIL_REFRESH_TOKEN",
121488
- outlook: "EMAIL_DELIVERY_OUTLOOK_REFRESH_TOKEN",
121489
- };
121490
- const FROM_EMAIL_ENV_KEYS = {
121491
- gmail: "EMAIL_DELIVERY_CONNECTED_GMAIL",
121492
- outlook: "EMAIL_DELIVERY_CONNECTED_OUTLOOK",
121493
- };
121494
- class EmailDeliveryUtils {
121495
- neetoPlaywrightUtilities;
121496
- emailDeliveryApi;
121497
- constructor(neetoPlaywrightUtilities) {
121498
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
121499
- this.emailDeliveryApi = new NeetoEmailDeliveryApi(neetoPlaywrightUtilities);
121500
- }
121501
- connectViaRequest = async ({ provider }) => {
121502
- const refreshTokenEnvKey = REFRESH_TOKEN_ENV_KEYS[provider];
121503
- const refreshToken = process.env[refreshTokenEnvKey];
121504
- if (ramda.isNil(refreshToken)) {
121505
- throw new Error(`ENV variable ${refreshTokenEnvKey} is not properly configured`);
121506
- }
121507
- const response = await this.emailDeliveryApi.connect({
121508
- emailProvider: provider,
121509
- refreshToken,
121510
- });
121511
- test.expect(response?.ok()).toBeTruthy();
121512
- return response;
121513
- };
121514
- verifyEmailViaRequest = async ({ subject, to, partialBody, from }, { provider, timeout = 30 * 1000, shouldThrowErrorOnTimeout = true, }) => {
121515
- const fromEmail = from ?? process.env[FROM_EMAIL_ENV_KEYS[provider]];
121516
- if (ramda.isNil(fromEmail)) {
121517
- throw new Error(`ENV variable ${FROM_EMAIL_ENV_KEYS[provider]} is not properly configured`);
121518
- }
121519
- const verifyParams = {
121520
- emailProvider: provider,
121521
- subject,
121522
- to,
121523
- from: fromEmail,
121524
- body: partialBody,
121525
- };
121526
- let lastResult = null;
121527
- const fetchEmail = async () => {
121528
- const response = await this.emailDeliveryApi.verifyEmail(verifyParams);
121529
- if (!response?.ok()) {
121530
- lastResult = null;
121531
- return;
121532
- }
121533
- lastResult = (await response.json());
121534
- };
121535
- const email = (await this.neetoPlaywrightUtilities.executeRecursively({
121536
- condition: async () => {
121537
- await fetchEmail();
121538
- return Boolean(lastResult?.exists);
121539
- },
121540
- callback: async () => lastResult?.exists ? (lastResult.email ?? null) : null,
121541
- timeout,
121542
- }));
121543
- if (!email && shouldThrowErrorOnTimeout) {
121544
- throw new Error(`Timed out waiting for ${provider} email matching subject "${subject}"`);
121545
- }
121546
- return email;
121547
- };
121548
- }
121549
-
121550
121484
  const USER_AGENTS = {
121551
121485
  windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
121552
121486
  mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
@@ -125247,6 +125181,72 @@ class NeetoAuthServer {
125247
125181
  };
125248
125182
  }
125249
125183
 
125184
+ const REFRESH_TOKEN_ENV_KEYS = {
125185
+ gmail: "EMAIL_DELIVERY_GMAIL_REFRESH_TOKEN",
125186
+ outlook: "EMAIL_DELIVERY_OUTLOOK_REFRESH_TOKEN",
125187
+ };
125188
+ const FROM_EMAIL_ENV_KEYS = {
125189
+ gmail: "EMAIL_DELIVERY_CONNECTED_GMAIL",
125190
+ outlook: "EMAIL_DELIVERY_CONNECTED_OUTLOOK",
125191
+ };
125192
+ class EmailDeliveryUtils {
125193
+ neetoPlaywrightUtilities;
125194
+ emailDeliveryApi;
125195
+ constructor(neetoPlaywrightUtilities) {
125196
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
125197
+ this.emailDeliveryApi = new NeetoEmailDeliveryApi(neetoPlaywrightUtilities);
125198
+ }
125199
+ connectViaRequest = async ({ provider, ownerId }) => {
125200
+ const refreshTokenEnvKey = REFRESH_TOKEN_ENV_KEYS[provider];
125201
+ const refreshToken = process.env[refreshTokenEnvKey];
125202
+ if (ramda.isNil(refreshToken)) {
125203
+ throw new Error(`ENV variable ${refreshTokenEnvKey} is not properly configured`);
125204
+ }
125205
+ const response = await this.emailDeliveryApi.connect({
125206
+ emailProvider: provider,
125207
+ refreshToken,
125208
+ ownerId,
125209
+ });
125210
+ test.expect(response?.ok()).toBeTruthy();
125211
+ return response;
125212
+ };
125213
+ verifyEmailViaRequest = async ({ subject, to, partialBody, from }, { provider, ownerId, timeout = 30 * 1000, shouldThrowErrorOnTimeout = true, }) => {
125214
+ const fromEmail = from ?? process.env[FROM_EMAIL_ENV_KEYS[provider]];
125215
+ if (ramda.isNil(fromEmail)) {
125216
+ throw new Error(`ENV variable ${FROM_EMAIL_ENV_KEYS[provider]} is not properly configured`);
125217
+ }
125218
+ const verifyParams = {
125219
+ emailProvider: provider,
125220
+ subject,
125221
+ to,
125222
+ from: fromEmail,
125223
+ body: partialBody,
125224
+ ownerId,
125225
+ };
125226
+ let lastResult = null;
125227
+ const fetchEmail = async () => {
125228
+ const response = await this.emailDeliveryApi.verifyEmail(verifyParams);
125229
+ if (!response?.ok()) {
125230
+ lastResult = null;
125231
+ return;
125232
+ }
125233
+ lastResult = (await response.json());
125234
+ };
125235
+ const email = (await this.neetoPlaywrightUtilities.executeRecursively({
125236
+ condition: async () => {
125237
+ await fetchEmail();
125238
+ return Boolean(lastResult?.exists);
125239
+ },
125240
+ callback: async () => lastResult?.exists ? (lastResult.email ?? null) : null,
125241
+ timeout,
125242
+ }));
125243
+ if (!email && shouldThrowErrorOnTimeout) {
125244
+ throw new Error(`Timed out waiting for ${provider} email matching subject "${subject}"`);
125245
+ }
125246
+ return email;
125247
+ };
125248
+ }
125249
+
125250
125250
  var main$1 = {exports: {}};
125251
125251
 
125252
125252
  var version = "17.3.1";
@@ -126114,6 +126114,7 @@ exports.EmailDeliveryUtils = EmailDeliveryUtils;
126114
126114
  exports.EmbedBase = EmbedBase;
126115
126115
  exports.FILE_FORMATS = FILE_FORMATS;
126116
126116
  exports.FONT_SIZE_SELECTORS = FONT_SIZE_SELECTORS;
126117
+ exports.FROM_EMAIL_ENV_KEYS = FROM_EMAIL_ENV_KEYS;
126117
126118
  exports.GLOBAL_TRANSLATIONS_PATTERN = GLOBAL_TRANSLATIONS_PATTERN;
126118
126119
  exports.GOOGLE_ANALYTICS_SELECTORS = GOOGLE_ANALYTICS_SELECTORS;
126119
126120
  exports.GOOGLE_CALENDAR_DATE_FORMAT = GOOGLE_CALENDAR_DATE_FORMAT;