-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser): let configure XML attribute processing
Remove the 'entities' dependency. By default, there is no need to be able to decode all entities as most of the time, only 'basic' entities are generally used in BPMN sources. Instead, `bpmn-visualization` now provides a small set of entities transform. If there is a need to transform more entities, a new Parser option is now available to let application perform more processing.
- Loading branch information
Showing
10 changed files
with
138 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright 2023 Bonitasoft S.A. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { BpmnVisualization } from '@lib/component/BpmnVisualization'; | ||
import { readFileSync } from '@test/shared/file-helper'; | ||
|
||
const additionalXmlAttributeProcessor = (val: string): string => { | ||
val = val.replace(/®/g, '®'); | ||
val = val.replace(/♠/g, '♠'); | ||
val = val.replace(/Ø/g, 'Ø'); | ||
val = val.replace(/⧵/g, '⧵'); | ||
return val; | ||
}; | ||
|
||
describe('From BPMN diagram with entities in attributes', () => { | ||
describe.each([false, true])('XML parser with additional attribute processor: %s', (useAdditionalXmlAttributeProcessor: boolean) => { | ||
const bpmnVisualization = useAdditionalXmlAttributeProcessor | ||
? new BpmnVisualization({ container: null, parser: { additionalXmlAttributeProcessor } }) | ||
: new BpmnVisualization(null); | ||
bpmnVisualization.load(readFileSync('../fixtures/bpmn/xml-parsing/special/start-tasks-end_entities_in_attributes.bpmn')); | ||
|
||
const expectElementLabel = (id: string): jest.JestMatchers<string> => { | ||
const model = bpmnVisualization.graph.getModel(); | ||
const cell = model.getCell(id); | ||
expect(cell).toBeDefined(); | ||
// eslint-disable-next-line jest/valid-expect -- util function | ||
return expect(String(cell.getValue())); | ||
}; | ||
|
||
test('start event', () => { | ||
expectElementLabel('StartEvent_1').toBe(useAdditionalXmlAttributeProcessor ? '®Start Event 1 ®\nbuilt with ♠' : '®Start Event 1 ®\nbuilt with ♠'); | ||
}); | ||
test('task', () => { | ||
expectElementLabel('Activity_1').toBe(useAdditionalXmlAttributeProcessor ? 'Task 1 or task 2∕3⧵4' : 'Task 1 or task 2∕3⧵4'); | ||
}); | ||
test('end event', () => { | ||
expectElementLabel('EndEvent_1').toBe( | ||
useAdditionalXmlAttributeProcessor ? '&unknown; End Event & 1/2\\3 Ø \n ¥ / ¥' : '&unknown; End Event & 1/2\\3 Ø \n ¥ / ¥', | ||
); | ||
}); | ||
test('sequence flow 1', () => { | ||
expectElementLabel('Flow_1').toBe('<Sequence> Flow 1&2'); | ||
}); | ||
test('sequence flow 2', () => { | ||
expectElementLabel('Flow_2').toBe('Sequence \'Flow" 2'); | ||
}); | ||
}); | ||
}); |
This file contains 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
This file contains 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