@bigbinary/neeto-playwright-commons 2.2.5 → 2.3.0
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/README.md +1 -0
- package/index.cjs.js +85 -0
- package/index.cjs.js.map +1 -1
- package/index.d.ts +76 -2
- package/index.js +84 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -130,6 +130,7 @@ import { COMMON_SELECTORS } from "@bigbinary/neeto-playwright-common";
|
|
|
130
130
|
- [Routes](./docs/routes.md)
|
|
131
131
|
- [Custom commands](./docs/custom-commands.md)
|
|
132
132
|
- [MailerUtils](./docs/utils/mailer-utils.md)
|
|
133
|
+
- [EmailDeliveryUtils](./docs/utils/email-delivery-utils.md)
|
|
133
134
|
- [NeetoAuthServer](./docs/utils/neeto-auth-server.md)
|
|
134
135
|
- [Util functions](./docs/utils)
|
|
135
136
|
- [POMs](./docs/poms)
|
package/index.cjs.js
CHANGED
|
@@ -247,6 +247,25 @@ class MemberApis {
|
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
const NEETO_EMAIL_DELIVERY_TESTING_BASE_URL = "/neeto_email_delivery/api/v1/testing";
|
|
251
|
+
class NeetoEmailDeliveryApi {
|
|
252
|
+
neetoPlaywrightUtilities;
|
|
253
|
+
constructor(neetoPlaywrightUtilities) {
|
|
254
|
+
this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
|
|
255
|
+
}
|
|
256
|
+
connect = (payload) => this.neetoPlaywrightUtilities.apiRequest({
|
|
257
|
+
method: "post",
|
|
258
|
+
url: `${NEETO_EMAIL_DELIVERY_TESTING_BASE_URL}/connect`,
|
|
259
|
+
body: {
|
|
260
|
+
connect: neetoCist.keysToSnakeCase(payload),
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
verifyEmail = (params) => this.neetoPlaywrightUtilities.apiRequest({
|
|
264
|
+
url: `${NEETO_EMAIL_DELIVERY_TESTING_BASE_URL}/verify_email`,
|
|
265
|
+
params: neetoCist.keysToSnakeCase(params),
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
250
269
|
class RailsEmailApiClient {
|
|
251
270
|
port = process.env.RAILS_SERVER_PORT;
|
|
252
271
|
subdomain = process.env.SUBDOMAIN ?? "spinkart";
|
|
@@ -121461,6 +121480,70 @@ class TagsPage {
|
|
|
121461
121480
|
};
|
|
121462
121481
|
}
|
|
121463
121482
|
|
|
121483
|
+
const REFRESH_TOKEN_ENV_KEYS = {
|
|
121484
|
+
gmail: "EMAIL_DELIVERY_GMAIL_REFRESH_TOKEN",
|
|
121485
|
+
outlook: "EMAIL_DELIVERY_OUTLOOK_REFRESH_TOKEN",
|
|
121486
|
+
};
|
|
121487
|
+
const FROM_EMAIL_ENV_KEYS = {
|
|
121488
|
+
gmail: "EMAIL_DELIVERY_CONNECTED_GMAIL",
|
|
121489
|
+
outlook: "EMAIL_DELIVERY_CONNECTED_OUTLOOK",
|
|
121490
|
+
};
|
|
121491
|
+
class EmailDeliveryUtils {
|
|
121492
|
+
neetoPlaywrightUtilities;
|
|
121493
|
+
emailDeliveryApi;
|
|
121494
|
+
constructor(neetoPlaywrightUtilities) {
|
|
121495
|
+
this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
|
|
121496
|
+
this.emailDeliveryApi = new NeetoEmailDeliveryApi(neetoPlaywrightUtilities);
|
|
121497
|
+
}
|
|
121498
|
+
connectViaRequest = async ({ provider }) => {
|
|
121499
|
+
const refreshTokenEnvKey = REFRESH_TOKEN_ENV_KEYS[provider];
|
|
121500
|
+
const refreshToken = process.env[refreshTokenEnvKey];
|
|
121501
|
+
if (ramda.isNil(refreshToken)) {
|
|
121502
|
+
throw new Error(`ENV variable ${refreshTokenEnvKey} is not properly configured`);
|
|
121503
|
+
}
|
|
121504
|
+
const response = await this.emailDeliveryApi.connect({
|
|
121505
|
+
emailProvider: provider,
|
|
121506
|
+
refreshToken,
|
|
121507
|
+
});
|
|
121508
|
+
test.expect(response?.ok()).toBeTruthy();
|
|
121509
|
+
return response;
|
|
121510
|
+
};
|
|
121511
|
+
verifyEmailViaRequest = async ({ subject, to, partialBody, from }, { provider, timeout = 30 * 1000, shouldThrowErrorOnTimeout = true, }) => {
|
|
121512
|
+
const fromEmail = from ?? process.env[FROM_EMAIL_ENV_KEYS[provider]];
|
|
121513
|
+
if (ramda.isNil(fromEmail)) {
|
|
121514
|
+
throw new Error(`ENV variable ${FROM_EMAIL_ENV_KEYS[provider]} is not properly configured`);
|
|
121515
|
+
}
|
|
121516
|
+
const verifyParams = {
|
|
121517
|
+
emailProvider: provider,
|
|
121518
|
+
subject,
|
|
121519
|
+
to,
|
|
121520
|
+
from: fromEmail,
|
|
121521
|
+
body: partialBody,
|
|
121522
|
+
};
|
|
121523
|
+
let lastResult = null;
|
|
121524
|
+
const fetchEmail = async () => {
|
|
121525
|
+
const response = await this.emailDeliveryApi.verifyEmail(verifyParams);
|
|
121526
|
+
if (!response?.ok()) {
|
|
121527
|
+
lastResult = null;
|
|
121528
|
+
return;
|
|
121529
|
+
}
|
|
121530
|
+
lastResult = (await response.json());
|
|
121531
|
+
};
|
|
121532
|
+
const email = (await this.neetoPlaywrightUtilities.executeRecursively({
|
|
121533
|
+
condition: async () => {
|
|
121534
|
+
await fetchEmail();
|
|
121535
|
+
return Boolean(lastResult?.exists);
|
|
121536
|
+
},
|
|
121537
|
+
callback: async () => lastResult?.exists ? (lastResult.email ?? null) : null,
|
|
121538
|
+
timeout,
|
|
121539
|
+
}));
|
|
121540
|
+
if (!email && shouldThrowErrorOnTimeout) {
|
|
121541
|
+
throw new Error(`Timed out waiting for ${provider} email matching subject "${subject}"`);
|
|
121542
|
+
}
|
|
121543
|
+
return email;
|
|
121544
|
+
};
|
|
121545
|
+
}
|
|
121546
|
+
|
|
121464
121547
|
const USER_AGENTS = {
|
|
121465
121548
|
windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
|
|
121466
121549
|
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",
|
|
@@ -126025,6 +126108,7 @@ exports.EXAMPLE_URL = EXAMPLE_URL;
|
|
|
126025
126108
|
exports.EXPANDED_FONT_SIZE = EXPANDED_FONT_SIZE;
|
|
126026
126109
|
exports.EXPORT_FILE_TYPES = EXPORT_FILE_TYPES;
|
|
126027
126110
|
exports.EditorPage = EditorPage;
|
|
126111
|
+
exports.EmailDeliveryUtils = EmailDeliveryUtils;
|
|
126028
126112
|
exports.EmbedBase = EmbedBase;
|
|
126029
126113
|
exports.FILE_FORMATS = FILE_FORMATS;
|
|
126030
126114
|
exports.FONT_SIZE_SELECTORS = FONT_SIZE_SELECTORS;
|
|
@@ -126070,6 +126154,7 @@ exports.NEETO_ROUTES = NEETO_ROUTES;
|
|
|
126070
126154
|
exports.NEETO_SEO_SELECTORS = NEETO_SEO_SELECTORS;
|
|
126071
126155
|
exports.NEETO_TEXT_MODIFIER_SELECTORS = NEETO_TEXT_MODIFIER_SELECTORS;
|
|
126072
126156
|
exports.NeetoAuthServer = NeetoAuthServer;
|
|
126157
|
+
exports.NeetoEmailDeliveryApi = NeetoEmailDeliveryApi;
|
|
126073
126158
|
exports.NeetoTowerApi = NeetoTowerApi;
|
|
126074
126159
|
exports.ONBOARDING_SELECTORS = ONBOARDING_SELECTORS;
|
|
126075
126160
|
exports.ORGANIZATION_TEXTS = ORGANIZATION_TEXTS;
|