@bigbinary/neeto-playwright-commons 3.0.0 → 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.
@@ -0,0 +1,128 @@
1
+ import neeto from "@bigbinary/eslint-plugin-neeto";
2
+ import js from "@eslint/js";
3
+ import tsEslint from "@typescript-eslint/eslint-plugin";
4
+ import tsParser from "@typescript-eslint/parser";
5
+ import playwrightPlugin from "eslint-plugin-playwright";
6
+ import importPlugin from "eslint-plugin-import";
7
+ import globals from "globals";
8
+ import path from "path";
9
+
10
+ const commonEslintConfig = ({
11
+ ignores = [],
12
+ extendsOverrides = [],
13
+ overrideRules = {},
14
+ tsconfigRootDir = "",
15
+ }) => {
16
+ const configs = [
17
+ js.configs.recommended,
18
+ {
19
+ ignores: [...ignores],
20
+ },
21
+
22
+ {
23
+ files: ["**/*.ts", "**/*.spec.ts"],
24
+ ignores: ["**/*.d.ts"],
25
+ languageOptions: {
26
+ parser: tsParser,
27
+ parserOptions: {
28
+ ecmaVersion: "latest",
29
+ sourceType: "module",
30
+ tsconfigRootDir,
31
+ project: ["./tsconfig.json"],
32
+ },
33
+ globals: {
34
+ ...globals.browser,
35
+ ...globals.es2021,
36
+ ...globals.node,
37
+ },
38
+ },
39
+ plugins: {
40
+ "@typescript-eslint": tsEslint,
41
+ playwright: playwrightPlugin,
42
+ import: importPlugin,
43
+ "@bigbinary/neeto": neeto,
44
+ },
45
+ rules: {
46
+ ...tsEslint.configs.recommended.rules,
47
+ ...playwrightPlugin.configs.recommended.rules,
48
+
49
+ "@bigbinary/neeto/use-dayjs-from-neeto-commons-fronted": "off",
50
+ "@bigbinary/neeto/use-array-methods": "off",
51
+ "@typescript-eslint/no-floating-promises": "error",
52
+ "no-unused-vars": "off",
53
+ "@typescript-eslint/no-unused-vars": [
54
+ "error",
55
+ { destructuredArrayIgnorePattern: "^_" },
56
+ ],
57
+ "@typescript-eslint/no-explicit-any": [
58
+ "error",
59
+ { ignoreRestArgs: true },
60
+ ],
61
+ "@typescript-eslint/no-unused-expressions": [
62
+ "error",
63
+ { allowShortCircuit: true, allowTernary: true },
64
+ ],
65
+
66
+ "playwright/expect-expect": "off",
67
+ "playwright/no-conditional-in-test": "warn",
68
+ "playwright/no-nth-methods": "error",
69
+ "playwright/no-page-pause": "error",
70
+ "playwright/no-raw-locators": "warn",
71
+ "playwright/no-useless-await": "error",
72
+ "playwright/no-useless-not": "error",
73
+ "playwright/no-wait-for-timeout": "error",
74
+ "playwright/prefer-strict-equal": "warn",
75
+ "playwright/prefer-to-be": "warn",
76
+ "playwright/prefer-to-contain": "error",
77
+ "playwright/prefer-to-have-count": "error",
78
+ "playwright/prefer-to-have-length": "error",
79
+ "playwright/prefer-web-first-assertions": "error",
80
+ "playwright/require-top-level-describe": "error",
81
+ "playwright/require-soft-assertions": "off",
82
+ "playwright/valid-expect": "error",
83
+ "playwright/no-standalone-expect": "warn",
84
+ "playwright/valid-title": [
85
+ "warn",
86
+ { mustMatch: { test: "^(must|should)" }, ignoreTypeOfStepName: true },
87
+ ],
88
+ "playwright/prefer-lowercase-title": [
89
+ "error",
90
+ { ignoreTopLevelDescribe: true, allowedPrefixes: ["Step"] },
91
+ ],
92
+ "import/order": [
93
+ "error",
94
+ {
95
+ "newlines-between": "always",
96
+ alphabetize: { order: "asc", caseInsensitive: true },
97
+ warnOnUnassignedImports: true,
98
+ groups: [
99
+ "builtin",
100
+ "external",
101
+ "internal",
102
+ "index",
103
+ "sibling",
104
+ "parent",
105
+ "object",
106
+ "type",
107
+ ],
108
+ },
109
+ ],
110
+ ...overrideRules,
111
+ },
112
+ settings: {
113
+ "import/resolver": {
114
+ typescript: {
115
+ alwaysTryTypes: true,
116
+ project: path.join(tsconfigRootDir, "tsconfig.json"),
117
+ },
118
+ },
119
+ },
120
+ },
121
+
122
+ ...extendsOverrides,
123
+ ];
124
+
125
+ return configs;
126
+ };
127
+
128
+ export default commonEslintConfig;
@@ -0,0 +1,42 @@
1
+ import path from "path";
2
+ import eslintConfig from "./common.js";
3
+ import { fileURLToPath } from "url";
4
+ import { dirname } from "path";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+
9
+ const hostEslintConfig = ({ rules = {}, tsconfigRootDir = "", ignores }) => {
10
+ return eslintConfig({
11
+ tsconfigRootDir,
12
+ overrideRules: {
13
+ "import/named": "off",
14
+ "react-hooks/rules-of-hooks": "off",
15
+ "@bigbinary/neeto/no-missing-localization": [
16
+ "warn",
17
+ {
18
+ translationsDir: path.resolve(
19
+ __dirname,
20
+ "../../../../../..",
21
+ "app/javascript/src/translations"
22
+ ),
23
+ languages: ["en"],
24
+ nanosTranslationDir: [
25
+ path.resolve(
26
+ __dirname,
27
+ "../../../../../..",
28
+ "node_modules/@bigbinary/neeto-commons-frontend/translations"
29
+ ),
30
+ ],
31
+ },
32
+ ],
33
+ "@bigbinary/neeto/use-standard-date-time-formats": "warn",
34
+ "@bigbinary/neeto/no-dangling-constants": "off",
35
+ "@bigbinary/neeto/use-webpack-alias": "off",
36
+ ...rules,
37
+ },
38
+ ignores,
39
+ });
40
+ };
41
+
42
+ export default hostEslintConfig;
@@ -0,0 +1,41 @@
1
+ import { complement, startsWith } from "ramda";
2
+
3
+ export const REMARK_NODE_TYPES = {
4
+ HTML: "html",
5
+ PARAGRAPH: "paragraph",
6
+ CODE: "code",
7
+ HEADING: "heading",
8
+ TEXT: "text",
9
+ INLINE_CODE: "inlineCode",
10
+ };
11
+
12
+ export const BABEL_NODE_TYPES = { IDENTIFIER: "Identifier" };
13
+
14
+ export const SUBHEADING_PATTERN = { type: REMARK_NODE_TYPES.HEADING, depth: 2 };
15
+ export const HTML_PATTERN = { type: REMARK_NODE_TYPES.HTML };
16
+ export const IMG_PATTERN = {
17
+ type: REMARK_NODE_TYPES.HTML,
18
+ value: startsWith("<img"),
19
+ };
20
+ export const CODE_PATTERN = { type: REMARK_NODE_TYPES.CODE };
21
+ export const PARAGRAPH_PATTERN = { type: REMARK_NODE_TYPES.PARAGRAPH };
22
+ export const HTML_EXCEPT_IMG_PATTERN = {
23
+ type: REMARK_NODE_TYPES.HTML,
24
+ value: complement(startsWith("<img")),
25
+ };
26
+ export const INLINE_CODE_PATTERN = { type: REMARK_NODE_TYPES.INLINE_CODE };
27
+ export const TEXT_PATTERN = { type: REMARK_NODE_TYPES.TEXT };
28
+ export const DOCS_FOLDER_NAME = "docs";
29
+ export const TYPES_FOLDER_NAME = "typeTemplates";
30
+ export const EXPORTED_TYPES_FOLDER_NAME = "."; // root
31
+
32
+ export const JSDOC_IMG_HEIGHT = "200";
33
+ export const JSDOC_IMG_WIDTH = "300";
34
+
35
+ export const DOUBLE_LINE_BREAK_WITH_LEADING_COMMENT = "\n *\n";
36
+ export const LINE_BREAK = "\n";
37
+ export const JSDOC_EXAMPLE_TAG = "@example ";
38
+ export const JSDOC_END_EXAMPLE_TAG = "@endexample";
39
+ export const ASTERISK = "*";
40
+ export const ASTERISK_WITH_SPACES = " * ";
41
+ export const WHITESPACE_PARENTHESIS_REGEX = /[\s()]/g;
@@ -0,0 +1,257 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ import * as babelParser from "@babel/parser";
5
+ import { mergeLeft } from "ramda";
6
+ import remarkParse from "remark-parse";
7
+ import { unified } from "unified";
8
+
9
+ import {
10
+ ASTERISK,
11
+ ASTERISK_WITH_SPACES,
12
+ CODE_PATTERN,
13
+ DOUBLE_LINE_BREAK_WITH_LEADING_COMMENT,
14
+ HTML_EXCEPT_IMG_PATTERN,
15
+ IMG_PATTERN,
16
+ JSDOC_EXAMPLE_TAG,
17
+ JSDOC_END_EXAMPLE_TAG,
18
+ JSDOC_IMG_HEIGHT,
19
+ JSDOC_IMG_WIDTH,
20
+ LINE_BREAK,
21
+ PARAGRAPH_PATTERN,
22
+ SUBHEADING_PATTERN,
23
+ TYPES_FOLDER_NAME,
24
+ WHITESPACE_PARENTHESIS_REGEX,
25
+ } from "./constants.mjs";
26
+ import * as babelTypes from "@babel/types";
27
+ import _traverse from "@babel/traverse";
28
+ import _generate from "@babel/generator";
29
+
30
+ import { matches } from "@bigbinary/neeto-cist";
31
+ import { endsWith } from "ramda";
32
+
33
+ const traverse = _traverse.default;
34
+ const generate = _generate.default;
35
+
36
+ const removeWhiteSpaceAndParentheses = string =>
37
+ string.replace(WHITESPACE_PARENTHESIS_REGEX, "");
38
+
39
+ const addLeadingCommentForTextWithLineBreaks = ({
40
+ text,
41
+ addCommentForFirstItem = true,
42
+ addDoubleLineBreaks = true,
43
+ }) => {
44
+ if (!hasLineBreaks(text)) return addLeadingComment(text);
45
+ const joinString = addDoubleLineBreaks
46
+ ? DOUBLE_LINE_BREAK_WITH_LEADING_COMMENT
47
+ : LINE_BREAK;
48
+
49
+ return text
50
+ .split(LINE_BREAK)
51
+ .map((item, idx) => {
52
+ if (!addCommentForFirstItem && idx === 0) return item;
53
+
54
+ return addLeadingComment(item);
55
+ })
56
+ .join(joinString);
57
+ };
58
+
59
+ const addLeadingComment = (text, trimWhiteSpace = false) =>
60
+ (trimWhiteSpace ? ASTERISK : ASTERISK_WITH_SPACES) + text;
61
+
62
+ const transformCode = node => {
63
+ let text = "";
64
+ text += addLeadingComment(JSDOC_EXAMPLE_TAG);
65
+ text += DOUBLE_LINE_BREAK_WITH_LEADING_COMMENT;
66
+ text += addLeadingCommentForTextWithLineBreaks({
67
+ text: removeCommentTags(node.value),
68
+ addDoubleLineBreaks: false,
69
+ });
70
+ text += LINE_BREAK;
71
+ text += addLeadingComment(JSDOC_END_EXAMPLE_TAG);
72
+ text += LINE_BREAK;
73
+
74
+ return text;
75
+ };
76
+
77
+ const hasLineBreaks = text => text?.includes(LINE_BREAK);
78
+
79
+ const getParagraphChildrenText = node => {
80
+ const children = node.children;
81
+ if (children.length === 1) return children[0].value;
82
+
83
+ return children
84
+ .map(child => child.value || child.children?.[0]?.value)
85
+ .join("");
86
+ };
87
+
88
+ const transformParagraph = node => {
89
+ let text = "";
90
+ text += ASTERISK_WITH_SPACES;
91
+ const childrenText = getParagraphChildrenText(node);
92
+
93
+ if (hasLineBreaks(childrenText)) {
94
+ text += addLeadingCommentForTextWithLineBreaks({
95
+ text: childrenText,
96
+ addCommentForFirstItem: false,
97
+ });
98
+ } else {
99
+ text += childrenText;
100
+ }
101
+ text += DOUBLE_LINE_BREAK_WITH_LEADING_COMMENT;
102
+
103
+ return text;
104
+ };
105
+
106
+ const transformImg = node => {
107
+ const { src, alt } = parseImgTag(node.value);
108
+ let text = ASTERISK_WITH_SPACES;
109
+ text += `![${alt}](${src}|height=${JSDOC_IMG_HEIGHT}|width=${JSDOC_IMG_WIDTH})`;
110
+ text += DOUBLE_LINE_BREAK_WITH_LEADING_COMMENT;
111
+
112
+ return text;
113
+ };
114
+
115
+ const transformNodesToText = nodes => {
116
+ let text = DOUBLE_LINE_BREAK_WITH_LEADING_COMMENT;
117
+
118
+ nodes.forEach(node => {
119
+ if (matches(CODE_PATTERN, node)) {
120
+ text += transformCode(node);
121
+ } else if (matches(IMG_PATTERN, node)) {
122
+ text += transformImg(node);
123
+ } else if (matches(PARAGRAPH_PATTERN, node)) {
124
+ text += transformParagraph(node);
125
+ }
126
+ });
127
+
128
+ return addLeadingComment(text, true);
129
+ };
130
+
131
+ const parseImgTag = imgTagStr =>
132
+ imgTagStr.split(" ").reduce((acc, item) => {
133
+ let [attrName, attrValue] = item.split("=");
134
+ attrValue = attrValue?.replaceAll(">", "").replaceAll('"', "");
135
+
136
+ return mergeLeft({ [attrName]: attrValue }, acc);
137
+ }, {});
138
+
139
+ const removeCommentTags = str => str.replaceAll("/*", "").replaceAll("*/", "");
140
+
141
+ export const parseTypeFile = typeFileContent =>
142
+ babelParser.parse(typeFileContent, {
143
+ sourceType: "module",
144
+ plugins: [["typescript", { dts: true }]],
145
+ });
146
+
147
+ export const buildEntityTitleToEntityDescMap = (nodes, map) => {
148
+ nodes.forEach((node, idx) => {
149
+ if (!matches(SUBHEADING_PATTERN, node)) return;
150
+
151
+ const entityName = removeWhiteSpaceAndParentheses(node.children[0].value);
152
+ const entityRightSiblings = [];
153
+
154
+ for (let i = idx + 1; i < nodes.length; i++) {
155
+ const siblingNode = nodes[i];
156
+
157
+ if (matches(HTML_EXCEPT_IMG_PATTERN, siblingNode)) continue;
158
+
159
+ if (matches(SUBHEADING_PATTERN, siblingNode)) break;
160
+
161
+ entityRightSiblings.push(siblingNode);
162
+ }
163
+ const entityRightSiblingsText = transformNodesToText(entityRightSiblings);
164
+ map[entityName] = entityRightSiblingsText;
165
+ });
166
+ };
167
+
168
+ export const syncTypeFiles = exportedTypesFolderName => {
169
+ const sourceDir = path.resolve(TYPES_FOLDER_NAME);
170
+ const destDir = path.resolve(exportedTypesFolderName);
171
+
172
+ fs.cpSync(sourceDir, destDir, { recursive: true });
173
+ };
174
+
175
+ export const getFileNameList = dirPath => {
176
+ let files = [];
177
+ const items = fs.readdirSync(dirPath, { withFileTypes: true });
178
+
179
+ for (const item of items) {
180
+ if (item.isDirectory()) {
181
+ files = [...files, ...getFileNameList(path.join(dirPath, item.name))];
182
+ } else {
183
+ files.push(path.join(dirPath, item.name));
184
+ }
185
+ }
186
+
187
+ return files;
188
+ };
189
+
190
+ export const getFileContent = fileName =>
191
+ fs.readFileSync(path.resolve(fileName), "utf8").toString();
192
+
193
+ export const parseMarkdown = fileContent =>
194
+ unified().use(remarkParse).parse(fileContent);
195
+
196
+ export const defaultTypeFileTraverser = options => {
197
+ traverse(options.typeFileAST, {
198
+ VariableDeclaration: ({ node }) =>
199
+ handleNode({
200
+ node,
201
+ options,
202
+ extractEntityName: findVariableDeclarationName,
203
+ }),
204
+ ClassProperty: ({ node }) =>
205
+ handleNode({ node, options, extractEntityName: findClassPropertyName }),
206
+ });
207
+ };
208
+
209
+ export const findVariableDeclarationName = node =>
210
+ node?.declarations?.[0]?.id?.name || node?.declaration?.id?.name;
211
+
212
+ export const isUtil = entityName => endsWith("Utils", entityName);
213
+
214
+ export const findClassPropertyName = node => node?.key?.name;
215
+
216
+ export const handleEntity = (
217
+ node,
218
+ entityTitleToDescMapOfAllFiles,
219
+ entityName
220
+ ) => {
221
+ const entityDesc = entityTitleToDescMapOfAllFiles[entityName];
222
+
223
+ if (!entityName || !entityDesc) {
224
+ return;
225
+ }
226
+
227
+ babelTypes.addComment(node, "leading", entityDesc);
228
+ };
229
+
230
+ export const handleUtilityMethods = (node, entityTitleToDescMapOfAllFiles) => {
231
+ const members =
232
+ node?.declarations?.[0]?.id?.typeAnnotation?.typeAnnotation?.members;
233
+
234
+ members?.map(methodNode => {
235
+ handleEntity(
236
+ methodNode,
237
+ entityTitleToDescMapOfAllFiles,
238
+ methodNode.key.name
239
+ );
240
+ });
241
+ };
242
+
243
+ export const handleNode = ({
244
+ node,
245
+ extractEntityName,
246
+ options: { entityTitleToDescMapOfAllFiles, typeFileName, typeFileAST },
247
+ }) => {
248
+ const entityName = extractEntityName(node);
249
+
250
+ isUtil(entityName)
251
+ ? handleUtilityMethods(node, entityTitleToDescMapOfAllFiles)
252
+ : handleEntity(node, entityTitleToDescMapOfAllFiles, entityName);
253
+
254
+ const { code } = generate(typeFileAST, {});
255
+
256
+ fs.writeFileSync(path.resolve(typeFileName), code);
257
+ };
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;