Skip to content

Commit 180e858

Browse files
test: fix minor issues to successfully run test in firefox
* test(testfiles): fix invalid *.scd file * test(editors/communicationsubnetwork): fix invalid xml file * fix(lnodetype-wizard): fix unstable compare function * fix(lnodetype-wizard): remove superfluous import statement
1 parent b6294ef commit 180e858

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

__snapshots__/LNodeType wizards.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,18 +3082,18 @@
30823082
mwc-list-item=""
30833083
role="option"
30843084
tabindex="0"
3085-
value="Dummy.LLN0.Beh"
3085+
value="Dummy.LLN0.Health"
30863086
>
3087-
Dummy.LLN0.Beh
3087+
Dummy.LLN0.Health
30883088
</mwc-list-item>
30893089
<mwc-list-item
30903090
aria-disabled="false"
30913091
mwc-list-item=""
30923092
role="option"
30933093
tabindex="-1"
3094-
value="Dummy.LLN0.Health"
3094+
value="Dummy.LLN0.Beh"
30953095
>
3096-
Dummy.LLN0.Health
3096+
Dummy.LLN0.Beh
30973097
</mwc-list-item>
30983098
</mwc-select>
30993099
<mwc-select

src/editors/templates/lnodetype-wizard.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { ListItem } from '@material/mwc-list/mwc-list-item';
3333
import { Select } from '@material/mwc-select';
3434
import { SingleSelectedEvent } from '@material/mwc-list/mwc-list-foundation';
3535
import { Switch } from '@material/mwc-switch';
36-
import { Formfield } from '@material/mwc-formfield';
3736

3837
function updateDoAction(element: Element): WizardActor {
3938
return (inputs: WizardInput[]): EditorAction[] => {
@@ -294,9 +293,19 @@ function createNewLNodeType(parent: Element, element: Element): WizardActor {
294293
};
295294
}
296295

297-
function compareDOTypeId(id: string, cdc: string): -1 | 0 | 1 {
298-
if (id.includes(cdc)) return 1;
299-
return 0;
296+
function doComparator(name: string) {
297+
return (a: Element, b: Element) => {
298+
const idA = a.getAttribute('id') ?? '';
299+
const idB = b.getAttribute('id') ?? '';
300+
301+
const aHasName = idA.includes(name);
302+
const bHasName = idB.includes(name);
303+
304+
if (!aHasName && bHasName) return 1;
305+
if (aHasName && !bHasName) return -1;
306+
307+
return idA.localeCompare(idB);
308+
};
300309
}
301310

302311
function createLNodeTypeHelperWizard(
@@ -319,7 +328,7 @@ function createLNodeTypeHelperWizard(
319328
parent
320329
.closest('DataTypeTemplates')!
321330
.querySelectorAll(`DOType[cdc="${DO.getAttribute('type')}"]`)
322-
).sort((a, b) => compareDOTypeId(b.getAttribute('id') ?? '', name));
331+
).sort(doComparator(name));
323332

324333
return html`<mwc-select
325334
fixedMenuPosition

test/testfiles/updatesubstation-ours.scd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<ConfLNs fixPrefix="true" fixLnInst="true" />
6060
</Services>
6161
<AccessPoint name="P1">
62-
<LN prefix="DC3" lnClass="XSWI" inst="2" lnType="Dummy.XSWI1">
62+
<LN prefix="DC3" lnClass="XSWI" inst="2" lnType="Dummy.XSWI1"/>
6363
<Server>
6464
<Authentication none="true" />
6565
<LDevice inst="CircuitBreaker_CB1">
@@ -87,4 +87,4 @@
8787
</AccessPoint>
8888
<KDC iedName="IED1" apName="P1"/>
8989
</IED>
90-
</SCL>
90+
</SCL>

test/unit/editors/communication/SubNetwork.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('SubNetworkEditor', () => {
9090
element = new DOMParser().parseFromString(
9191
`<SubNetwork>
9292
<BitRate unit="b/s" multiplier="M">100</BitRate>
93-
</BitRate>`,
93+
</SubNetwork>`,
9494
'application/xml'
9595
).documentElement;
9696
});

0 commit comments

Comments
 (0)