Skip to content

Commit

Permalink
feat(zeroline/ied-editor): add show report action (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobVogelsang authored and Jakob Vogelsang committed Jan 20, 2022
1 parent 53470a6 commit 5c44c58
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/zeroline/ied-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import { Fab } from '@material/mwc-fab';

import '../action-icon.js';
import { createClientLnWizard } from '../wizards/clientln.js';
import { gooseIcon, smvIcon } from '../icons.js';
import { gooseIcon, smvIcon, reportIcon } from '../icons.js';
import { newWizardEvent } from '../foundation.js';
import { wizards } from "../wizards/wizard-library.js";
import { wizards } from '../wizards/wizard-library.js';
import { selectGseControlWizard } from '../wizards/gsecontrol.js';
import { selectSampledValueControlWizard } from '../wizards/sampledvaluecontrol.js';
import { selectReportControlWizard } from '../wizards/reportcontrol.js';

/** [[`SubstationEditor`]] subeditor for a child-less `IED` element. */
@customElement('ied-editor')
Expand All @@ -38,11 +39,8 @@ export class IedEditor extends LitElement {
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
}

private openCommunicationMapping(): void {
const sendingIeds = Array.from(
this.element.closest('SCL')?.querySelectorAll('IED') ?? []
);
const wizard = createClientLnWizard(sendingIeds, this.element);
private openReportControlSelection(): void {
const wizard = selectReportControlWizard(this.element);
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
}

Expand All @@ -56,6 +54,14 @@ export class IedEditor extends LitElement {
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
}

private openCommunicationMapping(): void {
const sendingIeds = Array.from(
this.element.closest('SCL')?.querySelectorAll('IED') ?? []
);
const wizard = createClientLnWizard(sendingIeds, this.element);
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
}

render(): TemplateResult {
return html`<action-icon label="${this.name}" icon="developer_board"
><mwc-fab
Expand Down Expand Up @@ -83,7 +89,13 @@ export class IedEditor extends LitElement {
mini
@click="${() => this.openEditWizard()}"
icon="edit"
></mwc-fab
></mwc-fab>
<mwc-fab
slot="action"
class="selectreport"
mini
@click="${() => this.openReportControlSelection()}"
><mwc-icon slot="icon">${reportIcon}</mwc-icon></mwc-fab
></action-icon
> `;
}
Expand Down
66 changes: 66 additions & 0 deletions test/integration/zeroline/ied-editor-wizarding-integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { expect, fixture, html } from '@open-wc/testing';

import '../../mock-wizard-editor.js';
import { MockWizardEditor } from '../../mock-wizard-editor.js';

import '../../../src/zeroline/ied-editor.js';
import { FilteredList } from '../../../src/filtered-list.js';
import { IedEditor } from '../../../src/zeroline/ied-editor.js';

describe('IED editor component wizarding editing integration', () => {
let doc: XMLDocument;
let parent: MockWizardEditor;
let iededitor: IedEditor;

beforeEach(async () => {
doc = await fetch('/test/testfiles/valid2007B4.scd')
.then(response => response.text())
.then(str => new DOMParser().parseFromString(str, 'application/xml'));

const ied = doc.querySelector('IED[name="IED2"]');

parent = <MockWizardEditor>(
await fixture(
html`<mock-wizard-editor
><ied-editor .element=${ied}></ied-editor
></mock-wizard-editor>`
)
);
iededitor = <IedEditor>parent.querySelector('ied-editor');
await parent.updateComplete;
});

it('opens select wizard showing GSEControl of one IED', async () => {
(<HTMLElement>(
iededitor.shadowRoot?.querySelector('mwc-fab[class="selectgse"]')
)).click();
await parent.updateComplete;

expect(parent.wizardUI.dialog).to.exist;
const gseControlList = <FilteredList>(
parent.wizardUI.dialog?.querySelector('filtered-list')
);
await gseControlList.updateComplete;

expect(gseControlList.items.length).to.equal(
doc.querySelectorAll('IED[name="IED2"] GSEControl').length
);
});

it('opens select wizard showing ReportControl of one IED', async () => {
(<HTMLElement>(
iededitor.shadowRoot?.querySelector('mwc-fab[class="selectreport"]')
)).click();
await parent.updateComplete;

expect(parent.wizardUI.dialog).to.exist;
const reportControlList = <FilteredList>(
parent.wizardUI.dialog?.querySelector('filtered-list')
);
await reportControlList.updateComplete;

expect(reportControlList.items.length).to.equal(
doc.querySelectorAll('IED[name="IED2"] ReportControl').length
);
});
});
1 change: 1 addition & 0 deletions test/unit/zeroline/__snapshots__/ied-editor.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ snapshots["A component to visualize SCL element IED looks like the latest snapsh
</mwc-fab>
<mwc-fab
class="selectsmv"
class="selectreport"
mini=""
slot="action"
>
Expand Down
11 changes: 11 additions & 0 deletions test/unit/zeroline/ied-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ describe('A component to visualize SCL element IED', () => {
expect(wizardEvent.args[0][0].detail.wizard()[0].title).to.contain('select');
});

it('triggers select wizard for ReportControl element on action button click', async () => {
(<HTMLElement>(
element.shadowRoot?.querySelector('mwc-fab[class="selectreport"]')
)).click();

await element.requestUpdate();

expect(wizardEvent).to.have.be.calledOnce;
expect(wizardEvent.args[0][0].detail.wizard[0].title).to.contain('select');
});

it('triggers create wizard for ClientLN element on action button click', async () => {
(<HTMLElement>(
element.shadowRoot?.querySelector('mwc-fab[class="connectreport"]')
Expand Down

0 comments on commit 5c44c58

Please sign in to comment.