diff --git a/src/editors/substation/conducting-equipment-editor.ts b/src/editors/substation/conducting-equipment-editor.ts index de44ccb07f..19629c4e9d 100644 --- a/src/editors/substation/conducting-equipment-editor.ts +++ b/src/editors/substation/conducting-equipment-editor.ts @@ -14,8 +14,13 @@ import '@material/mwc-icon-button'; import '../../action-icon.js'; import '../../action-pane.js'; +import './eq-function-editor.js'; import { startMove, getIcon } from './foundation.js'; -import { newActionEvent, newWizardEvent } from '../../foundation.js'; +import { + getChildElementsByTagName, + newActionEvent, + newWizardEvent, +} from '../../foundation.js'; import { BayEditor } from './bay-editor.js'; import { wizards } from '../../wizards/wizard-library.js'; @@ -57,6 +62,16 @@ export class ConductingEquipmentEditor extends LitElement { ); } + renderEqFunctions(): TemplateResult { + if (!this.showfunctions) return html``; + + const eqFunctions = getChildElementsByTagName(this.element, 'EqFunction'); + return html` ${eqFunctions.map( + eqFunction => + html`` + )}`; + } + renderContentPane(): TemplateResult { return html`${getIcon(this.element)}${this.renderContentPane()}${this.renderContentPane()}${this.renderEqFunctions()}`; return html``; + } +} diff --git a/src/editors/substation/powertransformer-editor.ts b/src/editors/substation/powertransformer-editor.ts index ffedbc8f45..6f6b97700a 100644 --- a/src/editors/substation/powertransformer-editor.ts +++ b/src/editors/substation/powertransformer-editor.ts @@ -16,7 +16,11 @@ import '../../action-icon.js'; import '../../action-pane.js'; import { powerTransformerTwoWindingIcon } from '../../icons/icons.js'; import { wizards } from '../../wizards/wizard-library.js'; -import { newActionEvent, newWizardEvent } from '../../foundation.js'; +import { + getChildElementsByTagName, + newActionEvent, + newWizardEvent, +} from '../../foundation.js'; import { startMove } from './foundation.js'; import { SubstationEditor } from './substation-editor.js'; import { BayEditor } from './bay-editor.js'; @@ -61,6 +65,16 @@ export class PowerTransformerEditor extends LitElement { ); } + renderEqFunctions(): TemplateResult { + if (!this.showfunctions) return html``; + + const eqFunctions = getChildElementsByTagName(this.element, 'EqFunction'); + return html` ${eqFunctions.map( + eqFunction => + html`` + )}`; + } + renderContentPane(): TemplateResult { return html`${powerTransformerTwoWindingIcon}${this.renderContentPane()}${this.renderContentPane()}${this.renderEqFunctions()} `; return html` - + + + + + @@ -29,8 +33,23 @@ - - + + + + + + + + + + + + + + + + + diff --git a/test/unit/editors/substation/__snapshots__/bay-editor.test.snap.js b/test/unit/editors/substation/__snapshots__/bay-editor.test.snap.js index c5554720a4..c9cf9629b7 100644 --- a/test/unit/editors/substation/__snapshots__/bay-editor.test.snap.js +++ b/test/unit/editors/substation/__snapshots__/bay-editor.test.snap.js @@ -300,6 +300,12 @@ snapshots["bay-editor with function filter deactivated looks like the latest sna + + + + + + `; diff --git a/test/unit/editors/substation/__snapshots__/conducting-equipment-editor.test.snap.js b/test/unit/editors/substation/__snapshots__/conducting-equipment-editor.test.snap.js index 458d05d8a9..8e145f8b9f 100644 --- a/test/unit/editors/substation/__snapshots__/conducting-equipment-editor.test.snap.js +++ b/test/unit/editors/substation/__snapshots__/conducting-equipment-editor.test.snap.js @@ -94,3 +94,63 @@ snapshots["conducting-equipment-editor rendered as action pane looks like the la `; /* end snapshot conducting-equipment-editor rendered as action pane looks like the latest snapshot */ +snapshots["conducting-equipment-editor rendered as action pane with EqFunction children looks like the latest snapshot"] = +` + + + + + + + + + + + + + + + + + + + + + +`; +/* end snapshot conducting-equipment-editor rendered as action pane with EqFunction children looks like the latest snapshot */ + diff --git a/test/unit/editors/substation/__snapshots__/eq-function-editor.test.snap.js b/test/unit/editors/substation/__snapshots__/eq-function-editor.test.snap.js new file mode 100644 index 0000000000..674815ab52 --- /dev/null +++ b/test/unit/editors/substation/__snapshots__/eq-function-editor.test.snap.js @@ -0,0 +1,27 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["web component rendering EqFunction element with complete attribute set and existing children looks like the latest snapshot"] = +` + +`; +/* end snapshot web component rendering EqFunction element with complete attribute set and existing children looks like the latest snapshot */ + +snapshots["web component rendering EqFunction element with missing desc and type attribute looks like the latest snapshot"] = +` + +`; +/* end snapshot web component rendering EqFunction element with missing desc and type attribute looks like the latest snapshot */ + diff --git a/test/unit/editors/substation/__snapshots__/powertransformer-editor.test.snap.js b/test/unit/editors/substation/__snapshots__/powertransformer-editor.test.snap.js index 0b834d83de..bb06c2da07 100644 --- a/test/unit/editors/substation/__snapshots__/powertransformer-editor.test.snap.js +++ b/test/unit/editors/substation/__snapshots__/powertransformer-editor.test.snap.js @@ -95,3 +95,63 @@ snapshots["powertransformer-editor rendered as action pane looks like the latest `; /* end snapshot powertransformer-editor rendered as action pane looks like the latest snapshot */ +snapshots["powertransformer-editor rendered as action pane with EqFunction childrend looks like the latest snapshot"] = +` + + + + + + + + + + + + + + + + + + + + + +`; +/* end snapshot powertransformer-editor rendered as action pane with EqFunction childrend looks like the latest snapshot */ + diff --git a/test/unit/editors/substation/conducting-equipment-editor.test.ts b/test/unit/editors/substation/conducting-equipment-editor.test.ts index 91809e5b39..b0546d5e2a 100644 --- a/test/unit/editors/substation/conducting-equipment-editor.test.ts +++ b/test/unit/editors/substation/conducting-equipment-editor.test.ts @@ -98,6 +98,22 @@ describe('conducting-equipment-editor', () => { await expect(element).shadowDom.to.equalSnapshot(); }); + describe('with EqFunction children', () => { + beforeEach(async () => { + const doc = await fetch('/test/testfiles/zeroline/functions.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + + element.element = doc.querySelector( + 'Bay[name="COUPLING_BAY"] > ConductingEquipment[name="QA1"]' + )!; + await element.requestUpdate(); + }); + + it('looks like the latest snapshot', async () => + await expect(element).shadowDom.to.equalSnapshot()); + }); + it('renders empty string in case ConductingEquipment name attribute is missing', async () => { const condEq = validSCL.querySelector('ConductingEquipment'); condEq?.removeAttribute('name'); diff --git a/test/unit/editors/substation/eq-function-editor.test.ts b/test/unit/editors/substation/eq-function-editor.test.ts new file mode 100644 index 0000000000..22b53d46b6 --- /dev/null +++ b/test/unit/editors/substation/eq-function-editor.test.ts @@ -0,0 +1,45 @@ +import { fixture, html, expect } from '@open-wc/testing'; + +import '../../../../src/editors/substation/eq-function-editor.js'; +import { EqFunctionEditor } from '../../../../src/editors/substation/eq-function-editor.js'; + +describe('web component rendering EqFunction element', () => { + let element: EqFunctionEditor; + let doc: XMLDocument; + + beforeEach(async () => { + doc = await fetch('/test/testfiles/zeroline/functions.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + }); + + describe('with complete attribute set and existing children', () => { + beforeEach(async () => { + element = ( + await fixture( + html`` + ) + ); + }); + + it('looks like the latest snapshot', async () => + await expect(element).shadowDom.to.equalSnapshot()); + }); + + describe('with missing desc and type attribute', () => { + beforeEach(async () => { + element = ( + await fixture( + html`` + ) + ); + }); + + it('looks like the latest snapshot', async () => + await expect(element).shadowDom.to.equalSnapshot()); + }); +}); diff --git a/test/unit/editors/substation/powertransformer-editor.test.ts b/test/unit/editors/substation/powertransformer-editor.test.ts index 7d33257c1d..75fa0f4751 100644 --- a/test/unit/editors/substation/powertransformer-editor.test.ts +++ b/test/unit/editors/substation/powertransformer-editor.test.ts @@ -91,6 +91,20 @@ describe('powertransformer-editor', () => { await expect(element).shadowDom.to.equalSnapshot(); }); + describe('with EqFunction childrend', () => { + beforeEach(async () => { + const doc = await fetch('/test/testfiles/zeroline/functions.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + + element.element = doc.querySelector('PowerTransformer[name="myPtr2"]')!; + await element.requestUpdate(); + }); + + it('looks like the latest snapshot', async () => + await expect(element).shadowDom.to.equalSnapshot()); + }); + it('triggers edit wizard for Linking LNode element on action button click', async () => { (( element.shadowRoot?.querySelector(