Skip to content

Commit ca87ca5

Browse files
jjoderisOhKai
andauthored
Documentation Page E2E Tests (#324)
* Added e2e tests for the documentation page * Fixed: some tests don't clean up the created processes correctly * Generalized version creation in the process modeler for tests and used that in the documentation page tests * Merged main into ms2/new-documentation-page-e2e * split up the documentation page test from one big one into multiple smaller ones * Fixed: Undid some changes that broke tests from main * Extended the timeout for a long running test * Split a long test into two and replaced waitForHydration helper function with a documentation page specific test for a fully loaded page * Fixed: documentation page e2e tests don't click the correct position in the process list to get to the modeler * Replaced unchecking of checkboxes in tests with a simple click in an attempt to fix flakyness in the pipeline * Fixed: E2E tests are not correctly working with the changes from the main branch * Marked tests that have to import multiple processes as slow * Trying to make a test work by extending its timeout * Adjusted test for importing a process into your workspace from the documentation page --------- Co-authored-by: Kai Rohwer <[email protected]>
1 parent 93517e2 commit ca87ca5

File tree

13 files changed

+1276
-22
lines changed

13 files changed

+1276
-22
lines changed

src/management-system-v2/app/shared-viewer/documentation-page-utils.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,23 @@ export async function getElementSVG(
182182
} else if (isType(el, 'bpmn:CallActivity')) {
183183
// check if the call activity references another process which this user can access
184184
let importDefinitionId: string | undefined;
185-
let version: string | undefined;
185+
let versionId: string | undefined;
186186
try {
187-
({ definitionId: importDefinitionId, versionId: version } =
187+
({ definitionId: importDefinitionId, versionId } =
188188
getTargetDefinitionsAndProcessIdForCallActivityByObject(getRootFromElement(el), el.id));
189189
} catch (err) {}
190190

191191
if (
192192
importDefinitionId &&
193-
version &&
193+
versionId &&
194194
availableImports[importDefinitionId] &&
195-
availableImports[importDefinitionId][version]
195+
availableImports[importDefinitionId][versionId]
196196
) {
197197
// remember the bpmn currently loaded into the viewer so we can return to it after getting the svg for the elements in the imported process
198198
({ xml: oldBpmn } = await bpmnViewer.saveXML());
199199

200200
// get the bpmn for the import and load it into the viewer
201-
const importBpmn = availableImports[importDefinitionId][version];
201+
const importBpmn = availableImports[importDefinitionId][versionId];
202202

203203
await bpmnViewer.importXML(importBpmn);
204204

@@ -216,7 +216,7 @@ export async function getElementSVG(
216216
name: `Imported Process: ${definitions.name}`,
217217
...getMetaDataFromBpmnElement(el, mdEditor),
218218
planeSvg: await getSVGFromBPMN(bpmnViewer),
219-
version,
219+
versionId,
220220
versionName,
221221
versionDescription,
222222
};

src/management-system-v2/app/shared-viewer/documentation-page.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const BPMNSharedViewer = ({
9292
currentRootId?: string, // the layer the current element is in (e.g. the root process/collaboration or a collapsed sub-process)
9393
): Promise<ElementInfo> {
9494
let svg;
95+
const name = getTitle(el);
9596

9697
let nestedSubprocess;
9798
let importedProcess;
@@ -140,7 +141,7 @@ const BPMNSharedViewer = ({
140141
return {
141142
svg,
142143
id: el.id,
143-
name: getTitle(el),
144+
name,
144145
description,
145146
meta,
146147
milestones,
@@ -158,9 +159,11 @@ const BPMNSharedViewer = ({
158159
const root = canvas.getRootElement();
159160

160161
const definitions = getRootFromElement(root.businessObject);
161-
getDefinitionsVersionInformation(definitions).then(({ versionId, name, description }) =>
162-
setVersionInfo({ id: versionId, name, description }),
163-
);
162+
163+
const { versionId, name, description, versionCreatedOn } =
164+
await getDefinitionsVersionInformation(definitions);
165+
166+
setVersionInfo({ id: versionId, name, description, versionCreatedOn });
164167

165168
const hierarchy = await transform(
166169
viewer,

src/management-system-v2/app/shared-viewer/process-document.tsx

+22-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ import { useEnvironment } from '@/components/auth-can';
1818
import { EntityType } from '@/lib/helpers/fileManagerHelpers';
1919
import { useFileManager } from '@/lib/useFileManager';
2020
import { enableUseFileManager } from 'FeatureFlags';
21+
import { fromCustomUTCString } from '@/lib/helpers/timeHelper';
2122

2223
export type VersionInfo = {
2324
id?: string;
2425
name?: string;
2526
description?: string;
27+
versionCreatedOn?: string;
2628
};
2729

2830
type ProcessDocumentProps = {
@@ -64,7 +66,6 @@ const ProcessDocument: React.FC<ProcessDocumentProps> = ({
6466
!hierarchyElement.image &&
6567
!hierarchyElement.children?.length
6668
) {
67-
setProcessPages(currentPages);
6869
return;
6970
}
7071

@@ -224,20 +225,30 @@ const ProcessDocument: React.FC<ProcessDocumentProps> = ({
224225
(settings.nestedSubprocesses || !hierarchyElement.nestedSubprocess) &&
225226
(settings.importedProcesses || !hierarchyElement.importedProcess)
226227
) {
227-
hierarchyElement.children?.forEach((child) => getContent(child, currentPages));
228+
if (hierarchyElement.children) {
229+
for (const child of hierarchyElement.children) {
230+
await getContent(child, currentPages);
231+
}
232+
}
228233
}
229234
}
230235

231236
// transform the document data into the respective pages of the document
232237
useEffect(() => {
233-
processHierarchy && getContent(processHierarchy, processPages);
234-
}, [processHierarchy]);
238+
const updateProcessPages = async () => {
239+
const newProcessPages: React.JSX.Element[] = [];
240+
processHierarchy && (await getContent(processHierarchy, newProcessPages));
241+
setProcessPages(newProcessPages);
242+
};
243+
244+
updateProcessPages();
245+
}, [processHierarchy, settings]);
235246

236247
return (
237248
<>
238249
<div className={styles.ProcessDocument}>
239250
{!processHierarchy ? (
240-
<Spin tip="Loading" size="large" style={{ top: '50px' }}>
251+
<Spin tip="Loading process data" size="large" style={{ top: '50px' }}>
241252
<div></div>
242253
</Spin>
243254
) : (
@@ -268,7 +279,12 @@ const ProcessDocument: React.FC<ProcessDocumentProps> = ({
268279
<div>Version: Latest</div>
269280
)}
270281
{version.id ? (
271-
<div>Creation Time: {new Date(version.id).toUTCString()}</div>
282+
<div>
283+
Creation Time:{' '}
284+
{version.versionCreatedOn
285+
? fromCustomUTCString(version.versionCreatedOn).toUTCString()
286+
: 'Unknown'}
287+
</div>
272288
) : (
273289
<div>Last Edit: {processData.lastEditedOn.toUTCString()}</div>
274290
)}

src/management-system-v2/lib/schema.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,13 @@ export const schema = {
250250
],
251251
},
252252
{
253-
name: 'version',
253+
name: 'versionId',
254254
extends: ['bpmn:Definitions', 'bpmn:Import'],
255255
properties: [
256256
{
257-
name: 'version',
257+
name: 'versionId',
258258
isAttr: true,
259-
type: 'Number',
259+
type: 'string',
260260
},
261261
],
262262
},
@@ -293,6 +293,17 @@ export const schema = {
293293
},
294294
],
295295
},
296+
{
297+
name: 'versionCreatedOn',
298+
extends: ['bpmn:Definitions'],
299+
properties: [
300+
{
301+
name: 'versionCreatedOn',
302+
isAttr: true,
303+
type: 'String',
304+
},
305+
],
306+
},
296307
{
297308
name: 'creatorEnvironmentId',
298309
extends: ['bpmn:Definitions'],

0 commit comments

Comments
 (0)