@bigbinary/neeto-playwright-commons 1.14.3 → 1.15.1
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 +6 -25
- package/index.cjs.js +16 -55
- package/index.cjs.js.map +1 -1
- package/index.d.ts +10 -102
- package/index.js +18 -56
- package/index.js.map +1 -1
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -57,14 +57,6 @@ yarn add lint-staged
|
|
|
57
57
|
yarn add dotenv-webpack
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
### `mailosaur`
|
|
61
|
-
|
|
62
|
-
Using `Mailosaur` you can automate email and SMS tests.
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
yarn add mailosaur
|
|
66
|
-
```
|
|
67
|
-
|
|
68
60
|
### `dayjs`
|
|
69
61
|
|
|
70
62
|
Dayjs is a JavaScript library that parses, validates, manipulates, and displays
|
|
@@ -95,21 +87,16 @@ yarn add playwright-i18next-fixture
|
|
|
95
87
|
We can install all the above peer dependencies by running a single command.
|
|
96
88
|
|
|
97
89
|
```
|
|
98
|
-
yarn add @bigbinary/neeto-cist @faker-js/faker @playwright/test lint-staged dotenv-webpack
|
|
90
|
+
yarn add @bigbinary/neeto-cist @faker-js/faker @playwright/test lint-staged dotenv-webpack dayjs ramda playwright-i18next-fixture
|
|
99
91
|
```
|
|
100
92
|
|
|
101
93
|
## External dependencies
|
|
102
94
|
|
|
103
95
|
### Methods
|
|
104
96
|
|
|
105
|
-
##
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this methods to work.
|
|
109
|
-
|
|
110
|
-
We can find `MAILOUSAUR_KEY` by visiting https://mailosaur.com/app/account/keys
|
|
111
|
-
and `MAILOSAUR_SERVER_ID` by visiting https://mailosaur.com/app/servers
|
|
112
|
-
|
|
97
|
+
## MailerUtils
|
|
98
|
+
Note: ENV variables `NEETO_AUTOMATION_FASTMAIL_API_KEY` and
|
|
99
|
+
`FASTMAIL_DOMAIN_NAME` are required for this methods to work.
|
|
113
100
|
## Slack integration methods
|
|
114
101
|
|
|
115
102
|
Note: Either ENV variables `SLACK_WORKSPACE`, `SLACK_LOGIN_PASSWORD` and
|
|
@@ -118,13 +105,7 @@ Note: Either ENV variables `SLACK_WORKSPACE`, `SLACK_LOGIN_PASSWORD` and
|
|
|
118
105
|
|
|
119
106
|
## Zapier integration methods
|
|
120
107
|
|
|
121
|
-
Note: ENV variables `
|
|
122
|
-
`INTEGRATION_MAILOSAUR_SERVER_ID`, `ZAPIER_LOGIN_PASSWORD`,
|
|
123
|
-
`ZAPIER_LOGIN_EMAIL`, and `ZAP_ID` are required for this methods to work.
|
|
124
|
-
|
|
125
|
-
We can find `INTEGRATION_MAILOSAUR_SERVER_ID` by visiting
|
|
126
|
-
https://mailosaur.com/app/servers and `INTEGRATION_MAILOSAUR_API_KEY` by
|
|
127
|
-
visiting https://mailosaur.com/app/servers/ymn2s6kt/keys
|
|
108
|
+
Note: ENV variables `NEETO_AUTOMATION_FASTMAIL_API_KEY`, `FASTMAIL_DOMAIN_NAME`, `ZAPIER_LOGIN_EMAIL`, `ZAPIER_LOGIN_PASSWORD`, and `ZAP_ID` are required for this methods to work.
|
|
128
109
|
|
|
129
110
|
## Usage
|
|
130
111
|
|
|
@@ -141,7 +122,7 @@ import { COMMON_SELECTORS } from "@bigbinary/neeto-playwright-common";
|
|
|
141
122
|
- [Commons and Envs](./docs/common.md)
|
|
142
123
|
- [Routes](./docs/routes.md)
|
|
143
124
|
- [Custom commands](./docs/custom-commands.md)
|
|
144
|
-
- [
|
|
125
|
+
- [MailerUtils](./docs/utils/mailer-utils.md)
|
|
145
126
|
- [Util functions](./docs/utils)
|
|
146
127
|
- [POMs](./docs/poms)
|
|
147
128
|
- [Integration](./docs/integration)
|
package/index.cjs.js
CHANGED
|
@@ -7,7 +7,6 @@ var child_process = require('child_process');
|
|
|
7
7
|
var ramda = require('ramda');
|
|
8
8
|
var require$$0$1 = require('util');
|
|
9
9
|
var faker = require('@faker-js/faker');
|
|
10
|
-
var MailosaurClient = require('mailosaur');
|
|
11
10
|
var dayjs = require('dayjs');
|
|
12
11
|
var require$$0$3 = require('tty');
|
|
13
12
|
var require$$0$2 = require('os');
|
|
@@ -12182,59 +12181,16 @@ class MailerUtils {
|
|
|
12182
12181
|
}
|
|
12183
12182
|
}
|
|
12184
12183
|
|
|
12185
|
-
class MailosaurUtils {
|
|
12186
|
-
constructor(mailosaur) {
|
|
12187
|
-
this.getEmailContent = ({ email, subjectSubstring = "", timeout = 2 * 60 * 1000, receivedAfter = new Date(), }) => this.mailosaur.messages.get(this.serverId, { sentTo: email, subject: subjectSubstring }, { timeout, receivedAfter });
|
|
12188
|
-
this.fetchOtpFromEmail = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 2 * 60 * 1000, receivedAfter = new Date(), }) => {
|
|
12189
|
-
var _a, _b, _c;
|
|
12190
|
-
const receivedEmail = await this.getEmailContent({
|
|
12191
|
-
email,
|
|
12192
|
-
subjectSubstring,
|
|
12193
|
-
timeout,
|
|
12194
|
-
receivedAfter,
|
|
12195
|
-
});
|
|
12196
|
-
const otp = (_c = (_b = (_a = receivedEmail === null || receivedEmail === void 0 ? void 0 : receivedEmail.text) === null || _a === void 0 ? void 0 : _a.codes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.value;
|
|
12197
|
-
if (ramda.isNil(otp)) {
|
|
12198
|
-
throw new Error(`No codes found in the email with subject: ${receivedEmail === null || receivedEmail === void 0 ? void 0 : receivedEmail.subject}. Please re-evaluate the filtering parameters.`);
|
|
12199
|
-
}
|
|
12200
|
-
return otp;
|
|
12201
|
-
};
|
|
12202
|
-
this.generateRandomMailosaurEmail = () => faker.faker.internet.email({ provider: `${this.serverId}.mailosaur.net` });
|
|
12203
|
-
this.mailosaur = mailosaur;
|
|
12204
|
-
if (ramda.isNotNil(process.env.MAILOSAUR_SERVER_ID)) {
|
|
12205
|
-
this.serverId = process.env.MAILOSAUR_SERVER_ID;
|
|
12206
|
-
}
|
|
12207
|
-
else {
|
|
12208
|
-
throw new Error("ENV variable MAILOSAUR_SERVER_ID is not defined. Please add the Server ID to use this method. Please visit https://mailosaur.com/app/servers to find the Server ID.");
|
|
12209
|
-
}
|
|
12210
|
-
}
|
|
12211
|
-
}
|
|
12212
|
-
|
|
12213
12184
|
const commands = {
|
|
12214
12185
|
neetoPlaywrightUtilities: async ({ page, request, baseURL }, use) => {
|
|
12215
12186
|
const commands = new CustomCommands(page, request, baseURL);
|
|
12216
12187
|
await use(commands);
|
|
12217
12188
|
},
|
|
12218
|
-
mailosaur: async ({}, use) => {
|
|
12219
|
-
skipTest.forAllExceptStagingEnv();
|
|
12220
|
-
if (ramda.isNotNil(process.env.MAILOSAUR_API_KEY)) {
|
|
12221
|
-
const mailosaur = new MailosaurClient(process.env.MAILOSAUR_API_KEY);
|
|
12222
|
-
await use(mailosaur);
|
|
12223
|
-
}
|
|
12224
|
-
else {
|
|
12225
|
-
throw new Error("ENV variable MAILOSAUR_API_KEY is not defined. Please add the API key to use this fixture. Please visit https://mailosaur.com/app/account/keys to find the API key.");
|
|
12226
|
-
}
|
|
12227
|
-
},
|
|
12228
12189
|
page: async ({ page }, use) => {
|
|
12229
12190
|
await page.goto("/", { timeout: 20000 });
|
|
12230
12191
|
await page.waitForLoadState();
|
|
12231
12192
|
await use(page);
|
|
12232
12193
|
},
|
|
12233
|
-
mailosaurUtils: async ({ mailosaur }, use) => {
|
|
12234
|
-
skipTest.forAllExceptStagingEnv();
|
|
12235
|
-
const mailosaurUtils = new MailosaurUtils(mailosaur);
|
|
12236
|
-
await use(mailosaurUtils);
|
|
12237
|
-
},
|
|
12238
12194
|
mailerUtils: async ({ neetoPlaywrightUtilities }, use) => {
|
|
12239
12195
|
const mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
|
|
12240
12196
|
await mailerUtils.fastmailApi.authorizeAndSetAccountId();
|
|
@@ -21312,7 +21268,9 @@ class EmbedBase {
|
|
|
21312
21268
|
.getByTestId(COMMON_SELECTORS.radioLabel(embedLabel))
|
|
21313
21269
|
.check();
|
|
21314
21270
|
};
|
|
21315
|
-
this.verifyInlineCustomization = async ({ headingTestId,
|
|
21271
|
+
this.verifyInlineCustomization = async ({ headingTestId,
|
|
21272
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21273
|
+
inlineEmbedInterceptParams, customizationOptions, }) => {
|
|
21316
21274
|
const embedHeightPercentage = `${customizationOptions.embedHeight}%`;
|
|
21317
21275
|
const embedWidthPercentage = `${customizationOptions.embedWidth}%`;
|
|
21318
21276
|
await this.page
|
|
@@ -21330,14 +21288,14 @@ class EmbedBase {
|
|
|
21330
21288
|
`height: "${embedHeightPercentage}"`,
|
|
21331
21289
|
`width: "${embedWidthPercentage}"`,
|
|
21332
21290
|
]);
|
|
21333
|
-
const inlineEmbedPromise = this.neetoPlaywrightUtilities.interceptMultipleResponses(inlineEmbedInterceptParams);
|
|
21334
21291
|
(await this.previewTab.isVisible()) && (await this.previewTab.click());
|
|
21335
|
-
await inlineEmbedPromise;
|
|
21336
21292
|
const iframe = this.page.locator("iframe");
|
|
21337
21293
|
await iframe.waitFor({ state: "visible" });
|
|
21338
21294
|
await test$1.expect(this.page.frameLocator("iframe").getByTestId(headingTestId)).toBeVisible({ timeout: 10000 });
|
|
21339
|
-
const iframeHeight = await iframe.evaluate(node =>
|
|
21340
|
-
|
|
21295
|
+
const [iframeHeight, iframeWidth] = await iframe.evaluate(node => [
|
|
21296
|
+
node.getAttribute("height"),
|
|
21297
|
+
node.getAttribute("width"),
|
|
21298
|
+
]);
|
|
21341
21299
|
// eslint-disable-next-line playwright/no-standalone-expect
|
|
21342
21300
|
test$1.expect(iframeHeight).toStrictEqual(embedHeightPercentage);
|
|
21343
21301
|
// eslint-disable-next-line playwright/no-standalone-expect
|
|
@@ -21394,12 +21352,14 @@ class EmbedBase {
|
|
|
21394
21352
|
const floatingButton = this.page.getByRole("button", {
|
|
21395
21353
|
name: customizationOptions.buttonText,
|
|
21396
21354
|
});
|
|
21397
|
-
await test$1.expect(floatingButton).toHaveCSS("color", hexToRGB(customizationOptions.buttonTextColorHex));
|
|
21398
|
-
await test$1.expect(floatingButton).toHaveCSS("background-color", hexToRGB(customizationOptions.buttonColorHex));
|
|
21399
21355
|
const classRegExp = customizationOptions.buttonPosition
|
|
21400
21356
|
.toLocaleLowerCase()
|
|
21401
21357
|
.replace(" ", ".*");
|
|
21402
|
-
await
|
|
21358
|
+
await Promise.all([
|
|
21359
|
+
test$1.expect(floatingButton).toHaveClass(RegExp(classRegExp)),
|
|
21360
|
+
test$1.expect(floatingButton).toHaveCSS("background-color", hexToRGB(customizationOptions.buttonColorHex)),
|
|
21361
|
+
test$1.expect(floatingButton).toHaveCSS("color", hexToRGB(customizationOptions.buttonTextColorHex)),
|
|
21362
|
+
]);
|
|
21403
21363
|
const floatingButtonIcon = floatingButton.locator("svg");
|
|
21404
21364
|
if (customizationOptions.showIcon === true) {
|
|
21405
21365
|
await test$1.expect(floatingButtonIcon).toBeVisible();
|
|
@@ -21414,8 +21374,10 @@ class EmbedBase {
|
|
|
21414
21374
|
.fill(customizationOptions.customId);
|
|
21415
21375
|
await test$1.expect(this.codeBlock).toContainText(`elementSelector: "#${customizationOptions.customId}"`);
|
|
21416
21376
|
(await this.previewTab.isVisible()) && (await this.previewTab.click());
|
|
21417
|
-
await
|
|
21418
|
-
|
|
21377
|
+
await Promise.all([
|
|
21378
|
+
test$1.expect(this.page.getByTestId(EMBED_SELECTORS.previewElementPopupButton)).toBeVisible(),
|
|
21379
|
+
await test$1.expect(this.page.locator(`#${customizationOptions.customId}`)).toBeVisible(),
|
|
21380
|
+
]);
|
|
21419
21381
|
};
|
|
21420
21382
|
this.expectMultipleTextsInCodeblock = async (containTextOptions) => {
|
|
21421
21383
|
const codeBlock = this.page.getByTestId(EMBED_SELECTORS.codeBlock);
|
|
@@ -158649,7 +158611,6 @@ exports.MEMBER_SELECTORS = MEMBER_SELECTORS;
|
|
|
158649
158611
|
exports.MEMBER_TEXTS = MEMBER_TEXTS;
|
|
158650
158612
|
exports.MERGE_TAGS_SELECTORS = MERGE_TAGS_SELECTORS;
|
|
158651
158613
|
exports.MailerUtils = MailerUtils;
|
|
158652
|
-
exports.MailosaurUtils = MailosaurUtils;
|
|
158653
158614
|
exports.Member = Member;
|
|
158654
158615
|
exports.NEETO_AUTH_BASE_URL = NEETO_AUTH_BASE_URL;
|
|
158655
158616
|
exports.NEETO_EDITOR_SELECTORS = NEETO_EDITOR_SELECTORS;
|