@@ -13,6 +13,92 @@ import ImportingIedPlugin from '../../../../src/menu/ImportIEDs.js';
13
13
describe ( 'ImportIedsPlugin' , ( ) => {
14
14
customElements . define ( 'import-ieds-plugin' , ImportingIedPlugin ) ;
15
15
16
+ describe ( 'imports valid ied elements to empty projects' , ( ) => {
17
+ let doc : XMLDocument ;
18
+ let importDoc : XMLDocument ;
19
+
20
+ let parent : MockWizardEditor ;
21
+ let element : ImportingIedPlugin ;
22
+
23
+ beforeEach ( async ( ) => {
24
+ parent = await fixture (
25
+ html `< mock-wizard-editor
26
+ > < import-ieds-plugin > </ import-ieds-plugin
27
+ > </ mock-wizard-editor > `
28
+ ) ;
29
+
30
+ element = < ImportingIedPlugin > parent . querySelector ( 'import-ieds-plugin' ) ! ;
31
+
32
+ doc = await fetch ( '/test/testfiles/importieds/emptyproject.scd' )
33
+ . then ( response => response . text ( ) )
34
+ . then ( str => new DOMParser ( ) . parseFromString ( str , 'application/xml' ) ) ;
35
+ element . doc = doc ;
36
+ await element . updateComplete ;
37
+
38
+ importDoc = await fetch ( '/test/testfiles/importieds/valid.iid' )
39
+ . then ( response => response . text ( ) )
40
+ . then ( str => new DOMParser ( ) . parseFromString ( str , 'application/xml' ) ) ;
41
+ } ) ;
42
+
43
+ it ( 'loads ied element to the project' , async ( ) => {
44
+ expect ( element . doc ?. querySelector ( ':root > IED[name="TestImportIED"]' ) ) . to
45
+ . not . exist ;
46
+ element . prepareImport ( importDoc , doc ) ;
47
+ await element . updateComplete ;
48
+ expect ( element . doc ?. querySelector ( ':root > IED[name="TestImportIED"]' ) ) . to
49
+ . exist ;
50
+ } ) ;
51
+
52
+ it ( 'adds the connectedap of the imported ied' , async ( ) => {
53
+ element . prepareImport ( importDoc , doc ) ;
54
+ await element . updateComplete ;
55
+ expect (
56
+ element . doc . querySelector (
57
+ 'SubNetwork[name="NewSubNetwork"] > ConnectedAP[iedName="TestImportIED"]'
58
+ )
59
+ ) . to . exist ;
60
+ } ) ;
61
+
62
+ it ( 'creates new subnetwork if not present in the doc' , ( ) => {
63
+ expect ( element . doc . querySelector ( 'SubNetwork[name="NewSubNetwork"]' ) ) . to
64
+ . not . exist ;
65
+ element . prepareImport ( importDoc , doc ) ;
66
+ expect ( element . doc . querySelector ( 'SubNetwork[name="NewSubNetwork"]' ) ) . to
67
+ . exist ;
68
+ } ) ;
69
+
70
+ it ( 'allows multiple import of TEMPLATE IEDs' , async ( ) => {
71
+ const templateIED1 = await fetch (
72
+ '/test/testfiles/importieds/template.icd'
73
+ )
74
+ . then ( response => response . text ( ) )
75
+ . then ( str => new DOMParser ( ) . parseFromString ( str , 'application/xml' ) ) ;
76
+ element . prepareImport ( templateIED1 , doc ) ;
77
+
78
+ const templateIED2 = await fetch (
79
+ '/test/testfiles/importieds/template.icd'
80
+ )
81
+ . then ( response => response . text ( ) )
82
+ . then ( str => new DOMParser ( ) . parseFromString ( str , 'application/xml' ) ) ;
83
+ element . prepareImport ( templateIED2 , doc ) ;
84
+
85
+ expect ( element . doc . querySelector ( 'IED[name="TEMPLATE_IED1"]' ) ) . to . exist ;
86
+ expect ( element . doc . querySelector ( 'IED[name="TEMPLATE_IED2"]' ) ) . to . exist ;
87
+ } ) ;
88
+
89
+ it ( 'loads unique lnodetypes to the project' , ( ) => {
90
+ expect (
91
+ element . doc ?. querySelectorAll ( ':root > DataTypeTemplates > LNodeType' )
92
+ . length
93
+ ) . to . equal ( 0 ) ;
94
+ element . prepareImport ( importDoc , doc ) ;
95
+ expect (
96
+ element . doc ?. querySelectorAll ( ':root > DataTypeTemplates > LNodeType' )
97
+ . length
98
+ ) . to . equal ( 5 ) ;
99
+ } ) ;
100
+ } ) ;
101
+
16
102
describe ( 'imports valid ied elements' , ( ) => {
17
103
let doc : XMLDocument ;
18
104
let importDoc : XMLDocument ;
@@ -83,6 +169,7 @@ describe('ImportIedsPlugin', () => {
83
169
. length
84
170
) . to . equal ( 11 ) ;
85
171
} ) ;
172
+
86
173
it ( 'loads unique enumtypes to the project' , ( ) => {
87
174
expect (
88
175
element . doc ?. querySelectorAll ( ':root > DataTypeTemplates > EnumType' )
@@ -94,6 +181,7 @@ describe('ImportIedsPlugin', () => {
94
181
. length
95
182
) . to . equal ( 10 ) ;
96
183
} ) ;
184
+
97
185
it ( 'adds the connectedap of the imported ied' , ( ) => {
98
186
expect ( element . doc . querySelector ( 'ConnectedAP[iedName="TestImportIED"]' ) )
99
187
. to . not . exist ;
@@ -105,13 +193,15 @@ describe('ImportIedsPlugin', () => {
105
193
?. parentElement
106
194
) . to . equal ( element . doc . querySelector ( 'SubNetwork[name="NewSubNetwork"]' ) ) ;
107
195
} ) ;
196
+
108
197
it ( 'creates new subnetwork if not present in the doc' , ( ) => {
109
198
expect ( element . doc . querySelector ( 'SubNetwork[name="NewSubNetwork"]' ) ) . to
110
199
. not . exist ;
111
200
element . prepareImport ( importDoc , doc ) ;
112
201
expect ( element . doc . querySelector ( 'SubNetwork[name="NewSubNetwork"]' ) ) . to
113
202
. exist ;
114
203
} ) ;
204
+
115
205
it ( 'allows multiple import of TEMPLATE IEDs' , async ( ) => {
116
206
expect ( element . doc . querySelectorAll ( 'IED' ) . length ) . to . equal ( 3 ) ;
117
207
@@ -132,6 +222,7 @@ describe('ImportIedsPlugin', () => {
132
222
expect ( element . doc . querySelector ( 'IED[name="TEMPLATE_IED1"]' ) ) . to . exist ;
133
223
expect ( element . doc . querySelector ( 'IED[name="TEMPLATE_IED2"]' ) ) . to . exist ;
134
224
} ) ;
225
+
135
226
it ( 'renders wizard for files containing more than one IED' , async ( ) => {
136
227
const multipleIedDoc = await fetch (
137
228
'/test/testfiles/importieds/multipleied.scd'
@@ -147,6 +238,7 @@ describe('ImportIedsPlugin', () => {
147
238
parent . wizardUI . dialog ?. querySelectorAll ( 'mwc-check-list-item' ) . length
148
239
) . to . equal ( 3 ) ;
149
240
} ) ;
241
+
150
242
it ( 'imports selected IED from Import IED wizard' , async ( ) => {
151
243
const multipleIedDoc = await fetch (
152
244
'/test/testfiles/importieds/multipleied.scd'
0 commit comments