Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.

Commit a0945be

Browse files
committed
test: update snapshots and unit tests
1 parent b22d1cf commit a0945be

9 files changed

Lines changed: 127 additions & 56 deletions

File tree

packages/plugins/src/wizards/accesspoint.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,8 @@ function reservedNamesAccessPoint(currentElement: Element): string[] {
120120

121121
function removeAccessPointAndReferences(element: Element): WizardActor {
122122
return (inputs: WizardInputElement[], wizard: Element): EditorAction[] => {
123-
// Close Edit Wizard, if open.
124123
wizard.dispatchEvent(newWizardEvent());
125-
126-
// Get Delete Actions for other elements that also need to be removed
127124
const referencesDeleteActions = deleteReferences(element);
128-
// Use the ExtRef Elements to check if after removing the ExtRef there are empty Inputs that can also be removed.
129-
const extRefsDeleteActions = referencesDeleteActions.filter(
130-
deleteAction => (<Element>deleteAction.old.element).tagName === 'ExtRef'
131-
);
132-
133-
// Create Complex Action to remove AccessPoint and all references.
134125
const name = element.getAttribute('name') ?? 'Unknown';
135126
const complexAction: ComplexAction = {
136127
actions: [],

packages/plugins/test/unit/editors/ied/__snapshots__/access-point-container.test.snap.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ snapshots["access-point-container with Server Elements looks like the latest sna
55
`<action-pane tabindex="0">
66
<mwc-icon slot="icon">
77
</mwc-icon>
8+
<mwc-icon-button
9+
icon="delete"
10+
slot="action"
11+
title="[remove]"
12+
>
13+
</mwc-icon-button>
14+
<mwc-icon-button
15+
icon="edit"
16+
slot="action"
17+
title="[edit]"
18+
>
19+
</mwc-icon-button>
820
<server-container>
921
</server-container>
1022
<div id="lnContainer">
@@ -17,6 +29,18 @@ snapshots["access-point-container with LN Elements and all LN Classes displayed
1729
`<action-pane tabindex="0">
1830
<mwc-icon slot="icon">
1931
</mwc-icon>
32+
<mwc-icon-button
33+
icon="delete"
34+
slot="action"
35+
title="[remove]"
36+
>
37+
</mwc-icon-button>
38+
<mwc-icon-button
39+
icon="edit"
40+
slot="action"
41+
title="[edit]"
42+
>
43+
</mwc-icon-button>
2044
<div id="lnContainer">
2145
<ln-container>
2246
</ln-container>
@@ -43,6 +67,18 @@ snapshots["access-point-container with LN Elements and some LN Classes hidden lo
4367
`<action-pane tabindex="0">
4468
<mwc-icon slot="icon">
4569
</mwc-icon>
70+
<mwc-icon-button
71+
icon="delete"
72+
slot="action"
73+
title="[remove]"
74+
>
75+
</mwc-icon-button>
76+
<mwc-icon-button
77+
icon="edit"
78+
slot="action"
79+
title="[edit]"
80+
>
81+
</mwc-icon-button>
4682
<div id="lnContainer">
4783
<ln-container>
4884
</ln-container>
@@ -61,6 +97,18 @@ snapshots["access-point-container with LN Elements and all LN Classes hidden loo
6197
`<action-pane tabindex="0">
6298
<mwc-icon slot="icon">
6399
</mwc-icon>
100+
<mwc-icon-button
101+
icon="delete"
102+
slot="action"
103+
title="[remove]"
104+
>
105+
</mwc-icon-button>
106+
<mwc-icon-button
107+
icon="edit"
108+
slot="action"
109+
title="[edit]"
110+
>
111+
</mwc-icon-button>
64112
<div id="lnContainer">
65113
</div>
66114
</action-pane>

packages/plugins/test/unit/editors/ied/__snapshots__/ldevice-container.test.snap.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ snapshots["ldevice-container LDevice Element with LN Elements and all LN Element
55
`<action-pane tabindex="0">
66
<mwc-icon slot="icon">
77
</mwc-icon>
8+
<mwc-icon-button
9+
icon="delete"
10+
slot="action"
11+
title="[remove]"
12+
>
13+
</mwc-icon-button>
814
<abbr
915
slot="action"
1016
title="[edit]"
@@ -61,6 +67,12 @@ snapshots["ldevice-container LDevice Element with LN Elements and some LN Elemen
6167
`<action-pane tabindex="0">
6268
<mwc-icon slot="icon">
6369
</mwc-icon>
70+
<mwc-icon-button
71+
icon="delete"
72+
slot="action"
73+
title="[remove]"
74+
>
75+
</mwc-icon-button>
6476
<abbr
6577
slot="action"
6678
title="[edit]"
@@ -107,6 +119,12 @@ snapshots["ldevice-container LDevice Element with LN Elements and no LN Elements
107119
`<action-pane tabindex="0">
108120
<mwc-icon slot="icon">
109121
</mwc-icon>
122+
<mwc-icon-button
123+
icon="delete"
124+
slot="action"
125+
title="[remove]"
126+
>
127+
</mwc-icon-button>
110128
<abbr
111129
slot="action"
112130
title="[edit]"
@@ -133,6 +151,12 @@ snapshots["ldevice-container LDevice Element without LN Element looks like the l
133151
`<action-pane tabindex="0">
134152
<mwc-icon slot="icon">
135153
</mwc-icon>
154+
<mwc-icon-button
155+
icon="delete"
156+
slot="action"
157+
title="[remove]"
158+
>
159+
</mwc-icon-button>
136160
<abbr
137161
slot="action"
138162
title="[edit]"

packages/plugins/test/unit/editors/ied/__snapshots__/ln-container.test.snap.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ snapshots["looks like the latest snapshot with a LN0 element and child elements
6666

6767
snapshots["looks like the latest snapshot with a LN element."] =
6868
`<action-pane tabindex="0">
69+
<mwc-icon-button
70+
icon="delete"
71+
slot="action"
72+
title="[remove]"
73+
>
74+
</mwc-icon-button>
6975
<abbr slot="action">
7076
<mwc-icon-button
7177
icon="edit"
@@ -91,6 +97,12 @@ snapshots["looks like the latest snapshot with a LN element."] =
9197

9298
snapshots["looks like the latest snapshot with a LN element and child elements are toggled."] =
9399
`<action-pane tabindex="0">
100+
<mwc-icon-button
101+
icon="delete"
102+
slot="action"
103+
title="[remove]"
104+
>
105+
</mwc-icon-button>
94106
<abbr slot="action">
95107
<mwc-icon-button
96108
icon="edit"

packages/plugins/test/unit/wizards/__snapshots__/ied.test.snap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ snapshots["Wizards for SCL element IED edit IED looks like the latest snapshot"]
5656
>
5757
</wizard-textfield>
5858
<wizard-textfield
59-
disabled=""
59+
helper="[ied.wizard.manufacturerHelper]"
6060
label="manufacturer"
61-
readonly=""
61+
pattern="([ -~]|[…]|[ -퟿]|[-�])*"
6262
>
6363
</wizard-textfield>
6464
<wizard-textfield

packages/plugins/test/unit/wizards/__snapshots__/ldevice.test.snap.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ snapshots["Wizards for SCL element LDevice Allowing/Disallowing ldName editing l
2626
>
2727
</wizard-textfield>
2828
<wizard-textfield
29-
disabled=""
30-
label="ldInst"
31-
readonly=""
29+
helper="[ldevice.wizard.instHelper]"
30+
label="inst"
31+
pattern="([ -~]|[…]|[ -퟿]|[-�])*"
32+
required=""
33+
validationmessage="[textfield.required]"
3234
>
3335
</wizard-textfield>
3436
</div>

packages/plugins/test/unit/wizards/ldevice.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Wizards for SCL element LDevice', () => {
4040

4141
it('contains a wizard-textfield with a non-empty "inst" value', async () => {
4242
expect(
43-
(<WizardTextField[]>inputs).find(textField => textField.label == 'ldInst')
43+
(<WizardTextField[]>inputs).find(textField => textField.label == 'inst')
4444
?.value
4545
).to.be.equal(ldevice.getAttribute('inst'));
4646
});

packages/plugins/test/unit/wizards/ln.test.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { WizardInputElement } from '@openscd/open-scd/src/foundation.js';
77
import { fetchDoc, setWizardTextFieldValue } from './test-support.js';
88
import { WizardTextField } from '@openscd/open-scd/src/wizard-textfield.js';
99

10-
11-
1210
describe('ln wizards', () => {
1311
let doc: XMLDocument;
1412
let element: OscdWizards;
@@ -21,12 +19,7 @@ describe('ln wizards', () => {
2119
lnClass: 'LN-class',
2220
inst: '1',
2321
};
24-
const readonlyFields = [
25-
'lnType',
26-
'prefix',
27-
'lnClass',
28-
'inst'
29-
];
22+
const readonlyFields = ['lnType', 'lnClass'];
3023

3124
const ln = <Element>(
3225
new DOMParser().parseFromString(
@@ -52,16 +45,16 @@ describe('ln wizards', () => {
5245
it(`contains a wizard-textfield with a non-empty "${key}" value`, async () => {
5346
expect(
5447
(<WizardInputElement[]>inputs).find(
55-
(textField) => textField.label === key
48+
textField => textField.label === key
5649
)?.value
5750
).to.equal(value);
5851
});
5952
});
6053

61-
readonlyFields.forEach((field) => {
54+
readonlyFields.forEach(field => {
6255
it(`is a readonly field ${field}`, async () => {
6356
const input = (<WizardInputElement[]>inputs).find(
64-
(textField) => textField.label === field
57+
textField => textField.label === field
6558
) as WizardTextField;
6659

6760
expect(input.readOnly).to.be.true;

packages/plugins/test/unit/wizards/ln0.test.ts

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,23 @@ import { OscdWizards } from '@openscd/open-scd/src/addons/Wizards';
44

55
import { editLN0Wizard } from '../../../src/wizards/ln0.js';
66
import { WizardInputElement } from '@openscd/open-scd/src/foundation.js';
7-
import { fetchDoc, setWizardTextFieldValue } from './test-support.js';
7+
import { fetchDoc } from './test-support.js';
88
import { WizardTextField } from '@openscd/open-scd/src/wizard-textfield.js';
99

10-
11-
1210
describe('ln0 wizards', () => {
1311
let doc: XMLDocument;
1412
let element: OscdWizards;
1513
let inputs: WizardInputElement[];
14+
let ln: Element;
1615

17-
const values = {
18-
lnType: 'LN0-type',
19-
desc: 'LN0-description',
20-
lnClass: 'LN0-class',
21-
inst: '1',
22-
};
23-
const readonlyFields = [
24-
'lnType',
25-
'lnClass',
26-
'inst'
27-
];
28-
29-
const ln = <Element>(
30-
new DOMParser().parseFromString(
31-
`<LN0 desc="${values.desc}" lnType="${values.lnType}" inst="${values.inst}" lnClass="${values.lnClass}"></LN0>`,
32-
'application/xml'
33-
).documentElement
34-
);
16+
const readonlyFields = ['lnClass', 'inst'];
3517

3618
beforeEach(async () => {
3719
doc = await fetchDoc('/test/testfiles/wizards/ied.scd');
3820

21+
ln = doc.querySelector('LN0')!;
22+
expect(ln).to.exist;
23+
3924
element = await fixture(
4025
html`<oscd-wizards .host=${document}></oscd-wizards>`
4126
);
@@ -46,20 +31,36 @@ describe('ln0 wizards', () => {
4631
inputs = Array.from(element.wizardUI.inputs);
4732
});
4833

49-
Object.entries(values).forEach(([key, value]) => {
50-
it(`contains a wizard-textfield with a non-empty "${key}" value`, async () => {
51-
expect(
52-
(<WizardInputElement[]>inputs).find(
53-
(textField) => textField.label === key
54-
)?.value
55-
).to.equal(value);
34+
it('contains a wizard-select for lnType with available LNodeTypes', async () => {
35+
const lnTypeInput = (<WizardInputElement[]>inputs).find(
36+
input => input.label === 'lnType'
37+
);
38+
expect(lnTypeInput).to.exist;
39+
expect(lnTypeInput?.tagName).to.equal('WIZARD-SELECT');
40+
});
41+
42+
it('lnType select contains LNodeType options with lnClass="LLN0"', async () => {
43+
const lnTypeSelect = (<WizardInputElement[]>inputs).find(
44+
input => input.label === 'lnType'
45+
);
46+
const options = lnTypeSelect?.querySelectorAll('mwc-list-item');
47+
expect(options).to.have.length.greaterThan(0);
48+
49+
const lln0Types = doc.querySelectorAll('LNodeType[lnClass="LLN0"]');
50+
expect(options).to.have.lengthOf(lln0Types.length);
51+
});
52+
53+
it('contains required fields', async () => {
54+
['lnType', 'lnClass'].forEach(field => {
55+
const input = (<WizardInputElement[]>inputs).find(i => i.label === field);
56+
expect(input).to.exist;
5657
});
5758
});
5859

59-
readonlyFields.forEach((field) => {
60+
readonlyFields.forEach(field => {
6061
it(`is a readonly field ${field}`, async () => {
6162
const input = (<WizardInputElement[]>inputs).find(
62-
(textField) => textField.label === field
63+
textField => textField.label === field
6364
) as WizardTextField;
6465

6566
expect(input.readOnly).to.be.true;

0 commit comments

Comments
 (0)