File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
test/integration/editors/triggered Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ import {
30
30
31
31
function uniqueTemplateIedName ( doc : XMLDocument , ied : Element ) : string {
32
32
const [ manufacturer , type ] = [ 'manufacturer' , 'type' ] . map ( attr =>
33
- ied . getAttribute ( attr )
33
+ ied . getAttribute ( attr ) ?. replace ( / [ ^ A - Z a - z 0 - 9 _ ] / g , '' )
34
34
) ;
35
35
const nameCore =
36
36
manufacturer || type
Original file line number Diff line number Diff line change @@ -78,6 +78,30 @@ describe('ImportIedsPlugin', () => {
78
78
. exist ;
79
79
} ) ;
80
80
81
+ it ( 'renames TEMPLATE IED element if manufacturer/type has illegal characters' , async ( ) => {
82
+ importDoc = await fetch ( '/test/testfiles/importieds/template.icd' )
83
+ . then ( response => response . text ( ) )
84
+ . then ( str => new DOMParser ( ) . parseFromString ( str , 'application/xml' ) ) ;
85
+
86
+ const ied = importDoc . querySelector ( 'IED' ) ! ;
87
+ ied . setAttribute ( 'manufacturer' , 'Fancy-Vendy' ) ;
88
+ ied . setAttribute ( 'type' , 'Z#Mega$Y' ) ;
89
+
90
+ element . importDoc = importDoc ;
91
+ await element . updateComplete ;
92
+
93
+ element . prepareImport ( ) ;
94
+ await parent . updateComplete ;
95
+
96
+ console . log (
97
+ element . doc ?. querySelector ( ':root > IED' ) ?. getAttribute ( 'name' )
98
+ ) ;
99
+
100
+ expect (
101
+ element . doc ?. querySelector ( ':root > IED[name="FancyVendy_ZMegaY_001"]' )
102
+ ) . to . exist ;
103
+ } ) ;
104
+
81
105
it ( 'allows multiple import of TEMPLATE IEDs' , async ( ) => {
82
106
const templateIED1 = await fetch (
83
107
'/test/testfiles/importieds/template.icd'
You can’t perform that action at this time.
0 commit comments