Skip to content

Commit db93440

Browse files
authored
fix(wizards/connectedap) Scope Address for ConnectedAP more narrowly, closes openscd#1123 (openscd#1124)
* Scope Address for ConnectedAP more narrowly, closes openscd#1123
1 parent 598988b commit db93440

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

src/wizards/connectedap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export function createPTextField(
331331
label="${pType}"
332332
pattern="${ifDefined(typePattern[pType])}"
333333
?nullable=${typeNullable[pType]}
334-
.maybeValue=${element.querySelector(`Address > P[type="${pType}"]`)
334+
.maybeValue=${element.querySelector(`:scope > Address > P[type="${pType}"]`)
335335
?.innerHTML ?? null}
336336
maxLength="${ifDefined(typeMaxLength[pType])}"
337337
></wizard-textfield>`;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { expect, fixture, html } from '@open-wc/testing';
2+
3+
import '../../mock-wizard-editor.js';
4+
import { MockWizardEditor } from '../../mock-wizard-editor.js';
5+
6+
import { editConnectedApWizard } from '../../../src/wizards/connectedap.js';
7+
8+
describe('connectedap wizarding editing integration', () => {
9+
let doc: XMLDocument;
10+
let element: MockWizardEditor;
11+
12+
beforeEach(async () => {
13+
element = await fixture(html`<mock-wizard-editor></mock-wizard-editor>`);
14+
doc = await fetch('/test/testfiles/valid2003.scd')
15+
.then(response => response.text())
16+
.then(str => new DOMParser().parseFromString(str, 'application/xml'));
17+
});
18+
19+
it('does not inherit the VLAN-ID and VLAN-PRIORITY of a child Address element', async () => {
20+
const parser = new DOMParser();
21+
const newGSE = `
22+
<GSE ldInst="CircuitBreaker_CB1" cbName="GCB">
23+
<Address>
24+
<P type="MAC-Address">01-0C-CD-01-00-10</P>
25+
<P type="VLAN-ID">005</P>
26+
<P type="VLAN-PRIORITY">4</P>
27+
<P type="APPID">0010</P>
28+
</Address>
29+
</GSE>
30+
`;
31+
const connectedAP = doc.querySelector('ConnectedAP[iedName="IED1"]')!;
32+
connectedAP.appendChild(
33+
parser.parseFromString(newGSE, 'application/xml').documentElement
34+
);
35+
36+
const wizard = editConnectedApWizard(connectedAP);
37+
element.workflow.push(() => wizard);
38+
await element.requestUpdate();
39+
await element.updateComplete;
40+
41+
const vlanId = element.wizardUI.shadowRoot!.querySelector(
42+
'wizard-textfield[label="VLAN-ID"]'
43+
)!;
44+
const vlanPriority = element.wizardUI.shadowRoot!.querySelector(
45+
'wizard-textfield[label="VLAN-PRIORITY"]'
46+
)!;
47+
48+
expect(vlanId.hasAttribute('disabled')).to.be.true;
49+
expect(vlanPriority.hasAttribute('disabled')).to.be.true;
50+
});
51+
});

test/unit/wizards/__snapshots__/connectedap-pattern.test.snap.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,15 @@ snapshots["Edit wizard for SCL element ConnectedAP include an edit wizard that f
411411
>
412412
</wizard-textfield>
413413
<wizard-textfield
414+
disabled=""
414415
label="VLAN-ID"
415416
nullable=""
416417
pattern="[0-9A-F]{3}"
417418
required=""
418419
>
419420
</wizard-textfield>
420421
<wizard-textfield
422+
disabled=""
421423
label="VLAN-PRIORITY"
422424
nullable=""
423425
pattern="[0-7]"

0 commit comments

Comments
 (0)