@camunda/e2e-test-suite 0.0.571 → 0.0.573

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.
@@ -410,14 +410,48 @@ async function createStringClusterVariable(authToken, environment = 'saas', cust
410
410
  }
411
411
  exports.createStringClusterVariable = createStringClusterVariable;
412
412
  async function getOptimizeCoockie(page) {
413
- await (0, utils_1.loginToApp)(process.env.CAMUNDA_OPTIMIZE_BASE_URL, page);
413
+ const optimizeUrl = process.env.CAMUNDA_OPTIMIZE_BASE_URL;
414
+ const maxLoginAttempts = 3;
415
+ // Auth0 can fail or rate-limit concurrent logins. Retry the whole flow if
416
+ // loginToApp throws (e.g. waitForURL times out after a bad Auth0 redirect).
417
+ for (let loginAttempt = 0; loginAttempt < maxLoginAttempts; loginAttempt++) {
418
+ try {
419
+ await page.goto('about:blank');
420
+ await page.context().clearCookies();
421
+ await (0, utils_1.loginToApp)(optimizeUrl, page);
422
+ break;
423
+ }
424
+ catch (error) {
425
+ if (loginAttempt < maxLoginAttempts - 1) {
426
+ console.warn(`getOptimizeCoockie: login attempt ${loginAttempt + 1} failed, retrying after backoff...`, error);
427
+ await page.goto('about:blank');
428
+ await page.waitForTimeout(5000 * (loginAttempt + 1));
429
+ }
430
+ else {
431
+ throw error;
432
+ }
433
+ }
434
+ }
414
435
  const context = page.context();
415
- const tempFile = path_1.default.join(os_1.default.tmpdir(), `.auth_optimize_${Date.now()}_${Math.random().toString(36).slice(2)}`);
416
- await context.storageState({ path: tempFile });
417
- const authData = JSON.parse(fs_1.default.readFileSync(tempFile, 'utf8'));
418
- fs_1.default.unlinkSync(tempFile);
419
- const serviceTokenCookie = authData.cookies.find((cookie) => cookie.name === 'X-Optimize-Service-Token_0');
420
- const authTokenCookie = authData.cookies.find((cookie) => cookie.name === 'X-Optimize-Authorization_0');
436
+ // Optimize sets its session cookies asynchronously after the Auth0 redirect.
437
+ // Poll storage state until both cookies are present (up to ~30 s).
438
+ let serviceTokenCookie;
439
+ let authTokenCookie;
440
+ for (let i = 0; i < 10; i++) {
441
+ const tempFile = path_1.default.join(os_1.default.tmpdir(), `.auth_optimize_${Date.now()}_${Math.random().toString(36).slice(2)}`);
442
+ await context.storageState({ path: tempFile });
443
+ const authData = JSON.parse(fs_1.default.readFileSync(tempFile, 'utf8'));
444
+ fs_1.default.unlinkSync(tempFile);
445
+ serviceTokenCookie = authData.cookies.find((cookie) => cookie.name === 'X-Optimize-Service-Token_0');
446
+ authTokenCookie = authData.cookies.find((cookie) => cookie.name === 'X-Optimize-Authorization_0');
447
+ if (serviceTokenCookie?.value && authTokenCookie?.value) {
448
+ break;
449
+ }
450
+ if (i < 9) {
451
+ console.warn(`getOptimizeCoockie: cookies not ready yet (attempt ${i + 1}/10), retrying in 3 s...`);
452
+ await page.waitForTimeout(3000);
453
+ }
454
+ }
421
455
  const optimizeServiceToken = serviceTokenCookie?.value || '';
422
456
  const optimizeAuthToken = authTokenCookie?.value || '';
423
457
  const optimizeCookie = `X-Optimize-Service-Token_0=${optimizeServiceToken}; X-Optimize-Authorization_0=${optimizeAuthToken}`;
@@ -12,9 +12,9 @@ async function loginToApp(appName, page) {
12
12
  await (0, test_1.expect)(loginPage.usernameInput).toHaveValue(process.env.C8_USERNAME);
13
13
  await (0, test_1.expect)(loginPage.loginMessage).toBeVisible();
14
14
  await loginPage.clickContinueButton();
15
- await (0, test_1.expect)(loginPage.passwordInput).toBeVisible({ timeout: 60000 });
15
+ await (0, test_1.expect)(loginPage.passwordInput).toBeVisible({ timeout: 90000 });
16
16
  await loginPage.fillPassword(process.env.C8_PASSWORD);
17
- await (0, test_1.expect)(loginPage.passwordHeading).toBeVisible();
17
+ await (0, test_1.expect)(loginPage.passwordHeading).toBeVisible({ timeout: 90000 });
18
18
  await loginPage.clickLoginButton();
19
19
  await page.waitForURL((url) => url.toString().startsWith(appName), {
20
20
  timeout: 60000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/e2e-test-suite",
3
- "version": "0.0.571",
3
+ "version": "0.0.573",
4
4
  "description": "End-to-end test helpers for Camunda 8",
5
5
  "repository": {
6
6
  "type": "git",