Last active
August 17, 2025 07:38
-
-
Save jwulf/69e9b07f4ab67ce98a78bb48a33e23ec to your computer and use it in GitHub Desktop.
Generated API endpoint test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { test, expect } from '@playwright/test'; | |
| import { buildBaseUrl, authHeaders } from '../support/env'; | |
| test.describe('createProcessInstance', () => { | |
| test('feature-1 - createProcessInstance - base (1)', async ({ request }) => { | |
| const baseUrl = buildBaseUrl(); | |
| const ctx: Record<string, any> = {}; | |
| // Seed scenario bindings | |
| // Step 1: createDeployment | |
| { | |
| const url = baseUrl + `/deployments`; | |
| const body1 = { | |
| "fields": { | |
| "tenantId": ctx["tenantIdVar"] | |
| }, | |
| "files": { | |
| "resources": "@@FILE:bpmn/simple.bpmn" | |
| } | |
| }; | |
| const formData: Array<{ name: string; value: any; fileName?: string }> = []; | |
| for (const [k,v] of Object.entries(body1.fields||{})) formData.push({ name: k, value: String(v) }); | |
| for (const [k,v] of Object.entries(body1.files||{})) { | |
| if (typeof v === 'string' && v.startsWith('@@FILE:')) { | |
| const p = v.slice('@@FILE:'.length); | |
| formData.push({ name: k, value: await (await import('fs')).promises.readFile(p), fileName: p.split('/').pop() }); | |
| } else { | |
| formData.push({ name: k, value: v }); | |
| } | |
| } | |
| const resp1 = await request.post(url, { headers: await authHeaders(), multipart: formData }); | |
| expect(resp1.status()).toBe(200); | |
| const json = await resp1.json(); | |
| ctx['processDefinitionIdVar'] = json.deployments[0].processDefinition.processDefinitionId; | |
| ctx['processDefinitionKeyVar'] = json.deployments[0].processDefinition.processDefinitionKey; | |
| ctx['formKeyVar'] = json.deployments[0].form.formKey; | |
| } | |
| // Step 2: createProcessInstance | |
| { | |
| const url = baseUrl + `/process-instances`; | |
| const body2 = { | |
| "processDefinitionKey": ctx["processDefinitionKeyVar"] | |
| }; | |
| const resp2 = await request.post(url, { headers: await authHeaders(), data: body2 }); | |
| expect(resp2.status()).toBe(200); | |
| const json = await resp2.json(); | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| ctx['processDefinitionKeyVar'] = json.processDefinitionKey; | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| } | |
| }); | |
| test('feature-2 - createProcessInstance - oneOf group0 Process creation by ID (2)', async ({ request }) => { | |
| const baseUrl = buildBaseUrl(); | |
| const ctx: Record<string, any> = {}; | |
| // Seed scenario bindings | |
| // Step 1: createDeployment | |
| { | |
| const url = baseUrl + `/deployments`; | |
| const body1 = { | |
| "fields": { | |
| "tenantId": ctx["tenantIdVar"] | |
| }, | |
| "files": { | |
| "resources": "@@FILE:bpmn/simple.bpmn" | |
| } | |
| }; | |
| const formData: Array<{ name: string; value: any; fileName?: string }> = []; | |
| for (const [k,v] of Object.entries(body1.fields||{})) formData.push({ name: k, value: String(v) }); | |
| for (const [k,v] of Object.entries(body1.files||{})) { | |
| if (typeof v === 'string' && v.startsWith('@@FILE:')) { | |
| const p = v.slice('@@FILE:'.length); | |
| formData.push({ name: k, value: await (await import('fs')).promises.readFile(p), fileName: p.split('/').pop() }); | |
| } else { | |
| formData.push({ name: k, value: v }); | |
| } | |
| } | |
| const resp1 = await request.post(url, { headers: await authHeaders(), multipart: formData }); | |
| expect(resp1.status()).toBe(200); | |
| const json = await resp1.json(); | |
| ctx['processDefinitionIdVar'] = json.deployments[0].processDefinition.processDefinitionId; | |
| ctx['processDefinitionKeyVar'] = json.deployments[0].processDefinition.processDefinitionKey; | |
| ctx['formKeyVar'] = json.deployments[0].form.formKey; | |
| } | |
| // Step 2: createProcessInstance | |
| { | |
| const url = baseUrl + `/process-instances`; | |
| const body2 = { | |
| "processDefinitionId": ctx["processDefinitionIdVar"] | |
| }; | |
| const resp2 = await request.post(url, { headers: await authHeaders(), data: body2 }); | |
| expect(resp2.status()).toBe(200); | |
| const json = await resp2.json(); | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| ctx['processDefinitionKeyVar'] = json.processDefinitionKey; | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| } | |
| }); | |
| test('feature-3 - createProcessInstance - oneOf group0 Process creation by ID:rich rich (3)', async ({ request }) => { | |
| const baseUrl = buildBaseUrl(); | |
| const ctx: Record<string, any> = {}; | |
| // Seed scenario bindings | |
| // Step 1: createDeployment | |
| { | |
| const url = baseUrl + `/deployments`; | |
| const body1 = { | |
| "fields": { | |
| "tenantId": ctx["tenantIdVar"] | |
| }, | |
| "files": { | |
| "resources": "@@FILE:bpmn/simple.bpmn" | |
| } | |
| }; | |
| const formData: Array<{ name: string; value: any; fileName?: string }> = []; | |
| for (const [k,v] of Object.entries(body1.fields||{})) formData.push({ name: k, value: String(v) }); | |
| for (const [k,v] of Object.entries(body1.files||{})) { | |
| if (typeof v === 'string' && v.startsWith('@@FILE:')) { | |
| const p = v.slice('@@FILE:'.length); | |
| formData.push({ name: k, value: await (await import('fs')).promises.readFile(p), fileName: p.split('/').pop() }); | |
| } else { | |
| formData.push({ name: k, value: v }); | |
| } | |
| } | |
| const resp1 = await request.post(url, { headers: await authHeaders(), multipart: formData }); | |
| expect(resp1.status()).toBe(200); | |
| const json = await resp1.json(); | |
| ctx['processDefinitionIdVar'] = json.deployments[0].processDefinition.processDefinitionId; | |
| ctx['processDefinitionKeyVar'] = json.deployments[0].processDefinition.processDefinitionKey; | |
| ctx['formKeyVar'] = json.deployments[0].form.formKey; | |
| } | |
| // Step 2: createProcessInstance | |
| { | |
| const url = baseUrl + `/process-instances`; | |
| const body2 = { | |
| "processDefinitionKey": ctx["processDefinitionKeyVar"] | |
| }; | |
| const resp2 = await request.post(url, { headers: await authHeaders(), data: body2 }); | |
| expect(resp2.status()).toBe(200); | |
| const json = await resp2.json(); | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| ctx['processDefinitionKeyVar'] = json.processDefinitionKey; | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| } | |
| }); | |
| test('feature-4 - createProcessInstance - oneOf group0 Process creation by key (4)', async ({ request }) => { | |
| const baseUrl = buildBaseUrl(); | |
| const ctx: Record<string, any> = {}; | |
| // Seed scenario bindings | |
| // Step 1: createDeployment | |
| { | |
| const url = baseUrl + `/deployments`; | |
| const body1 = { | |
| "fields": { | |
| "tenantId": ctx["tenantIdVar"] | |
| }, | |
| "files": { | |
| "resources": "@@FILE:bpmn/simple.bpmn" | |
| } | |
| }; | |
| const formData: Array<{ name: string; value: any; fileName?: string }> = []; | |
| for (const [k,v] of Object.entries(body1.fields||{})) formData.push({ name: k, value: String(v) }); | |
| for (const [k,v] of Object.entries(body1.files||{})) { | |
| if (typeof v === 'string' && v.startsWith('@@FILE:')) { | |
| const p = v.slice('@@FILE:'.length); | |
| formData.push({ name: k, value: await (await import('fs')).promises.readFile(p), fileName: p.split('/').pop() }); | |
| } else { | |
| formData.push({ name: k, value: v }); | |
| } | |
| } | |
| const resp1 = await request.post(url, { headers: await authHeaders(), multipart: formData }); | |
| expect(resp1.status()).toBe(200); | |
| const json = await resp1.json(); | |
| ctx['processDefinitionIdVar'] = json.deployments[0].processDefinition.processDefinitionId; | |
| ctx['processDefinitionKeyVar'] = json.deployments[0].processDefinition.processDefinitionKey; | |
| ctx['formKeyVar'] = json.deployments[0].form.formKey; | |
| } | |
| // Step 2: createProcessInstance | |
| { | |
| const url = baseUrl + `/process-instances`; | |
| const body2 = { | |
| "processDefinitionKey": ctx["processDefinitionKeyVar"] | |
| }; | |
| const resp2 = await request.post(url, { headers: await authHeaders(), data: body2 }); | |
| expect(resp2.status()).toBe(200); | |
| const json = await resp2.json(); | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| ctx['processDefinitionKeyVar'] = json.processDefinitionKey; | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| } | |
| }); | |
| test('feature-5 - createProcessInstance - oneOf group0 Process creation by key:rich rich (5)', async ({ request }) => { | |
| const baseUrl = buildBaseUrl(); | |
| const ctx: Record<string, any> = {}; | |
| // Seed scenario bindings | |
| // Step 1: createDeployment | |
| { | |
| const url = baseUrl + `/deployments`; | |
| const body1 = { | |
| "fields": { | |
| "tenantId": ctx["tenantIdVar"] | |
| }, | |
| "files": { | |
| "resources": "@@FILE:bpmn/simple.bpmn" | |
| } | |
| }; | |
| const formData: Array<{ name: string; value: any; fileName?: string }> = []; | |
| for (const [k,v] of Object.entries(body1.fields||{})) formData.push({ name: k, value: String(v) }); | |
| for (const [k,v] of Object.entries(body1.files||{})) { | |
| if (typeof v === 'string' && v.startsWith('@@FILE:')) { | |
| const p = v.slice('@@FILE:'.length); | |
| formData.push({ name: k, value: await (await import('fs')).promises.readFile(p), fileName: p.split('/').pop() }); | |
| } else { | |
| formData.push({ name: k, value: v }); | |
| } | |
| } | |
| const resp1 = await request.post(url, { headers: await authHeaders(), multipart: formData }); | |
| expect(resp1.status()).toBe(200); | |
| const json = await resp1.json(); | |
| ctx['processDefinitionIdVar'] = json.deployments[0].processDefinition.processDefinitionId; | |
| ctx['processDefinitionKeyVar'] = json.deployments[0].processDefinition.processDefinitionKey; | |
| ctx['formKeyVar'] = json.deployments[0].form.formKey; | |
| } | |
| // Step 2: createProcessInstance | |
| { | |
| const url = baseUrl + `/process-instances`; | |
| const body2 = { | |
| "processDefinitionKey": ctx["processDefinitionKeyVar"] | |
| }; | |
| const resp2 = await request.post(url, { headers: await authHeaders(), data: body2 }); | |
| expect(resp2.status()).toBe(200); | |
| const json = await resp2.json(); | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| ctx['processDefinitionKeyVar'] = json.processDefinitionKey; | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| } | |
| }); | |
| test('feature-6 - createProcessInstance - oneOf group0 union violation (6)', async ({ request }) => { | |
| const baseUrl = buildBaseUrl(); | |
| const ctx: Record<string, any> = {}; | |
| // Seed scenario bindings | |
| // Step 1: createDeployment | |
| { | |
| const url = baseUrl + `/deployments`; | |
| const body1 = { | |
| "fields": { | |
| "tenantId": ctx["tenantIdVar"] | |
| }, | |
| "files": { | |
| "resources": "@@FILE:bpmn/simple.bpmn" | |
| } | |
| }; | |
| const formData: Array<{ name: string; value: any; fileName?: string }> = []; | |
| for (const [k,v] of Object.entries(body1.fields||{})) formData.push({ name: k, value: String(v) }); | |
| for (const [k,v] of Object.entries(body1.files||{})) { | |
| if (typeof v === 'string' && v.startsWith('@@FILE:')) { | |
| const p = v.slice('@@FILE:'.length); | |
| formData.push({ name: k, value: await (await import('fs')).promises.readFile(p), fileName: p.split('/').pop() }); | |
| } else { | |
| formData.push({ name: k, value: v }); | |
| } | |
| } | |
| const resp1 = await request.post(url, { headers: await authHeaders(), multipart: formData }); | |
| expect(resp1.status()).toBe(200); | |
| const json = await resp1.json(); | |
| ctx['processDefinitionIdVar'] = json.deployments[0].processDefinition.processDefinitionId; | |
| ctx['processDefinitionKeyVar'] = json.deployments[0].processDefinition.processDefinitionKey; | |
| ctx['formKeyVar'] = json.deployments[0].form.formKey; | |
| } | |
| // Step 2: createProcessInstance | |
| { | |
| const url = baseUrl + `/process-instances`; | |
| const body2 = { | |
| "processDefinitionId": ctx["processDefinitionIdVar"], | |
| "processDefinitionVersion": ctx["processDefinitionVersionVar"], | |
| "variables": ctx["variablesVar"], | |
| "tenantId": ctx["tenantIdVar"], | |
| "operationReference": ctx["operationReferenceVar"], | |
| "startInstructions": ctx["startInstructionsVar"], | |
| "runtimeInstructions": ctx["runtimeInstructionsVar"], | |
| "awaitCompletion": ctx["awaitCompletionVar"], | |
| "fetchVariables": ctx["fetchVariablesVar"], | |
| "requestTimeout": ctx["requestTimeoutVar"], | |
| "processDefinitionKey": ctx["processDefinitionKeyVar"] | |
| }; | |
| const resp2 = await request.post(url, { headers: await authHeaders(), data: body2 }); | |
| expect(resp2.status()).toBe(400); | |
| const json = await resp2.json(); | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| ctx['processDefinitionKeyVar'] = json.processDefinitionKey; | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| } | |
| }); | |
| test('feature-7 - createProcessInstance - oneOf group0 pair violation (processDefinitionId+processDefinitionKey) (7)', async ({ request }) => { | |
| const baseUrl = buildBaseUrl(); | |
| const ctx: Record<string, any> = {}; | |
| // Seed scenario bindings | |
| // Step 1: createDeployment | |
| { | |
| const url = baseUrl + `/deployments`; | |
| const body1 = { | |
| "fields": { | |
| "tenantId": ctx["tenantIdVar"] | |
| }, | |
| "files": { | |
| "resources": "@@FILE:bpmn/simple.bpmn" | |
| } | |
| }; | |
| const formData: Array<{ name: string; value: any; fileName?: string }> = []; | |
| for (const [k,v] of Object.entries(body1.fields||{})) formData.push({ name: k, value: String(v) }); | |
| for (const [k,v] of Object.entries(body1.files||{})) { | |
| if (typeof v === 'string' && v.startsWith('@@FILE:')) { | |
| const p = v.slice('@@FILE:'.length); | |
| formData.push({ name: k, value: await (await import('fs')).promises.readFile(p), fileName: p.split('/').pop() }); | |
| } else { | |
| formData.push({ name: k, value: v }); | |
| } | |
| } | |
| const resp1 = await request.post(url, { headers: await authHeaders(), multipart: formData }); | |
| expect(resp1.status()).toBe(200); | |
| const json = await resp1.json(); | |
| ctx['processDefinitionIdVar'] = json.deployments[0].processDefinition.processDefinitionId; | |
| ctx['processDefinitionKeyVar'] = json.deployments[0].processDefinition.processDefinitionKey; | |
| ctx['formKeyVar'] = json.deployments[0].form.formKey; | |
| } | |
| // Step 2: createProcessInstance | |
| { | |
| const url = baseUrl + `/process-instances`; | |
| const body2 = { | |
| "processDefinitionId": ctx["processDefinitionIdVar"], | |
| "processDefinitionKey": ctx["processDefinitionKeyVar"] | |
| }; | |
| const resp2 = await request.post(url, { headers: await authHeaders(), data: body2 }); | |
| expect(resp2.status()).toBe(200); | |
| const json = await resp2.json(); | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| ctx['processDefinitionKeyVar'] = json.processDefinitionKey; | |
| ctx['processInstanceKeyVar'] = json.processInstanceKey; | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment