@bigbinary/neeto-playwright-commons 1.12.8 → 1.12.10

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
@@ -114,10 +114,6 @@ const THIRD_PARTY_ROUTES = {
114
114
  const NEETO_ROUTES = {
115
115
  imageUploader: "/neeto_image_uploader_engine",
116
116
  };
117
- const FASTMAIL_ROUTES = {
118
- authorize: "https://api.fastmail.com/.well-known/jmap",
119
- api: "https://api.fastmail.com/jmap/api/",
120
- };
121
117
 
122
118
  const ENVIRONMENT = {
123
119
  development: "development",
@@ -3556,15 +3552,13 @@ class CustomCommands {
3556
3552
  ]);
3557
3553
  };
3558
3554
  this.apiRequest = async ({ url, failOnStatusCode = true, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
3559
- const csrfToken = await this.page
3560
- .locator("[name='csrf-token']")
3561
- .getAttribute("content");
3555
+ var _a;
3562
3556
  const requestOptions = {
3563
3557
  failOnStatusCode,
3564
3558
  headers: {
3565
3559
  ...additionalHeaders,
3566
3560
  "accept-encoding": "gzip",
3567
- "x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
3561
+ "x-csrf-token": (_a = this.csrfToken) !== null && _a !== void 0 ? _a : "",
3568
3562
  },
3569
3563
  data,
3570
3564
  ...otherOptions,
@@ -3654,6 +3648,13 @@ class CustomCommands {
3654
3648
  this.responses = [];
3655
3649
  this.request = request;
3656
3650
  this.baseURL = baseURL;
3651
+ this.page
3652
+ .locator("[name='csrf-token']")
3653
+ .getAttribute("content")
3654
+ .then(csrfToken => {
3655
+ this.csrfToken = csrfToken;
3656
+ }, reason => console.error(reason) // eslint-disable-line
3657
+ );
3657
3658
  }
3658
3659
  }
3659
3660
 
@@ -11607,24 +11608,23 @@ conventions.NAMESPACE;
11607
11608
  var domParser = domParser$1;
11608
11609
  var DOMParser = domParser.DOMParser;
11609
11610
 
11610
- const dateTimeOneHourAgo = () => new Date(new Date().valueOf() - 60 * 60 * 1000);
11611
- class MailerUtils {
11611
+ class FastmailApi {
11612
11612
  constructor(neetoPlaywrightUtilities) {
11613
11613
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
11614
11614
  this.authorizeAndSetAccountId = async () => {
11615
11615
  const response = await this.neetoPlaywrightUtilities.apiRequest({
11616
11616
  method: "get",
11617
- url: FASTMAIL_ROUTES.authorize,
11618
- headers: this.fastmailHeaders,
11617
+ url: "https://api.fastmail.com/.well-known/jmap",
11618
+ headers: this.headers,
11619
11619
  });
11620
11620
  const { primaryAccounts: { "urn:ietf:params:jmap:mail": accountId }, } = await response.json();
11621
11621
  this.accountId = accountId;
11622
11622
  };
11623
- this.fastmailApiRequest = async (method, body) => {
11623
+ this.apiRequest = async (method, body) => {
11624
11624
  const response = await this.neetoPlaywrightUtilities.apiRequest({
11625
11625
  method: "post",
11626
- url: FASTMAIL_ROUTES.api,
11627
- headers: this.fastmailHeaders,
11626
+ url: "https://api.fastmail.com/jmap/api/",
11627
+ headers: this.headers,
11628
11628
  data: {
11629
11629
  using: ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
11630
11630
  methodCalls: [[method, { accountId: this.accountId, ...body }, "0"]],
@@ -11632,6 +11632,19 @@ class MailerUtils {
11632
11632
  });
11633
11633
  return response === null || response === void 0 ? void 0 : response.json();
11634
11634
  };
11635
+ if (!process.env.NEETO_AUTOMATION_FASTMAIL_API_KEY)
11636
+ throw new Error("Please set the environment variable NEETO_AUTOMATION_FASTMAIL_API_KEYS. Credentials can be found in the Automation Credentials vault in the BigBinary 1Password account.");
11637
+ this.headers = {
11638
+ "Content-Type": "application/json",
11639
+ Authorization: `Bearer ${process.env.NEETO_AUTOMATION_FASTMAIL_API_KEY}`,
11640
+ };
11641
+ }
11642
+ }
11643
+
11644
+ const dateTimeOneHourAgo = () => new Date(new Date().valueOf() - 60 * 60 * 1000);
11645
+ class MailerUtils {
11646
+ constructor(neetoPlaywrightUtilities) {
11647
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
11635
11648
  this.queryEmail = async (messageSearchCriteria, { receivedAfter = dateTimeOneHourAgo(), page = 1, itemsPerPage = 50, }) => {
11636
11649
  const limit = itemsPerPage;
11637
11650
  const position = (page - 1) * itemsPerPage;
@@ -11643,7 +11656,7 @@ class MailerUtils {
11643
11656
  limit,
11644
11657
  position,
11645
11658
  };
11646
- const { methodResponses: [[, { ids, total }]], } = await this.fastmailApiRequest("Email/query", body);
11659
+ const { methodResponses: [[, { ids, total }]], } = await this.fastmailApi.apiRequest("Email/query", body);
11647
11660
  return { ids, total };
11648
11661
  };
11649
11662
  this.getEmails = async (ids) => {
@@ -11652,7 +11665,7 @@ class MailerUtils {
11652
11665
  bodyProperties: ["type"],
11653
11666
  fetchHTMLBodyValues: true,
11654
11667
  };
11655
- const { methodResponses: [[, { list }]], } = await this.fastmailApiRequest("Email/get", messageDetailsBody);
11668
+ const { methodResponses: [[, { list }]], } = await this.fastmailApi.apiRequest("Email/get", messageDetailsBody);
11656
11669
  const formattedList = list.map((listItem) => {
11657
11670
  var _a;
11658
11671
  const { id, from, to, bodyValues, cc, bcc, replyTo, receivedAt, subject, } = listItem;
@@ -11722,12 +11735,7 @@ class MailerUtils {
11722
11735
  this.generateRandomEmail = () => faker.faker.internet.email({
11723
11736
  provider: process.env.FASTMAIL_DOMAIN_NAME,
11724
11737
  });
11725
- if (!process.env.NEETO_AUTOMATION_FASTMAIL_API_KEY)
11726
- throw new Error("Please set the environment variable NEETO_AUTOMATION_FASTMAIL_API_KEYS. Credentials can be found in the Automation Credentials vault in the BigBinary 1Password account.");
11727
- this.fastmailHeaders = {
11728
- "Content-Type": "application/json",
11729
- Authorization: `Bearer ${process.env.NEETO_AUTOMATION_FASTMAIL_API_KEY}`,
11730
- };
11738
+ this.fastmailApi = new FastmailApi(neetoPlaywrightUtilities);
11731
11739
  }
11732
11740
  }
11733
11741
 
@@ -11786,7 +11794,7 @@ const commands = {
11786
11794
  },
11787
11795
  mailerUtils: async ({ neetoPlaywrightUtilities }, use) => {
11788
11796
  const mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
11789
- await mailerUtils.authorizeAndSetAccountId();
11797
+ await mailerUtils.fastmailApi.authorizeAndSetAccountId();
11790
11798
  await use(mailerUtils);
11791
11799
  },
11792
11800
  };
@@ -21215,15 +21223,16 @@ const GOOGLE_LOGIN_TEXTS = {
21215
21223
  backToSafety: "Back to safety",
21216
21224
  neetoAutomation: "neeto.automation",
21217
21225
  };
21226
+ const ENGAGE_TEXTS = { subscribe: "Subscribe" };
21218
21227
 
21219
21228
  const HELP_CENTER_SELECTORS = {
21220
21229
  helpButton: "help-button",
21221
21230
  documentationButton: "help-link-help-center-button",
21222
21231
  keyboardShortcutButton: "help-link-keyboard-shortcut-button",
21223
21232
  chatButton: "help-link-live-chat-button",
21224
- whatsNewButton: "help-link-changelog-button",
21233
+ whatsNewButton: "help-link-engage-button",
21225
21234
  whatsNewWidgetInfo: "h1",
21226
- whatsNewWidgetCloseButton: ".nc-widget-header__btn",
21235
+ whatsNewWidgetCloseButton: ".ne-widget-header__btn",
21227
21236
  keyboardShortcutPaneHeading: "keyboard-shortcuts-pane-title",
21228
21237
  keyboardShortcutPaneCrossIcon: "keyboard-shortcuts-pane-close-button",
21229
21238
  };
@@ -21251,9 +21260,9 @@ const CHAT_WIDGET_SELECTORS = {
21251
21260
  chatQuestionHeader: "chat-question-header",
21252
21261
  };
21253
21262
  const CHANGELOG_WIDGET_SELECTORS = {
21254
- changelogWrapper: ".nc-widget__wrapper",
21255
- closeButton: "nc-widget-close-btn",
21256
- publicUrlLink: "nc-widget-public-url",
21263
+ changelogWrapper: ".ne-widget__wrapper",
21264
+ closeButton: "ne-widget-close-btn",
21265
+ publicUrlLink: "ne-widget-public-url",
21257
21266
  };
21258
21267
  const KEYBOARD_SHORTCUTS_SELECTORS = {
21259
21268
  keyboardShortcutsPane: "keyboard-shortcuts-pane",
@@ -21357,11 +21366,7 @@ class HelpAndProfilePage {
21357
21366
  .getByTestId(CHANGELOG_WIDGET_SELECTORS.publicUrlLink)
21358
21367
  .click();
21359
21368
  const changelogPage = await changelogPagePromise;
21360
- await this.neetoPlaywrightUtilities.interceptMultipleResponses({
21361
- customPageContext: changelogPage,
21362
- baseUrl: this.changelogBaseURL.split("/site")[0],
21363
- times: 3,
21364
- });
21369
+ await test$1.expect(changelogPage.getByRole("button", { name: ENGAGE_TEXTS.subscribe })).toBeVisible();
21365
21370
  await test$1.expect(changelogPage).toHaveURL(this.changelogBaseURL);
21366
21371
  await changelogPage.close();
21367
21372
  });
@@ -24988,8 +24993,21 @@ const MERGE_TAGS_SELECTORS = {
24988
24993
  destinationTagRow: "neeto-tags-merge-destination-tags",
24989
24994
  };
24990
24995
 
24996
+ class TagsApi {
24997
+ constructor(neetoPlaywrightUtilities) {
24998
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
24999
+ this.create = ({ body, tagsRequestUrl, }) => this.neetoPlaywrightUtilities.apiRequest({
25000
+ url: tagsRequestUrl,
25001
+ body,
25002
+ method: "post",
25003
+ });
25004
+ }
25005
+ }
25006
+
24991
25007
  class TagsPage {
24992
25008
  constructor(page, neetoPlaywrightUtilities) {
25009
+ this.page = page;
25010
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
24993
25011
  this.searchAndVerifyTags = async (tagName) => {
24994
25012
  await this.page.getByTestId(TAGS_SELECTORS.searchTextField).fill(tagName);
24995
25013
  await test$1.expect(this.page.getByRole("row", { name: tagName })).toBeVisible();
@@ -25057,11 +25075,7 @@ class TagsPage {
25057
25075
  await this.neetoPlaywrightUtilities.verifyToast();
25058
25076
  await test$1.expect(this.page.getByRole("row", { name: tagName })).toBeHidden();
25059
25077
  };
25060
- this.addTagsViaRequest = ({ name, description = "", tagsRequestUrl, }) => this.neetoPlaywrightUtilities.apiRequest({
25061
- url: tagsRequestUrl,
25062
- body: { name, description },
25063
- method: "post",
25064
- });
25078
+ this.addTagsViaRequest = ({ name, description = "", tagsRequestUrl, }) => this.tagsApi.create({ body: { name, description }, tagsRequestUrl });
25065
25079
  this.navigateToMergeTagsPage = async () => {
25066
25080
  await this.page.getByTestId(MERGE_TAGS_SELECTORS.mergeTagsButton).click();
25067
25081
  await this.neetoPlaywrightUtilities.waitForPageLoad();
@@ -25093,9 +25107,8 @@ class TagsPage {
25093
25107
  await test$1.expect(this.page.getByText(sourceTagName)).toBeHidden();
25094
25108
  await test$1.expect(this.page.getByText(destinationTagName)).toBeVisible();
25095
25109
  };
25096
- this.page = page;
25097
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
25098
25110
  this.t = playwrightI18nextFixture.getI18nInstance().t;
25111
+ this.tagsApi = new TagsApi(neetoPlaywrightUtilities);
25099
25112
  }
25100
25113
  }
25101
25114
 
@@ -157289,11 +157302,11 @@ exports.CustomCommands = CustomCommands;
157289
157302
  exports.DESCRIPTION_EDITOR_TEXTS = DESCRIPTION_EDITOR_TEXTS;
157290
157303
  exports.EMBED_SELECTORS = EMBED_SELECTORS;
157291
157304
  exports.EMOJI_LABEL = EMOJI_LABEL;
157305
+ exports.ENGAGE_TEXTS = ENGAGE_TEXTS;
157292
157306
  exports.ENVIRONMENT = ENVIRONMENT;
157293
157307
  exports.EXPANDED_FONT_SIZE = EXPANDED_FONT_SIZE;
157294
157308
  exports.EditorPage = EditorPage;
157295
157309
  exports.EmbedBase = EmbedBase;
157296
- exports.FASTMAIL_ROUTES = FASTMAIL_ROUTES;
157297
157310
  exports.FONT_SIZE_SELECTORS = FONT_SIZE_SELECTORS;
157298
157311
  exports.GLOBAL_TRANSLATIONS_PATTERN = GLOBAL_TRANSLATIONS_PATTERN;
157299
157312
  exports.GOOGLE_CALENDAR_DATE_FORMAT = GOOGLE_CALENDAR_DATE_FORMAT;