@bigbinary/neeto-playwright-commons 1.24.8 → 1.25.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/index.cjs.js CHANGED
@@ -21,6 +21,8 @@ var require$$0$a = require('tty');
21
21
  var require$$0$9 = require('os');
22
22
  var stealth$1 = require('puppeteer-extra-plugin-stealth');
23
23
  var require$$1$4 = require('events');
24
+ var timezone = require('dayjs/plugin/timezone');
25
+ var utc = require('dayjs/plugin/utc');
24
26
  var https = require('https');
25
27
 
26
28
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -5052,6 +5054,9 @@ const PROFILE_SECTION_SELECTORS = {
5052
5054
  actionHeaderUserName: "floating-action-menu-header-user-name",
5053
5055
  actionHeaderUserEmail: "floating-action-menu-header-user-email",
5054
5056
  submitButton: "ntm-profile-submit-button",
5057
+ editBtn: "edit-basic-info-menu-button",
5058
+ firstNameTextField: "profile-first-name-text-field",
5059
+ lastNameTextField: "profile-last-name-text-field",
5055
5060
  manageBillingAndSubscriptionsButton: "manage-billing-subscriptions-menu-button",
5056
5061
  };
5057
5062
 
@@ -5321,6 +5326,12 @@ const IP_RESTRICTIONS_SELECTORS = {
5321
5326
  typeSelectError: "type-select-error",
5322
5327
  resetButton: "ip-restriction-reset-button",
5323
5328
  };
5329
+ const AUDIT_LOGS_SELECTORS = {
5330
+ card: "audit-log-card",
5331
+ content: "audit-log-content",
5332
+ timestamp: "audit-log-timestamp",
5333
+ text: "audit-log-text",
5334
+ };
5324
5335
 
5325
5336
  const DATE_PICKER_SELECTORS = {
5326
5337
  pickerInput: "picker-input",
@@ -5658,7 +5669,7 @@ class CustomCommands {
5658
5669
  await test.expect(breadcrumbHeader).toHaveCount(titlesAndRoutes.length);
5659
5670
  await Promise.all(titlesAndRoutes.map(({ title, route }) => test.expect(breadcrumbHeader.getByRole("link", { name: title, exact: true })).toHaveAttribute("href", route)));
5660
5671
  };
5661
- this.uploadFileViaDispatchV2 = async ({ droppableZone = this.page.getByTestId(COMMON_SELECTORS.fileUploadBody), dispatchEvent = "drop", timeout = 30000, file, }) => {
5672
+ this.uploadFileViaDispatchV2 = async ({ droppableZone = this.page.getByTestId(COMMON_SELECTORS.fileUploadBody), dispatchEvent = "drop", timeout = 45000, file, }) => {
5662
5673
  const serializedFile = await serializeFileForBrowser(file);
5663
5674
  const dataTransfer = await Promise.race([
5664
5675
  droppableZone.evaluateHandle(async (_, { name, type, buffer, lastModified }) => {
@@ -113694,7 +113705,6 @@ const COMMUNITY_TEXTS = { joinNow: "Join Now" };
113694
113705
  const STATUS_TEXTS = {
113695
113706
  application: (appName) => `Neeto${appName} Application`,
113696
113707
  };
113697
- const AUDIT_LOGS_TEXTS = { organizationRole: "Organization Role" };
113698
113708
  const COMMON_TEXTS = {
113699
113709
  skipCleanup: "@SKIP_CLEANUP",
113700
113710
  skipSetup: "@SKIP_SETUP",
@@ -114153,6 +114163,28 @@ class HelpAndProfilePage {
114153
114163
  });
114154
114164
  });
114155
114165
  };
114166
+ this.updateProfile = async ({ firstName, lastName }) => {
114167
+ await this.openHelpCenter();
114168
+ await this.page
114169
+ .getByTestId(PROFILE_SECTION_SELECTORS.myProfileButton)
114170
+ .click();
114171
+ await this.page
114172
+ .getByTestId(COMMON_SELECTORS.pane)
114173
+ .getByTestId(COMMON_SELECTORS.dropdownIcon)
114174
+ .click();
114175
+ await this.page.getByTestId(PROFILE_SECTION_SELECTORS.editBtn).click();
114176
+ firstName &&
114177
+ (await this.page
114178
+ .getByTestId(PROFILE_SECTION_SELECTORS.firstNameTextField)
114179
+ .fill(firstName));
114180
+ lastName &&
114181
+ (await this.page
114182
+ .getByTestId(PROFILE_SECTION_SELECTORS.lastNameTextField)
114183
+ .fill(lastName));
114184
+ await this.page.getByTestId(PROFILE_SECTION_SELECTORS.submitButton).click();
114185
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
114186
+ await test.expect(this.page.getByTestId(COMMON_SELECTORS.paneModalCrossIcon)).toBeHidden();
114187
+ };
114156
114188
  this.page = page;
114157
114189
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
114158
114190
  this.chatApiBaseURL = chatApiBaseURL;
@@ -117681,6 +117713,7 @@ const filterUtils = {
117681
117713
  class TeamMembers {
117682
117714
  constructor({ page, neetoPlaywrightUtilities, }) {
117683
117715
  this.navigateToTeamMembers = async () => {
117716
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
117684
117717
  await this.page.getByTestId(MEMBER_SELECTORS.membersTab).click();
117685
117718
  await this.neetoPlaywrightUtilities.waitForPageLoad();
117686
117719
  };
@@ -117709,13 +117742,17 @@ class TeamMembers {
117709
117742
  await this.neetoPlaywrightUtilities.waitForPageLoad();
117710
117743
  };
117711
117744
  this.submit = async () => {
117745
+ const pane = this.page.getByTestId(COMMON_SELECTORS.paneBody);
117746
+ const submitBtn = this.page.getByTestId(MEMBER_SELECTORS.submitButton);
117747
+ const buttonSpinner = submitBtn.getByTestId(COMMON_SELECTORS.uiSpinner);
117748
+ await test.expect(submitBtn).toBeVisible({ timeout: 10000 });
117712
117749
  await test.expect(async () => {
117713
- await this.neetoPlaywrightUtilities.clickButtonAndAwaitLoad({
117714
- locator: this.page.getByTestId(MEMBER_SELECTORS.submitButton),
117715
- timeout: 10000,
117716
- });
117717
- await test.expect(this.page.getByTestId(COMMON_SELECTORS.paneBody)).toBeHidden();
117718
- }).toPass({ timeout: 40000 });
117750
+ if (await pane.isHidden())
117751
+ return;
117752
+ (await buttonSpinner.isHidden()) && (await submitBtn.click());
117753
+ await test.expect(buttonSpinner).toBeHidden({ timeout: 10000 });
117754
+ await test.expect(pane).toBeHidden();
117755
+ }).toPass({ timeout: 60000 });
117719
117756
  await this.neetoPlaywrightUtilities.verifyToast();
117720
117757
  };
117721
117758
  this.searchAndVerifyMemberByEmail = async ({ email }) => {
@@ -117872,7 +117909,9 @@ class TeamMembers {
117872
117909
  this.applyFilter = async () => {
117873
117910
  await test.expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible();
117874
117911
  await this.neetoPlaywrightUtilities.waitForPageLoad();
117875
- await test.expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
117912
+ await test.expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden({
117913
+ timeout: 30000,
117914
+ });
117876
117915
  await this.page
117877
117916
  .getByTestId(NEETO_FILTERS_SELECTORS.filterDoneButton)
117878
117917
  .click();
@@ -118198,49 +118237,68 @@ class ApiKeysPage {
118198
118237
  }
118199
118238
  }
118200
118239
 
118240
+ const ACTIONS = {
118241
+ inviteUsers: "invitedUsers",
118242
+ updatedUser: "updatedUser",
118243
+ removedUser: "removedUser",
118244
+ createdRole: "createdRole",
118245
+ addedPermission: "addedPermission",
118246
+ removedPermission: "removedPermission",
118247
+ updatedRole: "updatedRole",
118248
+ deletedRole: "deletedRole",
118249
+ updatedName: "updatedName",
118250
+ };
118251
+
118252
+ dayjs.extend(utc);
118253
+ dayjs.extend(timezone);
118201
118254
  class AuditLogsPage {
118202
- constructor(page, neetoPlaywrightUtilities) {
118255
+ constructor(page, neetoPlaywrightUtilities,
118256
+ // TODO: Make this parameter required in the next major release
118257
+ product) {
118203
118258
  this.page = page;
118204
118259
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
118205
- this.verifyAuditLogEntry = async ({ page = this.page, tableDetails, paneDetails, }) => {
118206
- await this.verifyAuditLog(tableDetails);
118207
- await this.verifyDataInPane({
118208
- ...paneDetails,
118209
- page,
118210
- action: tableDetails.action,
118211
- });
118212
- };
118213
- this.verifyAuditLog = async ({ targetRow, action, date, adminName, }) => {
118214
- if (targetRow) {
118215
- this.targetRow = targetRow;
118216
- }
118217
- await Promise.all([action, this.t("neetoMolecules.common.success"), adminName, date].map(name => test.expect(this.targetRow.getByRole("cell", { name })).toBeVisible()));
118260
+ this.product = product;
118261
+ this.verifyAuditLogs = async ({ action, adminName, data, }) => {
118262
+ if (adminName)
118263
+ this.admin = adminName;
118264
+ const expectedMessage = this.messageBuilders[action](data);
118265
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
118266
+ await this.assertAuditLogContent(expectedMessage);
118218
118267
  };
118219
- this.verifyDataInPane = async ({ page = this.page, action, values, firstName, lastName, roleName, }) => {
118220
- const rowInPane = page
118221
- .getByTestId(COMMON_SELECTORS.paneBody)
118222
- .getByRole("row");
118223
- await this.targetRow.getByText(action).click();
118268
+ this.assertAuditLogContent = async (expectedMessage) => {
118269
+ // Using nth-methods here because we need to select the latest audit log card
118270
+ // eslint-disable-next-line playwright/no-nth-methods
118271
+ const card = this.page.getByTestId(AUDIT_LOGS_SELECTORS.card).first();
118272
+ const content = card.getByTestId(AUDIT_LOGS_SELECTORS.content);
118224
118273
  await Promise.all([
118225
- ...values.map(value => test.expect(page.getByTestId(COMMON_SELECTORS.paneBody).getByText(value)).toBeVisible()),
118226
- firstName &&
118227
- // eslint-disable-next-line playwright/missing-playwright-await
118228
- test.expect(rowInPane
118229
- .filter({ hasText: this.t("neetoTeamMembers.labels.firstName") })
118230
- .getByText(firstName)).toBeVisible(),
118231
- lastName &&
118232
- // eslint-disable-next-line playwright/missing-playwright-await
118233
- test.expect(rowInPane
118234
- .filter({ hasText: this.t("neetoTeamMembers.labels.lastName") })
118235
- .getByText(lastName)).toBeVisible(),
118236
- roleName &&
118237
- // eslint-disable-next-line playwright/missing-playwright-await
118238
- test.expect(rowInPane
118239
- .filter({ hasText: AUDIT_LOGS_TEXTS.organizationRole })
118240
- .getByText(roleName)).toBeVisible(),
118274
+ test.expect(content.getByTestId(AUDIT_LOGS_SELECTORS.timestamp)).toContainText(this.currentDate),
118275
+ test.expect(content.getByTestId(AUDIT_LOGS_SELECTORS.text)).toHaveText(expectedMessage),
118241
118276
  ]);
118242
118277
  };
118243
- this.t = playwrightI18nextFixture.getI18nInstance().t;
118278
+ /**
118279
+ * @deprecated This method is deprecated. Use verifyAuditLogs instead.
118280
+ */
118281
+ this.verifyDataInPane = ({}) => { };
118282
+ /**
118283
+ * @deprecated This method is deprecated. Use verifyAuditLogs instead.
118284
+ */
118285
+ this.verifyAuditLog = async ({}) => { };
118286
+ /**
118287
+ * @deprecated This method is deprecated. Use verifyAuditLogs instead.
118288
+ */
118289
+ this.verifyAuditLogEntry = async ({}) => { };
118290
+ this.currentDate = dayjs().tz("Asia/Kolkata").format("MMM D, YYYY");
118291
+ this.messageBuilders = {
118292
+ [ACTIONS.inviteUsers]: (data) => `${this.admin} has invited ${data.emails.join(", ").toLowerCase()} to Neeto${this.product}`,
118293
+ [ACTIONS.updatedUser]: (data) => `${this.admin} updated ${data.emails[1].toLowerCase()}'s email: from ${data.emails[0].toLowerCase()} to ${data.emails[1]} on Neeto${this.product}`,
118294
+ [ACTIONS.removedUser]: (data) => `${this.admin} updated ${data.emails[0].toLowerCase()}'s active: from true to false on Neeto${this.product}`,
118295
+ [ACTIONS.createdRole]: (data) => `${this.admin} created ${data.roleName} role on Neeto${this.product}`,
118296
+ [ACTIONS.addedPermission]: (data) => `${this.admin} added ${data.permissions.join(", ").toLowerCase()} permission to ${data.roleName} role on Neeto${this.product}`,
118297
+ [ACTIONS.removedPermission]: (data) => `${this.admin} removed ${data.permissions.join(", ")} permissions from ${data.roleName} role on Neeto${this.product}`,
118298
+ [ACTIONS.updatedRole]: (data) => `${this.admin} updated ${data.roleName} role on Neeto${this.product}`,
118299
+ [ACTIONS.deletedRole]: (data) => `${this.admin} deleted ${data.roleName} role on Neeto${this.product}`,
118300
+ [ACTIONS.updatedName]: (data) => `${this.admin} updated their first name: from ${data.name} to ${this.admin.split(" ")[0]} on Neeto${this.product}`,
118301
+ };
118244
118302
  }
118245
118303
  }
118246
118304
 
@@ -124107,10 +124165,11 @@ const definePlaywrightConfig = (overrides) => {
124107
124165
  });
124108
124166
  };
124109
124167
 
124168
+ exports.ACTIONS = ACTIONS;
124110
124169
  exports.ADMIN_PANEL_SELECTORS = ADMIN_PANEL_SELECTORS;
124111
124170
  exports.API_KEYS_SELECTORS = API_KEYS_SELECTORS;
124112
124171
  exports.API_ROUTES = API_ROUTES;
124113
- exports.AUDIT_LOGS_TEXTS = AUDIT_LOGS_TEXTS;
124172
+ exports.AUDIT_LOGS_SELECTORS = AUDIT_LOGS_SELECTORS;
124114
124173
  exports.AdminPanelPage = AdminPanelPage;
124115
124174
  exports.ApiKeysApi = ApiKeysApi;
124116
124175
  exports.ApiKeysPage = ApiKeysPage;