From 1cd6fb72b0ecae47106425ecff1b1d8523f7d50e Mon Sep 17 00:00:00 2001 From: Juan Munoz Date: Thu, 16 Jun 2022 12:30:15 +0200 Subject: [PATCH] feat(wizards/ied): added new textfields for IED properties (#822) * chore(translations): adding helpers for additional IED wizard-textfields * feat(wizards/ied): added new textfields for IED properties * test(wizard/ied): verifying correct render of IED properties as texfields * test(wizard/ied): generated new snapshot with textfields * feat(wizard/ied): updated IED prop texfields to match other readonly fields in the app (DO wizard) * test(wizard/ied): updated tests to match changes in ied wizard implementation * chore(wizard/ied): removed unused helper translations * test(wizard/ied): fixed bug of using wrong comparative fn in tests and replaced old snapshot * feat(wizard/ied): updated validatedVersionAttribute() with suggestion from @dlabordus * test(wizard/ied): using ied's attributes in the XML doc instead of fixed values for comparissons --- src/wizards/ied.ts | 54 +++++++++++++++++++ .../wizards/__snapshots__/ied.test.snap.js | 36 +++++++++++++ test/unit/wizards/ied.test.ts | 25 ++++++++- 3 files changed, 114 insertions(+), 1 deletion(-) diff --git a/src/wizards/ied.ts b/src/wizards/ied.ts index 92f25aaa5f..5c74bbe271 100644 --- a/src/wizards/ied.ts +++ b/src/wizards/ied.ts @@ -36,6 +36,12 @@ const iedNamePattern = export function renderIEDWizard( name: string | null, desc: string | null, + type: string | null, + manufacturer: string | null, + configVersion: string | null, + originalSclVersion: string, + engRight: string | null, + owner: string | null, reservedNames: string[] ): TemplateResult[] { return [ @@ -56,6 +62,42 @@ export function renderIEDWizard( helper="${translate('ied.wizard.descHelper')}" pattern="${patterns.normalizedString}" >`, + html``, + html``, + html``, + html``, + html``, + html`` ]; } @@ -78,6 +120,12 @@ function renderIEDReferencesWizard(references: Delete[]): TemplateResult[] { ]; } +function validatedVersionAttribute(element: Element): string { + return (element.getAttribute('originalSclVersion') ?? '') + .concat(element.getAttribute('originalSclRevision') ?? '') + .concat(element.getAttribute('originalSclRelease') ?? '') +} + export function reservedNamesIED(currentElement: Element): string[] { return Array.from(currentElement.parentNode!.querySelectorAll('IED')) .filter(isPublic) @@ -169,6 +217,12 @@ export function editIEDWizard(element: Element): Wizard { content: renderIEDWizard( element.getAttribute('name'), element.getAttribute('desc'), + element.getAttribute('type'), + element.getAttribute('manufacturer'), + element.getAttribute('configVersion'), + validatedVersionAttribute(element), + element.getAttribute('engRight'), + element.getAttribute('owner'), reservedNamesIED(element) ), }, diff --git a/test/unit/wizards/__snapshots__/ied.test.snap.js b/test/unit/wizards/__snapshots__/ied.test.snap.js index bd079925fe..fd95e37b4e 100644 --- a/test/unit/wizards/__snapshots__/ied.test.snap.js +++ b/test/unit/wizards/__snapshots__/ied.test.snap.js @@ -49,6 +49,42 @@ snapshots["Wizards for SCL element IED edit IED looks like the latest snapshot"] pattern="([ -~]|[…]|[ -퟿]|[-�])*" > + + + + + + + + + + + + { await element.requestUpdate(); inputs = Array.from(element.wizardUI.inputs); }); - + it('contains a wizard-textfield with a non-empty "type" value', async () => { + expect((inputs).find(textField => textField.label == 'type')?.value).to + .be.equal(ied.getAttribute('type') || '-'); + }); + it('contains a wizard-textfield with a non-empty "manufacturer" value', async () => { + expect((inputs).find(textField => textField.label == 'manufacturer')?.value).to + .be.equal(ied.getAttribute('manufacturer') || '-'); + }); + it('contains a wizard-textfield with a non-empty "configVersion" value', async () => { + expect((inputs).find(textField => textField.label == 'configVersion')?.value).to + .be.equal(ied.getAttribute('configVersion') || '-'); + }); + it('contains a wizard-textfield with a non-empty "originalSclVersion" value', async () => { + expect((inputs).find(textField => textField.label == 'originalSclVersion')?.value).to + .contain(ied.getAttribute('originalSclVersion') || '-'); + }); + it('contains a wizard-textfield with an empty "engRight" value', async () => { + expect((inputs).find(textField => textField.label == 'engRight')?.value).to + .be.equal(ied.getAttribute('engRight') || '-'); + }); + it('contains a wizard-textfield with a non-empty "owner" value', async () => { + expect((inputs).find(textField => textField.label == 'owner')?.value).to + .be.equal(ied.getAttribute('owner') || '-'); + }); it('update name should be updated in document', async function () { await setWizardTextFieldValue(inputs[0], 'OtherIED3');