Skip to content

Commit

Permalink
fix(wizards/reportcontrol): do not copy to IED with name conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobVogelsang committed Mar 24, 2022
1 parent 8ec925e commit 4009cd7
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/wizards/reportcontrol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,20 @@ function copyReportControlActions(element: Element): WizardActor {
const sourceDataSet = element.parentElement?.querySelector(
`DataSet[name="${element.getAttribute('datSet')}"]`
);
if (
sourceDataSet &&
sinkLn0.querySelector(
`DataSet[name="${sourceDataSet!.getAttribute('name')}"]`
)
)
return [];

if (
sinkLn0.querySelector(
`ReportControl[name="${element.getAttribute('name')}"]`
)
)
return [];

// clone DataSet and make sure that FCDA is valid in ied
const sinkDataSet = <Element>sourceDataSet?.cloneNode(true);
Expand Down
37 changes: 34 additions & 3 deletions test/integration/wizards/reportcontrol-wizarding-editing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,6 @@ describe('Wizards for SCL element ReportControl', () => {
it('opens a potential list of sink IEDs for the copy operation', () =>
expect(iedsPicker).to.exist);

it('allows to copy to multiple IED at once', () =>
expect(iedsPicker.multi).to.be.true);

describe('with a sink IED not meeting any of the data references', () => {
beforeEach(async () => {
iedsPicker.paths = [['IED: IED4']];
Expand Down Expand Up @@ -478,6 +475,40 @@ describe('Wizards for SCL element ReportControl', () => {
it('does close the wizard', () =>
expect(element.wizardUI.dialog).to.not.exist);
});

describe('with a sink IED already containing ReportControl', () => {
beforeEach(async () => {
iedsPicker.paths = [['IED: IED6']];
primaryAction.click();

await element.requestUpdate();
});

it('does not copy report control block nor DataSet ', () => {
const rpControl = doc.querySelector('IED[name="IED6"] ReportControl')!;
expect(rpControl.getAttribute('datSet')).to.not.exist;

const dataSet = doc.querySelector(`IED[name="IED6"] DataSet`);
expect(dataSet).to.not.exist;
});
});

describe('with a sink IED already containing DataSet', () => {
beforeEach(async () => {
iedsPicker.paths = [['IED: IED7']];
primaryAction.click();

await element.requestUpdate();
});

it('does not copy report control block nor DataSet ', () => {
const rpControl = doc.querySelector('IED[name="IED7"] ReportControl')!;
expect(rpControl).to.not.exist;

const dataSet = doc.querySelector(`IED[name="IED7"] DataSet`);
expect(dataSet?.children).to.have.lengthOf(3);
});
});
});

describe('defines a create wizards that', () => {
Expand Down
103 changes: 103 additions & 0 deletions test/testfiles/wizards/reportcontrol.scd
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,109 @@
</Server>
</AccessPoint>
</IED>
<IED name="IED6" type="DummyIED" manufacturer="DummyManufactorer" configVersion="1" originalSclVersion="2007" originalSclRevision="B" owner="DummyOwner">
<Services>
<DynAssociation />
<GetDirectory />
<GetDataObjectDefinition />
<DataObjectDirectory />
<GetDataSetValue />
<SetDataSetValue />
<DataSetDirectory />
<ConfDataSet modify="false" max="3" />
<DynDataSet max="42" />
<ReadWrite />
<ConfReportControl max="10" />
<GetCBValues />
<ReportSettings rptID="Dyn" optFields="Dyn" bufTime="Dyn" trgOps="Dyn" intgPd="Dyn" resvTms="true" owner="true" />
<GOOSE max="1" />
<GSSE max="0" />
<ConfLNs fixPrefix="true" fixLnInst="true" />
</Services>
<AccessPoint name="P1">
<Server>
<Authentication />
<LDevice inst="CBSW">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0">
<Private type="dummyType">
<esld:FCDA xmlns:esld="http://www.dummyURL.com/dummyNS" ldInst="CBSW" prefix="" lnClass="XSWI" lnInst="2" doName="Pos" daName="stVal" fc="ST"/>
</Private>
<ReportControl rptID="reportCb1" confRev="9" buffered="true" bufTime="100" indexed="true" name="ReportCb" >
<TrgOps dchg="true" qchg="true" dupd="false" period="false" gi="true"/>
<OptFields seqNum="true" timeStamp="true" dataSet="true" reasonCode="true" dataRef="false" entryID="false" configRef="true" bufOvfl="false"/>
</ReportControl>
</LN0>
<LN lnClass="LPHD" inst="1" lnType="Dummy.LPHD1"/>
<LN lnClass="XCBR" inst="1" lnType="Dummy.XCBR1">
<DOI name="Pos">
<DAI name="ctlModel">
<Val>status-only</Val>
</DAI>
</DOI>
</LN>
<LN lnClass="XSWI" inst="2" lnType="Dummy.XSWI1">
<DOI name="Pos">
<DAI name="ctlModel">
<Val>status-only</Val>
</DAI>
</DOI>
</LN>
</LDevice>
</Server>
</AccessPoint>
</IED>
<IED name="IED7" type="DummyIED" manufacturer="DummyManufactorer" configVersion="1" originalSclVersion="2007" originalSclRevision="B" owner="DummyOwner">
<Services>
<DynAssociation />
<GetDirectory />
<GetDataObjectDefinition />
<DataObjectDirectory />
<GetDataSetValue />
<SetDataSetValue />
<DataSetDirectory />
<ConfDataSet modify="false" max="3" />
<DynDataSet max="42" />
<ReadWrite />
<ConfReportControl max="10" />
<GetCBValues />
<ReportSettings rptID="Dyn" optFields="Dyn" bufTime="Dyn" trgOps="Dyn" intgPd="Dyn" resvTms="true" owner="true" />
<GOOSE max="1" />
<GSSE max="0" />
<ConfLNs fixPrefix="true" fixLnInst="true" />
</Services>
<AccessPoint name="P1">
<Server>
<Authentication />
<LDevice inst="CBSW">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0">
<Private type="dummyType">
<esld:FCDA xmlns:esld="http://www.dummyURL.com/dummyNS" ldInst="CBSW" prefix="" lnClass="XSWI" lnInst="2" doName="Pos" daName="stVal" fc="ST"/>
</Private>
<DataSet name="GooseDataSet1">
<FCDA ldInst="CBSW" prefix="" lnClass="XSWI" lnInst="2" doName="Pos" daName="stVal" fc="ST"/>
<FCDA ldInst="CBSW" prefix="" lnClass="XSWI" lnInst="2" doName="Pos" daName="q" fc="ST"/>
<FCDA ldInst="CBSW" prefix="" lnClass="XSWI" lnInst="2" doName="OpSlc.dsd" daName="sasd.ads.asd" fc="ST"/>
</DataSet>
</LN0>
<LN lnClass="LPHD" inst="1" lnType="Dummy.LPHD1"/>
<LN lnClass="XCBR" inst="1" lnType="Dummy.XCBR1">
<DOI name="Pos">
<DAI name="ctlModel">
<Val>status-only</Val>
</DAI>
</DOI>
</LN>
<LN lnClass="XSWI" inst="2" lnType="Dummy.XSWI1">
<DOI name="Pos">
<DAI name="ctlModel">
<Val>status-only</Val>
</DAI>
</DOI>
</LN>
</LDevice>
</Server>
</AccessPoint>
</IED>
<DataTypeTemplates>
<LNodeType lnClass="LLN0" id="Dummy.LLN0">
<DO name="Mod" type="Dummy.LLN0.Mod" />
Expand Down
14 changes: 14 additions & 0 deletions test/unit/wizards/__snapshots__/reportcontrol.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,20 @@ snapshots["Wizards for SCL ReportControl element define a select wizard that wit
IED3>>CBSW> XSWI 1>ReportCb2
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
mwc-list-item=""
tabindex="-1"
twoline=""
value="IED6>>CBSW>ReportCb"
>
<span>
ReportCb
</span>
<span slot="secondary">
IED6>>CBSW>ReportCb
</span>
</mwc-list-item>
</filtered-list>
</div>
<mwc-button
Expand Down
51 changes: 51 additions & 0 deletions test/unit/wizards/reportcontrol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
editReportControlWizard,
removeReportControlAction,
selectReportControlWizard,
reportControlCopyToIedSelector,
} from '../../../src/wizards/reportcontrol.js';
import { inverseRegExp, regExp, regexString } from '../../foundation.js';
import { FinderList } from '../../../src/finder-list.js';
Expand Down Expand Up @@ -687,4 +688,54 @@ describe('Wizards for SCL ReportControl element', () => {
await expect(element.wizardUI.dialog).dom.to.equalSnapshot();
}).timeout(5000);
});

describe('define copy to other IED selector', () => {
let iedsPicker: FinderList;

beforeEach(async () => {
const sourceReportControl = doc.querySelector(
'IED[name="IED2"] ReportControl[name="ReportCb"]'
)!;
const wizard = reportControlCopyToIedSelector(sourceReportControl);
element.workflow.push(() => wizard);
await element.requestUpdate();

iedsPicker = <FinderList>(
element.wizardUI.dialog?.querySelector('finder-list')
);

primaryAction = <HTMLElement>(
element.wizardUI.dialog?.querySelector(
'mwc-button[slot="primaryAction"]'
)
);
});

it('allows to copy to multiple IED at once', () =>
expect(iedsPicker.multi).to.be.true);

describe('with missing sink IED', () => {
beforeEach(async () => {
iedsPicker.paths = [['IED: IED20']];
primaryAction.click();

await element.requestUpdate();
});

it('does not copy the control block ', () =>
expect(actionEvent).to.not.have.been.called);
});

describe('with a sink IED not meeting partially the data references', () => {
beforeEach(async () => {
iedsPicker.paths = [['IED: IED5']];
primaryAction.click();

await element.requestUpdate();
});

it('does copy the control block ', () =>
expect(actionEvent).to.have.been.called);
});
});
});

0 comments on commit 4009cd7

Please sign in to comment.