@bigbinary/neeto-playwright-commons 3.0.4 → 3.0.6
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 +42 -18
- package/index.cjs.js.map +1 -1
- package/index.d.ts +56 -49
- package/index.js +42 -18
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -340,23 +340,6 @@ class MemberApis {
|
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
const NEETO_EMAIL_DELIVERY_TESTING_BASE_URL = "/neeto_email_delivery/api/v1/testing";
|
|
344
|
-
class NeetoEmailDeliveryApi {
|
|
345
|
-
neetoPlaywrightUtilities;
|
|
346
|
-
constructor(neetoPlaywrightUtilities) {
|
|
347
|
-
this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
|
|
348
|
-
}
|
|
349
|
-
connect = ({ ownerId, ...payload }) => this.neetoPlaywrightUtilities.apiRequest({
|
|
350
|
-
method: "post",
|
|
351
|
-
url: `${NEETO_EMAIL_DELIVERY_TESTING_BASE_URL}/connect`,
|
|
352
|
-
body: neetoCist.keysToSnakeCase({ ownerId, connect: payload }),
|
|
353
|
-
});
|
|
354
|
-
verifyEmail = (params) => this.neetoPlaywrightUtilities.apiRequest({
|
|
355
|
-
url: `${NEETO_EMAIL_DELIVERY_TESTING_BASE_URL}/verify_email`,
|
|
356
|
-
params: neetoCist.keysToSnakeCase(params),
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
|
|
360
343
|
class RailsEmailApiClient {
|
|
361
344
|
port = process.env.RAILS_SERVER_PORT;
|
|
362
345
|
subdomain = process.env.SUBDOMAIN ?? "spinkart";
|
|
@@ -414,6 +397,7 @@ class RailsEmailApiClient {
|
|
|
414
397
|
clearEmails = () => this.fetchJson(this.emailsEndpoint, {
|
|
415
398
|
method: "DELETE",
|
|
416
399
|
});
|
|
400
|
+
clearStaleEmails = (receivedBefore) => this.fetchJson(`${this.emailsEndpoint}?received_before=${encodeURIComponent(receivedBefore)}`, { method: "DELETE" });
|
|
417
401
|
}
|
|
418
402
|
|
|
419
403
|
class RoleApis {
|
|
@@ -60474,7 +60458,14 @@ class RailsEmailUtils {
|
|
|
60474
60458
|
};
|
|
60475
60459
|
};
|
|
60476
60460
|
clearEmails = () => this.railsEmailClient.clearEmails();
|
|
60477
|
-
|
|
60461
|
+
clearStaleEmails = () => {
|
|
60462
|
+
const tenMinutesAgo = new Date(Date.now() - 10 * 60 * 1000);
|
|
60463
|
+
return this.railsEmailClient.clearStaleEmails(tenMinutesAgo.toISOString());
|
|
60464
|
+
};
|
|
60465
|
+
getLatestEmail = async (searchParams) => {
|
|
60466
|
+
await this.clearStaleEmails();
|
|
60467
|
+
await this.railsEmailClient.getLatestEmail(searchParams);
|
|
60468
|
+
};
|
|
60478
60469
|
listEmails = (searchParams) => this.railsEmailClient.listEmails(searchParams);
|
|
60479
60470
|
listMessages = async (messageSearchCriteria = {}, { receivedAfter = new Date(new Date().valueOf() - 60 * 60 * 1000), } = {}) => {
|
|
60480
60471
|
const emails = await this.railsEmailClient.listEmails({
|
|
@@ -107404,6 +107395,7 @@ const commands = {
|
|
|
107404
107395
|
const mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
|
|
107405
107396
|
await mailerUtils.fastmailApi.authorizeAndSetAccountId();
|
|
107406
107397
|
await use(mailerUtils);
|
|
107398
|
+
IS_DEV_ENV && (await mailerUtils.railsEmailUtils.clearStaleEmails());
|
|
107407
107399
|
},
|
|
107408
107400
|
colorPicker: async ({ page }, use) => {
|
|
107409
107401
|
const colorPicker = new ColorPickerUtils(page);
|
|
@@ -125288,6 +125280,23 @@ class NeetoAuthServer {
|
|
|
125288
125280
|
};
|
|
125289
125281
|
}
|
|
125290
125282
|
|
|
125283
|
+
const NEETO_EMAIL_DELIVERY_TESTING_BASE_URL = "/neeto_email_delivery/api/v1/testing";
|
|
125284
|
+
class NeetoEmailDeliveryApi {
|
|
125285
|
+
neetoPlaywrightUtilities;
|
|
125286
|
+
constructor(neetoPlaywrightUtilities) {
|
|
125287
|
+
this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
|
|
125288
|
+
}
|
|
125289
|
+
connect = ({ ownerId, ...payload }) => this.neetoPlaywrightUtilities.apiRequest({
|
|
125290
|
+
method: "post",
|
|
125291
|
+
url: `${NEETO_EMAIL_DELIVERY_TESTING_BASE_URL}/connect`,
|
|
125292
|
+
body: neetoCist.keysToSnakeCase({ ownerId, connect: payload }),
|
|
125293
|
+
});
|
|
125294
|
+
verifyEmail = (params) => this.neetoPlaywrightUtilities.apiRequest({
|
|
125295
|
+
url: `${NEETO_EMAIL_DELIVERY_TESTING_BASE_URL}/verify_email`,
|
|
125296
|
+
params: neetoCist.keysToSnakeCase(params),
|
|
125297
|
+
});
|
|
125298
|
+
}
|
|
125299
|
+
|
|
125291
125300
|
const REFRESH_TOKEN_ENV_KEYS = {
|
|
125292
125301
|
gmail: "EMAIL_DELIVERY_GMAIL_REFRESH_TOKEN",
|
|
125293
125302
|
outlook: "EMAIL_DELIVERY_OUTLOOK_REFRESH_TOKEN",
|
|
@@ -125295,6 +125304,7 @@ const REFRESH_TOKEN_ENV_KEYS = {
|
|
|
125295
125304
|
const FROM_EMAIL_ENV_KEYS = {
|
|
125296
125305
|
gmail: "EMAIL_DELIVERY_CONNECTED_GMAIL",
|
|
125297
125306
|
outlook: "EMAIL_DELIVERY_CONNECTED_OUTLOOK",
|
|
125307
|
+
sparkpost: "EMAIL_DELIVERY_CONNECTED_SPARKPOST",
|
|
125298
125308
|
};
|
|
125299
125309
|
class EmailDeliveryUtils {
|
|
125300
125310
|
neetoPlaywrightUtilities;
|
|
@@ -125304,6 +125314,20 @@ class EmailDeliveryUtils {
|
|
|
125304
125314
|
this.emailDeliveryApi = new NeetoEmailDeliveryApi(neetoPlaywrightUtilities);
|
|
125305
125315
|
}
|
|
125306
125316
|
connectViaRequest = async ({ provider, ownerId }) => {
|
|
125317
|
+
if (provider === "sparkpost") {
|
|
125318
|
+
const sparkpostEmailEnvKey = FROM_EMAIL_ENV_KEYS.sparkpost;
|
|
125319
|
+
const email = process.env[sparkpostEmailEnvKey];
|
|
125320
|
+
if (ramda.isNil(email)) {
|
|
125321
|
+
throw new Error(`ENV variable ${sparkpostEmailEnvKey} is not properly configured`);
|
|
125322
|
+
}
|
|
125323
|
+
const response = await this.emailDeliveryApi.connect({
|
|
125324
|
+
emailProvider: "sparkpost",
|
|
125325
|
+
email,
|
|
125326
|
+
ownerId,
|
|
125327
|
+
});
|
|
125328
|
+
test.expect(response?.ok()).toBeTruthy();
|
|
125329
|
+
return response;
|
|
125330
|
+
}
|
|
125307
125331
|
const refreshTokenEnvKey = REFRESH_TOKEN_ENV_KEYS[provider];
|
|
125308
125332
|
const refreshToken = process.env[refreshTokenEnvKey];
|
|
125309
125333
|
if (ramda.isNil(refreshToken)) {
|