Skip to content

Commit d2e1ef8

Browse files
committed
chore: added integration test
1 parent 2ba47bb commit d2e1ef8

File tree

2 files changed

+71324
-0
lines changed

2 files changed

+71324
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import { expect, fixture, html } from '@open-wc/testing';
2+
3+
import '../../../../unit/mock-editor.js';
4+
import { MockEditor } from '../../../../unit/mock-editor.js';
5+
import '../../../../../src/editors/substation/autogen-substation/autogen-substation.js';
6+
import CompasAutogenerateSubstation from '../../../../../src/editors/substation/autogen-substation/autogen-substation.js';
7+
8+
describe('autogen-substation-integration', () => {
9+
if (customElements.get('') === undefined)
10+
customElements.define('autogen-substation', CompasAutogenerateSubstation);
11+
12+
let parent: MockEditor;
13+
let element: CompasAutogenerateSubstation;
14+
let validSCL: XMLDocument;
15+
16+
before(async () => {
17+
parent = await fixture(html`
18+
<mock-editor><autogen-substation></autogen-substation></mock-editor>
19+
`);
20+
21+
validSCL = await fetch(
22+
'/test/testfiles/menu/autogen-substation/autogen-substation-demo.scd'
23+
)
24+
.then(response => response.text())
25+
.then(str => new DOMParser().parseFromString(str, 'application/xml'));
26+
27+
element = <CompasAutogenerateSubstation>(
28+
parent.querySelector('autogen-substation')!
29+
);
30+
31+
element.doc = validSCL;
32+
await element.updateComplete;
33+
await element.run();
34+
await element.requestUpdate();
35+
});
36+
37+
it('creates 2 voltage level with default description', () => {
38+
expect(
39+
element.doc.querySelectorAll(':root > Substation > VoltageLevel').length
40+
).to.equal(2);
41+
expect(
42+
validSCL
43+
.querySelectorAll(':root > Substation > VoltageLevel')[0]
44+
?.getAttribute('name')
45+
).to.equal('E01');
46+
expect(
47+
validSCL
48+
.querySelector(':root > Substation > VoltageLevel')
49+
?.getAttribute('desc')
50+
).to.equal('Voltage Level generated by CoMPAS');
51+
expect(
52+
validSCL
53+
.querySelectorAll(':root > Substation > VoltageLevel')[1]
54+
?.getAttribute('name')
55+
).to.equal('E02');
56+
expect(
57+
validSCL
58+
.querySelector(':root > Substation > VoltageLevel')
59+
?.getAttribute('desc')
60+
).to.equal('Voltage Level generated by CoMPAS');
61+
});
62+
63+
it('creates bays inside the voltageLevels based on the name convention', () => {
64+
expect(
65+
validSCL
66+
.querySelectorAll(':root > Substation > VoltageLevel')[0]
67+
.querySelectorAll('Bay').length
68+
).to.equal(4);
69+
expect(
70+
validSCL
71+
.querySelectorAll(':root > Substation > VoltageLevel')[1]
72+
.querySelectorAll('Bay').length
73+
).to.equal(3);
74+
});
75+
it('creates correct number of conducting equipments', () => {
76+
expect(
77+
validSCL.querySelectorAll(
78+
':root > Substation > VoltageLevel > Bay > ConductingEquipment'
79+
).length
80+
).to.equal(17);
81+
});
82+
it('creates only unique conducting equipment names', () => {
83+
const nameArray: string[] = Array.from(
84+
validSCL.querySelectorAll(
85+
':root > Substation > VoltageLevel > Bay > ConductingEquipment'
86+
)
87+
).map(item => item.getAttribute('name')!);
88+
const nameSet = new Set(nameArray);
89+
expect(nameArray.length).to.equal(nameSet.size);
90+
});
91+
it('creates unique conducting equipment name, if no prefix is there', () => {
92+
expect(
93+
validSCL
94+
.querySelector(
95+
':root > Substation > VoltageLevel > Bay > ConductingEquipment:nth-child(1)'
96+
)
97+
?.getAttribute('name')
98+
).to.equal('QA1');
99+
expect(
100+
validSCL
101+
.querySelector(
102+
':root > Substation > VoltageLevel > Bay > ConductingEquipment:nth-child(4)'
103+
)
104+
?.getAttribute('name')
105+
).to.equal('QB3');
106+
});
107+
it('uses prefix for conducting equipment name, if prefix is available', () => {
108+
expect(
109+
validSCL
110+
.querySelector(
111+
':root > Substation > VoltageLevel > Bay > ConductingEquipment:nth-child(2)'
112+
)
113+
?.getAttribute('name')
114+
).to.equal('QB1');
115+
expect(
116+
validSCL
117+
.querySelector(
118+
':root > Substation > VoltageLevel > Bay > ConductingEquipment:nth-child(3)'
119+
)
120+
?.getAttribute('name')
121+
).to.equal('QB2');
122+
});
123+
});

0 commit comments

Comments
 (0)