@bigbinary/neeto-playwright-commons 1.24.9 → 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",
@@ -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;
@@ -118205,49 +118237,68 @@ class ApiKeysPage {
118205
118237
  }
118206
118238
  }
118207
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);
118208
118254
  class AuditLogsPage {
118209
- constructor(page, neetoPlaywrightUtilities) {
118255
+ constructor(page, neetoPlaywrightUtilities,
118256
+ // TODO: Make this parameter required in the next major release
118257
+ product) {
118210
118258
  this.page = page;
118211
118259
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
118212
- this.verifyAuditLogEntry = async ({ page = this.page, tableDetails, paneDetails, }) => {
118213
- await this.verifyAuditLog(tableDetails);
118214
- await this.verifyDataInPane({
118215
- ...paneDetails,
118216
- page,
118217
- action: tableDetails.action,
118218
- });
118219
- };
118220
- this.verifyAuditLog = async ({ targetRow, action, date, adminName, }) => {
118221
- if (targetRow) {
118222
- this.targetRow = targetRow;
118223
- }
118224
- 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);
118225
118267
  };
118226
- this.verifyDataInPane = async ({ page = this.page, action, values, firstName, lastName, roleName, }) => {
118227
- const rowInPane = page
118228
- .getByTestId(COMMON_SELECTORS.paneBody)
118229
- .getByRole("row");
118230
- 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);
118231
118273
  await Promise.all([
118232
- ...values.map(value => test.expect(page.getByTestId(COMMON_SELECTORS.paneBody).getByText(value)).toBeVisible()),
118233
- firstName &&
118234
- // eslint-disable-next-line playwright/missing-playwright-await
118235
- test.expect(rowInPane
118236
- .filter({ hasText: this.t("neetoTeamMembers.labels.firstName") })
118237
- .getByText(firstName)).toBeVisible(),
118238
- lastName &&
118239
- // eslint-disable-next-line playwright/missing-playwright-await
118240
- test.expect(rowInPane
118241
- .filter({ hasText: this.t("neetoTeamMembers.labels.lastName") })
118242
- .getByText(lastName)).toBeVisible(),
118243
- roleName &&
118244
- // eslint-disable-next-line playwright/missing-playwright-await
118245
- test.expect(rowInPane
118246
- .filter({ hasText: AUDIT_LOGS_TEXTS.organizationRole })
118247
- .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),
118248
118276
  ]);
118249
118277
  };
118250
- 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
+ };
118251
118302
  }
118252
118303
  }
118253
118304
 
@@ -124114,10 +124165,11 @@ const definePlaywrightConfig = (overrides) => {
124114
124165
  });
124115
124166
  };
124116
124167
 
124168
+ exports.ACTIONS = ACTIONS;
124117
124169
  exports.ADMIN_PANEL_SELECTORS = ADMIN_PANEL_SELECTORS;
124118
124170
  exports.API_KEYS_SELECTORS = API_KEYS_SELECTORS;
124119
124171
  exports.API_ROUTES = API_ROUTES;
124120
- exports.AUDIT_LOGS_TEXTS = AUDIT_LOGS_TEXTS;
124172
+ exports.AUDIT_LOGS_SELECTORS = AUDIT_LOGS_SELECTORS;
124121
124173
  exports.AdminPanelPage = AdminPanelPage;
124122
124174
  exports.ApiKeysApi = ApiKeysApi;
124123
124175
  exports.ApiKeysPage = ApiKeysPage;