Skip to content

Commit

Permalink
XIVY-13943 extended sub-process connector example
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-rew committed Dec 20, 2024
1 parent 321932a commit 4c135f0
Show file tree
Hide file tree
Showing 10 changed files with 263 additions and 5 deletions.
1 change: 1 addition & 0 deletions build/screenshot/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pipeline {
}
archiveArtifacts artifacts: 'playwright/test-results/**', allowEmptyArchive: true
archiveArtifacts artifacts: 'playwright/process-test-project/target/**/ivy.log', allowEmptyArchive: true
archiveArtifacts artifacts: 'playwright/*/target/screenshots/**/*.png', allowEmptyArchive: true
withChecks('Screenshots') {
junit testDataPublishers: [[$class: 'StabilityTestDataPublisher']], testResults: 'node_modules/**/report.xml'
}
Expand Down
23 changes: 23 additions & 0 deletions playwright/process-test-project/dataclasses/market/Person.d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema" : "https://json-schema.axonivy.com/data-class/12.0.0/data-class.json",
"simpleName" : "Person",
"namespace" : "market",
"isBusinessCaseData" : false,
"fields" : [ {
"name" : "id",
"type" : "Long",
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "firstname",
"type" : "String",
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "lastname",
"type" : "String",
"modifiers" : [ "PERSISTENT" ]
}, {
"name" : "title",
"type" : "String",
"modifiers" : [ "PERSISTENT" ]
} ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema" : "https://json-schema.axonivy.com/data-class/12.0.0/data-class.json",
"simpleName" : "UserScriptData",
"namespace" : "market",
"isBusinessCaseData" : false,
"fields" : [ {
"name" : "user",
"type" : "market.Person",
"modifiers" : [ "PERSISTENT" ]
} ]
}
11 changes: 11 additions & 0 deletions playwright/process-test-project/dataclasses/market/erpData.d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema" : "https://json-schema.axonivy.com/data-class/12.0.0/data-class.json",
"simpleName" : "erpData",
"namespace" : "market",
"isBusinessCaseData" : false,
"fields" : [ {
"name" : "user",
"type" : "market.Person",
"modifiers" : [ "PERSISTENT" ]
} ]
}
52 changes: 52 additions & 0 deletions playwright/process-test-project/processes/market/UserEnroll.p.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"$schema" : "https://json-schema.axonivy.com/process/12.0.0/process.json",
"id" : "193E3ABB2D641C01",
"config" : {
"data" : "market.UserScriptData"
},
"elements" : [ {
"id" : "f0",
"type" : "RequestStart",
"name" : "enroll",
"config" : {
"signature" : "start"
},
"visual" : {
"at" : { "x" : 96, "y" : 64 }
},
"connect" : [
{ "id" : "f2", "to" : "f5" }
]
}, {
"id" : "f1",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 352, "y" : 64 },
"labelOffset" : { "x" : 13, "y" : 33 }
}
}, {
"id" : "f5",
"type" : "SubProcessCall",
"name" : "evalUser",
"config" : {
"processCall" : "market/erp:evalUser(Long)",
"call" : {
"map" : {
"param.id" : "in.user.id"
}
},
"output" : {
"map" : {
"out" : "in",
"out.user" : "result.user"
}
}
},
"visual" : {
"at" : { "x" : 224, "y" : 64 }
},
"connect" : [
{ "id" : "f3", "to" : "f1" }
]
} ]
}
58 changes: 58 additions & 0 deletions playwright/process-test-project/processes/market/UserScript.p.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"$schema" : "https://json-schema.axonivy.com/process/12.0.0/process.json",
"id" : "193E3B0AD20672E7",
"config" : {
"data" : "market.UserScriptData"
},
"elements" : [ {
"id" : "f0",
"type" : "RequestStart",
"name" : "enroll",
"config" : {
"signature" : "start"
},
"visual" : {
"at" : { "x" : 96, "y" : 64 }
},
"connect" : [
{ "id" : "f2", "to" : "f3" }
]
}, {
"id" : "f1",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 392, "y" : 64 },
"labelOffset" : { "x" : 13, "y" : 33 }
}
}, {
"id" : "f3",
"type" : "Script",
"name" : "lookupErp",
"config" : {
"output" : {
"code" : "// my heavy java lookup"
}
},
"visual" : {
"at" : { "x" : 240, "y" : 63 },
"size" : { "width" : 120, "height" : 63 }
},
"connect" : [
{ "id" : "f4", "to" : "f1", "color" : "default" }
]
}, {
"id" : "f5",
"type" : "ProcessAnnotation",
"name" : [
"Heavy Java Logic:",
"- Connects to ERP",
"- Finds users by ID"
],
"visual" : {
"at" : { "x" : 240, "y" : 160 }
},
"connect" : [
{ "id" : "f6", "to" : "f3" }
]
} ]
}
79 changes: 79 additions & 0 deletions playwright/process-test-project/processes/market/erp.p.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"$schema" : "https://json-schema.axonivy.com/process/12.0.0/process.json",
"id" : "193E3AEFF2379C85",
"kind" : "CALLABLE_SUB",
"config" : {
"data" : "market.erpData"
},
"elements" : [ {
"id" : "f0",
"type" : "CallSubStart",
"name" : "evalUser(Long)",
"config" : {
"signature" : "evalUser",
"input" : {
"params" : [
{ "name" : "id", "type" : "Long", "desc" : "known unique ERP userID" }
],
"map" : {
"out.user.id" : "param.id"
}
},
"result" : {
"params" : [
{ "name" : "user", "type" : "market.Person", "desc" : "Resolved ERP user" }
],
"map" : {
"result.user" : "in.user"
}
}
},
"tags" : [
"connector"
],
"visual" : {
"at" : { "x" : 96, "y" : 64 },
"icon" : "res:/webContent/icons/user.png?small"
},
"connect" : [
{ "id" : "f2", "to" : "f3" }
]
}, {
"id" : "f1",
"type" : "CallSubEnd",
"visual" : {
"at" : { "x" : 352, "y" : 64 },
"labelOffset" : { "x" : 13, "y" : 33 }
}
}, {
"id" : "f3",
"type" : "Script",
"name" : "lookupErp",
"config" : {
"output" : {
"code" : "// my heavy java lookup"
}
},
"visual" : {
"at" : { "x" : 224, "y" : 63 },
"size" : { "width" : 120, "height" : 63 }
},
"connect" : [
{ "id" : "f4", "to" : "f1" }
]
}, {
"id" : "f5",
"type" : "ProcessAnnotation",
"name" : [
"Heavy Java Logic:",
"- Connects to ERP",
"- Finds users by ID"
],
"visual" : {
"at" : { "x" : 224, "y" : 160 }
},
"connect" : [
{ "id" : "f6", "to" : "f3" }
]
} ]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions playwright/tests/screenshots/editor/editor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Page } from '@playwright/test';
import { test, expect } from '@playwright/test';
import { ProcessEditor } from '../../page-objects/editor/process-editor';
import { Inscription } from '../../page-objects/inscription/inscription-view';

test.beforeEach(async ({ page }) => {
await page.emulateMedia({ colorScheme: 'light' });
Expand Down Expand Up @@ -40,6 +41,28 @@ test('extensions', async ({ page }) => {
await screenshot(page, 'extensions.png');
});

test('connector-process', async ({ page }) => {
const editor = await ProcessEditor.openProcess(page, { file: '/processes/market/erp.p.json', waitFor: '.sprotty-graph' });
await editor.element('start:callSubStart').inscribe();
const inscription = new Inscription(page);
inscription.waitForView();
const start = inscription.accordion('Start');
await start.toggle();
await start.section('Mapping').close();
await start.section('Input parameters').open();
await screenshot(page, 'connector-process.png', { height: 400 });
});

test('connector-user', async ({ page }) => {
const editor = await ProcessEditor.openProcess(page, { file: '/processes/market/UserEnroll.p.json', waitFor: '.sprotty-graph' });
await editor.element('subProcessCall').inscribe();
const inscription = new Inscription(page);
inscription.waitForView();
const process = inscription.accordion('Process');
await process.toggle();
await screenshot(page, 'connector-user.png', { height: 400 });
});

async function screenshot(page: Page, name: string, size?: { width?: number; height?: number }) {
await page.setViewportSize({ width: size?.width ?? 700, height: size?.height ?? 550 });
const dir = process.env.SCREENSHOT_DIR ?? './target';
Expand Down
10 changes: 5 additions & 5 deletions playwright/tests/standalone/tool-bar/extensions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { expect, test } from '@playwright/test';
import { ProcessEditor } from '../../page-objects/editor/process-editor';

test('extnsions with entries', async ({ page }) => {
test('extensions with entries', async ({ page }) => {
const editor = await ProcessEditor.openEmptyProcess(page);
await editor.toolbar().openElementPalette('extensions');
const menu = editor.toolbar().menu();

await menu.expectMenuGroups(['Rest Clients', 'Callable Sub Processes']);
await menu.expectMenuItemCount(4);
await menu.expectMenuItemCount(5);
const items = menu.locator().locator('.menu-item');
await expect(items.nth(0)).toContainText('genderizehttp://localhost/');
await expect(items.nth(0).locator('img')).toHaveAttribute('src', /javax.faces.resource\/icons\/genderize.png/);
await expect(items.nth(1)).toContainText('testhttp://localhost/');
await expect(items.nth(2)).toContainText('subproc');
await expect(items.nth(3)).toContainText('subWithIcon');
await expect(items.nth(3).locator('img')).toHaveAttribute('src', /javax.faces.resource\/icons\/Developer.jpg/);
await expect(items.nth(3)).toContainText('subproc');
await expect(items.nth(4)).toContainText('subWithIcon');
await expect(items.nth(4).locator('img')).toHaveAttribute('src', /javax.faces.resource\/icons\/Developer.jpg/);

await menu.search('gen');
await menu.expectMenuItemCount(1);
Expand Down

0 comments on commit 4c135f0

Please sign in to comment.