@camunda/e2e-test-suite 0.0.1537 → 0.0.1539

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.
@@ -22,6 +22,7 @@ declare class AppsPage {
22
22
  private expandHubClusterGroup;
23
23
  private clickHubClusterApp;
24
24
  private hubAppLink;
25
+ goBackToHub(): Promise<void>;
25
26
  isHubClusterAppPresent(clusterName: string, appName: string): Promise<boolean>;
26
27
  clickModeler(): Promise<void>;
27
28
  clickTasklist(clusterName: string): Promise<void>;
@@ -292,12 +292,31 @@ class AppsPage {
292
292
  }))
293
293
  .first();
294
294
  }
295
+ // Returns to the Hub shell after a cluster app was opened.
296
+ // clickHubClusterApp follows the app's href in the CURRENT tab (Hub marks
297
+ // these links target="_blank"), so a caller that opened Operate/Tasklist to
298
+ // check its permission gate is left on operate.*/tasklist.* and has to come
299
+ // back deliberately. goBack() restores the exact Hub route; when the app's
300
+ // own redirects have already replaced that history entry it can land
301
+ // off-Hub, so fall back to the Hub root -- a relative goto() resolves
302
+ // against baseURL, which is Hub. Mirrors pages/8.9/AppsPage.ts
303
+ // goBackToHub().
304
+ async goBackToHub() {
305
+ await this.page.goBack();
306
+ if (!new URL(this.page.url()).hostname.startsWith('hub.')) {
307
+ await this.page.goto('/', { waitUntil: 'domcontentloaded' });
308
+ }
309
+ }
295
310
  // Checks whether an app link is present inside the requested cluster's Hub
296
- // sidebar group, without clicking it. Unlike clickHubClusterApp, absence is
297
- // an expected, valid outcome here -- this is how callers assert per-cluster
298
- // app authorization (e.g. an Analyst-role user should not see Operate),
299
- // which on Hub renders as the link never appearing in the expanded group
300
- // rather than a disabled control -- so this never throws on a miss.
311
+ // sidebar group, without clicking it. Absence is an expected, valid outcome
312
+ // here (unlike clickHubClusterApp), so this never throws on a miss. Note it
313
+ // is NOT an authorization check: camunda-hub's
314
+ // use-organization-environment-sidebar-model.ts states outright that "there
315
+ // is no role gate here" -- the org environment listing is filtered
316
+ // server-side by workspace visibility only, so every environment the viewer
317
+ // can see lists every one of its applications regardless of the viewer's
318
+ // Operate/Tasklist/Optimize permission. A caller proving "this role has no
319
+ // access" must open the app and assert its forbidden page instead.
301
320
  async isHubClusterAppPresent(clusterName, appName) {
302
321
  try {
303
322
  await this.expandHubClusterGroup(clusterName);
@@ -2,6 +2,7 @@ import { Page, Locator } from '@playwright/test';
2
2
  import { ClientCredentialsDetailsPage } from '../8.7/ClientCredentialsDetailsPage';
3
3
  declare class ClusterDetailsPage {
4
4
  private page;
5
+ private clusterDetailsUrl;
5
6
  readonly apiTab: Locator;
6
7
  readonly createFirstClientButton: Locator;
7
8
  readonly clientNameTextbox: Locator;
@@ -27,7 +28,13 @@ declare class ClusterDetailsPage {
27
28
  readonly disableRBADialog: Locator;
28
29
  readonly rbaEnabledMessage: Locator;
29
30
  readonly alertsTab: Locator;
31
+ readonly alertsTabPanel: Locator;
30
32
  readonly alertsList: Locator;
33
+ readonly alertExpandRowButtons: Locator;
34
+ readonly alertRowActionsButtons: Locator;
35
+ readonly deleteAlertMenuItem: Locator;
36
+ readonly deleteAlertConfirmButton: Locator;
37
+ readonly alertsPanel: Locator;
31
38
  readonly createFirstAlertButton: Locator;
32
39
  readonly createNewAlertButton: Locator;
33
40
  readonly emailRadioButton: Locator;
@@ -69,12 +76,14 @@ declare class ClusterDetailsPage {
69
76
  searchAndClickClientCredentialsLink(name: string): Promise<ClientCredentialsDetailsPage>;
70
77
  deleteAPIClientsIfExist(name?: string): Promise<void>;
71
78
  clickAlertsTab(): Promise<void>;
79
+ reopenAlertsTab(): Promise<void>;
72
80
  clickCreateFirstAlertButton(): Promise<void>;
73
81
  clickCreateNewAlertButton(): Promise<void>;
74
82
  createAlert(isFirstAlert?: boolean): Promise<void>;
75
83
  selectEmailRadioButton(): Promise<void>;
76
84
  clickCreateAlertButton(): Promise<void>;
77
85
  deleteAlerts(): Promise<void>;
86
+ expandAlerts(): Promise<void>;
78
87
  private doDelete;
79
88
  assertComponentsHealth(components?: string[]): Promise<void>;
80
89
  userTaskEnabledAssertion(): Promise<void>;
@@ -6,8 +6,14 @@ const sleep_1 = require("../../utils/sleep");
6
6
  const clickLocatorWithRetry_1 = require("../../utils/assertionHelpers/clickLocatorWithRetry");
7
7
  const ClientCredentialsDetailsPage_1 = require("../8.7/ClientCredentialsDetailsPage");
8
8
  const expectLocatorWithRetry_1 = require("../../utils/assertionHelpers/expectLocatorWithRetry");
9
+ const sessionRecovery_1 = require("../../utils/sessionRecovery");
10
+ // Hub's own /login and /login-callback routes, which render only a spinner
11
+ // while the Auth0 hand-off of a full page load is in flight.
12
+ const HUB_LOGIN_ROUTE = /^\/login(-callback)?\/?$/;
9
13
  class ClusterDetailsPage {
10
14
  page;
15
+ // The cluster page reopenAlertsTab() goes back to -- see there.
16
+ clusterDetailsUrl;
11
17
  apiTab;
12
18
  createFirstClientButton;
13
19
  clientNameTextbox;
@@ -33,7 +39,13 @@ class ClusterDetailsPage {
33
39
  disableRBADialog;
34
40
  rbaEnabledMessage;
35
41
  alertsTab;
42
+ alertsTabPanel;
36
43
  alertsList;
44
+ alertExpandRowButtons;
45
+ alertRowActionsButtons;
46
+ deleteAlertMenuItem;
47
+ deleteAlertConfirmButton;
48
+ alertsPanel;
37
49
  createFirstAlertButton;
38
50
  createNewAlertButton;
39
51
  emailRadioButton;
@@ -124,15 +136,43 @@ class ClusterDetailsPage {
124
136
  this.userTaskRestriction = page.locator('button[aria-label="Switch Enforce user task restrictions"]');
125
137
  this.rbaEnabledMessage = page.getByText('Resource-based authorizations enabled');
126
138
  this.alertsTab = page.getByRole('tab', { name: 'Alerts' });
127
- this.alertsList = page
139
+ // Only the selected tab's panel is exposed (the design-system tabs unmount
140
+ // the others, Carbon marks them hidden), and it is named after its tab.
141
+ // Page-wide, getByRole('row') read the Overview "Cluster Details" rows
142
+ // whenever Overview was showing -- the nightly's `Received string:
143
+ // "NameAlert Flow Cluster"` where the Email alert row was expected.
144
+ this.alertsTabPanel = page.getByRole('tabpanel', { name: 'Alerts' });
145
+ this.alertsList = this.alertsTabPanel
128
146
  .getByRole('row')
129
147
  .filter({ hasNotText: 'Delivery method' }); //Filter out header row
148
+ // Hub's Alerts tab is a design-system data table: one summary row per
149
+ // alert (Delivery method / Created at / Created by), with the detail
150
+ // fields in a sibling expansion row that only exists once the row's
151
+ // "Expand row" toggle is clicked, and Delete behind the row's "Row
152
+ // actions" kebab -> "Delete" -> "Delete alert" dialog (camunda-hub e2e
153
+ // ConsoleClusterDetailsPage). Scoped to the visible tab panel.
154
+ this.alertExpandRowButtons = page
155
+ .getByRole('tabpanel')
156
+ .getByRole('button', { name: 'Expand row', exact: true });
157
+ this.alertRowActionsButtons = page
158
+ .getByRole('tabpanel')
159
+ .getByRole('button', { name: 'Row actions', exact: true });
160
+ this.deleteAlertMenuItem = page.getByRole('menuitem', {
161
+ name: 'Delete',
162
+ exact: true,
163
+ });
164
+ this.deleteAlertConfirmButton = page
165
+ .getByRole('dialog', { name: 'Delete alert' })
166
+ .getByRole('button', { name: 'Delete', exact: true });
130
167
  this.createFirstAlertButton = page.getByRole('button', {
131
168
  name: 'Create an alert',
132
169
  });
133
170
  this.createNewAlertButton = page.getByRole('button', {
134
171
  name: 'Create new alert',
135
172
  });
173
+ // The Alerts panel offers "Create an alert" while empty and "Create new
174
+ // alert" once it holds one, so either proves the panel itself mounted.
175
+ this.alertsPanel = this.createFirstAlertButton.or(this.createNewAlertButton);
136
176
  this.emailRadioButton = page.getByRole('radio', {
137
177
  name: 'Email',
138
178
  });
@@ -348,6 +388,46 @@ class ClusterDetailsPage {
348
388
  async clickAlertsTab() {
349
389
  await (0, test_1.expect)(this.alertsTab).toBeVisible({ timeout: 40000 });
350
390
  await this.alertsTab.click();
391
+ // The tab bar remounts while the cluster payload is still arriving, which
392
+ // discards the click and leaves Overview selected -- and the tab is a
393
+ // button, not a route, so nothing later re-selects it. Callers would then
394
+ // find no Alerts panel for alertsList to read. Confirm the panel mounted,
395
+ // re-selecting the tab after a reload between attempts.
396
+ await (0, expectLocatorWithRetry_1.expectLocatorWithRetry)(this.page, this.alertsPanel, {
397
+ visibilityTimeout: 60000,
398
+ totalTimeout: 240000,
399
+ maxRetries: 4,
400
+ postAction: async () => {
401
+ await this.page.reload({ waitUntil: 'domcontentloaded' });
402
+ await this.alertsTab.waitFor({ state: 'visible', timeout: 60000 });
403
+ await this.alertsTab.click({ timeout: 60000 });
404
+ },
405
+ });
406
+ }
407
+ // Re-enters the cluster page and re-opens the Alerts tab, for callers that
408
+ // poll the alerts table for a server-side change. Hub keeps the selected
409
+ // tab out of the URL (ClusterDetails.saas.tsx drops c4's tabChange), so any
410
+ // full load comes back on Overview and the tab has to be clicked again.
411
+ // A goto to the remembered cluster page rather than a reload: a full load
412
+ // re-runs Hub's Auth0 hand-off, and a reload issued while the page is still
413
+ // parked on /login-callback?code=... replays that single-use code.
414
+ async reopenAlertsTab() {
415
+ if ((0, sessionRecovery_1.isAtIdentityProvider)(this.page)) {
416
+ await (0, sessionRecovery_1.restoreSessionIfLoggedOut)(this.page);
417
+ }
418
+ const current = new URL(this.page.url());
419
+ if (!(0, sessionRecovery_1.isAtIdentityProvider)(this.page) &&
420
+ !HUB_LOGIN_ROUTE.test(current.pathname)) {
421
+ this.clusterDetailsUrl = current.href;
422
+ }
423
+ const target = this.clusterDetailsUrl ?? current.href;
424
+ const host = new URL(target).host;
425
+ await this.page.goto(target, { waitUntil: 'domcontentloaded' });
426
+ // goto() resolves on the first document; the hand-off then bounces
427
+ // through /login and /login-callback (~45s on CI) before it lands back.
428
+ await this.page.waitForURL((url) => url.host === host && !HUB_LOGIN_ROUTE.test(url.pathname), { timeout: 120000 });
429
+ await this.alertsTab.click({ timeout: 60000 });
430
+ await (0, test_1.expect)(this.alertsPanel.first()).toBeVisible({ timeout: 60000 });
351
431
  }
352
432
  async clickCreateFirstAlertButton() {
353
433
  await (0, test_1.expect)(this.createFirstAlertButton).toBeVisible({ timeout: 40000 });
@@ -383,7 +463,47 @@ class ClusterDetailsPage {
383
463
  });
384
464
  }
385
465
  async deleteAlerts() {
386
- await this.doDelete(this.dialog, 'Alerts');
466
+ const hasRowActions = await this.alertRowActionsButtons
467
+ .first()
468
+ .waitFor({ state: 'visible', timeout: 10000 })
469
+ .then(() => true)
470
+ .catch(() => false);
471
+ if (!hasRowActions) {
472
+ await this.doDelete(this.dialog, 'Alerts');
473
+ return;
474
+ }
475
+ let remaining = await this.alertRowActionsButtons.count();
476
+ while (remaining > 0) {
477
+ // A re-render can detach the menu between opening it and the click, so
478
+ // open-menu-and-choose-Delete is retried as one unit.
479
+ await (0, test_1.expect)(async () => {
480
+ await this.alertRowActionsButtons.first().click({ timeout: 10000 });
481
+ await this.deleteAlertMenuItem.click({ timeout: 10000 });
482
+ await (0, test_1.expect)(this.deleteAlertConfirmButton).toBeVisible({
483
+ timeout: 10000,
484
+ });
485
+ }).toPass({ timeout: 60000 });
486
+ await this.deleteAlertConfirmButton.click({ timeout: 30000 });
487
+ await (0, test_1.expect)(this.alertRowActionsButtons).toHaveCount(remaining - 1, {
488
+ timeout: 60000,
489
+ });
490
+ remaining = await this.alertRowActionsButtons.count();
491
+ }
492
+ }
493
+ // Reveals each alert's detail row. A no-op on the legacy table, whose
494
+ // detail rows are always rendered.
495
+ async expandAlerts() {
496
+ for (let i = 0; i < 10; i++) {
497
+ const toggle = this.alertExpandRowButtons.first();
498
+ if (!(await toggle.isVisible().catch(() => false))) {
499
+ return;
500
+ }
501
+ const before = await this.alertExpandRowButtons.count();
502
+ await toggle.click({ timeout: 10000 });
503
+ await (0, test_1.expect)(this.alertExpandRowButtons).toHaveCount(before - 1, {
504
+ timeout: 10000,
505
+ });
506
+ }
387
507
  }
388
508
  async doDelete(dialog, text) {
389
509
  try {
@@ -53,8 +53,11 @@ declare class ConsoleOrganizationPage {
53
53
  checkReadPermissionCheckbox(): Promise<void>;
54
54
  checkStartInstancePermissionCheckbox(): Promise<void>;
55
55
  clickUsersTab(): Promise<void>;
56
- clickOptionsButton(): Promise<void>;
57
- clickEditUserMenuItem(): Promise<void>;
56
+ filterTableToUser(username: string): Promise<void>;
57
+ private userRow;
58
+ private rowActionsTrigger;
59
+ clickOptionsButton(username?: string): Promise<void>;
60
+ clickEditUserMenuItem(username?: string): Promise<void>;
58
61
  clickOperationsEngineerCheckbox(): Promise<void>;
59
62
  checkDeveloperCheckbox(): Promise<void>;
60
63
  uncheckDeveloperCheckbox(): Promise<void>;
@@ -243,22 +243,90 @@ class ConsoleOrganizationPage {
243
243
  },
244
244
  });
245
245
  }
246
- async clickOptionsButton() {
247
- const dataRow = this.rows.nth(1);
246
+ // The Users table loads the org member list once per page load and filters
247
+ // it client side -- the trace shows a single /members request per load with
248
+ // no search parameter -- so a member who joined after that fetch is simply
249
+ // not findable, and the table settles on "No results.". filterTable only
250
+ // waits for rows.nth(1), which is still satisfied by the stale pre-filter
251
+ // rows, so the caller would then drive a different user's row. Reload to
252
+ // refetch the member list until the searched user's own row is present.
253
+ async filterTableToUser(username) {
254
+ await (0, test_1.expect)(async () => {
255
+ await this.filterTable([username]);
256
+ const found = await this.userRow(username)
257
+ .waitFor({ state: 'visible', timeout: 10000 })
258
+ .then(() => true)
259
+ .catch(() => false);
260
+ if (!found) {
261
+ await this.page.reload();
262
+ await this.clickUsersTab();
263
+ throw new Error(`Users table has no row for ${username} yet`);
264
+ }
265
+ }).toPass({ timeout: 180000, intervals: [5000, 10000, 15000] });
266
+ }
267
+ // Scoped to the user's own row: the table still lists other members until
268
+ // the client-side filter settles, and an unscoped row would open -- and edit
269
+ // -- the wrong user's menu. Mirrors pages/8.9/ConsoleOrganizationPage.ts.
270
+ userRow(username) {
271
+ return this.rows.filter({ hasText: username }).first();
272
+ }
273
+ // The design-system Users table renders the row kebab with a stable
274
+ // data-slot, but its accessible name is not stable: the a11y tree captured
275
+ // at the failure moment shows the same element as an unnamed
276
+ // `button [expanded]` once its menu is open, so a name-only locator stops
277
+ // resolving in exactly the state the retry loop keeps re-entering. Match the
278
+ // data-slot first and keep the name-based variants for any org still served
279
+ // the older table.
280
+ rowActionsTrigger(row) {
281
+ return row
282
+ .locator('button[data-slot="data-table-actions-trigger"]')
283
+ .or(row.getByRole('button', { name: 'Options' }))
284
+ .or(row.getByRole('button', { name: 'Row actions' }))
285
+ .first();
286
+ }
287
+ async clickOptionsButton(username) {
288
+ const dataRow = username ? this.userRow(username) : this.rows.nth(1);
248
289
  await dataRow.hover({ timeout: 30000 }).catch(() => { });
290
+ const rowOptions = this.rowActionsTrigger(dataRow);
291
+ // A second click on an already-open trigger closes the menu again, and the
292
+ // open menu's overlay blocks the trigger anyway, so only click it closed.
293
+ const alreadyOpen = await rowOptions
294
+ .getAttribute('aria-expanded', { timeout: 10000 })
295
+ .then((value) => value === 'true')
296
+ .catch(() => false);
297
+ if (alreadyOpen) {
298
+ return;
299
+ }
300
+ if (username) {
301
+ await rowOptions.click({ timeout: 30000 });
302
+ return;
303
+ }
249
304
  // Try scoped click first; fall back to page-level with force
250
305
  try {
251
- await dataRow
252
- .getByRole('button', { name: 'Options' })
253
- .or(dataRow.getByRole('button', { name: 'Row actions' }))
254
- .click({ timeout: 30000 });
306
+ await rowOptions.click({ timeout: 30000 });
255
307
  }
256
308
  catch (_e) {
257
309
  await this.optionsButton.first().click({ force: true, timeout: 60000 });
258
310
  }
259
311
  }
260
- async clickEditUserMenuItem() {
261
- await this.editUserMenuItem.click({ timeout: 60000 });
312
+ // The row menu can close under the click when the Users table re-renders
313
+ // ("element was detached from the DOM", after which the item never returns),
314
+ // so reopen the row menu and retry rather than wait on a closed menu. Same
315
+ // recovery as pages/8.9/ConsoleOrganizationPage.ts. The item is also probed
316
+ // for enabled, not just visible: Console renders it aria-disabled when the
317
+ // viewer may not manage org users, and a pinned click would otherwise burn
318
+ // its whole timeout on an element that never becomes actionable.
319
+ async clickEditUserMenuItem(username) {
320
+ await (0, test_1.expect)(async () => {
321
+ const clickable = await this.editUserMenuItem
322
+ .waitFor({ state: 'visible', timeout: 5000 })
323
+ .then(() => this.editUserMenuItem.isEnabled())
324
+ .catch(() => false);
325
+ if (!clickable) {
326
+ await this.clickOptionsButton(username);
327
+ }
328
+ await this.editUserMenuItem.click({ timeout: 10000 });
329
+ }).toPass({ timeout: 90000, intervals: [1000, 2000, 5000] });
262
330
  }
263
331
  async clickOperationsEngineerCheckbox() {
264
332
  await this.operationsEngineerCheckbox.click();
@@ -14,6 +14,7 @@ import { LoginPage } from './LoginPage';
14
14
  import { ConnectorSettingsPage } from './ConnectorSettingsPage';
15
15
  import { ConnectorMarketplacePage } from './ConnectorMarketplacePage';
16
16
  import { ConnectorTemplatePage } from './ConnectorTemplatePage';
17
+ import { MailSlurp } from 'mailslurp-client';
17
18
  export declare function loginWithRetry(page: Page, loginPage: LoginPage, testUser: {
18
19
  username: string;
19
20
  password: string;
@@ -46,3 +47,4 @@ export declare function deleteAllUserGroups(homePage: HomePage, organizationPage
46
47
  export declare function deleteCluster(clusterName: string, homePage: HomePage, clusterPage: ClusterPage, appsPage: AppsPage): Promise<void>;
47
48
  export declare function modelAndRunConnectorsDocHandlingDiagram(modelerCreatePage: ModelerCreatePage, modelerHomePage: ModelerHomePage, processName: string, page: Page, connectorMarketplacePage: ConnectorMarketplacePage, clusterName: string, zeebeUrl: string, zeebeClientId: string, zeebeClientSecret: string): Promise<void>;
48
49
  export declare function modelAndRunConnectorsTimerEventDiagram(modelerCreatePage: ModelerCreatePage, modelerHomePage: ModelerHomePage, processName: string, page: Page, connectorMarketplacePage: ConnectorMarketplacePage, clusterName: string, connectorTemplatePage: ConnectorTemplatePage): Promise<void>;
50
+ export declare function assertLatestAlertEmail(id: string, mailSlurp: MailSlurp, processName: string, alertText: string): Promise<string>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.modelAndRunConnectorsTimerEventDiagram = exports.modelAndRunConnectorsDocHandlingDiagram = exports.deleteCluster = exports.deleteAllUserGroups = exports.assertTestUsesCorrectOrganization = exports.clickInvitationLinkInEmail = exports.enableRBA = exports.disableRBA = exports.modelDiagramFromFile = exports.runProcess = exports.runMultipleProcesses = exports.completeTaskWithRetry = exports.assertPageTextWithRetry = exports.assertLocatorVisibleWithRetry = exports.modelRestConnector = exports.withSessionRecovery = exports.isSignedOut = exports.loginWithRetry = void 0;
3
+ exports.assertLatestAlertEmail = exports.modelAndRunConnectorsTimerEventDiagram = exports.modelAndRunConnectorsDocHandlingDiagram = exports.deleteCluster = exports.deleteAllUserGroups = exports.assertTestUsesCorrectOrganization = exports.clickInvitationLinkInEmail = exports.enableRBA = exports.disableRBA = exports.modelDiagramFromFile = exports.runProcess = exports.runMultipleProcesses = exports.completeTaskWithRetry = exports.assertPageTextWithRetry = exports.assertLocatorVisibleWithRetry = exports.modelRestConnector = exports.withSessionRecovery = exports.isSignedOut = exports.loginWithRetry = void 0;
4
4
  const test_1 = require("@playwright/test");
5
5
  const ModelerHomePage_1 = require("./ModelerHomePage");
6
6
  const HomePage_1 = require("./HomePage");
@@ -653,3 +653,27 @@ async function modelAndRunConnectorsTimerEventDiagram(modelerCreatePage, modeler
653
653
  await modelerCreatePage.runProcessInstance(clusterName);
654
654
  }
655
655
  exports.modelAndRunConnectorsTimerEventDiagram = modelAndRunConnectorsTimerEventDiagram;
656
+ async function assertLatestAlertEmail(id, mailSlurp, processName, alertText) {
657
+ // waitForLatestEmail returns the newest email at once when the inbox is not
658
+ // empty, so a second call on the same inbox re-reads the first alert email.
659
+ // Search the inbox for an email that carries the expected text instead.
660
+ let body;
661
+ await (0, test_1.expect)(async () => {
662
+ const previews = await mailSlurp.getEmails(id, {
663
+ minCount: 1,
664
+ retryTimeout: 60000,
665
+ });
666
+ for (const preview of previews) {
667
+ const email = await mailSlurp.getEmail(preview.id);
668
+ if (email?.body?.includes(processName) &&
669
+ email.body.includes(alertText)) {
670
+ body = email.body;
671
+ return;
672
+ }
673
+ }
674
+ throw new Error(`No alert email for "${processName}" containing "${alertText}" in ` +
675
+ `inbox ${id} yet (${previews.length} email(s) present)`);
676
+ }).toPass({ timeout: 360000, intervals: [5000, 10000, 20000] });
677
+ return body;
678
+ }
679
+ exports.assertLatestAlertEmail = assertLatestAlertEmail;
@@ -7,20 +7,22 @@ const OperateProcessInstancePage_1 = require("../../pages/8.7/OperateProcessInst
7
7
  const sleep_1 = require("../../utils/sleep");
8
8
  const UtilitiesPage_1 = require("../../pages/8.7/UtilitiesPage");
9
9
  const formatDate_1 = require("../../utils/formatDate");
10
- const googleapi_1 = require("../../utils/googleapi");
11
10
  const users_1 = require("../../utils/users");
12
- const constants_1 = require("../../utils/constants");
11
+ const mailSlurpClient_1 = require("../../utils/mailSlurpClient");
13
12
  const testUser = (0, users_1.getTestUser)('eighteenthUser');
14
13
  _8_7_1.test.describe.configure({ mode: 'parallel' });
15
14
  _8_7_1.test.describe('Console User Flow Tests', () => {
16
15
  const clusterName = 'Test Cluster';
17
- const alertFlowClusterName = 'AWS Cluster';
16
+ let inbox = '';
18
17
  _8_7_1.test.beforeEach(async ({ page, loginPage }, testInfo) => {
19
18
  await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, testUser, (testInfo.workerIndex + 1) * 1000);
20
19
  });
21
20
  _8_7_1.test.afterEach(async ({ page }, testInfo) => {
22
21
  await (0, _setup_1.captureScreenshot)(page, testInfo);
23
22
  await (0, _setup_1.captureFailureVideo)(page, testInfo);
23
+ if (inbox.length > 0) {
24
+ await (0, mailSlurpClient_1.deleteInbox)(inbox);
25
+ }
24
26
  });
25
27
  (0, _8_7_1.test)('Create Cluster', async ({ homePage, clusterPage }, testInfo) => {
26
28
  _8_7_1.test.slow();
@@ -49,28 +51,38 @@ _8_7_1.test.describe('Console User Flow Tests', () => {
49
51
  }
50
52
  }
51
53
  });
52
- //Waiting infra team to provide DNS configuration for email testing, skipping for now
53
- _8_7_1.test.skip('Alert Trigger Flow - Email Notification', async ({ page, homePage, modelerHomePage, appsPage, modelerCreatePage, clusterPage, clusterDetailsPage, connectorSettingsPage, }) => {
54
+ (0, _8_7_1.test)('Alert Trigger Flow - Email Notification', async ({ page, homePage, modelerHomePage, appsPage, modelerCreatePage, clusterPage, clusterDetailsPage, connectorSettingsPage, }) => {
54
55
  _8_7_1.test.slow();
55
56
  const processName = 'Email_Alert_Process' + (await (0, _setup_1.generateRandomStringAsync)(3));
56
57
  const invalidURl = 'https://invalid';
57
- const senderEmail = 'no-reply@camunda.io';
58
58
  let lastTriggerTime = 0;
59
- await _8_7_1.test.step('Delete Alert Settings If Exist', async () => {
59
+ const alertFlowClusterName = 'Alert Flow Cluster';
60
+ const { id } = await (0, mailSlurpClient_1.createInbox)(testUser.username);
61
+ inbox = id;
62
+ await _8_7_1.test.step('Create Cluster', async () => {
60
63
  await (0, test_1.expect)(homePage.clusterTab).toBeVisible({ timeout: 30000 });
64
+ await homePage.clickClusters();
65
+ await clusterPage.createClusterIfNotExists(alertFlowClusterName);
66
+ });
67
+ await _8_7_1.test.step('Delete Alert Settings If Exist', async () => {
61
68
  await homePage.clickClusters();
62
69
  await clusterPage.clickClusterLink(alertFlowClusterName);
63
70
  await clusterDetailsPage.clickAlertsTab();
64
71
  await clusterDetailsPage.deleteAlerts();
65
- (0, test_1.expect)(await clusterDetailsPage.alertsList.count()).toBe(0);
72
+ await (0, test_1.expect)(clusterDetailsPage.alertsList).toHaveCount(0, {
73
+ timeout: 15000,
74
+ });
66
75
  });
67
76
  await _8_7_1.test.step('Create First Email Alert', async () => {
68
77
  await clusterDetailsPage.createAlert(true);
69
- (0, test_1.expect)(await clusterDetailsPage.alertsList.count()).toBeGreaterThan(1);
70
- await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(0)).toContainText(`Email`);
71
- await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(1)).toContainText(process.env.C8_USERNAME);
72
- await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(1)).toContainText((0, formatDate_1.formatDate)());
73
- await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(1)).toContainText('Amount triggered0');
78
+ await (0, test_1.expect)(async () => {
79
+ await clusterDetailsPage.expandAlerts();
80
+ (0, test_1.expect)(await clusterDetailsPage.alertsList.count()).toBeGreaterThan(1);
81
+ await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(0)).toContainText(`Email`);
82
+ await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(1)).toContainText(testUser.username);
83
+ await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(1)).toContainText((0, formatDate_1.formatDate)());
84
+ await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(1)).toContainText('Amount triggered0');
85
+ }).toPass({ timeout: 60000 });
74
86
  });
75
87
  await _8_7_1.test.step('Navigate to Web Modeler', async () => {
76
88
  await appsPage.clickCamundaApps();
@@ -112,18 +124,19 @@ _8_7_1.test.describe('Console User Flow Tests', () => {
112
124
  await _8_7_1.test.step('Verify Alert Count Increases to 1 After Trigger', async () => {
113
125
  await clusterDetailsPage.clickAlertsTab();
114
126
  await (0, test_1.expect)(async () => {
127
+ await clusterDetailsPage.reopenAlertsTab();
128
+ await (0, test_1.expect)(clusterDetailsPage.alertsList.first()).toBeVisible({
129
+ timeout: 20000,
130
+ });
131
+ await clusterDetailsPage.expandAlerts();
115
132
  (0, test_1.expect)(await clusterDetailsPage.alertsList.count()).toBeGreaterThan(1);
116
133
  await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(0)).toContainText(`Email`);
117
134
  await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(1)).toContainText('Amount triggered1');
118
- }).toPass(constants_1.defaultAssertionOptions);
135
+ }).toPass({ timeout: 240000 });
119
136
  });
120
137
  await _8_7_1.test.step('Verify Alerts Received via Email for Incident', async () => {
121
138
  await (0, sleep_1.sleep)(60000);
122
- const token = await (0, googleapi_1.getGoogleAccessToken)();
123
- const messages = await (0, googleapi_1.getGmailMessagesWithRetry)(token, senderEmail, processName);
124
- (0, test_1.expect)(messages.length).toBe(1);
125
- const emailDetails = await (0, googleapi_1.getLatestEmailDetails)(token, await messages[0]['id']);
126
- (0, test_1.expect)(emailDetails).toContain('New Incidents: 1');
139
+ await (0, UtilitiesPage_1.assertLatestAlertEmail)(id, mailSlurpClient_1.mailSlurp, processName, 'New Incidents: 1');
127
140
  lastTriggerTime = Math.floor(Date.now() / 1000); // Current time in seconds (Unix timestamp)
128
141
  console.log('Captured Target Time:', lastTriggerTime);
129
142
  });
@@ -138,9 +151,25 @@ _8_7_1.test.describe('Console User Flow Tests', () => {
138
151
  await modelerHomePage.clickCrossComponentProjectFolder();
139
152
  await modelerHomePage.clickProcessDiagram(processName);
140
153
  await modelerCreatePage.runProcessInstance(alertFlowClusterName);
141
- await (0, sleep_1.sleep)(10000);
154
+ // Straight into the next run, no wait. The email assertion below expects
155
+ // ONE mail reporting "New Incidents: 2", which only happens when both
156
+ // incidents fall inside the same alert evaluation cycle; a sleep here
157
+ // splits them across cycles and Console sends one mail per incident.
158
+ //
159
+ // Close the first run's toast before clicking again: camunda-hub 6813a7e
160
+ // made the "Instance started!" toast persistent whenever it carries the
161
+ // Operate action, so its action button covers "Deploy & run" and would
162
+ // swallow the second click.
163
+ const instanceStartedToast = page
164
+ .locator('[data-sonner-toast]')
165
+ .filter({ has: modelerCreatePage.viewProcessInstanceLink });
166
+ await instanceStartedToast
167
+ .locator('[data-close-button="true"]')
168
+ .click({ timeout: 30000 });
169
+ await (0, test_1.expect)(modelerCreatePage.viewProcessInstanceLink).toBeHidden({
170
+ timeout: 30000,
171
+ });
142
172
  await modelerCreatePage.runProcessInstance(alertFlowClusterName);
143
- await (0, sleep_1.sleep)(10000);
144
173
  });
145
174
  await _8_7_1.test.step('Navigate to Cluster Details', async () => {
146
175
  await appsPage.clickCamundaApps();
@@ -152,16 +181,18 @@ _8_7_1.test.describe('Console User Flow Tests', () => {
152
181
  await _8_7_1.test.step('Verify Alert Count Increases to 3 After Trigger', async () => {
153
182
  await clusterDetailsPage.clickAlertsTab();
154
183
  await (0, test_1.expect)(async () => {
184
+ await clusterDetailsPage.reopenAlertsTab();
185
+ await (0, test_1.expect)(clusterDetailsPage.alertsList.first()).toBeVisible({
186
+ timeout: 20000,
187
+ });
188
+ await clusterDetailsPage.expandAlerts();
155
189
  (0, test_1.expect)(await clusterDetailsPage.alertsList.count()).toBeGreaterThan(1);
156
190
  await (0, test_1.expect)(clusterDetailsPage.alertsList.nth(1)).toContainText('Amount triggered3');
157
- }).toPass(constants_1.defaultAssertionOptions);
191
+ }).toPass({ timeout: 240000 });
158
192
  });
159
193
  await _8_7_1.test.step('Verify Alerts Received via Email for Incident', async () => {
160
194
  await (0, sleep_1.sleep)(60000);
161
- const token = await (0, googleapi_1.getGoogleAccessToken)();
162
- const messages = await (0, googleapi_1.getGmailMessagesWithRetry)(token, senderEmail, processName, lastTriggerTime);
163
- const emailDetails = await (0, googleapi_1.getLatestEmailDetails)(token, await messages[0]['id']);
164
- (0, test_1.expect)(emailDetails).toContain('New Incidents: 2'); //# of alerts triggered since the last one
195
+ await (0, UtilitiesPage_1.assertLatestAlertEmail)(id, mailSlurpClient_1.mailSlurp, processName, 'New Incidents: 2');
165
196
  });
166
197
  });
167
198
  (0, _8_7_1.test)('Console Most Common Flow', async ({ page, homePage, modelerHomePage, appsPage, modelerCreatePage, clusterPage, clusterDetailsPage, }) => {
@@ -15,6 +15,15 @@ const resetSession_1 = require("../../utils/resetSession");
15
15
  const users_1 = require("../../utils/users");
16
16
  const node_crypto_1 = require("node:crypto");
17
17
  const testUser = (0, users_1.getTestUser)('eleventhUser');
18
+ // Console's permissions rework gates org user management on the viewer's own
19
+ // org role: an `admin` gets `org.users.admin`/`org.users.owner` all-false in
20
+ // the accounts permissions payload, and the Users tab then renders "Edit
21
+ // user", "Remove" and "Add new user" aria-disabled for every row. Only "User
22
+ // Roles User Flow" edits another member's roles, so it runs as the org owner
23
+ // -- the same actor 8.9/8.10/8.11 access-user-role-management.spec.ts use for
24
+ // these flows. Every other test in this file keeps testUser.
25
+ const orgOwner = (0, users_1.getTestUser)('mainUser');
26
+ const ORG_ROLE_MANAGEMENT_TEST = 'User Roles User Flow';
18
27
  _8_7_1.test.describe.configure({ mode: 'parallel' });
19
28
  _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
20
29
  const clusterName = 'Test Cluster';
@@ -23,7 +32,7 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
23
32
  'Invite Existing C8 member to Web Modeler flow': '',
24
33
  };
25
34
  _8_7_1.test.beforeEach(async ({ page, loginPage }, testInfo) => {
26
- await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, testUser, (testInfo.workerIndex + 1) * 1000);
35
+ await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, testInfo.title === ORG_ROLE_MANAGEMENT_TEST ? orgOwner : testUser, (testInfo.workerIndex + 1) * 1000);
27
36
  });
28
37
  _8_7_1.test.afterEach(async ({ page }, testInfo) => {
29
38
  await (0, _setup_1.captureScreenshot)(page, testInfo);
@@ -95,8 +104,7 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
95
104
  });
96
105
  });
97
106
  });
98
- // Skipped due to bug #64384: https://github.com/camunda/camunda/issues/64384
99
- _8_7_1.test.skip('User Roles User Flow', async ({ page, modelerHomePage, appsPage, consoleOrganizationsPage, settingsPage, loginPage, homePage, modelerCreatePage, }) => {
107
+ (0, _8_7_1.test)('User Roles User Flow', async ({ page, modelerHomePage, appsPage, consoleOrganizationsPage, settingsPage, loginPage, homePage, modelerCreatePage, }) => {
100
108
  _8_7_1.test.slow();
101
109
  const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
102
110
  const processName = 'User Roles User Flow' + randomString;
@@ -111,11 +119,9 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
111
119
  await _8_7_1.test.step('Change User Roles and Assert This Updates in Web Modeler', async () => {
112
120
  await modelerHomePage.openOrganizationManagement(120000);
113
121
  await consoleOrganizationsPage.clickUsersTab();
114
- await consoleOrganizationsPage.filterTable([
115
- process.env.C8_USERNAME_TEST_3,
116
- ]);
117
- await consoleOrganizationsPage.clickOptionsButton();
118
- await consoleOrganizationsPage.clickEditUserMenuItem();
122
+ await consoleOrganizationsPage.filterTableToUser(process.env.C8_USERNAME_TEST_3);
123
+ await consoleOrganizationsPage.clickOptionsButton(process.env.C8_USERNAME_TEST_3);
124
+ await consoleOrganizationsPage.clickEditUserMenuItem(process.env.C8_USERNAME_TEST_3);
119
125
  await consoleOrganizationsPage.checkAnalystCheckbox();
120
126
  await consoleOrganizationsPage.uncheckDeveloperCheckbox();
121
127
  await consoleOrganizationsPage.clickConfirmButton();
@@ -124,10 +130,10 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
124
130
  });
125
131
  await settingsPage.clickOpenSettingsButton();
126
132
  await settingsPage.clickLogoutButton();
127
- await loginPage.loginWithTestUser({
133
+ await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, {
128
134
  username: process.env.C8_USERNAME_TEST_3,
129
135
  password: process.env.C8_PASSWORD_TEST_3,
130
- });
136
+ }, 1000);
131
137
  await (0, test_1.expect)(homePage.camundaComponentsButton).toBeVisible({
132
138
  timeout: 60000,
133
139
  });
@@ -143,8 +149,30 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
143
149
  // (organization-store.saas.ts CLUSTER_OPERATOR_ROLE_IDS), so the
144
150
  // just-downgraded-to-Analyst user here should no longer see it either.
145
151
  await (0, test_1.expect)(appsPage.consoleLink).not.toBeVisible();
146
- await appsPage.assertOperatePresent(clusterName, false);
147
- await appsPage.assertTasklistPresent(clusterName, false);
152
+ // Link absence is no longer a valid proxy for "this role has no access".
153
+ // Hub's Environments sidebar applies no role gate at all -- camunda-hub
154
+ // use-organization-environment-sidebar-model.ts says so in those words,
155
+ // and filters the org listing server-side by workspace visibility only
156
+ // (EnvironmentVisibilityResolver) -- so every environment the viewer can
157
+ // see lists every one of its applications. Run 40496984694's failure
158
+ // snapshot shows exactly that: the just-downgraded Analyst still has
159
+ // Operate, Tasklist and Optimize under "Test Cluster". Prove the gate
160
+ // where it now lives, on the component itself.
161
+ await appsPage.assertOperatePresent(clusterName);
162
+ await appsPage.assertTasklistPresent(clusterName);
163
+ // The denial is Operate/Tasklist rejecting the SSO callback and sending
164
+ // the user to <app>/noPermission through Auth0's /v2/logout?returnTo=...
165
+ // The URL carries it either way: where that returnTo is an allowed
166
+ // logout URL the browser lands on /noPermission, and where it is not
167
+ // (camunda-dev answers 400 invalid_request) it stays on the logout URL
168
+ // whose returnTo is /noPermission. The forbidden page's own text can
169
+ // therefore not be asserted portably.
170
+ await appsPage.clickOperate(clusterName);
171
+ await (0, test_1.expect)(page).toHaveURL(/noPermission/, { timeout: 90000 });
172
+ await appsPage.goBackToHub();
173
+ await appsPage.clickTasklist(clusterName);
174
+ await (0, test_1.expect)(page).toHaveURL(/noPermission/, { timeout: 90000 });
175
+ await appsPage.goBackToHub();
148
176
  await appsPage.clickModeler();
149
177
  await homePage.clickSkipCustomization();
150
178
  await modelerHomePage.createCrossComponentProjectFolder();
@@ -177,7 +205,7 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
177
205
  });
178
206
  await settingsPage.clickOpenSettingsButton();
179
207
  await settingsPage.clickLogoutButton();
180
- await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, testUser, 1000);
208
+ await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, orgOwner, 1000);
181
209
  await (0, sleep_1.sleep)(30000);
182
210
  await appsPage.clickCamundaApps();
183
211
  await appsPage.clickModeler();
@@ -187,11 +215,9 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
187
215
  await modelerHomePage.clickMessageBanner();
188
216
  await modelerHomePage.openOrganizationManagement(120000);
189
217
  await consoleOrganizationsPage.clickUsersTab();
190
- await consoleOrganizationsPage.filterTable([
191
- process.env.C8_USERNAME_TEST_3,
192
- ]);
193
- await consoleOrganizationsPage.clickOptionsButton();
194
- await consoleOrganizationsPage.clickEditUserMenuItem();
218
+ await consoleOrganizationsPage.filterTableToUser(process.env.C8_USERNAME_TEST_3);
219
+ await consoleOrganizationsPage.clickOptionsButton(process.env.C8_USERNAME_TEST_3);
220
+ await consoleOrganizationsPage.clickEditUserMenuItem(process.env.C8_USERNAME_TEST_3);
195
221
  await consoleOrganizationsPage.uncheckAnalystCheckbox();
196
222
  await consoleOrganizationsPage.checkDeveloperCheckbox();
197
223
  await consoleOrganizationsPage.clickConfirmButton();
@@ -203,10 +229,10 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
203
229
  });
204
230
  await settingsPage.clickOpenSettingsButton();
205
231
  await settingsPage.clickLogoutButton();
206
- await loginPage.loginWithTestUser({
232
+ await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, {
207
233
  username: process.env.C8_USERNAME_TEST_3,
208
234
  password: process.env.C8_PASSWORD_TEST_3,
209
- });
235
+ }, 1000);
210
236
  await (0, test_1.expect)(homePage.camundaComponentsButton).toBeVisible({
211
237
  timeout: 120000,
212
238
  });
@@ -217,7 +243,14 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
217
243
  });
218
244
  await appsPage.assertOperatePresent(clusterName);
219
245
  await appsPage.assertTasklistPresent(clusterName);
220
- await appsPage.assertOptimizePresent(clusterName, false);
246
+ // Same ungated Hub sidebar as above: Optimize is listed for this
247
+ // Developer too, so its former `false` expectation asserted nothing real.
248
+ // Unlike Operate and Tasklist there is no component-side gate to assert
249
+ // instead -- 8.7's Optimize ships no forbidden page (no
250
+ // "You don't have access to this component" anywhere under optimize/) --
251
+ // so Developer-vs-Optimize access is deliberately left uncovered here
252
+ // rather than asserted against a page shape nobody has verified.
253
+ await appsPage.assertOptimizePresent(clusterName);
221
254
  await appsPage.clickModeler();
222
255
  await modelerHomePage.clickCrossComponentProjectFolder();
223
256
  await modelerHomePage.clickProcessDiagram(processName);
@@ -233,7 +266,7 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
233
266
  });
234
267
  await settingsPage.clickOpenSettingsButton();
235
268
  await settingsPage.clickLogoutButton();
236
- await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, testUser, 1000);
269
+ await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, orgOwner, 1000);
237
270
  await (0, sleep_1.sleep)(20000);
238
271
  await appsPage.clickCamundaApps();
239
272
  await appsPage.clickModeler();
@@ -243,11 +276,9 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
243
276
  await modelerHomePage.clickMessageBanner();
244
277
  await modelerHomePage.openOrganizationManagement(60000);
245
278
  await consoleOrganizationsPage.clickUsersTab();
246
- await consoleOrganizationsPage.filterTable([
247
- process.env.C8_USERNAME_TEST_3,
248
- ]);
249
- await consoleOrganizationsPage.clickOptionsButton();
250
- await consoleOrganizationsPage.clickEditUserMenuItem();
279
+ await consoleOrganizationsPage.filterTableToUser(process.env.C8_USERNAME_TEST_3);
280
+ await consoleOrganizationsPage.clickOptionsButton(process.env.C8_USERNAME_TEST_3);
281
+ await consoleOrganizationsPage.clickEditUserMenuItem(process.env.C8_USERNAME_TEST_3);
251
282
  await consoleOrganizationsPage.checkAnalystCheckbox();
252
283
  await consoleOrganizationsPage.clickConfirmButton();
253
284
  await (0, test_1.expect)(page.getByText('Updating...')).not.toBeVisible({
@@ -258,10 +289,10 @@ _8_7_1.test.describe('Web Modeler User Flow Tests', () => {
258
289
  });
259
290
  await settingsPage.clickOpenSettingsButton();
260
291
  await settingsPage.clickLogoutButton();
261
- await loginPage.loginWithTestUser({
292
+ await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, {
262
293
  username: process.env.C8_USERNAME_TEST_3,
263
294
  password: process.env.C8_PASSWORD_TEST_3,
264
- });
295
+ }, 1000);
265
296
  await (0, test_1.expect)(homePage.camundaComponentsButton).toBeVisible({
266
297
  timeout: 120000,
267
298
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/e2e-test-suite",
3
- "version": "0.0.1537",
3
+ "version": "0.0.1539",
4
4
  "description": "End-to-end test helpers for Camunda 8",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +0,0 @@
1
- import { Serializable } from 'playwright-core/types/structs';
2
- export declare function getGoogleAccessToken(): Promise<any>;
3
- export declare function getGmailMessagesWithRetry(token: string, sender: string, diagramName: string, laterThan?: number, maxRetries?: number): Promise<Serializable>;
4
- export declare function getGmailMessages(token: string, sender: string, diagramName: string, laterThan?: number): Promise<Serializable>;
5
- export declare function getLatestEmailDetails(token: string, emailId: string): Promise<string>;
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getLatestEmailDetails = exports.getGmailMessages = exports.getGmailMessagesWithRetry = exports.getGoogleAccessToken = void 0;
27
- const test_1 = require("@playwright/test");
28
- const console = __importStar(require("node:console"));
29
- const sleep_1 = require("./sleep");
30
- async function getGoogleAccessToken() {
31
- const tokenUrl = 'https://oauth2.googleapis.com/token';
32
- const context = await test_1.request.newContext();
33
- const response = await context.post(tokenUrl, {
34
- form: {
35
- client_id: process.env.GOOGLE_OATH_CLIENT_ID,
36
- grant_type: 'refresh_token',
37
- },
38
- });
39
- const responseBody = await response.json();
40
- (0, test_1.expect)(responseBody).toHaveProperty('access_token');
41
- (0, test_1.expect)(responseBody.access_token).not.toBeFalsy();
42
- return responseBody.access_token;
43
- }
44
- exports.getGoogleAccessToken = getGoogleAccessToken;
45
- async function getGmailMessagesWithRetry(token, sender, diagramName, laterThan, maxRetries = 5) {
46
- for (let attempt = 0; attempt < maxRetries; attempt++) {
47
- try {
48
- const messages = await getGmailMessages(token, sender, diagramName, laterThan);
49
- (0, test_1.expect)(messages.length).toBe(1);
50
- return messages;
51
- }
52
- catch (error) {
53
- if (attempt < maxRetries - 1) {
54
- console.warn(`Attempt ${attempt + 1} failed for finding alert email ${diagramName}. Retrying...`);
55
- await (0, sleep_1.sleep)(60000);
56
- }
57
- else {
58
- throw new Error(`Failed to find email for ${diagramName} failed after ${maxRetries} attempts`);
59
- }
60
- }
61
- }
62
- }
63
- exports.getGmailMessagesWithRetry = getGmailMessagesWithRetry;
64
- async function getGmailMessages(token, sender, diagramName, laterThan) {
65
- const context = await test_1.request.newContext({
66
- extraHTTPHeaders: {
67
- Authorization: `Bearer ${token}`,
68
- },
69
- });
70
- let url = `https://www.googleapis.com/gmail/v1/users/me/messages?q=from:${sender} "${diagramName}"`;
71
- if (laterThan) {
72
- url = ` ${url} after:${laterThan}`;
73
- }
74
- console.log(url);
75
- const response = await context.get(url);
76
- const responseBody = await response.json();
77
- (0, test_1.expect)(responseBody).toHaveProperty('messages');
78
- (0, test_1.expect)(responseBody.messages).not.toBeFalsy();
79
- return responseBody.messages;
80
- }
81
- exports.getGmailMessages = getGmailMessages;
82
- async function getLatestEmailDetails(token, emailId) {
83
- const context = await test_1.request.newContext({
84
- extraHTTPHeaders: {
85
- Authorization: `Bearer ${token}`,
86
- },
87
- });
88
- const response = await context.get(`https://www.googleapis.com/gmail/v1/users/me/messages/${emailId}`);
89
- const data = await response.json();
90
- let body = 'No body available';
91
- if (data.payload.parts) {
92
- const part = data.payload.parts.find((p) => p.mimeType === 'text/plain');
93
- if (part && part.body.data) {
94
- body = Buffer.from(part.body.data, 'base64').toString('utf-8');
95
- }
96
- }
97
- else if (data.payload.body.data) {
98
- body = Buffer.from(data.payload.body.data, 'base64').toString('utf-8');
99
- }
100
- return body;
101
- }
102
- exports.getLatestEmailDetails = getLatestEmailDetails;