@camunda/e2e-test-suite 0.0.389 → 0.0.390

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.
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const _8_9_1 = require("../../../fixtures/8.9");
4
+ const UtilitiesPage_1 = require("../../../pages/8.9/UtilitiesPage");
5
+ const _setup_1 = require("../../../test-setup.js");
6
+ const apiHelpers_1 = require("../../../utils/apiHelpers");
7
+ const userTaskHelpers_1 = require("../../../utils/userTaskHelpers");
8
+ const users_1 = require("../../../utils/users");
9
+ const test_1 = require("@playwright/test");
10
+ const testUser = (0, users_1.getTestUser)('fourteenthUser');
11
+ let authToken;
12
+ let toolsInstanceKey;
13
+ _8_9_1.test.describe.configure({ mode: 'parallel' });
14
+ _8_9_1.test.describe('Orchestration Cluster MCP Server - User Task Tools @tasklistV2', () => {
15
+ const clusterName = 'Agentic Orchestration Cluster';
16
+ _8_9_1.test.beforeAll(async () => {
17
+ authToken = await (0, apiHelpers_1.authSaasAPI)(undefined, 'agentic_cluster');
18
+ const [testFileProcessKey, toolsProcessKey] = await Promise.all([
19
+ (0, apiHelpers_1.deployProcess)('./resources/mcp_server_saas/mcp_user_task_test_file.bpmn', authToken, 'saas', 'agentic_cluster'),
20
+ (0, apiHelpers_1.deployProcess)('./resources/mcp_server_saas/mcp_user_task_tools.bpmn', authToken, 'saas', 'agentic_cluster'),
21
+ ]);
22
+ if (testFileProcessKey == null || toolsProcessKey == null) {
23
+ throw new Error('Failed to deploy user task tools processes');
24
+ }
25
+ // Create test instance which will create a user task
26
+ const testInstanceKey = await (0, apiHelpers_1.createProcessInstance)(String(testFileProcessKey), authToken, 'saas', 'agentic_cluster');
27
+ // Get the user task key created by the test instance (with retry logic)
28
+ const testUserTaskKey = await (0, userTaskHelpers_1.getUserTaskKeyByProcessInstanceKey)(testInstanceKey, authToken, 'saas', 'agentic_cluster');
29
+ console.log('Creating tools instance with variables:', {
30
+ testFileProcessKey,
31
+ testUserTaskKey,
32
+ });
33
+ // Create tools instance with required variables
34
+ toolsInstanceKey = await (0, apiHelpers_1.createProcessInstance)(String(toolsProcessKey), authToken, 'saas', 'agentic_cluster', { testFileProcessKey, testUserTaskKey });
35
+ });
36
+ _8_9_1.test.beforeEach(async ({ page, loginPage }, testInfo) => {
37
+ await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, testUser, (testInfo.workerIndex + 1) * 1000);
38
+ });
39
+ _8_9_1.test.afterEach(async ({ page }, testInfo) => {
40
+ await (0, _setup_1.captureScreenshot)(page, testInfo);
41
+ await (0, _setup_1.captureFailureVideo)(page, testInfo);
42
+ });
43
+ const userTaskToolTests = [
44
+ {
45
+ name: 'searchUserTasks - search user tasks with filters such as processDefinitionKey',
46
+ variable: 'mcpResultSearchUserTasks',
47
+ assertions: [
48
+ {
49
+ text: 'totalItems',
50
+ description: 'search response contains totalItems field',
51
+ },
52
+ {
53
+ text: 'userTaskKey',
54
+ description: 'search response contains userTaskKey field',
55
+ },
56
+ {
57
+ text: 'processDefinitionKey',
58
+ description: 'search response contains processDefinitionKey field',
59
+ },
60
+ ],
61
+ },
62
+ {
63
+ name: 'getUserTask - retrieve a user task by key',
64
+ variable: 'mcpResultGetUserTask',
65
+ assertions: [
66
+ {
67
+ text: 'userTaskKey',
68
+ description: 'response contains userTaskKey field',
69
+ },
70
+ {
71
+ text: 'processInstanceKey',
72
+ description: 'response contains processInstanceKey field',
73
+ },
74
+ {
75
+ text: 'assignee',
76
+ description: 'response contains assignee field',
77
+ },
78
+ ],
79
+ },
80
+ {
81
+ name: 'assignUserTask - update the assignment of a user task',
82
+ variable: 'mcpResultAssignUserTask',
83
+ assertions: [
84
+ {
85
+ text: 'mcpUser',
86
+ description: 'response reflects the assignee value mcpUser',
87
+ },
88
+ ],
89
+ },
90
+ {
91
+ name: 'searchUserTaskVariables - search variables scoped to a specific user task',
92
+ variable: 'mcpResultSearchUserTaskVariables',
93
+ assertions: [
94
+ {
95
+ text: 'totalItems',
96
+ description: 'search response contains totalItems field',
97
+ },
98
+ {
99
+ text: 'items',
100
+ description: 'search response contains items array',
101
+ },
102
+ ],
103
+ },
104
+ ];
105
+ for (const testCase of userTaskToolTests) {
106
+ (0, _8_9_1.test)(testCase.name, async ({ page, homePage, appsPage, operateHomePage, operateProcessesPage, operateProcessInstancePage, }) => {
107
+ _8_9_1.test.slow();
108
+ await _8_9_1.test.step('Navigate to completed process in Operate', async () => {
109
+ await page.goto('/');
110
+ await homePage.clickClusters();
111
+ await appsPage.clickOperate(clusterName);
112
+ await (0, test_1.expect)(operateHomePage.operateBanner).toBeVisible({
113
+ timeout: 60000,
114
+ });
115
+ await operateHomePage.clickProcessesTab();
116
+ await operateProcessesPage.clickProcessCompletedCheckbox();
117
+ await operateProcessesPage.applyMoreFilters('Process Instance Key(s)', String(toolsInstanceKey));
118
+ await operateProcessesPage.clickProcessInstanceLink('MCP User Task Tools');
119
+ await operateProcessInstancePage.assertProcessCompleteStatusWithRetry();
120
+ });
121
+ for (const assertion of testCase.assertions) {
122
+ await _8_9_1.test.step(assertion.description, async () => {
123
+ await operateProcessInstancePage.assertProcessVariableContainsText(testCase.variable, assertion.text);
124
+ });
125
+ }
126
+ });
127
+ }
128
+ });
@@ -1,8 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import { APIRequestContext, APIResponse, Response, Page } from '@playwright/test';
3
3
  import { Serializable } from 'playwright-core/types/structs';
4
+ export declare function getApiRequestContext(): Promise<APIRequestContext>;
4
5
  export declare function assertResponseStatus(response: APIResponse | Response, status: number): Promise<void>;
5
6
  export declare function sendRequestAndAssertResponse(request: APIRequestContext, url: string, requestBody?: string | Buffer | Serializable, maxRetries?: number): Promise<void>;
7
+ export declare function buildZeebeApiUrl(resourcePath: string, environmentOverride?: 'saas' | 'sm', clusterType?: string): string;
6
8
  export declare function authAPI(environment: 'saas'): Promise<string>;
7
9
  export declare function authAPI(environment: 'sm'): Promise<string>;
8
10
  export declare function authAPI(environment: 'saas', audience?: string): Promise<string>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.updateCollectionScope = exports.createSingleProcessReport = exports.createDashboard = exports.createCollection = exports.getOptimizeCoockie = exports.createGlobalClusterVariable = exports.createStringClusterVariable = exports.createJsonClusterVariable = exports.createProcessInstance = exports.deployProcess = exports.validateMcpServerHealth = exports.authC8runAPI = exports.authSmAPI = exports.authSaasAPI = exports.authAPI = exports.sendRequestAndAssertResponse = exports.assertResponseStatus = void 0;
6
+ exports.updateCollectionScope = exports.createSingleProcessReport = exports.createDashboard = exports.createCollection = exports.getOptimizeCoockie = exports.createGlobalClusterVariable = exports.createStringClusterVariable = exports.createJsonClusterVariable = exports.createProcessInstance = exports.deployProcess = exports.validateMcpServerHealth = exports.authC8runAPI = exports.authSmAPI = exports.authSaasAPI = exports.authAPI = exports.buildZeebeApiUrl = exports.sendRequestAndAssertResponse = exports.assertResponseStatus = exports.getApiRequestContext = void 0;
7
7
  const test_1 = require("@playwright/test");
8
8
  const sleep_1 = require("./sleep");
9
9
  const fs_1 = __importDefault(require("fs"));
@@ -17,6 +17,7 @@ async function getApiRequestContext() {
17
17
  }
18
18
  return apiRequestContext;
19
19
  }
20
+ exports.getApiRequestContext = getApiRequestContext;
20
21
  // ---- Common HTTP helpers ----
21
22
  async function assertResponseStatus(response, status) {
22
23
  (0, test_1.expect)(response.status()).toBe(status);
@@ -117,6 +118,7 @@ function buildZeebeApiUrl(resourcePath, environmentOverride, clusterType) {
117
118
  const pathWithPrefix = environment === 'sm' ? `${contextPath}${normalizedPath}` : normalizedPath;
118
119
  return `${baseUrl}${pathWithPrefix}`;
119
120
  }
121
+ exports.buildZeebeApiUrl = buildZeebeApiUrl;
120
122
  async function authAPI(environment, audience = process.env.ZEEBE_API_TOKEN_AUDIENCE) {
121
123
  apiRequestContext = await getApiRequestContext();
122
124
  if (environment === 'saas') {
@@ -0,0 +1 @@
1
+ export declare function getUserTaskKeyByProcessInstanceKey(processInstanceKey: string, authToken?: string, environment?: 'saas' | 'sm', clusterType?: string, maxRetries?: number, retryDelayMs?: number): Promise<string>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUserTaskKeyByProcessInstanceKey = void 0;
4
+ const test_1 = require("@playwright/test");
5
+ const apiHelpers_1 = require("./apiHelpers");
6
+ const sleep_1 = require("./sleep");
7
+ async function getUserTaskKeyByProcessInstanceKey(processInstanceKey, authToken, environment, clusterType, maxRetries = 10, retryDelayMs = 2000) {
8
+ const apiRequestContext = await (0, apiHelpers_1.getApiRequestContext)();
9
+ const url = (0, apiHelpers_1.buildZeebeApiUrl)('/v2/user-tasks/search', environment, clusterType);
10
+ let lastError = null;
11
+ // Retry logic to wait for user task to be indexed
12
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
13
+ try {
14
+ const response = await apiRequestContext.post(url, {
15
+ headers: {
16
+ Authorization: authToken ?? '',
17
+ },
18
+ data: {
19
+ filter: {
20
+ processInstanceKey: String(processInstanceKey),
21
+ },
22
+ },
23
+ });
24
+ (0, test_1.expect)(response.status()).toBe(200);
25
+ const responseBody = await response.json();
26
+ if (responseBody?.items && responseBody.items.length > 0) {
27
+ const userTaskKey = responseBody.items[0]?.userTaskKey;
28
+ if (userTaskKey != null) {
29
+ console.log(`Found user task key ${userTaskKey} for process instance ${processInstanceKey} on attempt ${attempt}`);
30
+ return String(userTaskKey);
31
+ }
32
+ }
33
+ lastError = new Error(`No user tasks found for processInstanceKey: ${processInstanceKey}`);
34
+ }
35
+ catch (error) {
36
+ lastError = error;
37
+ }
38
+ // Wait before retrying (except on last attempt)
39
+ if (attempt < maxRetries) {
40
+ console.log(`User task not found yet for process instance ${processInstanceKey}, retrying in ${retryDelayMs}ms (attempt ${attempt}/${maxRetries})...`);
41
+ await (0, sleep_1.sleep)(retryDelayMs);
42
+ }
43
+ }
44
+ throw new Error(`Failed to find user task after ${maxRetries} attempts: ${lastError?.message}`);
45
+ }
46
+ exports.getUserTaskKeyByProcessInstanceKey = getUserTaskKeyByProcessInstanceKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/e2e-test-suite",
3
- "version": "0.0.389",
3
+ "version": "0.0.390",
4
4
  "description": "End-to-end test helpers for Camunda 8",
5
5
  "repository": {
6
6
  "type": "git",