From 13fbd1873f486aabc1e7c8de58b7544cf7da2eb8 Mon Sep 17 00:00:00 2001 From: Jakob Vogelsang Date: Wed, 27 Oct 2021 08:38:08 +0200 Subject: [PATCH 01/18] feat(validators/validatetemplate): trigger validators with editor action (#300) * feat(validators/validatetemplate): restrict to 2007B3 and higher * feat(validators/validatetemplate): remove missing ctlModel from possible issues * feat(validators/validatetemplate): precise schame validation messages in the log * feat(Editing): trigger all validators onAction * refactor(validators/schemavalidator): diaplay successful schema validation in the diagnostics * refactor(validator/templates/dosdo): move DO and SDO validation * test(validators/doorsdo): add tests * test(validators/doorsdo): add test file * test(validators/lnodetype): add unit tests * test(validate/dotype): add unit tests * test(validator/lnodetype and dosdo): imporve tests * test(validator/dabda): add unit tests * test(validator): update test files * refactor(translation): update translation * feat(validators/datype): add DAType validator functions * fix(validator): fix minor issues * refactor(validators): minor improvement * fix(public/templates): remove issues * refactor(validator): change API for validate() * fix(validators/dosdo dabda): add missing identity * test(validator/SchemaValidator): adapt integration tests * test(validators/ValidateTemplates): improve unit test * test(validators/ValidateTemplates): improve integrations tests * test(validators/ValidateTemplates): add missing test file * test(Logging): adapt unit tests * test(validator/ValidateTemplates): fix import statement * fix: merge issues * test(ValidateTemplates): set default translate config to avoid translation * refactor(translations): adjust triggered by PR * refactor(Logging): improve wording --- __snapshots__/ValidateSchema plugin.md | 2 +- ...dateTemplates OpenSCD integration test .md | 538 ++++++++++++++++++ __snapshots__/ValidateTemplates plugin.md | 71 ++- public/xml/templates.scd | 4 +- src/Editing.ts | 2 + src/Hosting.ts | 44 +- src/Logging.ts | 24 +- src/foundation.ts | 13 +- src/translations/de.ts | 17 +- src/translations/en.ts | 17 +- src/validators/ValidateSchema.ts | 18 +- src/validators/ValidateTemplates.ts | 468 ++------------- src/validators/templates/dabda.ts | 31 + src/validators/templates/datype.ts | 86 +++ src/validators/templates/dosdo.ts | 30 + src/validators/templates/dotype.ts | 152 +++++ src/validators/templates/foundation.ts | 118 ++++ src/validators/templates/lnodetype.ts | 64 +++ .../validators/ValidateSchema.test.ts | 50 +- .../validators/ValidateTemplates.test.ts | 100 +++- .../validators/datatypetemplateerrors.scd | 500 +++++++--------- .../testfiles/validators/doandsdotestfile.scd | 67 +++ test/testfiles/validators/zeroissues.scd | 6 + test/unit/Logging.test.ts | 98 ---- .../unit/validators/ValidateTemplates.test.ts | 258 ++++----- test/unit/validators/templates/dabda.test.ts | 93 +++ test/unit/validators/templates/datype.test.ts | 72 +++ .../unit/validators/templates/doorsdo.test.ts | 46 ++ test/unit/validators/templates/dotype.test.ts | 126 ++++ .../validators/templates/foundation.test.ts | 26 + .../validators/templates/lnodetype.test.ts | 46 ++ 31 files changed, 2111 insertions(+), 1076 deletions(-) create mode 100644 __snapshots__/ValidateTemplates OpenSCD integration test .md create mode 100644 src/validators/templates/dabda.ts create mode 100644 src/validators/templates/datype.ts create mode 100644 src/validators/templates/dosdo.ts create mode 100644 src/validators/templates/dotype.ts create mode 100644 src/validators/templates/foundation.ts create mode 100644 src/validators/templates/lnodetype.ts create mode 100644 test/testfiles/validators/doandsdotestfile.scd create mode 100644 test/testfiles/validators/zeroissues.scd create mode 100644 test/unit/validators/templates/dabda.test.ts create mode 100644 test/unit/validators/templates/datype.test.ts create mode 100644 test/unit/validators/templates/doorsdo.test.ts create mode 100644 test/unit/validators/templates/dotype.test.ts create mode 100644 test/unit/validators/templates/foundation.test.ts create mode 100644 test/unit/validators/templates/lnodetype.test.ts diff --git a/__snapshots__/ValidateSchema plugin.md b/__snapshots__/ValidateSchema plugin.md index fa84ee8637..068099e1a8 100644 --- a/__snapshots__/ValidateSchema plugin.md +++ b/__snapshots__/ValidateSchema plugin.md @@ -2,7 +2,7 @@ ## `for valid SCL files` -#### `zeroissues indiacation looks like the latest snapshot` +#### `zeroissues indication looks like the latest snapshot` ```html + + + Validate Templates + +
  • +
  • + + + + lnClass CSWI is missing mandatory child DO Pos + + + #Dummy.CSWI > Pos + + + + + + + lnClass CILO is missing mandatory child DO Beh + + + #Dummy.CILO > Beh + + + + + + + lnClass XSWI is missing mandatory child DO SwTyp + + + #Dummy.XSWI1 > SwTyp + + + + + + + The attribute type is required but missing in DO + + + #Dummy.invalidChild>NamPlt + + + + + + + The attribute lnClass is required but missing in LNodeType + + + #Dummy.MissingLnClass + + + + + + + DO:stVal has a invalid reference - type attribute cannot be connected to a template + + + #Dummy.LLN0.Mod>stVal + + + + + + + DO:stVal has a invalid reference - type attribute cannot be connected to a template + + + #Dummy.LLN0.Beh>stVal + + + + + + + Common Data Class ENS is missing mandatory child DA stVal + + + #Dummy.LLN0.Health + + + + + + + Common Data Class SPC is missing mandatory child DA SBO + + + #Dummy.SPC2 + + + + + + + Common Data Class SPC is missing mandatory child DA SBOw + + + #Dummy.SPC1 + + + + + + + Common Data Class SPC is missing mandatory child DA Cancel + + + #Dummy.SPC8 + + + + + + + Common Data Class SPC is missing mandatory child DA Oper + + + #Dummy.SPC3 + + + + + + + Common Data Class DPC is missing mandatory child DA t + + + #Dummy.XCBR1.Pos + + + + + + + Common Data Class DPC is missing mandatory child DA ctlModel + + + #Dummy.CSWI.Pos1 + + + + + + + The attribute cdc is incorrect in the element DOType. + + + #Dummy.XCBR1.badNamPlt + + + + + + + The attribute cdc is required but missing in DOType + + + #Dummy.MissingCDC + + + + + + + The attribute type is required but missing in DA + + + #Dummy.MissingType>SBOw + + + + + + + The attribute type is required but missing in DA + + + #Dummy.MissingType>Oper + + + + + + + The attribute type is required but missing in DA + + + #Dummy.MissingType>Cancel + + + + + + + The attribute type is required but missing in SDO + + + #Dummy.badWYE>phsA + + + + + + + DO:ctlVal has a invalid reference - type attribute cannot be connected to a template + + + #Dummy.LLN0.Mod.SBOw>ctlVal + + + + + + + DO:ctlVal has a invalid reference - type attribute cannot be connected to a template + + + #Dummy.LLN0.Mod.Cancel>ctlVal + + + + + + + DAType Dummy.Operfalse is missing mandatory child BDA ctlNum + + + #Dummy.Operfalse + + + + + + + DAType Dummy.SBOwfalse is missing mandatory child BDA origin + + + #Dummy.SBOwfalse + + + + + + + DAType Dummy.Cancelfalse is missing mandatory child BDA ctlVal + + + #Dummy.Cancelfalse + + + + + + + DAType Dummy.ScaledValueConfig is missing mandatory child BDA scaleFactor + + + #Dummy.ScaledValueConfig + + + + + + + DO:SIUnit has a invalid reference - type attribute cannot be connected to a template + + + #Dummy.unit>SIUnit + + + + + + + DO:multiplier has a invalid reference - type attribute cannot be connected to a template + + + #Dummy.unit>multiplier + + + +
    + + Close + +
    + +``` + +## `with schema version smaller "2007B3"` + +#### `pushes a specific issue to the diagnostics pane that look like the latest snapshot` + +```html + + + + Validate Templates + +
  • +
  • + + + + Cannot validate DataTypeTemplates. The version of the project must be higher than or equal to 2007B3 + + + + + +
    + + Close + +
    + +``` + diff --git a/__snapshots__/ValidateTemplates plugin.md b/__snapshots__/ValidateTemplates plugin.md index d059b2c16d..be3b8039eb 100644 --- a/__snapshots__/ValidateTemplates plugin.md +++ b/__snapshots__/ValidateTemplates plugin.md @@ -1,6 +1,8 @@ # `ValidateTemplates plugin` -#### `pushes issues to the diagnostics pane that look like the latest snapshot` +## `with issues in the DataTypeTemplates section` + +#### `pushes issues to the diagnostics pane that look like the latest snapshot` ```html - - - - Missing ctlModel definition. Cannot validate ctlModel Val within DOType Dummy.CSWI.Pos1 - - - #Dummy.CSWI.Pos1 - - - + + + Validate Templates + +
  • +
  • + + + + Cannot validate DataTypeTemplates. The version of the project must be higher than or equal to 2007B3 + + + + + +
    + + Close + +
    + +``` + diff --git a/public/xml/templates.scd b/public/xml/templates.scd index efecee0f6c..a4c4fd8b0a 100644 --- a/public/xml/templates.scd +++ b/public/xml/templates.scd @@ -400,7 +400,7 @@ - + @@ -430,7 +430,7 @@ - + diff --git a/src/Editing.ts b/src/Editing.ts index fa7dfd7d5c..060c99b090 100644 --- a/src/Editing.ts +++ b/src/Editing.ts @@ -236,6 +236,8 @@ export function Editing(Base: TBase) { ); } + this.dispatchEvent(newValidateEvent()); + for (const element of event.composedPath()) if (element instanceof LitElement) element.requestUpdate(); } diff --git a/src/Hosting.ts b/src/Hosting.ts index 5cbd088aa2..5cc2b14951 100644 --- a/src/Hosting.ts +++ b/src/Hosting.ts @@ -1,16 +1,10 @@ import { Drawer } from '@material/mwc-drawer'; import { ActionDetail, List } from '@material/mwc-list'; import { ListItem } from '@material/mwc-list/mwc-list-item'; -import { - html, - internalProperty, - property, - query, - TemplateResult, -} from 'lit-element'; +import { html, property, query, TemplateResult } from 'lit-element'; import { until } from 'lit-html/directives/until'; import { translate } from 'lit-translate'; -import { Mixin, newPendingStateEvent, ValidateEvent } from './foundation.js'; +import { Mixin, newPendingStateEvent } from './foundation.js'; import { LoggingElement } from './Logging.js'; import { Plugin, PluggingElement, pluginIcons } from './Plugging.js'; import { SettingElement } from './Setting.js'; @@ -27,7 +21,7 @@ interface MenuItem { } interface Validator { - validate: (identity: string, run: number) => Promise; + validate: () => Promise; } interface MenuPlugin { @@ -47,10 +41,9 @@ export function Hosting< @property({ type: Number }) activeTab = 0; @property({ attribute: false }) - validated: Promise = Promise.resolve(); + validated: Promise = Promise.resolve(); - @internalProperty() - statusNumber = 0; + private shouldValidate = false; @query('#menu') menuUI!: Drawer; @@ -128,13 +121,16 @@ export function Hosting< icon: plugin.icon || pluginIcons['validator'], name: plugin.name, action: ae => { + if (this.diagnoses.get(plugin.src)) + this.diagnoses.get(plugin.src)!.length = 0; + this.dispatchEvent( newPendingStateEvent( (( (( (ae.target).items[ae.detail.index].lastElementChild )) - )).validate('', ++this.statusNumber) + )).validate() ) ); }, @@ -203,18 +199,24 @@ export function Hosting< constructor(...args: any[]) { super(...args); - this.addEventListener('validate', async (e: ValidateEvent) => { + this.addEventListener('validate', async () => { + this.shouldValidate = true; + await this.validated; + + if (!this.shouldValidate) return; + + this.diagnoses.clear(); + this.shouldValidate = false; + this.validated = Promise.allSettled( this.menuUI .querySelector('mwc-list')! .items.filter(item => item.className === 'validator') - .map(item => { - const promise = (( - (item.lastElementChild) - )).validate(e.detail.identity, ++this.statusNumber); - return promise; - }) - ); + .map(item => + ((item.lastElementChild)).validate() + ) + ).then(); + this.dispatchEvent(newPendingStateEvent(this.validated)); }); } diff --git a/src/Logging.ts b/src/Logging.ts index 74c7a7aba6..e1fb80eb35 100644 --- a/src/Logging.ts +++ b/src/Logging.ts @@ -73,7 +73,7 @@ export function Logging(Base: TBase) { @property() diagnoses = new Map(); @internalProperty() - lastIssue!: IssueDetail; + latestIssue!: IssueDetail; @query('#log') logUI!: Dialog; @query('#diagnostic') diagnosticUI!: Dialog; @@ -158,15 +158,11 @@ export function Logging(Base: TBase) { private onIssue(de: IssueEvent): void { const issues = this.diagnoses.get(de.detail.validatorId); - if (issues && issues[0].statusNumber > de.detail.statusNumber) return; - else if (issues && issues[0].statusNumber === de.detail.statusNumber) - issues.push(de.detail); - else if (issues && issues[0].statusNumber !== de.detail.statusNumber) { - issues.length = 0; - issues?.push(de.detail); - } else this.diagnoses.set(de.detail.validatorId, [de.detail]); - - this.lastIssue = de.detail; + + if (!issues) this.diagnoses.set(de.detail.validatorId, [de.detail]); + else issues?.push(de.detail); + + this.latestIssue = de.detail; this.issueUI.close(); this.issueUI.show(); } @@ -318,11 +314,7 @@ export function Logging(Base: TBase) { return issueItems.length ? issueItems : html` - ${translate( - this.history.length ? 'diag.zeroissues' : 'diag.placeholder' - )} + ${translate('diag.placeholder')} info `; } @@ -470,7 +462,7 @@ export function Logging(Base: TBase) { ; export function newIssueEvent( @@ -320,19 +319,15 @@ export function newPendingStateEvent( } /** Represents a request for validation. */ -export interface ValidateDetail { - identity: string; -} -export type ValidateEvent = CustomEvent; + +export type ValidateEvent = CustomEvent; export function newValidateEvent( - identity = '', - eventInitDict?: CustomEventInit> + eventInitDict?: CustomEventInit ): ValidateEvent { - return new CustomEvent('validate', { + return new CustomEvent('validate', { bubbles: true, composed: true, ...eventInitDict, - detail: { identity, ...eventInitDict?.detail }, }); } diff --git a/src/translations/de.ts b/src/translations/de.ts index 851c3f4708..65572d45c4 100644 --- a/src/translations/de.ts +++ b/src/translations/de.ts @@ -85,18 +85,21 @@ export const de: Translations = { validator: { schema: { title: 'Projekt validieren', - valid: '{{ name }} erfolgreich validiert', - invalid: '{{ name }} Validierung fehlgeschlagen', + valid: '{{ name }} erfolgreich validiert gegen XML-Schema', + invalid: '{{ name }} Schema-Validierung fehlgeschlagen', fatal: 'Fataler Validierungsfehler', - loadError: 'Konnte Schema {{ name }} nicht laden', + loadError: 'Konnte XML-Schema {{ name }} nicht laden', }, templates: { title: 'Templates validieren', mandatoryChild: '{{ tag }} {{ id }} fehlt ein obligatorisches {{ childTag }}-Kind {{ childId }}', - missingCoDO: 'Control-Dienst Datenattribut vom Typ {{ type }} fehlt', - missingCtlModelDef: - 'CtlModel Definition fehlt. Kann {{ childTag }} {{ childId }} in {{ tag }} {{ id }} nicht validieren.', + missingAttribute: + 'Das Attribut {{attr}} ist verpflichted und fehlt in {{element}}', + incorrectAttribute: + 'Das Attribut {{attr}} in Element {{element}} folgt nicht der Definition.', + missingReference: + '{{tag}} "{{name}}" hat eine ungültige Referenz - es fehlt der definierte Typ', }, }, textfield: { @@ -118,6 +121,8 @@ export const de: Translations = { name: 'Daignoseübersicht', zeroissues: 'Es konnten keine Fehler in dem Projekt gefunden werden.', placeholder: 'Hier werden Validierungsfehler angezeigt.', + missingnsd: + 'DataTypeTemplates können nicht validiert werden. Das Projekt muss die Version 2007B3 oder höher haben.', }, plugins: { heading: 'Erweiterungen', diff --git a/src/translations/en.ts b/src/translations/en.ts index ba86555822..8187304718 100644 --- a/src/translations/en.ts +++ b/src/translations/en.ts @@ -98,6 +98,8 @@ export const en = { name: 'Diagnostics', zeroissues: 'No errors found in the project', placeholder: 'Issues found during validation will show up here', + missingnsd: + 'Cannot validate DataTypeTemplates. The version of the project must be higher than or equal to 2007B3', }, plugins: { heading: 'Extensions', @@ -121,18 +123,21 @@ export const en = { validator: { schema: { title: 'Validate project', - valid: '{{ name }} validation successful', - invalid: '{{ name }} validation failed', + valid: '{{ name }} XML schema validation successful', + invalid: '{{ name }} XML schema validation failed', fatal: 'Fatal validation error', - loadError: 'Could not load schema {{ name }}', + loadError: 'Could not load XML schema {{ name }}', }, templates: { title: 'Validate templates', mandatoryChild: '{{ tag }} {{ id }} is missing mandatory child {{ childTag }} {{ childId }}', - missingCoDO: 'Control service related DA of type {{ type }} is missing', - missingCtlModelDef: - 'Missing ctlModel definition. Cannot validate {{ childTag }} {{ childId }} within {{ tag }} {{ id }}', + missingAttribute: + 'The attribute {{attr}} is required but missing in {{element}}', + incorrectAttribute: + 'The attribute {{attr}} is incorrect in the element {{element}}.', + missingReference: + '{{tag}}:{{name}} has a invalid reference - type attribute cannot be connected to a template', }, }, substation: { diff --git a/src/validators/ValidateSchema.ts b/src/validators/ValidateSchema.ts index 8e0bf4303f..4c693924ff 100644 --- a/src/validators/ValidateSchema.ts +++ b/src/validators/ValidateSchema.ts @@ -25,11 +25,7 @@ export default class ValidateSchema extends LitElement { @property() pluginId!: string; - private async getValidator( - xsd: string, - xsdName: string, - statusNumber: number - ): Promise { + private async getValidator(xsd: string, xsdName: string): Promise { if (!window.Worker) throw new Error(get('validator.schema.fatal')); if (validators[xsdName]) return validators[xsdName]!; @@ -61,7 +57,6 @@ export default class ValidateSchema extends LitElement { newIssueEvent({ title: description, validatorId: this.pluginId, - statusNumber, message: e.data.file + ':' + @@ -87,7 +82,7 @@ export default class ValidateSchema extends LitElement { }); } - async validate(indentity: string, statusNumber: number): Promise { + async validate(): Promise { const fileName = this.docName; let version = '2007'; let revision = 'B'; @@ -101,8 +96,7 @@ export default class ValidateSchema extends LitElement { ]; const result = await this.getValidator( getSchema(version, revision, release), - 'SCL' + version + revision + release + '.xsd', - statusNumber + 'SCL' + version + revision + release + '.xsd' ).then(validator => validator(new XMLSerializer().serializeToString(this.doc), fileName) ); @@ -123,5 +117,11 @@ export default class ValidateSchema extends LitElement { title: get('validator.schema.valid', { name: result.file }), }) ); + document.querySelector('open-scd')!.dispatchEvent( + newIssueEvent({ + validatorId: this.pluginId, + title: get('validator.schema.valid', { name: result.file }), + }) + ); } } diff --git a/src/validators/ValidateTemplates.ts b/src/validators/ValidateTemplates.ts index c568670a43..1144f9f71c 100644 --- a/src/validators/ValidateTemplates.ts +++ b/src/validators/ValidateTemplates.ts @@ -1,419 +1,32 @@ import { LitElement, property } from 'lit-element'; import { get } from 'lit-translate'; import { - identity, LogDetail, LogDetailBase, newIssueEvent, newLogEvent, } from '../foundation.js'; +import { validateChildren } from './templates/foundation.js'; type ValidationResult = LogDetailBase | LogDetail; -const iec6185074 = fetch('public/xml/IEC_61850-7-4_2007B3.nsd') - .then(response => response.text()) - .then(str => new DOMParser().parseFromString(str, 'application/xml')); - -const iec6185073 = fetch('public/xml/IEC_61850-7-3_2007B3.nsd') - .then(response => response.text()) - .then(str => new DOMParser().parseFromString(str, 'application/xml')); - -const iec6185072 = fetch('public/xml/IEC_61850-7-2_2007B3.nsd') - .then(response => response.text()) - .then(str => new DOMParser().parseFromString(str, 'application/xml')); - -const iec6185081 = fetch('public/xml/IEC_61850-8-1_2003A2.nsd') - .then(response => response.text()) - .then(str => new DOMParser().parseFromString(str, 'application/xml')); - -const serviceCDCs = ['SPC', 'DPC', 'INC', 'ENC', 'BSC', 'ISC', 'APC', 'BAC']; - -function dispatch( - detail: ValidationResult, - statusNumber: number, - validatorId: string -): void { +export function dispatch(detail: ValidationResult, validatorId: string): void { + const kind = (detail).kind; const title = (detail).title; const message = (detail).message; - document.querySelector('open-scd')?.dispatchEvent( - newIssueEvent({ - validatorId, - statusNumber: statusNumber, - title, - message, - }) - ); -} - -async function validateCoOperStructure( - oper: Element -): Promise { - const type = oper.getAttribute('type'); - if (!type) return []; - - const datype = - oper.closest('DataTypeTemplates')?.querySelector(`DAType[id="${type}"]`) ?? - null; - - const nsd81 = await iec6185081; - - const errors: ValidationResult[] = []; - const mandatoryBDAs = Array.from( - nsd81.querySelectorAll( - `ServiceConstructedAttributes > ServiceConstructedAttribute[name="Oper"] > SubDataAttribute[presCond="M"]` - ) - ).map(data => data.getAttribute('name')!); - - for (const mandatoryBDA of mandatoryBDAs) - if (datype && !datype.querySelector(`BDA[name="${mandatoryBDA}"]`)) - errors.push({ - title: get('validator.templates.mandatoryChild', { - tag: 'DAType', - id: type, - childTag: 'BDA', - childId: mandatoryBDA, - }), - message: `${identity(datype)}`, - }); - - return errors; -} - -async function validateCoSBOwStructure( - sbow: Element -): Promise { - const type = sbow.getAttribute('type'); - if (!type) return []; - - const datype = - sbow.closest('DataTypeTemplates')?.querySelector(`DAType[id="${type}"]`) ?? - null; - - const nsd81 = await iec6185081; - - const errors: ValidationResult[] = []; - const mandatoryBDAs = Array.from( - nsd81.querySelectorAll( - `ServiceConstructedAttributes > ServiceConstructedAttribute[name="SBOw"] > SubDataAttribute[presCond="M"]` - ) - ).map(data => data.getAttribute('name')!); - - for (const mandatoryBDA of mandatoryBDAs) - if (datype && !datype.querySelector(`BDA[name="${mandatoryBDA}"]`)) - errors.push({ - title: get('validator.templates.mandatoryChild', { - tag: 'SBOw', - id: type, - childTag: 'BDA', - childId: mandatoryBDA, - }), - message: `${identity(datype)}`, - }); - - return errors; -} - -async function validateCoCancelStructure( - cancel: Element -): Promise { - const type = cancel.getAttribute('type'); - if (!type) return []; - - const datype = - cancel - .closest('DataTypeTemplates') - ?.querySelector(`DAType[id="${type}"]`) ?? null; - const nsd81 = await iec6185081; - - const errors: ValidationResult[] = []; - const mandatoryBDAs = Array.from( - nsd81.querySelectorAll( - `ServiceConstructedAttributes > ServiceConstructedAttribute[name="Cancel"] > SubDataAttribute[presCond="M"]` - ) - ).map(data => data.getAttribute('name')!); - - for (const mandatoryBDA of mandatoryBDAs) - if (datype && !datype.querySelector(`BDA[name="${mandatoryBDA}"]`)) - errors.push({ - title: get('validator.templates.mandatoryChild', { - tag: 'DAType', - id: type, - childTag: 'BDA', - childId: mandatoryBDA, - }), - message: `${identity(datype)}`, - }); - - return errors; -} - -function missingCoDataToLog( - reference: string | number, - type: 'Oper' | 'SBOw' | 'SBO' | 'Cancel' -): ValidationResult { - return { - title: get('validator.templates.missingCoDO', { type }), - message: `${reference}`, - }; -} - -export async function validateControlCDC( - dotype: Element -): Promise { - //characteristic for controlable CDCs is the third and last character that must be xxC - if ( - dotype.getAttribute('cdc') && - !serviceCDCs.includes(dotype.getAttribute('cdc')!) - ) - return []; - - let errors: ValidationResult[] = []; - const ctlModel = dotype - .querySelector('DA[name="ctlModel"] > Val') - ?.textContent?.trim(); - const oper = dotype.querySelector('DA[fc="CO"][name="Oper"][bType="Struct"]'); - const sbo = dotype.querySelector('DA[fc="CO"][name="SBO"][bType="ObjRef"]'); - const cancel = dotype.querySelector( - 'DA[fc="CO"][name="Cancel"][bType="Struct"]' - ); - const sbow = dotype.querySelector('DA[fc="CO"][name="SBOw"][bType="Struct"]'); - - if (ctlModel === 'sbo-with-enhanced-security') { - const errorsSBOw = sbow - ? await validateCoSBOwStructure(sbow) - : [missingCoDataToLog(identity(dotype), 'SBOw')]; - const errorsCancel = cancel - ? await validateCoCancelStructure(cancel) - : [missingCoDataToLog(identity(dotype), 'Cancel')]; - errors = errorsSBOw.concat(errorsCancel); - } else if (ctlModel === 'sbo-with-normal-security') { - errors = cancel - ? await validateCoCancelStructure(cancel) - : [missingCoDataToLog(identity(dotype), 'Cancel')]; - if (!sbo) errors.push(missingCoDataToLog(identity(dotype), 'SBO')); - } else if ( - ctlModel === 'direct-with-normal-security' || - ctlModel === 'direct-with-enhanced-security' - ) { - errors = oper - ? await validateCoOperStructure(oper) - : [missingCoDataToLog(identity(dotype), 'Oper')]; - } else if (ctlModel !== 'status-only') { - return [ - { - title: get('validator.templates.missingCtlModelDef', { - tag: 'DOType', - id: dotype.id || 'UNIDENTIFIABLE', - childTag: 'ctlModel', - childId: 'Val', - }), - message: (identity(dotype) || 'UNIDENTIFIABLE'), - }, - ]; - } - - return errors; -} - -async function getMandatorySubDAs(datype: Element): Promise { - const parentDAs = - Array.from( - datype - .closest('DataTypeTemplates')! - .querySelectorAll( - `DOType > DA[type="${datype.getAttribute('id')}"]` - ) - ) ?? []; - - const nsd = await iec6185073; - const dataAttributes = parentDAs.map(parentDA => { - const parentCDC = parentDA.parentElement!; - return nsd.querySelector( - `CDC[name="${parentCDC.getAttribute( - 'cdc' - )}"] > DataAttribute[name="${parentDA.getAttribute('name')}"]` + if (kind) + document + .querySelector('open-scd') + ?.dispatchEvent(newLogEvent(detail)); + else + document.querySelector('open-scd')?.dispatchEvent( + newIssueEvent({ + validatorId, + title, + message, + }) ); - }); - - const type = dataAttributes - .filter(data => data && data.getAttribute('typeKind') === 'CONSTRUCTED') - .map(data => data?.getAttribute('type') ?? '') - .filter(type => type !== ''); - - return ( - Array.from( - nsd.querySelectorAll( - `ConstructedAttributes > ConstructedAttribute[name="${type[0]}"] > SubDataAttribute[presCond="M"]` - ) - ) ?? [] - ); -} - -export async function validateMandatorySubDAs( - datype: Element -): Promise { - const mandatorySubDAs = await getMandatorySubDAs(datype); - const subDANames = mandatorySubDAs.map( - DA => DA.getAttribute('name') ?? 'NONAME' - ); - const missingDANames = subDANames.filter( - da => !datype.querySelector(`BDA[name="${da}"]`) - ); - - return missingDANames.map(da => { - return { - title: get('validator.templates.mandatoryChild', { - tag: 'DAType', - id: datype.getAttribute('id') ?? '', - childTag: 'DA', - childId: da, - }), - message: `${datype}`, - }; - }); -} - -async function getMandatoryDataAttribute(base: string): Promise { - const nsd = await iec6185073; - const cdc = nsd.querySelector(`CDC[name="${base}"]`); - - if (!cdc) return []; - - return Array.from(cdc.querySelectorAll('DataAttribute[presCond="M"]')); -} - -export async function validateMandatoryDAs( - dotype: Element -): Promise { - const errors: ValidationResult[] = []; - const cdc = dotype.getAttribute('cdc'); - if (!cdc) return []; - - const mandatorydas = (await getMandatoryDataAttribute(cdc)).map( - DA => DA.getAttribute('name')! - ); - - mandatorydas.forEach(mandatoryda => { - if (!dotype.querySelector(`DA[name="${mandatoryda}"]`)) - errors.push({ - title: get('validator.templates.mandatoryChild', { - tag: 'Common Data Class', - id: cdc, - childTag: 'DA', - childId: mandatoryda, - }), - message: `${identity(dotype)}`, - }); - }); - - return errors; -} - -function getAdjacentClass(nsd: XMLDocument, base: string): Element[] { - if (base === '') return []; - const adjacents = getAdjacentClass( - nsd, - nsd - .querySelector(`LNClass[name="${base}"], AbstractLNClass[name="${base}"]`) - ?.getAttribute('base') ?? '' - ); - return Array.from( - nsd.querySelectorAll( - `LNClass[name="${base}"], AbstractLNClass[name="${base}"]` - ) - ).concat(adjacents); -} - -async function getAllDataObjects(base: string): Promise { - const lnodeclasses = getAdjacentClass(await iec6185074, base); - - return lnodeclasses.flatMap(lnodeclass => - Array.from(lnodeclass.querySelectorAll('DataObject')) - ); -} - -export async function validateDoCDCSetting( - lnodetype: Element -): Promise { - const errors: ValidationResult[] = []; - const lnClass = lnodetype.getAttribute('lnClass'); - if (!lnClass) return []; - - const alldos = await getAllDataObjects(lnClass); - - for (const DO of alldos) { - const type = lnodetype - .querySelector(`DO[name="${DO.getAttribute('name')}"]`) - ?.getAttribute('type'); - - if (!type) continue; - - const dOType = lnodetype - .closest('DataTypeTemplates') - ?.querySelector(`DOType[id="${type}"]`); - - if (!dOType) { - errors.push({ - title: get('validator.templates.cannotValidate', { - tag: 'LNodeType', - id: lnClass, - childTag: 'DO', - childId: DO.getAttribute('name') || 'UNNAMED', - }), - message: `${identity(lnodetype)}`, - }); - continue; - } - - if (dOType!.getAttribute('cdc') !== DO.getAttribute('type')) - errors.push({ - title: get('validator.templates.mandatoryChild', { - tag: 'DOType', - id: dOType.getAttribute('cdc') || 'UNCLASSIFIED', - childTag: 'DO', - childId: DO.getAttribute('type') || 'UNTYPED', - }), - message: `${identity(dOType)} > ${DO.getAttribute('name')}`, - }); - } - - return errors; -} - -async function getMandatoryDataObject(base: string): Promise { - const lnodeclasses = getAdjacentClass(await iec6185074, base); - - return lnodeclasses.flatMap(lnodeclass => - Array.from(lnodeclass.querySelectorAll('DataObject[presCond="M"]')) - ); -} - -export async function validateMandatoryDOs( - lnodetype: Element -): Promise { - const errors: LogDetailBase[] = []; - const lnClass = lnodetype.getAttribute('lnClass'); - if (!lnClass) return []; - - const mandatorydos = await ( - await getMandatoryDataObject(lnClass) - ).map(DO => DO.getAttribute('name')!); - - mandatorydos.forEach(mandatorydo => { - if (!lnodetype.querySelector(`DO[name="${mandatorydo}"]`)) - errors.push({ - title: get('validator.templates.mandatoryChild', { - tag: 'lnClass', - id: lnClass, - childTag: 'DO', - childId: mandatorydo, - }), - message: `${identity(lnodetype)} > ${mandatorydo}`, - }); - }); - - return errors; } export default class ValidateTemplates extends LitElement { @@ -425,44 +38,35 @@ export default class ValidateTemplates extends LitElement { @property() pluginId!: string; - async validate(identity: string, statusNumber: number): Promise { + async validate(): Promise { const promises: Promise[] = []; - for (const lnodetype of Array.from( - this.doc.querySelectorAll('LNodeType') - )) { - promises.push( - validateMandatoryDOs(lnodetype).then(errors => { - errors.forEach(error => dispatch(error, statusNumber, this.pluginId)); - }) - ); - promises.push( - validateDoCDCSetting(lnodetype).then(errors => { - errors.forEach(error => dispatch(error, statusNumber, this.pluginId)); - }) - ); - } + const [version, revision, release] = [ + this.doc.documentElement.getAttribute('version') ?? '', + this.doc.documentElement.getAttribute('revision') ?? '', + this.doc.documentElement.getAttribute('release') ?? '', + ]; - for (const dotype of Array.from(this.doc.querySelectorAll('DOType'))) { - promises.push( - validateMandatoryDAs(dotype).then(errors => { - errors.forEach(error => dispatch(error, statusNumber, this.pluginId)); - }) - ); - promises.push( - validateControlCDC(dotype).then(errors => { - errors.forEach(error => dispatch(error, statusNumber, this.pluginId)); + if (!(version === '2007' && revision === 'B' && Number(release) > 3)) { + document.querySelector('open-scd')?.dispatchEvent( + newIssueEvent({ + validatorId: this.pluginId, + title: get('diag.missingnsd'), + message: '', }) ); + return; } - for (const datype of Array.from(this.doc.querySelectorAll('DAType'))) - promises.push( - validateMandatorySubDAs(datype).then(errors => { - errors.forEach(error => dispatch(error, statusNumber, this.pluginId)); - }) - ); + const data = this.doc.querySelector('DataTypeTemplates'); + if (!data) return; + + const issuesTemaplte = await validateChildren(data); + if (issuesTemaplte.length === 0) + issuesTemaplte.push({ + title: get('diag.zeroissues'), + }); - await Promise.allSettled(promises); + issuesTemaplte.forEach(error => dispatch(error, this.pluginId)); } } diff --git a/src/validators/templates/dabda.ts b/src/validators/templates/dabda.ts new file mode 100644 index 0000000000..93ae28fd1c --- /dev/null +++ b/src/validators/templates/dabda.ts @@ -0,0 +1,31 @@ +import { get } from 'lit-translate'; + +import { identity, LogDetailBase } from '../../foundation.js'; +import { getTypeChild, isTypeMissing } from './foundation.js'; + +export async function dAValidator(element: Element): Promise { + if (isTypeMissing(element)) + return [ + { + title: get('validator.templates.missingAttribute', { + attr: 'type', + element: element.tagName, + }), + message: `${identity(element)}`, + }, + ]; + + const child = getTypeChild(element); + if (child === null) + return [ + { + title: get('validator.templates.missingReference', { + tag: 'DO', + name: element.getAttribute('name')!, + }), + message: `${identity(element)}`, + }, + ]; + + return []; +} diff --git a/src/validators/templates/datype.ts b/src/validators/templates/datype.ts new file mode 100644 index 0000000000..f760c703b3 --- /dev/null +++ b/src/validators/templates/datype.ts @@ -0,0 +1,86 @@ +import { get } from 'lit-translate'; +import { identity, LogDetailBase } from '../../foundation.js'; +import { iec6185073, iec6185081, validateChildren } from './foundation.js'; + +async function getChildren( + cdc: string | null | undefined, + daName: string | null | undefined +): Promise { + const nsd73 = await iec6185073; + + const dataAttribute = nsd73 + .querySelector(`CDC[name="${cdc}"] > DataAttribute[name="${daName}"]`) + ?.getAttribute('type'); + + return Array.from( + nsd73.querySelectorAll( + `ConstructedAttributes > ConstructedAttribute[name="${dataAttribute}"] > SubDataAttribute[presCond="M"]` + ) + ); +} + +async function getServiceChildren( + daName: string | null | undefined +): Promise { + const nsd81 = await iec6185081; + + return Array.from( + nsd81.querySelectorAll( + `ServiceConstructedAttributes > ServiceConstructedAttribute[name="${daName}"] > ` + + ` SubDataAttribute[presCond="M"]` + ) + ); +} + +async function getMandatoryChildren(datype: Element): Promise { + const id = datype.getAttribute('id'); + if (!id) return []; + + const dataAttribute = datype + .closest('DataTypeTemplates') + ?.querySelector(`DOType > DA[type="${id}"]`); + const daName = dataAttribute?.getAttribute('name'); + + if (daName && ['Oper', 'SBOw', 'SBO', 'Cancel'].includes(daName)) + return await getServiceChildren(daName); + + const cdc = dataAttribute?.parentElement?.getAttribute('cdc'); + return getChildren(cdc, daName); +} + +async function missingMandatoryChildren( + datype: Element +): Promise { + const mandatoryChildren = await getMandatoryChildren(datype); + const mandatoryChildNames = mandatoryChildren.map( + DA => DA.getAttribute('name')! + ); + const missingDaNames = mandatoryChildNames.filter( + da => !datype.querySelector(`BDA[name="${da}"]`) + ); + + return missingDaNames.map(missingDa => { + return { + title: get('validator.templates.mandatoryChild', { + tag: 'DAType', + id: datype.getAttribute('id')!, + childTag: 'BDA', + childId: missingDa, + }), + message: `${identity(datype)}`, + }; + }); +} + +export async function dATypeValidator( + datype: Element +): Promise { + const errors: LogDetailBase[] = []; + + if (datype.tagName !== 'DAType') return []; + + const missingChildren = await missingMandatoryChildren(datype); + const issuesChildren = await validateChildren(datype); + + return errors.concat(missingChildren, issuesChildren); +} diff --git a/src/validators/templates/dosdo.ts b/src/validators/templates/dosdo.ts new file mode 100644 index 0000000000..5f19983fad --- /dev/null +++ b/src/validators/templates/dosdo.ts @@ -0,0 +1,30 @@ +import { get } from 'lit-translate'; +import { identity, LogDetailBase } from '../../foundation.js'; +import { getTypeChild, isTypeMissing } from './foundation.js'; + +export async function dOValidator(element: Element): Promise { + if (isTypeMissing(element)) + return [ + { + title: get('validator.templates.missingAttribute', { + attr: 'type', + element: element.tagName, + }), + message: `${identity(element)}`, + }, + ]; + + const child = getTypeChild(element); + if (child === null) + return [ + { + title: get('validator.templates.missingReference', { + tag: 'DO', + name: element.getAttribute('name')!, + }), + message: `${identity(element)}`, + }, + ]; + + return []; +} diff --git a/src/validators/templates/dotype.ts b/src/validators/templates/dotype.ts new file mode 100644 index 0000000000..633234ff7d --- /dev/null +++ b/src/validators/templates/dotype.ts @@ -0,0 +1,152 @@ +import { get } from 'lit-translate'; + +import { identity, LogDetailBase } from '../../foundation.js'; +import { + getAdjacentClass, + iec6185073, + iec6185074, + iec6185081, + validateChildren, +} from './foundation.js'; + +async function getSpecificDataObject( + lnClass: string | null | undefined, + doName: string | null | undefined +): Promise { + if (!lnClass || !doName) return null; + + const lnodeclasses = getAdjacentClass(await iec6185074, lnClass!); + + return ( + lnodeclasses + .flatMap(lnodeclass => + Array.from(lnodeclass.querySelectorAll(`DataObject`)) + ) + .find(dataObject => dataObject.getAttribute('name') === doName) ?? null + ); +} + +async function getNsdReference(element: Element): Promise { + const id = element.getAttribute('id'); + + if (!id) return null; + + const doorsdo = element + .closest('DataTypeTemplates') + ?.querySelector( + `LNodeType > DO[type="${id}"], LNodeType > SDO[type="${id}"]` + ); + const doName = doorsdo?.getAttribute('name'); + + const lNodeType = doorsdo?.parentElement; + const lnClass = lNodeType?.getAttribute('lnClass'); + + return await getSpecificDataObject(lnClass, doName); +} + +function getControlServicePresConditions( + ctlModel: string | null | undefined +): string[] { + if (!ctlModel || ctlModel === 'status-only') return []; + + if (ctlModel.includes('direct')) return ['MOctrl']; + + if (ctlModel.includes('normal')) return ['MOctrl', 'MOsbo', 'MOsboNormal']; + + if (ctlModel.includes('enhanced')) + return ['MOctrl', 'MOsbo', 'MOsboEnhanced']; + + return []; +} + +async function getMandatoryDataAttribute( + dotype: Element, + cdc: string +): Promise { + const nsd73 = await iec6185073; + const nsd81 = await iec6185081; + + const dataAttributes = Array.from( + nsd73.querySelectorAll(`CDC[name="${cdc}"] > DataAttribute[presCond="M"]`) + ); + + const servicePresConds = getControlServicePresConditions( + dotype.querySelector('DA[name="ctlModel"] > Val')?.textContent?.trim() + ); + const serviceDataAttribute = Array.from( + nsd81.querySelectorAll(`ServiceCDC[cdc="${cdc}"] > ServiceDataAttribute`) + ).filter(da => servicePresConds.includes(da.getAttribute('presCond')!)); + + return dataAttributes.concat(serviceDataAttribute); +} + +async function validateAttributes( + dotype: Element, + cdc: string +): Promise { + const reference = await getNsdReference(dotype); + if (reference && cdc !== reference.getAttribute('type')) + return [ + { + title: get('validator.templates.incorrectAttribute', { + attr: 'cdc', + element: 'DOType', + }), + message: `${identity(dotype)}`, + }, + ]; + + return []; +} + +async function missingMandatoryChildren( + dotype: Element, + cdc: string +): Promise { + const errors: LogDetailBase[] = []; + + const mandatorydas = (await getMandatoryDataAttribute(dotype, cdc)).map( + DA => DA.getAttribute('name')! + ); + + mandatorydas.forEach(mandatoryda => { + if (!dotype.querySelector(`DA[name="${mandatoryda}"]`)) + errors.push({ + title: get('validator.templates.mandatoryChild', { + tag: 'Common Data Class', + id: cdc, + childTag: 'DA', + childId: mandatoryda, + }), + message: `${identity(dotype)}`, + }); + }); + + return errors; +} + +export async function dOTypeValidator( + dotype: Element +): Promise { + const errors: LogDetailBase[] = []; + + if (dotype.tagName !== 'DOType') return []; + + const cdc = dotype.getAttribute('cdc'); + if (!cdc) + return [ + { + title: get('validator.templates.missingAttribute', { + attr: 'cdc', + element: dotype.tagName, + }), + message: `${identity(dotype)}`, + }, + ]; + + const incorrectAttributes = await validateAttributes(dotype, cdc); + const missingChildren = await missingMandatoryChildren(dotype, cdc); + const issuesChildren = await validateChildren(dotype); + + return errors.concat(missingChildren, issuesChildren, incorrectAttributes); +} diff --git a/src/validators/templates/foundation.ts b/src/validators/templates/foundation.ts new file mode 100644 index 0000000000..a3dfcf5116 --- /dev/null +++ b/src/validators/templates/foundation.ts @@ -0,0 +1,118 @@ +import { LogDetailBase } from '../../foundation.js'; + +import { dAValidator } from './dabda.js'; +import { dATypeValidator } from './datype.js'; +import { dOValidator } from './dosdo.js'; +import { dOTypeValidator } from './dotype.js'; +import { lNodeTypeValidator } from './lnodetype.js'; + +export const iec6185074 = fetch('public/xml/IEC_61850-7-4_2007B3.nsd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + +export const iec6185073 = fetch('public/xml/IEC_61850-7-3_2007B3.nsd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + +const iec6185072 = fetch('public/xml/IEC_61850-7-2_2007B3.nsd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + +export const iec6185081 = fetch('public/xml/IEC_61850-8-1_2003A2.nsd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + +export const serviceCDCs = [ + 'SPC', + 'DPC', + 'INC', + 'ENC', + 'BSC', + 'ISC', + 'APC', + 'BAC', +]; + +export function isTypeMissing(element: Element): boolean { + const tagName = element.tagName; + const isTypeMandatory = + tagName === 'DO' || + tagName === 'SDO' || + ((tagName === 'DA' || tagName === 'BDA') && + (element.getAttribute('bType') === 'Enum' || + element.getAttribute('bType') === 'Struct')); + + const isTypeMissing = !element.getAttribute('type'); + + return isTypeMandatory && isTypeMissing; +} + +export function getTypeChild(element: Element): Element | null | undefined { + const isStruct = element.getAttribute('bType') === 'Struct'; + const isEnum = element.getAttribute('bType') === 'Enum'; + const isDo = element.tagName === 'DO' || element.tagName === 'SDO'; + + const referenceTag = isDo + ? 'DOType' + : isStruct || isEnum + ? isStruct + ? 'DAType' + : 'EnumType' + : null; + + if (!referenceTag) return undefined; + + return ( + element + .closest('DataTypeTemplates') + ?.querySelector( + `${referenceTag}[id="${element.getAttribute('type')}"]` + ) ?? null + ); +} + +export function getAdjacentClass(nsd: XMLDocument, base: string): Element[] { + if (base === '') return []; + const adjacents = getAdjacentClass( + nsd, + nsd + .querySelector(`LNClass[name="${base}"], AbstractLNClass[name="${base}"]`) + ?.getAttribute('base') ?? '' + ); + return Array.from( + nsd.querySelectorAll( + `LNClass[name="${base}"], AbstractLNClass[name="${base}"]` + ) + ).concat(adjacents); +} + +export async function validateChildren( + element: Element +): Promise { + const issues: LogDetailBase[] = []; + + const children = Array.from(element.children); + + for (const child of children) { + const validator = await tagValidator[child.tagName]; + if (!validator) continue; + + const childIssues = await validator(child); + if (childIssues.length) + for (const childIssue of childIssues) issues.push(childIssue); + } + + return issues; +} + +type ValidationFunction = (e: Element, r?: Element) => Promise; + +export const tagValidator: Partial> = { + LNodeType: lNodeTypeValidator, + DOType: dOTypeValidator, + DAType: dATypeValidator, + DO: dOValidator, + SDO: dOValidator, + DA: dAValidator, + BDA: dAValidator, +}; diff --git a/src/validators/templates/lnodetype.ts b/src/validators/templates/lnodetype.ts new file mode 100644 index 0000000000..0e32d21b30 --- /dev/null +++ b/src/validators/templates/lnodetype.ts @@ -0,0 +1,64 @@ +import { get } from 'lit-translate'; +import { identity, LogDetailBase } from '../../foundation.js'; +import { + getAdjacentClass, + iec6185074, + validateChildren, +} from './foundation.js'; + +async function getMandatoryDataObject(base: string): Promise { + const lnodeclasses = getAdjacentClass(await iec6185074, base); + + return lnodeclasses.flatMap(lnodeclass => + Array.from(lnodeclass.querySelectorAll('DataObject[presCond="M"]')) + ); +} + +async function missingMandatoryChildren( + lnodetype: Element, + lnClass: string +): Promise { + const errors: LogDetailBase[] = []; + + const mandatorydos = await ( + await getMandatoryDataObject(lnClass) + ).map(DO => DO.getAttribute('name')!); + + mandatorydos.forEach(mandatorydo => { + if (!lnodetype.querySelector(`DO[name="${mandatorydo}"]`)) + errors.push({ + title: get('validator.templates.mandatoryChild', { + tag: 'lnClass', + id: lnClass, + childTag: 'DO', + childId: mandatorydo, + }), + message: `${identity(lnodetype)} > ${mandatorydo}`, + }); + }); + + return errors; +} + +export async function lNodeTypeValidator( + element: Element +): Promise { + const errors: LogDetailBase[] = []; + + const lnClass = element.getAttribute('lnClass'); + if (!lnClass) + return [ + { + title: get('validator.templates.missingAttribute', { + attr: 'lnClass', + element: element.tagName, + }), + message: `${identity(element)}`, + }, + ]; + + const missingChildren = await missingMandatoryChildren(element, lnClass); + const issuesChildren = await validateChildren(element); + + return errors.concat(missingChildren, issuesChildren); +} diff --git a/test/integration/validators/ValidateSchema.test.ts b/test/integration/validators/ValidateSchema.test.ts index 2f365b9420..9bbb21dff8 100644 --- a/test/integration/validators/ValidateSchema.test.ts +++ b/test/integration/validators/ValidateSchema.test.ts @@ -1,5 +1,6 @@ import { expect, fixture, html } from '@open-wc/testing'; -import { LogEntry } from '../../../src/foundation.js'; + +import { IssueDetail, LogEntry } from '../../../src/foundation.js'; import { OpenSCD } from '../../../src/open-scd.js'; import ValidateSchema from '../../../src/validators/ValidateSchema.js'; @@ -26,31 +27,37 @@ describe('ValidateSchema plugin', () => { > - - - + + + `); element = parent.querySelector('validate-schema')!; element.pluginId = '/src/validators/ValidateSchema.js'; await element.requestUpdate(); }); - it('does not create issues in diagnose', async () => { - await element.validate('', 1); - await parent.workDone; - const lastEntry = parent.diagnoses.get( - '/src/validators/ValidateSchema.js' - ); - expect(lastEntry).to.be.undefined; - }).timeout(15000); - it('zeroissues indiacation looks like the latest snapshot', async () => { + it('zeroissues indication looks like the latest snapshot', async () => { await parent.requestUpdate(); expect(parent.diagnosticUI).to.equalSnapshot(); }); - it('indicates successful schema validation in the log', async () => { - await element.validate('', 1); + + it('indicates successful schema validation in the diagnoses pane', async () => { + await element.validate(); await parent.workDone; + const lastEntry = ( + parent.diagnoses.get('/src/validators/ValidateSchema.js') + ); + expect(lastEntry.length).to.equal(1); + expect(lastEntry[0].title).to.contain('validation successful'); + }).timeout(15000); + + it('indicates successful schema validation in the log', async () => { + await element.validate(); + await parent.workDone; const lastEntry = parent.history.pop(); expect(lastEntry.kind).to.equal('info'); expect(lastEntry.title).to.contain('validation successful'); @@ -71,9 +78,12 @@ describe('ValidateSchema plugin', () => { > - - - + + + `); element = parent.querySelector('validate-schema')!; @@ -81,7 +91,7 @@ describe('ValidateSchema plugin', () => { await element.requestUpdate(); try { - await element.validate('', 1); + await element.validate(); } catch (e) { e; } @@ -91,10 +101,12 @@ describe('ValidateSchema plugin', () => { const issues = parent.diagnoses.get('/src/validators/ValidateSchema.js'); expect(issues).to.not.be.undefined; }).timeout(15000); + it('pushes issues to the diagnostics pane that look like the latest snapshot', async () => { await parent.requestUpdate(); expect(parent.diagnosticUI).to.equalSnapshot(); }); + it('generates error messages in the log', async () => { const lastEntry = parent.history.pop(); expect(lastEntry.kind).to.equal('warning'); diff --git a/test/integration/validators/ValidateTemplates.test.ts b/test/integration/validators/ValidateTemplates.test.ts index 639d8d0522..cf6b819e07 100644 --- a/test/integration/validators/ValidateTemplates.test.ts +++ b/test/integration/validators/ValidateTemplates.test.ts @@ -3,41 +3,83 @@ import { expect, fixture, html } from '@open-wc/testing'; import { OpenSCD } from '../../../src/open-scd.js'; import ValidateTemplates from '../../../src/validators/ValidateTemplates.js'; -describe('ValidateTemplates plugin', () => { +describe('ValidateTemplates OpenSCD integration test ', () => { customElements.define('validate-templates', ValidateTemplates); let parent: OpenSCD; let element: ValidateTemplates; let doc: XMLDocument; - beforeEach(async () => { - doc = await fetch( - '/base/test/testfiles/validators/datatypetemplateerrors.scd' - ) - .then(response => response.text()) - .then(str => new DOMParser().parseFromString(str, 'application/xml')); - - parent = await fixture(html` - - - - - - `); - element = parent.querySelector('validate-templates')!; - element.pluginId = '/src/validators/ValidateTemplates.js'; - - await element.validate('', 1); - await parent.workDone; + describe('with issues in the DataTypeTemplates section', () => { + beforeEach(async () => { + doc = await fetch( + '/base/test/testfiles/validators/datatypetemplateerrors.scd' + ) + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + + parent = await fixture(html` + + + + + + `); + element = parent.querySelector('validate-templates')!; + element.pluginId = '/src/validators/ValidateTemplates.js'; + + await element.validate(); + await parent.workDone; + }); + it('generates issues in the diagnistics pane', async () => { + const issues = parent.diagnoses.get( + '/src/validators/ValidateTemplates.js' + ); + expect(issues?.length).to.equal(28); + }).timeout(1000); + it('pushes issues to the diagnostics pane that look like the latest snapshot', async () => { + await parent.requestUpdate(); + expect(parent.diagnosticUI).to.equalSnapshot(); + }); }); - it('generates issues in the diagnistics pane', async () => { - const issues = parent.diagnoses.get('/src/validators/ValidateTemplates.js'); - expect(issues?.length).to.equal(21); - }).timeout(1000); - it('pushes issues to the diagnostics pane that look like the latest snapshot', async () => { - await parent.requestUpdate(); - expect(parent.diagnosticUI).to.equalSnapshot(); + describe('with schema version smaller "2007B3"', () => { + beforeEach(async () => { + doc = await fetch('/base/test/testfiles/valid2007B.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + + parent = await fixture(html` + + + + + + `); + element = parent.querySelector('validate-templates')!; + element.pluginId = '/src/validators/ValidateTemplates.js'; + + await element.validate(); + await parent.workDone; + }); + it('generates only one specific in the diagnostics pane', async () => { + const issues = parent.diagnoses.get( + '/src/validators/ValidateTemplates.js' + ); + expect(issues?.length).to.equal(1); + }).timeout(1000); + it('pushes a specific issue to the diagnostics pane that look like the latest snapshot', async () => { + await parent.requestUpdate(); + expect(parent.diagnosticUI).to.equalSnapshot(); + }); }); }); diff --git a/test/testfiles/validators/datatypetemplateerrors.scd b/test/testfiles/validators/datatypetemplateerrors.scd index 3b2d781e56..4fcc8359ac 100644 --- a/test/testfiles/validators/datatypetemplateerrors.scd +++ b/test/testfiles/validators/datatypetemplateerrors.scd @@ -1,265 +1,11 @@ - +
    TrainingIEC61850
    - - - 110.0 - - - - - - - - - - - - - - - - - - - - - - 20 - - - - - - - 100.0 - -
    -

    192.168.210.111

    -

    255.255.255.0

    -

    192.168.210.1

    -

    1,3,9999,23

    -

    23

    -

    00000001

    -

    0001

    -

    0001

    -
    -
    -
    - - -
    -

    192.168.0.111

    -

    255.255.255.0

    -

    192.168.210.1

    -

    1,3,9999,23

    -

    23

    -

    00000001

    -

    0001

    -

    0001

    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - status-only - - - - - - - sbo-with-enhanced-security - - - - - - - status-only - - - - - - - sbo-with-enhanced-security - - - - - - - - - - status-only - - - - - - - - - status-only - - - - - - - - - direct-with-normal-security - - - - - - - sbo-with-normal-security - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - status-only - - - - - - - status-only - - - - - - - status-only - - - - - - - status-only - - - - - - - - - - - status-only - - - - - - - direct-with-enhanced-security - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -315,6 +61,20 @@ + + + + + + + + + + + + + + @@ -371,9 +131,9 @@ - - - + + + @@ -389,8 +149,8 @@ - - + + @@ -406,8 +166,8 @@ - - + + @@ -423,8 +183,8 @@ - - + + @@ -470,7 +230,7 @@ - + @@ -486,9 +246,9 @@ - - - + + + @@ -504,9 +264,9 @@ - - - + + + @@ -516,6 +276,13 @@ + + + + + + + @@ -536,7 +303,12 @@ - + + + + + + @@ -562,6 +334,59 @@ + + + + + + + + + + + + sbo-with-enhanced-security + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -581,7 +406,15 @@ - + + + + + + + + + @@ -589,27 +422,27 @@ - + - + - + - + @@ -620,12 +453,12 @@ - - - - - - + + + + + + @@ -657,5 +490,106 @@ maintenance process + + normal + high + low + high-high + low-low + + + + m + kg + s + A + K + mol + cd + deg + rad + sr + Gy + Bq + °C + Sv + F + C + S + H + V + ohm + J + N + Hz + lx + Lm + Wb + T + W + Pa + + + m/s + m/s² + m³/s + m/m³ + M + kg/m³ + m²/s + W/m K + J/K + ppm + 1/s + rad/s + VA + Watts + VAr + phi + cos(phi) + Vs + + As + + A²t + VAh + Wh + VArh + V/Hz + Hz/s + char + char/s + kgm² + dB + J/Wh + W/s + l/s + dBm + h + min + + + y + z + a + f + p + n + µ + m + c + d + + da + h + k + M + G + T + P + E + Z + Y +
    diff --git a/test/testfiles/validators/doandsdotestfile.scd b/test/testfiles/validators/doandsdotestfile.scd new file mode 100644 index 0000000000..0f134d3042 --- /dev/null +++ b/test/testfiles/validators/doandsdotestfile.scd @@ -0,0 +1,67 @@ + + +
    + TrainingIEC61850 + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    diff --git a/test/testfiles/validators/zeroissues.scd b/test/testfiles/validators/zeroissues.scd new file mode 100644 index 0000000000..c432616962 --- /dev/null +++ b/test/testfiles/validators/zeroissues.scd @@ -0,0 +1,6 @@ + + +
    + + + diff --git a/test/unit/Logging.test.ts b/test/unit/Logging.test.ts index 4b3286e763..81137a409e 100644 --- a/test/unit/Logging.test.ts +++ b/test/unit/Logging.test.ts @@ -79,7 +79,6 @@ describe('LoggingElement', () => { element.dispatchEvent( newIssueEvent({ validatorId: 'val', - statusNumber: 1, title: 'test issue', }) ); @@ -311,7 +310,6 @@ describe('LoggingElement', () => { element.dispatchEvent( newIssueEvent({ validatorId: '/src/validators/ValidateSchema.js', - statusNumber: 1, title: 'test run 1', }) ); @@ -334,105 +332,11 @@ describe('LoggingElement', () => { expect(element.diagnoses.has('/src/validators/ValidateTemplates.js')).to .be.false); - describe('with a second issue coming in - new statusNumber, same validator', () => { - beforeEach(() => { - element.dispatchEvent( - newIssueEvent({ - validatorId: '/src/validators/ValidateSchema.js', - statusNumber: 2, - title: 'test run 2', - }) - ); - }); - - it('removes old issues', () => { - expect(element.diagnoses.get('/src/validators/ValidateSchema.js')).to - .exist; - expect( - element.diagnoses.get('/src/validators/ValidateSchema.js')!.length - ).to.equal(1); - const issue = element.diagnoses.get( - '/src/validators/ValidateSchema.js' - )![0]; - expect(issue.statusNumber).to.equal(2); - expect(issue.title).to.not.equal('test run 1'); - }); - - it('saves a log message for the action', () => { - expect(element.diagnoses.get('/src/validators/ValidateSchema.js')).to - .exist; - expect( - element.diagnoses.get('/src/validators/ValidateSchema.js')!.length - ).to.equal(1); - const issue = element.diagnoses.get( - '/src/validators/ValidateSchema.js' - )![0]; - expect(issue.statusNumber).to.equal(2); - expect(issue.title).to.equal('test run 2'); - }); - }); - - describe('with a second issue coming in - same statusNumber, same validator', () => { - beforeEach(() => { - element.dispatchEvent( - newIssueEvent({ - validatorId: '/src/validators/ValidateSchema.js', - statusNumber: 1, - title: 'test issues 2', - }) - ); - }); - - it('adds issue to existing issues', () => { - expect(element.diagnoses.get('/src/validators/ValidateSchema.js')).to - .exist; - expect( - element.diagnoses.get('/src/validators/ValidateSchema.js')!.length - ).to.equal(2); - const issue = element.diagnoses.get( - '/src/validators/ValidateSchema.js' - )![0]; - expect(issue.statusNumber).to.equal(1); - expect(issue.title).to.equal('test run 1'); - const issue2 = element.diagnoses.get( - '/src/validators/ValidateSchema.js' - )![1]; - expect(issue2.statusNumber).to.equal(1); - expect(issue2.title).to.not.equal('test issue 2'); - }); - }); - - describe('with a second issue coming in - outdated statusNumber, same validator', () => { - beforeEach(() => { - element.dispatchEvent( - newIssueEvent({ - validatorId: '/src/validators/ValidateSchema.js', - statusNumber: 0, - title: 'test issues 2', - }) - ); - }); - - it('ignores incoming the issue', () => { - expect(element.diagnoses.get('/src/validators/ValidateSchema.js')).to - .exist; - expect( - element.diagnoses.get('/src/validators/ValidateSchema.js')!.length - ).to.equal(1); - const issue = element.diagnoses.get( - '/src/validators/ValidateSchema.js' - )![0]; - expect(issue.statusNumber).to.equal(1); - expect(issue.title).to.equal('test run 1'); - }); - }); - describe('with another issue coming in - new validator', () => { beforeEach(() => { element.dispatchEvent( newIssueEvent({ validatorId: '/src/validators/ValidateTemplates.js', - statusNumber: 3, title: 'test run 3', }) ); @@ -447,7 +351,6 @@ describe('LoggingElement', () => { const issue = element.diagnoses.get( '/src/validators/ValidateSchema.js' )![0]; - expect(issue.statusNumber).to.equal(1); expect(issue.title).to.equal('test run 1'); }); @@ -460,7 +363,6 @@ describe('LoggingElement', () => { const issue = element.diagnoses.get( '/src/validators/ValidateTemplates.js' )![0]; - expect(issue.statusNumber).to.equal(3); expect(issue.title).to.equal('test run 3'); }); }); diff --git a/test/unit/validators/ValidateTemplates.test.ts b/test/unit/validators/ValidateTemplates.test.ts index 716030d88e..7b144c5803 100644 --- a/test/unit/validators/ValidateTemplates.test.ts +++ b/test/unit/validators/ValidateTemplates.test.ts @@ -1,145 +1,147 @@ -import { expect } from '@open-wc/testing'; -import { LogDetail } from '../../../src/foundation.js'; -import { - validateControlCDC, - validateDoCDCSetting, - validateMandatoryDAs, - validateMandatoryDOs, - validateMandatorySubDAs, +import { expect, fixture, html } from '@open-wc/testing'; +import { registerTranslateConfig, use } from 'lit-translate'; +import sinon, { SinonSpy } from 'sinon'; + +import { OpenSCD } from '../../../src/open-scd.js'; + +import ValidateTemplates, { + dispatch, } from '../../../src/validators/ValidateTemplates.js'; -describe('VelidateTemplate', () => { - let doc: XMLDocument; +describe('ValidateTemplates', () => { + let logEvent: SinonSpy; + let issueEvent: SinonSpy; + beforeEach(async () => { - doc = await fetch( - '/base/test/testfiles/validators/datatypetemplateerrors.scd' - ) - .then(response => response.text()) - .then(str => new DOMParser().parseFromString(str, 'application/xml')); + logEvent = sinon.spy(); + issueEvent = sinon.spy(); + + window.addEventListener('log', logEvent); + window.addEventListener('issue', issueEvent); }); - describe('used on LNodeType element', () => { - it('return LogDetail array for missing mandatory DO e.g Beh', async () => { - const element = doc.querySelector('LNodeType[id="Dummy.CILO"]')!; - const errors = await validateMandatoryDOs(element); - expect(errors.length).to.equal(1); - }); - it('return LogDetail array for missing mandatory DO e.g Pos', async () => { - const element = doc.querySelector('LNodeType[id="Dummy.CSWI"]')!; - const errors = await validateMandatoryDOs(element); - expect(errors.length).to.equal(1); + describe('dispatch', () => { + beforeEach(async () => { + const doc = await fetch('/base/test/testfiles/validators/zeroissues.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + + await fixture(html` + + `); + }); + it('triggers as newIssuesEvent for detail not containing kind', () => { + const pluginId = '/src/validators/ValidateTemplates.js'; + const detail = { + title: 'title', + message: 'message', + }; + dispatch(detail, pluginId); + expect(issueEvent).to.have.been.called; + expect(logEvent).to.not.have.been.called; + expect(issueEvent.args[0][0].type).to.equal('issue'); + expect(issueEvent.args[0][0].detail.validatorId).to.equal( + '/src/validators/ValidateTemplates.js' + ); + expect(issueEvent.args[0][0].detail.message).to.equal('message'); + expect(issueEvent.args[0][0].detail.title).to.equal('title'); }); - it('returns empty array if LNodeType includes all mandatory DOs', async () => { - const element = doc.querySelector('LNodeType[id="Dummy.GGIO1"]')!; - const errors = await validateMandatoryDOs(element); - expect(errors.length).to.equal(0); + + it('triggers as newLogEvent for detail containing kind info', () => { + const pluginId = '/src/validators/ValidateTemplates.js'; + const detail = { + kind: 'info', + title: 'title', + message: 'message', + }; + dispatch(detail, pluginId); + expect(logEvent).to.have.been.called; + expect(issueEvent).to.not.have.been.called; + expect(logEvent.args[0][0].type).to.equal('log'); + expect(logEvent.args[0][0].detail.kind).to.equal('info'); + expect(logEvent.args[0][0].detail.message).to.equal('message'); + expect(logEvent.args[0][0].detail.title).to.equal('title'); }); - it('returns empty array if element is not LNodeType', async () => { - const element = doc.querySelector('DOType[id="Dummy.LLN0.Health"]')!; - const errors = await validateMandatoryDOs(element); - expect(errors.length).to.equal(0); + + it('triggers as newLogEvent for detail containing kind warning', () => { + const pluginId = '/src/validators/ValidateTemplates.js'; + const detail = { + kind: 'warning', + title: 'title', + message: 'message', + }; + dispatch(detail, pluginId); + expect(logEvent).to.have.been.called; + expect(issueEvent).to.not.have.been.called; + expect(logEvent.args[0][0].type).to.equal('log'); + expect(logEvent.args[0][0].detail.kind).to.equal('warning'); }); - it('return LogDetail array when LNodeTypes DO do not follow the CDC definition ', async () => { - const element = doc.querySelector('LNodeType[id="Dummy.GGIO1"]')!; - const errors = await validateDoCDCSetting(element); - expect(errors.length).to.equal(1); + + it('triggers as newLogEvent for detail containing kind error', () => { + const pluginId = '/src/validators/ValidateTemplates.js'; + const detail = { + kind: 'error', + title: 'title', + message: 'message', + }; + dispatch(detail, pluginId); + expect(logEvent).to.have.been.called; + expect(issueEvent).to.not.have.been.called; + expect(logEvent.args[0][0].type).to.equal('log'); + expect(logEvent.args[0][0].detail.kind).to.equal('error'); }); }); - describe('used on DOType element', () => { - it('return empty array if element is not DOType', async () => { - const element = doc.querySelector('LNodeType')!; - const errors = await validateMandatoryDAs(element); - expect(errors.length).to.equal(0); - }); - it('returns empty array if LNodeType includes all mandatory DOs', async () => { - const element = doc.querySelector('DOType[id="Dummy.LPHD1.Sim"]')!; - const errors = await validateMandatoryDAs(element); - expect(errors.length).to.equal(0); - }); - it('return LogDetail array for missing mandatory DA e.g stVal', async () => { - const element = doc.querySelector('DOType[id="Dummy.LLN0.Health"]')!; - const errors = await validateMandatoryDAs(element); - expect(errors.length).to.equal(1); - }); - it('return LogDetail array for missing mandatory DA e.g stVal', async () => { - const element = doc.querySelector('DOType[id="Dummy.XCBR1.Pos"]')!; - const errors = await validateMandatoryDAs(element); - expect(errors.length).to.equal(1); + + describe('validate', () => { + let element: ValidateTemplates; + beforeEach(async () => { + const doc = await fetch('/base/test/testfiles/validators/zeroissues.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + + const parent: OpenSCD = await fixture(html` + + `); + + element = parent.querySelector('validate-templates')!; }); - it('return LogDetail array for missing mandatory DA e.g ctlModel', async () => { - const element = doc.querySelector('DOType[id="Dummy.CSWI.Pos1"]')!; - const errors = await validateMandatoryDAs(element); - expect(errors.length).to.equal(1); + + it('pushes only diag.zeroissues issue to diagnostics when no issues found', async () => { + await element.validate(); + expect(issueEvent).to.have.been.calledOnce; + expect(issueEvent.args[0][0].detail.title).to.contain('No errors'); }); - }); - describe('used on DAType element', () => { - it('return empty array if element is not DAType', async () => { - const element = doc.querySelector('DOType')!; - const errors = await validateMandatorySubDAs(element); - expect(errors.length).to.equal(0); + + it('pushes only diag.missingnsd issue to diagnostics pane for SCL version < 2007B3', async () => { + element.doc.querySelector('SCL')?.setAttribute('version', '2003'); + await element.validate(); + expect(issueEvent).to.have.been.calledOnce; + expect(issueEvent.args[0][0].detail.title).to.contain('Cannot validate'); }); - it('returns empty array if DAType includes all mandatory BDAs', async () => { - const element = doc.querySelector('DAType[id="Dummy.RangeConfig"]')!; - const errors = await validateMandatorySubDAs(element); - expect(errors.length).to.equal(0); + + it('pushes only diag.missingnsd issue to diagnostics pane for SCL not having version information', async () => { + element.doc.querySelector('SCL')?.removeAttribute('version'); + element.doc.querySelector('SCL')?.removeAttribute('revision'); + await element.validate(); + expect(issueEvent).to.have.been.calledOnce; + expect(issueEvent.args[0][0].detail.title).to.contain('Cannot validate'); }); - it('return LogDetail array for missing mandatory BDA e.g scaledOffset', async () => { - const element = doc.querySelector( - 'DAType[id="Dummy.ScaledValueConfig"]' - )!; - const errors = await validateMandatorySubDAs(element); - expect(errors.length).to.equal(1); + + it('does not trigger anything for SCL missing DataTypeTemplates', async () => { + const data = element.doc.querySelector('DataTypeTemplates')!; + element.doc.querySelector('SCL')?.removeChild(data); + await element.validate(); + expect(issueEvent).to.not.have.been.calledOnce; }); }); - describe('used on controlable data objects', () => { - it('returns empty array for non-controlable data objects', async () => { - const element = doc.querySelector('DOType[id="Dummy.LPHD1.PhyNam"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(0); - }); - it('returns LogDetail array for missing SBOw', async () => { - const element = doc.querySelector('DOType[id="Dummy.SPC1"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(1); - }); - it('returns LogDetail array for missing SBO', async () => { - const element = doc.querySelector('DOType[id="Dummy.SPC2"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(1); - }); - it('returns LogDetail array for missing Oper', async () => { - const element = doc.querySelector('DOType[id="Dummy.SPC3"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(1); - }); - it('returns LogDetail array for missing Cancel', async () => { - const element = doc.querySelector('DOType[id="Dummy.SPC3"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(1); - }); - it('does not indicate false positive for status-only DOs', async () => { - const element = doc.querySelector('DOType[id="Dummy.SPC4"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(0); - }); - it('returns LogDetail array for missing DA within Oper structure', async () => { - const element = doc.querySelector('DOType[id="Dummy.SPC5"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(1); - }); - it('returns LogDetail array for missing DA within SBOw structure', async () => { - const element = doc.querySelector('DOType[id="Dummy.SPC6"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(1); - }); - it('returns LogDetail array for missing DA within Cancel structure', async () => { - const element = doc.querySelector('DOType[id="Dummy.SPC7"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(1); - }); - it('returns a warning if ctlModel definition is missing', async () => { - const element = doc.querySelector('DOType[id="Dummy.CSWI.Pos1"]')!; - const errors = await validateControlCDC(element); - expect(errors.length).to.equal(1); - }); +}).afterAll(async () => { + registerTranslateConfig({ + loader: () => Promise.resolve({}), + empty: key => `[${key}]`, + translationCache: {}, }); + use('none'); }); diff --git a/test/unit/validators/templates/dabda.test.ts b/test/unit/validators/templates/dabda.test.ts new file mode 100644 index 0000000000..4c1c146c1f --- /dev/null +++ b/test/unit/validators/templates/dabda.test.ts @@ -0,0 +1,93 @@ +import { expect } from '@open-wc/testing'; + +import { dAValidator } from '../../../../src/validators/templates/dabda.js'; + +describe('da or bda validator', () => { + let doc: XMLDocument; + + beforeEach(async () => { + doc = await fetch('/base/test/testfiles/validators/doandsdotestfile.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + }); + + it('return Issues when DA type attribute is missing for Struct type', async () => { + const element = doc.querySelector('DOType[id="missingType1"] > DA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingAttribute'); + }); + + it('return empty array for correct DA type attribute - Struct type', async () => { + const element = doc.querySelector('DOType[id="existingType1"] > DA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(0); + }); + + it('return Issues when DA type attribute is missing for Enum type', async () => { + const element = doc.querySelector('DOType[id="missingType2"] > DA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingAttribute'); + }); + + it('return empty array for correct DA type attribute - Enum type', async () => { + const element = doc.querySelector('DOType[id="existingType2"] > DA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(0); + }); + + it('return Issues when DA type reference is missing - Struct type', async () => { + const element = doc.querySelector('DOType[id="invalidReference1"] > DA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingReference'); + }); + + it('return Issues when DA type reference is missing - Enum type', async () => { + const element = doc.querySelector('DOType[id="invalidReference2"] > DA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingReference'); + }); + + it('return Issues when BDA type attribute is missing - Struct type', async () => { + const element = doc.querySelector('DAType[id="missingType1"] > BDA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingAttribute'); + }); + + it('return empty array for correct BDA type attribute - Struct type', async () => { + const element = doc.querySelector('DAType[id="existingType1"] > BDA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(0); + }); + + it('return Issues when BDA type attribute is missing for Enum type', async () => { + const element = doc.querySelector('DAType[id="missingType2"] > BDA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingAttribute'); + }); + + it('return empty array for correct BDA type attribute - Enum type', async () => { + const element = doc.querySelector('DAType[id="existingType2"] > BDA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(0); + }); + + it('return Issues when BDA type reference is missing - Struct type', async () => { + const element = doc.querySelector('DAType[id="invalidReference1"] > BDA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingReference'); + }); + + it('return Issues when BDA type reference is missing - Enum type', async () => { + const element = doc.querySelector('DAType[id="invalidReference2"] > BDA')!; + const errors = await dAValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingReference'); + }); +}); diff --git a/test/unit/validators/templates/datype.test.ts b/test/unit/validators/templates/datype.test.ts new file mode 100644 index 0000000000..f64f655423 --- /dev/null +++ b/test/unit/validators/templates/datype.test.ts @@ -0,0 +1,72 @@ +import { expect } from '@open-wc/testing'; +import { dATypeValidator } from '../../../../src/validators/templates/datype.js'; + +describe('datype validator', () => { + let doc: XMLDocument; + beforeEach(async () => { + doc = await fetch( + '/base/test/testfiles/validators/datatypetemplateerrors.scd' + ) + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + }); + + it('return empty array if element is not DAType', async () => { + const element = doc.querySelector('DOType')!; + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(0); + }); + it('returns empty array if DAType includes all mandatory BDAs', async () => { + const element = doc.querySelector('DAType[id="Dummy.RangeConfig"]')!; + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(0); + }); + it('return Issues for missing mandatory BDA e.g scaledOffset', async () => { + const element = doc.querySelector('DAType[id="Dummy.ScaledValueConfig"]')!; + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(1); + }); + + it('returns Issues for missing DA within Oper structure', async () => { + const element = doc.querySelector('DAType[id="Dummy.Operfalse"]')!; + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(1); + }); + + it('returns empty array for correct Oper structure', async () => { + const element = doc.querySelector('DAType[id="Dummy.Oper"]')!; + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(0); + }); + + it('returns Issue array for missing DA within SBOw structure', async () => { + const element = doc.querySelector('DAType[id="Dummy.SBOwfalse"]')!; + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(1); + }); + + it('returns empty array for correct SBOw structure', async () => { + const element = doc.querySelector('DAType[id="Dummy.SBOw"]')!; + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(0); + }); + + it('returns Issue array for missing DA within Cancel structure', async () => { + const element = doc.querySelector('DAType[id="Dummy.Cancelfalse"]')!; + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(1); + }); + + it('returns empty array for correct Cancel structure', async () => { + const element = doc.querySelector('DAType[id="Dummy.Cancel"]')!; + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(0); + }); + + it('returns empty array id less DAType', async () => { + const element = doc.querySelector('DAType[id="Dummy.Cancelfalse"]')!; + element.removeAttribute('id'); + const errors = await dATypeValidator(element); + expect(errors.length).to.equal(0); + }); +}); diff --git a/test/unit/validators/templates/doorsdo.test.ts b/test/unit/validators/templates/doorsdo.test.ts new file mode 100644 index 0000000000..6ae2ba66a0 --- /dev/null +++ b/test/unit/validators/templates/doorsdo.test.ts @@ -0,0 +1,46 @@ +import { expect } from '@open-wc/testing'; +import { dOValidator } from '../../../../src/validators/templates/dosdo.js'; + +describe('do or sdo validator', () => { + let doc: XMLDocument; + + beforeEach(async () => { + doc = await fetch('/base/test/testfiles/validators/doandsdotestfile.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + }); + + it('return Issues when DO type attribute is missing', async () => { + const typelessDo = doc.querySelector('LNodeType[id="typelessDo"] > DO')!; + const errors = await dOValidator(typelessDo); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingAttribute'); + }); + + it('return Issues when DO type reference is missing', async () => { + const referencelessDo = doc.querySelector('LNodeType[id="relessDo"] > DO')!; + const errors = await dOValidator(referencelessDo); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingReference'); + }); + + it('return Issues when SDO type attribute is missing', async () => { + const typelessSDo = doc.querySelector('LNodeType[id="typelessSDo"] > SDO')!; + const errors = await dOValidator(typelessSDo); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingAttribute'); + }); + + it('return Issues when SDO type reference is missing', async () => { + const reflessSDo = doc.querySelector('LNodeType[id="relessSDo"] > SDO')!; + const errors = await dOValidator(reflessSDo); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingReference'); + }); + + it('return empty array for valid DO or SDO', async () => { + const correctDo = doc.querySelector('LNodeType[id="correctDo"] > DO')!; + const errors = await dOValidator(correctDo); + expect(errors.length).to.equal(0); + }); +}); diff --git a/test/unit/validators/templates/dotype.test.ts b/test/unit/validators/templates/dotype.test.ts new file mode 100644 index 0000000000..6dcc18b1a7 --- /dev/null +++ b/test/unit/validators/templates/dotype.test.ts @@ -0,0 +1,126 @@ +import { expect } from '@open-wc/testing'; +import { dOTypeValidator } from '../../../../src/validators/templates/dotype.js'; + +describe('dotype validator', () => { + let doc: XMLDocument; + beforeEach(async () => { + doc = await fetch( + '/base/test/testfiles/validators/datatypetemplateerrors.scd' + ) + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + }); + + it('return empty array if element is not DOType', async () => { + const element = doc.querySelector('LNodeType')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(0); + }); + + it('returns empty array if DOType includes all mandatory DAs', async () => { + const element = doc.querySelector('DOType[id="Dummy.LPHD1.Sim"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(0); + }); + + it('return Issues for missing mandatory DA e.g stVal', async () => { + const element = doc.querySelector('DOType[id="Dummy.LLN0.Health"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('mandatoryChild'); + }); + + it('return Issues for missing mandatory DA e.g another stVal', async () => { + const element = doc.querySelector('DOType[id="Dummy.XCBR1.Pos"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('mandatoryChild'); + }); + + it('return Issues for missing mandatory DA e.g ctlModel', async () => { + const element = doc.querySelector('DOType[id="Dummy.CSWI.Pos1"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('mandatoryChild'); + }); + + it('return Issues for missing cdc attribute within DOType', async () => { + const element = doc.querySelector('DOType[id="Dummy.MissingCDC"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingAttribute'); + }); + + it('return Issues if CDC definition does not follow NSD ', async () => { + const element = doc.querySelector('DOType[id="Dummy.XCBR1.badNamPlt"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + }); + + it('does not validate CDC to NSD with missing id', async () => { + const element = doc.querySelector('DOType[id="Dummy.XCBR1.badNamPlt"]')!; + element.removeAttribute('id'); + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(0); + }); + + it('returns Issues from child validation', async () => { + const element = doc.querySelector('DOType[id="Dummy.badWYE"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + }); + + it('returns empty array for non-controllable data objects', async () => { + const element = doc.querySelector('DOType[id="Dummy.LPHD1.PhyNam"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(0); + }); + + it('returns Issues for missing SBOw', async () => { + const element = doc.querySelector('DOType[id="Dummy.SPC1"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('mandatoryChild'); + }); + + it('returns Issues for missing SBO', async () => { + const element = doc.querySelector('DOType[id="Dummy.SPC2"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('mandatoryChild'); + }); + + it('returns Issues for missing Oper', async () => { + const element = doc.querySelector('DOType[id="Dummy.SPC3"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('mandatoryChild'); + }); + + it('returns Issues for missing Cancel', async () => { + const element = doc.querySelector('DOType[id="Dummy.SPC3"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('mandatoryChild'); + }); + + it('does not indicate false positive for status-only DOs', async () => { + const element = doc.querySelector('DOType[id="Dummy.SPC4"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(0); + }); + + it('does not indicate false positive for empty ctlModel', async () => { + const element = doc.querySelector('DOType[id="Dummy.XCBR1.Pos1"]')!; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(0); + }); + + it('does not indicate false positive for wrong ctlModel', async () => { + const element = doc.querySelector('DOType[id="Dummy.SPC4"]')!; + const val = element.querySelector('Val')!; + val.innerHTML = 'invalidCtlModel'; + const errors = await dOTypeValidator(element); + expect(errors.length).to.equal(0); + }); +}); diff --git a/test/unit/validators/templates/foundation.test.ts b/test/unit/validators/templates/foundation.test.ts new file mode 100644 index 0000000000..f33eaf82b0 --- /dev/null +++ b/test/unit/validators/templates/foundation.test.ts @@ -0,0 +1,26 @@ +import { expect } from '@open-wc/testing'; +import { + tagValidator, + validateChildren, +} from '../../../../src/validators/templates/foundation.js'; + +describe('validator foundation', () => { + describe('tagValidator', () => { + it('tagValidator returns undefined with missing tagName', () => { + expect(tagValidator['noTag']).to.be.undefined; + }); + }); + describe('validateChildren', () => { + let element: Element; + beforeEach(() => { + element = new DOMParser().parseFromString( + '', + 'application/xml' + ).documentElement; + }); + it('does not throw Issues for unknown childTags', async () => { + const issues = await validateChildren(element); + expect(issues.length).to.equal(0); + }); + }); +}); diff --git a/test/unit/validators/templates/lnodetype.test.ts b/test/unit/validators/templates/lnodetype.test.ts new file mode 100644 index 0000000000..2d819e8d99 --- /dev/null +++ b/test/unit/validators/templates/lnodetype.test.ts @@ -0,0 +1,46 @@ +import { expect } from '@open-wc/testing'; + +import { lNodeTypeValidator } from '../../../../src/validators/templates/lnodetype.js'; + +describe('lnodetype validator', () => { + let doc: XMLDocument; + beforeEach(async () => { + doc = await fetch( + '/base/test/testfiles/validators/datatypetemplateerrors.scd' + ) + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + }); + + it('return Issue for missing mandatory DO e.g Beh', async () => { + const element = doc.querySelector('LNodeType[id="Dummy.CILO"]')!; + const errors = await lNodeTypeValidator(element); + expect(errors.length).to.equal(1); + }); + + it('return Issues for missing mandatory DO e.g Pos', async () => { + const element = doc.querySelector('LNodeType[id="Dummy.CSWI"]')!; + const errors = await lNodeTypeValidator(element); + expect(errors.length).to.equal(1); + }); + + it('returns Issues if child element is invalid', async () => { + const element = doc.querySelector('LNodeType[id="Dummy.invalidChild"]')!; + const errors = await lNodeTypeValidator(element); + expect(errors.length).to.equal(1); + }); + + it('returns Issues if lnClass attribute is missing', async () => { + const element = doc.querySelector('LNodeType[id="Dummy.CILO"]')!; + element.removeAttribute('lnClass'); + const errors = await lNodeTypeValidator(element); + expect(errors.length).to.equal(1); + expect(errors[0].title).to.contain('missingAttribute'); + }); + + it('returns empty array if LNodeType includes all mandatory DOs', async () => { + const element = doc.querySelector('LNodeType[id="Dummy.GGIO1"]')!; + const errors = await lNodeTypeValidator(element); + expect(errors.length).to.equal(0); + }); +}); From 09e7af5708dba8490ee60ecbe204f4a06dd7b7ce Mon Sep 17 00:00:00 2001 From: Jakob Vogelsang Date: Wed, 27 Oct 2021 11:13:00 +0200 Subject: [PATCH 02/18] fix(templates/lnodetype-wizard): deselect optional DOTypes at LNode creation (#326) This adds a toggle button next to DOTypes in the LNode create wizard under the template editor. --- __snapshots__/LNodeType wizards.md | 126 ++++++++++++------ src/editors/templates/lnodetype-wizard.ts | 12 +- .../templates/lnodetype-wizard.test.ts | 6 +- 3 files changed, 92 insertions(+), 52 deletions(-) diff --git a/__snapshots__/LNodeType wizards.md b/__snapshots__/LNodeType wizards.md index af97677ff1..c055827cd0 100644 --- a/__snapshots__/LNodeType wizards.md +++ b/__snapshots__/LNodeType wizards.md @@ -3482,10 +3482,12 @@ open="" >
    - Dummy.XCBR1.NamPlt - - + Dummy.LLN0.Health - - + Dummy.LLN0.Beh - - + Dummy.SPS - - + Dummy.LLN0.Mod - - + - - + Dummy.SPS - - + Dummy.XCBR1.OpCnt - - + Dummy.XCBR1.BlkOpn - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + Dummy.SPS - - + - - + Dummy.SPS - - + Dummy.SPS - +
    { @@ -255,8 +255,8 @@ function getAllDataObjects(nsd74: XMLDocument, base: string): Element[] { function createNewLNodeType(parent: Element, element: Element): WizardActor { return (_: WizardInput[], wizard: Element): EditorAction[] => { const selected = Array.from( - wizard.shadowRoot!.querySelectorAll('mwc-select') - ).filter(select => select.value); + wizard.shadowRoot!.querySelectorAll('wizard-select') + ).filter(select => select.maybeValue); const actions: Create[] = []; @@ -325,17 +325,19 @@ function createLNodeTypeHelperWizard( .querySelectorAll(`DOType[cdc="${DO.getAttribute('type')}"]`) ).sort(doComparator(name)); - return html`${validDOTypes.map( doType => html`${doType.getAttribute('id')}` - )}`; }), }, diff --git a/test/integration/editors/templates/lnodetype-wizard.test.ts b/test/integration/editors/templates/lnodetype-wizard.test.ts index 984d090d8e..f9fc3bcdc8 100644 --- a/test/integration/editors/templates/lnodetype-wizard.test.ts +++ b/test/integration/editors/templates/lnodetype-wizard.test.ts @@ -271,13 +271,13 @@ describe('LNodeType wizards', () => { )!; beh = parent.wizardUI.shadowRoot!.querySelector( - 'mwc-select:nth-child(21)' + 'wizard-select:nth-child(21)' )!; enaCls = parent.wizardUI.shadowRoot!.querySelectorinputs.find(i => i.label === 'values'); const selectedElement = values.selected ? templates.querySelector(`DOType[id="${values.selected.value}"]`) @@ -200,6 +202,7 @@ function addPredefinedDOType( : parent.ownerDocument.createElement('DOType'); element.setAttribute('id', id); + element.setAttribute('cdc', cdc); if (desc) element.setAttribute('desc', desc); const actions: Create[] = []; @@ -221,6 +224,22 @@ function addPredefinedDOType( }; } +function onSelectTemplateDOType(e: Event, templates: Document): void { + const cdcUI = e.target).parentElement!.querySelector( + 'wizard-textfield[label="cdc"]' + )! + ); + + const doTypeId = (e.target).selected?.value; const selectedBType = (( diff --git a/src/wizards/address.ts b/src/wizards/address.ts index 424ee2625f..addee466d4 100644 --- a/src/wizards/address.ts +++ b/src/wizards/address.ts @@ -2,6 +2,10 @@ import { html, TemplateResult } from 'lit-html'; import { ifDefined } from 'lit-html/directives/if-defined'; import { translate } from 'lit-translate'; +import '@material/mwc-checkbox'; +import '@material/mwc-formfield'; + +import '../wizard-textfield.js'; import { Create, createElement, diff --git a/src/wizards/bay.ts b/src/wizards/bay.ts index 832281437d..8416f6c23d 100644 --- a/src/wizards/bay.ts +++ b/src/wizards/bay.ts @@ -1,6 +1,7 @@ import { html, TemplateResult } from 'lit-html'; import { get, translate } from 'lit-translate'; +import '../wizard-textfield.js'; import { createElement, EditorAction, diff --git a/src/wizards/bda.ts b/src/wizards/bda.ts index abdc459e0b..24f599b085 100644 --- a/src/wizards/bda.ts +++ b/src/wizards/bda.ts @@ -1,6 +1,8 @@ import { html } from 'lit-html'; import { get, translate } from 'lit-translate'; +import '@material/mwc-button'; + import { cloneElement, createElement, @@ -13,7 +15,6 @@ import { WizardActor, WizardInput, } from '../foundation.js'; - import { getValAction, wizardContent } from './abstractda.js'; export function updateBDaAction(element: Element): WizardActor { diff --git a/src/wizards/clientln.ts b/src/wizards/clientln.ts index a6889a0ad8..ea95da88fe 100644 --- a/src/wizards/clientln.ts +++ b/src/wizards/clientln.ts @@ -1,6 +1,12 @@ import { html } from 'lit-element'; import { get } from 'lit-translate'; +import '@material/mwc-list/mwc-check-list-item'; +import '@material/mwc-icon'; +import { List } from '@material/mwc-list'; +import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; + +import '../filtered-list.js'; import { createElement, identity, @@ -11,12 +17,8 @@ import { WizardActor, WizardInput, } from '../foundation.js'; - -import { List } from '@material/mwc-list'; -import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; - -import { openCommunicationMappingWizard } from './commmap-wizards.js'; import { clientIcon } from '../icons.js'; +import { openCommunicationMappingWizard } from './commmap-wizards.js'; function getPath(identity: string | number): string { if (typeof identity !== 'string') return ''; diff --git a/src/wizards/commmap-wizards.ts b/src/wizards/commmap-wizards.ts index 98d24dbdfc..577c50659a 100644 --- a/src/wizards/commmap-wizards.ts +++ b/src/wizards/commmap-wizards.ts @@ -1,7 +1,11 @@ import { html } from 'lit-element'; import { get } from 'lit-translate'; +import '@material/mwc-icon'; +import '@material/mwc-list/mwc-list-item'; import { SingleSelectedEvent } from '@material/mwc-list/mwc-list-foundation'; + +import '../filtered-list.js'; import { findControlBlocks, identity, diff --git a/src/wizards/conductingequipment.ts b/src/wizards/conductingequipment.ts index 40c8820ab9..9cb7291da3 100644 --- a/src/wizards/conductingequipment.ts +++ b/src/wizards/conductingequipment.ts @@ -1,6 +1,10 @@ import { html, TemplateResult } from 'lit-element'; import { get, translate } from 'lit-translate'; +import '@material/mwc-list/mwc-list-item'; +import '@material/mwc-select'; + +import '../wizard-textfield.js'; import { createElement, EditorAction, diff --git a/src/wizards/controlwithiedname.ts b/src/wizards/controlwithiedname.ts index 2763edaaa1..57d3feec0a 100644 --- a/src/wizards/controlwithiedname.ts +++ b/src/wizards/controlwithiedname.ts @@ -1,5 +1,12 @@ import { html } from 'lit-element'; import { get } from 'lit-translate'; + +import '@material/mwc-icon'; +import '@material/mwc-list'; +import '@material/mwc-list/mwc-check-list-item'; +import { List } from '@material/mwc-list'; + +import '../filtered-list.js'; import { createElement, EditorAction, @@ -11,8 +18,6 @@ import { WizardInput, } from '../foundation.js'; -import { List } from '@material/mwc-list'; - import { inputIcon } from '../icons.js'; import { getSourceReferences, diff --git a/src/wizards/da.ts b/src/wizards/da.ts index 3823057c01..56a6418092 100644 --- a/src/wizards/da.ts +++ b/src/wizards/da.ts @@ -1,6 +1,10 @@ import { html, TemplateResult } from 'lit-html'; import { get, translate } from 'lit-translate'; +import '@material/mwc-button'; +import '@material/mwc-list/mwc-list-item'; + +import '../wizard-select.js'; import { cloneElement, createElement, @@ -13,7 +17,6 @@ import { WizardActor, WizardInput, } from '../foundation.js'; - import { getValAction, wizardContent } from './abstractda.js'; import { functionalConstraintEnum } from './foundation/enums.js'; diff --git a/src/wizards/dataset.ts b/src/wizards/dataset.ts index c30cc8f147..7bf27bc6b1 100644 --- a/src/wizards/dataset.ts +++ b/src/wizards/dataset.ts @@ -2,6 +2,11 @@ import { CheckListItem } from '@material/mwc-list/mwc-check-list-item'; import { html } from 'lit-element'; import { get, translate } from 'lit-translate'; +import '@material/mwc-button'; +import '@material/mwc-list/mwc-check-list-item'; + +import '../wizard-textfield.js'; +import '../filtered-list.js'; import { cloneElement, getValue, diff --git a/src/wizards/fcda.ts b/src/wizards/fcda.ts index e143a8f006..d8b418966c 100644 --- a/src/wizards/fcda.ts +++ b/src/wizards/fcda.ts @@ -1,6 +1,7 @@ import { html } from 'lit-element'; import { get, translate } from 'lit-translate'; +import '../finder-list.js'; import { createElement, identity, @@ -11,7 +12,6 @@ import { WizardInput, } from '../foundation.js'; import { getChildren } from './foundation/functions.js'; - import { Directory, FinderList } from '../finder-list.js'; function newFCDA(parent: Element, path: string[]): Element | undefined { diff --git a/src/wizards/foundation/limits.ts b/src/wizards/foundation/limits.ts index 473252e620..157e802629 100644 --- a/src/wizards/foundation/limits.ts +++ b/src/wizards/foundation/limits.ts @@ -1,7 +1,7 @@ const nameStartChar = '[:_A-Za-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]' + '|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]' + - '|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\u{10000}\\-\u{EFFFF}]'; + '|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]'; const nameChar = nameStartChar + '|[.0-9-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]'; const name = nameStartChar + '(' + nameChar + ')*'; @@ -10,16 +10,15 @@ const nmToken = '(' + nameChar + ')+'; export const patterns = { string: '([\u0009-\u000A]|[\u000D]|[\u0020-\u007E]|[\u0085]|[\u00A0-\uD7FF]' + - '|[\uE000-\uFFFD]|[\u{10000}\\-\u{10FFFF}])*', + '|[\uE000-\uFFFD])*', normalizedString: - '([\u0020-\u007E]|[\u0085]|[\u00A0-\uD7FF]|[\uE000-\uFFFD]' + - '|[\u{10000}\\-\u{10FFFF}])*', + '([\u0020-\u007E]|[\u0085]|[\u00A0-\uD7FF]|[\uE000-\uFFFD])*', name, nmToken, names: name + '( ' + name + ')*', nmTokens: nmToken + '( ' + nmToken + ')*', - decimal: '((-|\\+)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+))', - unsigned: '\\+?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)', + decimal: '[+-]?[0-9]+(([.][0-9]*)?|([.][0-9]+))', + unsigned: '[+]?[0-9]+(([.][0-9]*)?|([.][0-9]+))', alphanumericFirstUpperCase: '[A-Z][0-9,A-Z,a-z]*', asciName: '[A-Za-z][0-9,A-Z,a-z_]*', lnClass: '[A-Z]{4,4}', diff --git a/src/wizards/gse.ts b/src/wizards/gse.ts index 484dc9fb1e..a39d5fcdfa 100644 --- a/src/wizards/gse.ts +++ b/src/wizards/gse.ts @@ -1,6 +1,9 @@ import { html } from 'lit-element'; import { get } from 'lit-translate'; +import { Checkbox } from '@material/mwc-checkbox'; + +import '../wizard-textfield.js'; import { ComplexAction, createElement, @@ -12,11 +15,8 @@ import { WizardActor, WizardInput, } from '../foundation.js'; - import { renderGseSmvAddress, updateAddress } from './address.js'; -import { Checkbox } from '@material/mwc-checkbox'; - export function getMTimeAction( type: 'MinTime' | 'MaxTime', oldTime: Element | null, diff --git a/src/wizards/gsecontrol.ts b/src/wizards/gsecontrol.ts index e0ef293ba0..14f8923bfb 100644 --- a/src/wizards/gsecontrol.ts +++ b/src/wizards/gsecontrol.ts @@ -1,10 +1,15 @@ import { html, TemplateResult } from 'lit-element'; import { get, translate } from 'lit-translate'; +import '@material/mwc-button'; +import '@material/mwc-list/mwc-list-item'; import { List } from '@material/mwc-list'; import { ListItem } from '@material/mwc-list/mwc-list-item'; import { SingleSelectedEvent } from '@material/mwc-list/mwc-list-foundation'; +import '../filtered-list.js'; +import '../wizard-select.js'; +import '../wizard-textfield.js'; import { cloneElement, Delete, @@ -20,7 +25,6 @@ import { WizardInput, } from '../foundation.js'; import { maxLength, patterns } from './foundation/limits.js'; - import { editDataSetWizard } from './dataset.js'; import { editGseWizard } from './gse.js'; diff --git a/src/wizards/lnode.ts b/src/wizards/lnode.ts index 974ca5ba78..ab2d497d87 100644 --- a/src/wizards/lnode.ts +++ b/src/wizards/lnode.ts @@ -1,6 +1,15 @@ import { html, render, TemplateResult } from 'lit-html'; import { get, translate } from 'lit-translate'; +import '@material/mwc-icon'; +import '@material/mwc-list/mwc-check-list-item'; +import '@material/mwc-list/mwc-list-item'; +import { List } from '@material/mwc-list'; +import { ListBase } from '@material/mwc-list/mwc-list-base'; +import { ListItem } from '@material/mwc-list/mwc-list-item'; +import { MultiSelectedEvent } from '@material/mwc-list/mwc-list-foundation'; + +import '../filtered-list.js'; import { createElement, EditorAction, @@ -14,11 +23,6 @@ import { WizardInput, } from '../foundation.js'; -import { List } from '@material/mwc-list'; -import { ListBase } from '@material/mwc-list/mwc-list-base'; -import { ListItem } from '@material/mwc-list/mwc-list-item'; -import { MultiSelectedEvent } from '@material/mwc-list/mwc-list-foundation'; - /** Description of a `ListItem` representing an `IED` or `LN[0]` */ interface ItemDescription { selected: boolean; diff --git a/src/wizards/substation.ts b/src/wizards/substation.ts index d34d089fc6..2f43537f0d 100644 --- a/src/wizards/substation.ts +++ b/src/wizards/substation.ts @@ -1,6 +1,10 @@ import { html, TemplateResult } from 'lit-element'; import { get, translate } from 'lit-translate'; +import '@material/mwc-checkbox'; +import '@material/mwc-formfield'; + +import '../wizard-textfield.js'; import { createElement, EditorAction, @@ -11,7 +15,6 @@ import { WizardInput, } from '../foundation.js'; import { updateNamingAction } from './foundation/actions.js'; - import { guessVoltageLevel } from '../editors/substation/guess-wizard.js'; function render( diff --git a/src/wizards/voltagelevel.ts b/src/wizards/voltagelevel.ts index 063817c338..ba3739147f 100644 --- a/src/wizards/voltagelevel.ts +++ b/src/wizards/voltagelevel.ts @@ -1,6 +1,7 @@ import { html, TemplateResult } from 'lit-html'; import { get, translate } from 'lit-translate'; +import '../wizard-textfield.js'; import { cloneElement, createElement, diff --git a/src/zeroline-pane.ts b/src/zeroline-pane.ts index 1326c89982..8d7d8359fa 100644 --- a/src/zeroline-pane.ts +++ b/src/zeroline-pane.ts @@ -9,18 +9,20 @@ import { } from 'lit-element'; import { translate } from 'lit-translate'; -import { isPublic, newWizardEvent } from './foundation.js'; -import { getAttachedIeds } from './zeroline/foundation.js'; +import '@material/mwc-icon-button'; +import '@material/mwc-icon-button-toggle'; +import { IconButton } from '@material/mwc-icon-button'; +import { IconButtonToggle } from '@material/mwc-icon-button-toggle'; import './zeroline/substation-editor.js'; import './zeroline/ied-editor.js'; import { Settings } from './Setting.js'; -import { wizards } from './wizards/wizard-library.js'; import { communicationMappingWizard } from './wizards/commmap-wizards.js'; -import { IconButton } from '@material/mwc-icon-button'; -import { IconButtonToggle } from '@material/mwc-icon-button-toggle'; -import { selectGseControlWizard } from './wizards/gsecontrol.js'; import { gooseIcon } from './icons.js'; +import { isPublic, newWizardEvent } from './foundation.js'; +import { selectGseControlWizard } from './wizards/gsecontrol.js'; +import { wizards } from './wizards/wizard-library.js'; +import { getAttachedIeds } from './zeroline/foundation.js'; function shouldShowIEDs(): boolean { return localStorage.getItem('showieds') === 'on'; diff --git a/src/zeroline/bay-editor.ts b/src/zeroline/bay-editor.ts index d0a714982b..c329ee3595 100644 --- a/src/zeroline/bay-editor.ts +++ b/src/zeroline/bay-editor.ts @@ -9,7 +9,15 @@ import { } from 'lit-element'; import { translate } from 'lit-translate'; -import { startMove, styles, cloneSubstationElement } from './foundation.js'; +import '@material/mwc-icon-button'; +import { Menu } from '@material/mwc-menu'; +import { IconButton } from '@material/mwc-icon-button'; +import { ListItem } from '@material/mwc-list/mwc-list-item'; + +import '../action-pane.js'; +import './ied-editor.js'; +import './conducting-equipment-editor.js'; +import { VoltageLevelEditor } from './voltage-level-editor.js'; import { getChildElementsByTagName, newActionEvent, @@ -17,16 +25,8 @@ import { SCLTag, tags, } from '../foundation.js'; - import { emptyWizard, wizards } from '../wizards/wizard-library.js'; -import { VoltageLevelEditor } from './voltage-level-editor.js'; -import './conducting-equipment-editor.js'; -import '../action-pane.js'; -import { Menu } from '@material/mwc-menu'; -import { IconButton } from '@material/mwc-icon-button'; -import { ListItem } from '@material/mwc-list/mwc-list-item'; - function childTags(element: Element | null | undefined): SCLTag[] { if (!element) return []; @@ -34,6 +34,7 @@ function childTags(element: Element | null | undefined): SCLTag[] { child => wizards[child].create !== emptyWizard ); } +import { startMove, styles, cloneSubstationElement } from './foundation.js'; /** [[`SubstationEditor`]] subeditor for a `Bay` element. */ @customElement('bay-editor') diff --git a/src/zeroline/conducting-equipment-editor.ts b/src/zeroline/conducting-equipment-editor.ts index 9d2ad74978..ef5184178a 100644 --- a/src/zeroline/conducting-equipment-editor.ts +++ b/src/zeroline/conducting-equipment-editor.ts @@ -7,10 +7,11 @@ import { TemplateResult, } from 'lit-element'; -import { startMove, getIcon } from './foundation.js'; -import { newActionEvent, newWizardEvent } from '../foundation.js'; +import '@material/mwc-fab'; import { BayEditor } from './bay-editor.js'; +import { startMove, getIcon } from './foundation.js'; +import { newActionEvent, newWizardEvent } from '../foundation.js'; import { wizards } from '../wizards/wizard-library.js'; /** [[`SubstationEditor`]] subeditor for a `ConductingEquipment` element. */ diff --git a/src/zeroline/ied-editor.ts b/src/zeroline/ied-editor.ts index e61b5548eb..02ed1ef2bc 100644 --- a/src/zeroline/ied-editor.ts +++ b/src/zeroline/ied-editor.ts @@ -7,12 +7,15 @@ import { query, TemplateResult, } from 'lit-element'; -import { newWizardEvent } from '../foundation.js'; -import { createClientLnWizard } from '../wizards/clientln.js'; +import '@material/mwc-fab'; +import '@material/mwc-icon'; import { Fab } from '@material/mwc-fab'; -import { selectGseControlWizard } from '../wizards/gsecontrol.js'; + +import { createClientLnWizard } from '../wizards/clientln.js'; import { gooseIcon } from '../icons.js'; +import { newWizardEvent } from '../foundation.js'; +import { selectGseControlWizard } from '../wizards/gsecontrol.js'; /** [[`SubstationEditor`]] subeditor for a `ConductingEquipment` element. */ @customElement('ied-editor') diff --git a/src/zeroline/substation-editor.ts b/src/zeroline/substation-editor.ts index cbc83d497f..a34ccc7a46 100644 --- a/src/zeroline/substation-editor.ts +++ b/src/zeroline/substation-editor.ts @@ -9,7 +9,16 @@ import { } from 'lit-element'; import { translate } from 'lit-translate'; +import '@material/mwc-icon-button'; +import { Menu } from '@material/mwc-menu'; +import { IconButton } from '@material/mwc-icon-button'; +import { ListItem } from '@material/mwc-list/mwc-list-item'; + +import '../action-pane.js'; +import './ied-editor.js'; +import './voltage-level-editor.js'; import { newActionEvent, newWizardEvent, SCLTag, tags } from '../foundation.js'; +import { emptyWizard, wizards } from '../wizards/wizard-library.js'; import { cloneSubstationElement, selectors, @@ -17,14 +26,6 @@ import { styles, } from './foundation.js'; -import { emptyWizard, wizards } from '../wizards/wizard-library.js'; - -import './voltage-level-editor.js'; -import '../action-pane.js'; -import { Menu } from '@material/mwc-menu'; -import { IconButton } from '@material/mwc-icon-button'; -import { ListItem } from '@material/mwc-list/mwc-list-item'; - function childTags(element: Element | null | undefined): SCLTag[] { if (!element) return []; diff --git a/src/zeroline/voltage-level-editor.ts b/src/zeroline/voltage-level-editor.ts index f77854dfad..4cc5e01def 100644 --- a/src/zeroline/voltage-level-editor.ts +++ b/src/zeroline/voltage-level-editor.ts @@ -9,6 +9,14 @@ import { } from 'lit-element'; import { translate } from 'lit-translate'; +import '@material/mwc-icon-button'; +import { Menu } from '@material/mwc-menu'; +import { IconButton } from '@material/mwc-icon-button'; +import { ListItem } from '@material/mwc-list/mwc-list-item'; + +import '../action-pane.js'; +import './bay-editor.js'; +import './ied-editor.js'; import { selectors, startMove, @@ -20,12 +28,6 @@ import { newActionEvent, newWizardEvent, SCLTag, tags } from '../foundation.js'; import { SubstationEditor } from './substation-editor.js'; import { emptyWizard, wizards } from '../wizards/wizard-library.js'; -import './bay-editor.js'; -import '../action-pane.js'; -import { Menu } from '@material/mwc-menu'; -import { IconButton } from '@material/mwc-icon-button'; -import { ListItem } from '@material/mwc-list/mwc-list-item'; - function childTags(element: Element | null | undefined): SCLTag[] { if (!element) return []; diff --git a/test/integration/Editing.test.ts b/test/integration/Editing.test.ts index 435bf5f4c1..906f9c057c 100644 --- a/test/integration/Editing.test.ts +++ b/test/integration/Editing.test.ts @@ -1,9 +1,9 @@ import { expect, fixture, html } from '@open-wc/testing'; -import { newActionEvent } from '../../src/foundation.js'; +import '../mock-editor-logger.js'; import { MockEditorLogger } from '../mock-editor-logger.js'; -import '../mock-editor-logger.js'; +import { newActionEvent } from '../../src/foundation.js'; describe('Editing-Logging integration', () => { let elm: MockEditorLogger; @@ -11,7 +11,7 @@ describe('Editing-Logging integration', () => { let element: Element; beforeEach(async () => { - const doc = await fetch('/base/test/testfiles/Editing.scd') + const doc = await fetch('/test/testfiles/Editing.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); elm = ( diff --git a/__snapshots__/open-scd.md b/test/integration/__snapshots__/open-scd.test.snap.js similarity index 99% rename from __snapshots__/open-scd.md rename to test/integration/__snapshots__/open-scd.test.snap.js index 271a06673b..cd086c5636 100644 --- a/__snapshots__/open-scd.md +++ b/test/integration/__snapshots__/open-scd.test.snap.js @@ -1,9 +1,8 @@ -# `open-scd` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -#### `looks like its snapshot` - -```html - - -``` +`; +/* end snapshot open-scd looks like its snapshot */ diff --git a/test/integration/editors/Substation.test.ts b/test/integration/editors/Substation.test.ts index d0c297b34e..42e8715887 100644 --- a/test/integration/editors/Substation.test.ts +++ b/test/integration/editors/Substation.test.ts @@ -1,9 +1,11 @@ import { html, fixture, expect } from '@open-wc/testing'; import '../../mock-wizard.js'; +import { MockWizard } from '../../mock-wizard.js'; + import { Editing } from '../../../src/Editing.js'; import Substation from '../../../src/editors/Substation.js'; -import { Wizarding, WizardingElement } from '../../../src/Wizarding.js'; +import { Wizarding } from '../../../src/Wizarding.js'; describe('Substation Plugin', () => { customElements.define('substation-plugin', Wizarding(Editing(Substation))); @@ -13,8 +15,8 @@ describe('Substation Plugin', () => { }); describe('without a doc loaded', () => { - it('looks like the latest snapshot', () => { - expect(element).shadowDom.to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(element).shadowDom.to.equalSnapshot(); }); }); @@ -22,7 +24,7 @@ describe('Substation Plugin', () => { let doc: XMLDocument; let element: Substation; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element = await fixture( @@ -36,13 +38,13 @@ describe('Substation Plugin', () => { describe('with a doc loaded missing a substation section', () => { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/missingSubstation.scd') + doc = await fetch('/test/testfiles/missingSubstation.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` + +

    + + +

    + + +`; +/* end snapshot Substation Plugin without a doc loaded looks like the latest snapshot */ + diff --git a/test/integration/editors/communication/Communication.test.ts b/test/integration/editors/communication/Communication.test.ts index db6e03950c..1c57658d85 100644 --- a/test/integration/editors/communication/Communication.test.ts +++ b/test/integration/editors/communication/Communication.test.ts @@ -1,8 +1,11 @@ import { html, fixture, expect } from '@open-wc/testing'; +import '../../../mock-wizard.js'; +import { MockWizard } from '../../../mock-wizard.js'; + import Communication from '../../../../src/editors/Communication.js'; import { Editing } from '../../../../src/Editing.js'; -import { Wizarding, WizardingElement } from '../../../../src/Wizarding.js'; +import { Wizarding } from '../../../../src/Wizarding.js'; describe('Communication Plugin', () => { customElements.define( @@ -17,8 +20,8 @@ describe('Communication Plugin', () => { }); describe('without a doc loaded', () => { - it('looks like the latest snapshot', () => { - expect(element).shadowDom.to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(element).shadowDom.to.equalSnapshot(); }); }); @@ -26,7 +29,7 @@ describe('Communication Plugin', () => { let doc: XMLDocument; let element: Communication; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element = await fixture( @@ -40,14 +43,14 @@ describe('Communication Plugin', () => { describe('with a doc loaded missing a communication section', () => { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; let fab: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/missingCommunication.scd') + doc = await fetch('/test/testfiles/missingCommunication.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` + + [communication.missing] + + + + + + +`; +/* end snapshot Communication Plugin without a doc loaded looks like the latest snapshot */ + diff --git a/__snapshots__/conductingap-editor wizarding integration.md b/test/integration/editors/communication/__snapshots__/connectedap-editor-wizarding.test.snap.js similarity index 78% rename from __snapshots__/conductingap-editor wizarding integration.md rename to test/integration/editors/communication/__snapshots__/connectedap-editor-wizarding.test.snap.js index af8e1ea7c1..4dd617a620 100644 --- a/__snapshots__/conductingap-editor wizarding integration.md +++ b/test/integration/editors/communication/__snapshots__/connectedap-editor-wizarding.test.snap.js @@ -1,11 +1,8 @@ -# `conductingap-editor wizarding integration` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `for schema 2003 (Edition1) projects` - -#### `looks like the latest snapshot` - -```html -
    +`; +/* end snapshot conductingap-editor wizarding integration for schema 2003 (Edition1) projects looks like the latest snapshot */ -``` - -## `for schema 2007B (Edition2) projects` - -#### `looks like the latest snapshot` - -```html - +`; +/* end snapshot conductingap-editor wizarding integration for schema 2007B (Edition2) projects looks like the latest snapshot */ -``` - -## `for schema 2007B4 (Edition2.1) projects` - -#### `looks like the latest snapshot` - -```html - - -``` +`; +/* end snapshot conductingap-editor wizarding integration for schema 2007B4 (Edition2.1) projects looks like the latest snapshot */ diff --git a/__snapshots__/subnetwork-editor wizarding integration.md b/test/integration/editors/communication/__snapshots__/subnetwork-editor-wizarding.test.snap.js similarity index 83% rename from __snapshots__/subnetwork-editor wizarding integration.md rename to test/integration/editors/communication/__snapshots__/subnetwork-editor-wizarding.test.snap.js index 3db2bfea8c..a07b8baed4 100644 --- a/__snapshots__/subnetwork-editor wizarding integration.md +++ b/test/integration/editors/communication/__snapshots__/subnetwork-editor-wizarding.test.snap.js @@ -1,11 +1,8 @@ -# `subnetwork-editor wizarding integration` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `edit/add Subnetwork wizard` - -#### `looks like the latest snapshot` - -```html - +`; +/* end snapshot subnetwork-editor wizarding integration edit/add Subnetwork wizard looks like the latest snapshot */ -``` - -## `add ConnectedAP wizard` - -#### `looks like the latest snapshot` - -```html - - -``` +`; +/* end snapshot subnetwork-editor wizarding integration add ConnectedAP wizard looks like the latest snapshot */ diff --git a/test/integration/editors/communication/connectedap-editor-wizarding-editing.test.ts b/test/integration/editors/communication/connectedap-editor-wizarding-editing.test.ts index 3b83c73d3d..92e486c48d 100644 --- a/test/integration/editors/communication/connectedap-editor-wizarding-editing.test.ts +++ b/test/integration/editors/communication/connectedap-editor-wizarding-editing.test.ts @@ -1,27 +1,26 @@ import { fixture, html, expect } from '@open-wc/testing'; import '../../../mock-wizard-editor.js'; -import '../../../../src/editors/communication/connectedap-editor.js'; +import { MockWizardEditor } from '../../../mock-wizard-editor.js'; -import { EditingElement } from '../../../../src/Editing.js'; -import { WizardingElement } from '../../../../src/Wizarding.js'; +import '../../../../src/editors/communication/connectedap-editor.js'; import { ConnectedAPEditor } from '../../../../src/editors/communication/connectedap-editor.js'; import { WizardTextField } from '../../../../src/wizard-textfield.js'; describe('connectedap-editor wizarding editing integration', () => { describe('edit wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: ConnectedAPEditor | null; let secondaryAction: HTMLElement; let primaryAction: HTMLElement; let ipField: WizardTextField; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('remove action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: ConnectedAPEditor | null; let deleteButton: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { describe('for schema 2003 (Edition1) projects', () => { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2003.scd') + doc = await fetch('/test/testfiles/valid2003.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { )).click(); await parent.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); describe('the 1st input element', () => { it('edits the attribute IP', async () => { @@ -227,13 +226,13 @@ describe('conductingap-editor wizarding integration', () => { }); describe('for schema 2007B (Edition2) projects', () => { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B.scd') + doc = await fetch('/test/testfiles/valid2007B.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { )).click(); await parent.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); describe('the 14th input element', () => { it('edits the attribute SNTP-Port', async () => { @@ -357,13 +356,13 @@ describe('conductingap-editor wizarding integration', () => { }); describe('for schema 2007B4 (Edition2.1) projects', () => { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { )).click(); await parent.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); describe('the 20th input element', () => { it('edits the attribute IPv6', async () => { diff --git a/test/integration/editors/communication/subnetwork-editor-wizarding-editing.test.ts b/test/integration/editors/communication/subnetwork-editor-wizarding-editing.test.ts index a71a1e912a..09c7545be8 100644 --- a/test/integration/editors/communication/subnetwork-editor-wizarding-editing.test.ts +++ b/test/integration/editors/communication/subnetwork-editor-wizarding-editing.test.ts @@ -1,17 +1,18 @@ import { fixture, html, expect } from '@open-wc/testing'; import '../../../mock-wizard-editor.js'; -import { EditingElement } from '../../../../src/Editing.js'; -import { SubNetworkEditor } from '../../../../src/editors/communication/subnetwork-editor.js'; -import { WizardingElement } from '../../../../src/Wizarding.js'; -import { WizardTextField } from '../../../../src/wizard-textfield.js'; +import { MockWizardEditor } from '../../../mock-wizard-editor.js'; import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; +import '../../../../src/editors/communication/subnetwork-editor.js'; +import { SubNetworkEditor } from '../../../../src/editors/communication/subnetwork-editor.js'; +import { WizardTextField } from '../../../../src/wizard-textfield.js'; + describe('subnetwork-editor wizarding editing integration', () => { describe('edit wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: SubNetworkEditor | null; let nameField: WizardTextField; let descField: WizardTextField; @@ -20,10 +21,10 @@ describe('subnetwork-editor wizarding editing integration', () => { let primaryAction: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('remove action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: SubNetworkEditor | null; let deleteButton: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('add ConnectedAP action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: SubNetworkEditor | null; let newConnectedAPItem: HTMLElement; let primaryAction: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { describe('edit/add Subnetwork wizard', () => { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { )).click(); await parent.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); describe('the first input element', () => { it('edits the attribute name', async () => { @@ -108,13 +109,13 @@ describe('subnetwork-editor wizarding integration', () => { }); describe('add ConnectedAP wizard', () => { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { )).click(); await parent.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('display all access point in the project', async () => { expect(parent.wizardUI.dialog).to.exist; diff --git a/test/integration/editors/substation/guess-wizarding-editing.test.ts b/test/integration/editors/substation/guess-wizarding-editing.test.ts index b893c0e88d..622540aee9 100644 --- a/test/integration/editors/substation/guess-wizarding-editing.test.ts +++ b/test/integration/editors/substation/guess-wizarding-editing.test.ts @@ -1,21 +1,17 @@ import { expect, fixture, html } from '@open-wc/testing'; -import '../../../mock-wizard-editor.js'; import '../../../mock-wizard.js'; - -import '@material/mwc-list/mwc-check-list-item'; -import '@material/mwc-list/mwc-list'; - -import { EditingElement } from '../../../../src/Editing.js'; import { MockWizard } from '../../../mock-wizard.js'; +import '../../../mock-wizard-editor.js'; +import { MockWizardEditor } from '../../../mock-wizard-editor.js'; + import { guessVoltageLevel } from '../../../../src/editors/substation/guess-wizard.js'; -import { WizardingElement } from '../../../../src/Wizarding.js'; describe('guess-wizard-integration', () => { let element: MockWizard; let validSCL: XMLDocument; beforeEach(async () => { - validSCL = await fetch('/base/test/testfiles/valid2007B4.scd') + validSCL = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); validSCL.querySelector('Substation')!.innerHTML = ''; @@ -72,14 +68,14 @@ describe('guess-wizard-integration', () => { }); describe('guess-wizarding-editing-integration', () => { - let element: WizardingElement & EditingElement; + let element: MockWizardEditor; let validSCL: XMLDocument; beforeEach(async () => { - validSCL = await fetch('/base/test/testfiles/valid2007B4.scd') + validSCL = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); validSCL.querySelector('Substation')!.innerHTML = ''; - element = ( + element = ( await fixture(html``) ); element.workflow.push(guessVoltageLevel(validSCL)); diff --git a/test/integration/editors/substation/lnodewizard.test.ts b/test/integration/editors/substation/lnodewizard.test.ts index 1c23085573..275bb16df5 100644 --- a/test/integration/editors/substation/lnodewizard.test.ts +++ b/test/integration/editors/substation/lnodewizard.test.ts @@ -1,20 +1,18 @@ import { expect, fixture, html } from '@open-wc/testing'; -import '@material/mwc-list/mwc-check-list-item'; -import '@material/mwc-list/mwc-list'; +import '../../../mock-wizard-editor.js'; +import { MockWizardEditor } from '../../../mock-wizard-editor.js'; + import { List } from '@material/mwc-list'; import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; import { lNodeWizard } from '../../../../src/wizards/lnode.js'; -import '../../../mock-wizard.js'; -import { MockWizardEditor } from '../../../mock-wizard-editor.js'; - describe('lnodewizard', () => { let element: MockWizardEditor; let doc: Document; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/lnodewizard.scd') + doc = await fetch('/test/testfiles/lnodewizard.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); }); diff --git a/test/integration/editors/templates/Templates.test.ts b/test/integration/editors/templates/Templates.test.ts index ab4bb7c293..d632b1271c 100644 --- a/test/integration/editors/templates/Templates.test.ts +++ b/test/integration/editors/templates/Templates.test.ts @@ -1,8 +1,11 @@ import { html, fixture, expect } from '@open-wc/testing'; -import TemplatesPlugin from '../../../../src/editors/Templates.js'; +import '../../../mock-wizard-editor.js'; +import { MockWizardEditor } from '../../../mock-wizard-editor.js'; + import { Editing, EditingElement } from '../../../../src/Editing.js'; import { Wizarding, WizardingElement } from '../../../../src/Wizarding.js'; +import TemplatesPlugin from '../../../../src/editors/Templates.js'; describe('Templates Plugin', () => { customElements.define( @@ -15,35 +18,35 @@ describe('Templates Plugin', () => { }); describe('without a doc loaded', () => { - it('looks like the latest snapshot', () => { - expect(element).shadowDom.to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(element).shadowDom.to.equalSnapshot(); }); }); describe('with a doc loaded', () => { let doc: XMLDocument; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/templates/datypes.scd') + doc = await fetch('/test/testfiles/templates/datypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element.doc = doc; await element.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(element).shadowDom.to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(element).shadowDom.to.equalSnapshot(); }); }); describe('with a doc loaded missing a datatypetemplates section', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/templates/missingdatatypes.scd') + doc = await fetch('/test/testfiles/templates/missingdatatypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { let parent: WizardingElement & EditingElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/templates/datypes.scd') + doc = await fetch('/test/testfiles/templates/datypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = ( diff --git a/__snapshots__/Templates Plugin.md b/test/integration/editors/templates/__snapshots__/Templates.test.snap.js similarity index 96% rename from __snapshots__/Templates Plugin.md rename to test/integration/editors/templates/__snapshots__/Templates.test.snap.js index ab69d1bbe2..76682bf27a 100644 --- a/__snapshots__/Templates Plugin.md +++ b/test/integration/editors/templates/__snapshots__/Templates.test.snap.js @@ -1,11 +1,8 @@ -# `Templates Plugin` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `without a doc loaded` - -#### `looks like the latest snapshot` - -```html -

    +snapshots["Templates Plugin without a doc loaded looks like the latest snapshot"] = +`

    [templates.missing] @@ -18,15 +15,11 @@

    +`; +/* end snapshot Templates Plugin without a doc loaded looks like the latest snapshot */ -``` - -## `with a doc loaded` - -#### `looks like the latest snapshot` - -```html -
    +snapshots["Templates Plugin with a doc loaded looks like the latest snapshot"] = +`

    [scl.LNodeType] @@ -586,6 +579,6 @@

    - -``` +`; +/* end snapshot Templates Plugin with a doc loaded looks like the latest snapshot */ diff --git a/__snapshots__/DAType wizards.md b/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js similarity index 96% rename from __snapshots__/DAType wizards.md rename to test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js index 6328bd0743..c15583c5a2 100644 --- a/__snapshots__/DAType wizards.md +++ b/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js @@ -1,11 +1,8 @@ -# `DAType wizards` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `defines a createDATypeWizard` - -#### `looks like the latest snapshot` - -```html - @@ -594,7 +591,7 @@ helper="[scl.desc]" label="desc" nullable="" - pattern="([ -~]|[…]|[ -퟿]|[-�]|[𐀀\-􏿿])*" + pattern="([ -~]|[…]|[ -퟿]|[-�])*" >
    @@ -614,15 +611,11 @@ > +`; +/* end snapshot DAType wizards defines a createDATypeWizard looks like the latest snapshot */ -``` - -## `defines a dATypeWizard` - -#### `looks like the latest snapshot` - -```html - @@ -650,7 +643,7 @@ helper="[scl.desc]" label="desc" nullable="" - pattern="([ -~]|[…]|[ -퟿]|[-�]|[𐀀\-􏿿])*" + pattern="([ -~]|[…]|[ -퟿]|[-�])*" > - -``` +`; +/* end snapshot DAType wizards defines a dATypeWizard looks like the latest snapshot */ diff --git a/__snapshots__/DOType wizards.md b/test/integration/editors/templates/__snapshots__/dotype-wizarding.test.snap.js similarity index 95% rename from __snapshots__/DOType wizards.md rename to test/integration/editors/templates/__snapshots__/dotype-wizarding.test.snap.js index 4efaee4a91..fd94b5b3c9 100644 --- a/__snapshots__/DOType wizards.md +++ b/test/integration/editors/templates/__snapshots__/dotype-wizarding.test.snap.js @@ -1,11 +1,8 @@ -# `DOType wizards` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `defines a createDOTypeWizard` - -#### `looks like the latest snapshot` - -```html - @@ -690,7 +687,7 @@ helper="[scl.desc]" label="desc" nullable="" - pattern="([ -~]|[…]|[ -퟿]|[-�]|[𐀀\-􏿿])*" + pattern="([ -~]|[…]|[ -퟿]|[-�])*" > +`; +/* end snapshot DOType wizards defines a createDOTypeWizard looks like the latest snapshot */ -``` - -## `defines a dOTypeWizard` - -#### `looks like the latest snapshot` - -```html - @@ -753,13 +746,13 @@ helper="[scl.desc]" label="desc" nullable="" - pattern="([ -~]|[…]|[ -퟿]|[-�]|[𐀀\-􏿿])*" + pattern="([ -~]|[…]|[ -퟿]|[-�])*" >
    @@ -1007,15 +1000,11 @@ > +`; +/* end snapshot DOType wizards defines a dOTypeWizard looks like the latest snapshot */ -``` - -## `defines a sDOWizard to edit an existing SDO` - -#### `looks like the latest snapshot` - -```html - +`; +/* end snapshot DOType wizards defines a sDOWizard to edit an existing SDO looks like the latest snapshot */ -``` - -## `defines a sDOWizard to create a new SDO element` - -#### `looks like the latest snapshot` - -```html - - -``` +`; +/* end snapshot DOType wizards defines a sDOWizard to create a new SDO element looks like the latest snapshot */ diff --git a/__snapshots__/EnumType wizards.md b/test/integration/editors/templates/__snapshots__/enumtype-wizarding.test.snap.js similarity index 96% rename from __snapshots__/EnumType wizards.md rename to test/integration/editors/templates/__snapshots__/enumtype-wizarding.test.snap.js index 3c3e0a7076..6686453321 100644 --- a/__snapshots__/EnumType wizards.md +++ b/test/integration/editors/templates/__snapshots__/enumtype-wizarding.test.snap.js @@ -1,11 +1,8 @@ -# `EnumType wizards` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `defines a createEnumTypeWizard` - -#### `looks like the latest snapshot` - -```html - @@ -1346,7 +1343,7 @@ helper="[scl.desc]" label="desc" nullable="" - pattern="([ -~]|[…]|[ -퟿]|[-�]|[𐀀\-􏿿])*" + pattern="([ -~]|[…]|[ -퟿]|[-�])*" > @@ -1366,15 +1363,11 @@ > +`; +/* end snapshot EnumType wizards defines a createEnumTypeWizard looks like the latest snapshot */ -``` - -## `defines an eNumTypeEditWizard` - -#### `looks like the latest snapshot` - -```html - @@ -1402,7 +1395,7 @@ helper="[scl.desc]" label="desc" nullable="" - pattern="([ -~]|[…]|[ -퟿]|[-�]|[𐀀\-􏿿])*" + pattern="([ -~]|[…]|[ -퟿]|[-�])*" > +`; +/* end snapshot EnumType wizards defines an eNumTypeEditWizard looks like the latest snapshot */ -``` - -## `defines a eNumValWizard to edit an existing EnumVal` - -#### `looks like the latest snapshot` - -```html - @@ -1566,15 +1555,11 @@ > +`; +/* end snapshot EnumType wizards defines a eNumValWizard to edit an existing EnumVal looks like the latest snapshot */ -``` - -## `defines a eNumValWizard to create a new EnumVal element` - -#### `looks like the latest snapshot` - -```html - @@ -1620,6 +1605,6 @@ > - -``` +`; +/* end snapshot EnumType wizards defines a eNumValWizard to create a new EnumVal element looks like the latest snapshot */ diff --git a/__snapshots__/LNodeType wizards.md b/test/integration/editors/templates/__snapshots__/lnodetype-wizard.test.snap.js similarity index 93% rename from __snapshots__/LNodeType wizards.md rename to test/integration/editors/templates/__snapshots__/lnodetype-wizard.test.snap.js index c055827cd0..0406d34451 100644 --- a/__snapshots__/LNodeType wizards.md +++ b/test/integration/editors/templates/__snapshots__/lnodetype-wizard.test.snap.js @@ -1,11 +1,8 @@ -# `LNodeType wizards` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `defines a lNodeTypeHelperWizard` - -#### `looks like the latest snapshot` - -```html - @@ -33,7 +30,7 @@ helper="[scl.desc]" label="desc" nullable="" - pattern="([ -~]|[…]|[ -퟿]|[-�]|[𐀀\-􏿿])*" + pattern="([ -~]|[…]|[ -퟿]|[-�])*" > +`; +/* end snapshot LNodeType wizards defines a lNodeTypeHelperWizard looks like the latest snapshot */ -``` - -## `defines a createLNodeTypeWizard` - -#### `looks like the latest snapshot` - -```html - @@ -3448,7 +3441,7 @@ helper="[scl.desc]" label="desc" nullable="" - pattern="([ -~]|[…]|[ -퟿]|[-�]|[𐀀\-􏿿])*" + pattern="([ -~]|[…]|[ -퟿]|[-�])*" > @@ -3468,15 +3461,11 @@ > +`; +/* end snapshot LNodeType wizards defines a createLNodeTypeWizard looks like the latest snapshot */ -``` - -## `opens a createLNodeTypeHelperWizard` - -#### `looks like the latest snapshot` - -```html - +`; +/* end snapshot LNodeType wizards defines a createLNodeTypeWizard opens a createLNodeTypeHelperWizard looks like the latest snapshot */ -``` - -## `defines a dOWizard to edit an existing DO` - -#### `looks like the latest snapshot` - -```html - -
    - - - - > - - - - - - Dummy.LLN0.Mod - - - Dummy.LLN0.Beh - - - Dummy.LLN0.Health - - - Dummy.LLN0.NamPlt - - - Dummy.LPHD1.PhyNam - - - Dummy.LPHD1.Sim - - - Dummy.XCBR1.Pos - - - Dummy.CSWI.Pos1 - - - Dummy.CSWI.Pos2 - - - Dummy.XCBR1.OpCnt - - - Dummy.XCBR1.NamPlt - - - Dummy.XCBR1.BlkOpn - - - Dummy.SPS - - - Dummy.WYE - - - Dummy.CMV - - - - - - - - - true - - - false - - -
    - - - - -
    - -``` - -## `defines a dOWizard to create a new DO element` - -#### `looks like the latest snapshot` - -```html - - -``` +`; +/* end snapshot LNodeType wizards defines a dOWizard to create a new DO element looks like the latest snapshot */ diff --git a/test/integration/editors/templates/datype-wizarding.test.ts b/test/integration/editors/templates/datype-wizarding.test.ts index 3df8e331aa..f594ffd5fc 100644 --- a/test/integration/editors/templates/datype-wizarding.test.ts +++ b/test/integration/editors/templates/datype-wizarding.test.ts @@ -1,12 +1,14 @@ import { html, fixture, expect } from '@open-wc/testing'; -import TemplatesPlugin from '../../../../src/editors/Templates.js'; +import '../../../mock-wizard-editor.js'; import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import { ListItem } from '@material/mwc-list/mwc-list-item'; import { Select } from '@material/mwc-select'; -import { WizardTextField } from '../../../../src/wizard-textfield.js'; + import { FilteredList } from '../../../../src/filtered-list.js'; -import { ListItem } from '@material/mwc-list/mwc-list-item'; +import { WizardTextField } from '../../../../src/wizard-textfield.js'; +import TemplatesPlugin from '../../../../src/editors/Templates.js'; describe('DAType wizards', () => { if (customElements.get('templates-editor') === undefined) @@ -25,7 +27,7 @@ describe('DAType wizards', () => { templates = parent.querySelector('templates-editor')!; - doc = await fetch('/base/test/testfiles/templates/datypes.scd') + doc = await fetch('/test/testfiles/templates/datypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); templates.doc = doc; @@ -61,8 +63,8 @@ describe('DAType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('allows to add empty DATypes to the project', async () => { @@ -137,8 +139,8 @@ describe('DAType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('edits DAType attributes id', async () => { expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).to.exist; diff --git a/test/integration/editors/templates/dotype-wizarding.test.ts b/test/integration/editors/templates/dotype-wizarding.test.ts index f915d7fe81..792581bb9c 100644 --- a/test/integration/editors/templates/dotype-wizarding.test.ts +++ b/test/integration/editors/templates/dotype-wizarding.test.ts @@ -1,12 +1,14 @@ import { html, fixture, expect } from '@open-wc/testing'; -import TemplatesPlugin from '../../../../src/editors/Templates.js'; +import '../../../mock-wizard-editor.js'; import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import { ListItem } from '@material/mwc-list/mwc-list-item'; import { Select } from '@material/mwc-select'; -import { WizardTextField } from '../../../../src/wizard-textfield.js'; + import { FilteredList } from '../../../../src/filtered-list.js'; -import { ListItem } from '@material/mwc-list/mwc-list-item'; +import TemplatesPlugin from '../../../../src/editors/Templates.js'; +import { WizardTextField } from '../../../../src/wizard-textfield.js'; describe('DOType wizards', () => { if (customElements.get('templates-editor') === undefined) @@ -25,7 +27,7 @@ describe('DOType wizards', () => { templates = parent.querySelector('templates-editor')!; - doc = await fetch('/base/test/testfiles/templates/dotypes.scd') + doc = await fetch('/test/testfiles/templates/dotypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); templates.doc = doc; @@ -65,8 +67,8 @@ describe('DOType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('allows to add empty DOTypes to the project', async () => { expect(doc.querySelector('DOType[id="myGeneralDOType"]')).to.not.exist; @@ -157,8 +159,8 @@ describe('DOType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('edits DAType attributes id', async () => { expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.exist; @@ -225,8 +227,8 @@ describe('DOType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('edits SDO attributes name', async () => { expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).to @@ -309,8 +311,8 @@ describe('DOType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('creates a new SDO element', async () => { expect( diff --git a/test/integration/editors/templates/enumtype-wizarding.test.ts b/test/integration/editors/templates/enumtype-wizarding.test.ts index 91209e5c92..62e4b06269 100644 --- a/test/integration/editors/templates/enumtype-wizarding.test.ts +++ b/test/integration/editors/templates/enumtype-wizarding.test.ts @@ -1,12 +1,14 @@ import { html, fixture, expect } from '@open-wc/testing'; -import TemplatesPlugin from '../../../../src/editors/Templates.js'; +import '../../../mock-wizard-editor.js'; import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import { ListItem } from '@material/mwc-list/mwc-list-item'; import { Select } from '@material/mwc-select'; -import { WizardTextField } from '../../../../src/wizard-textfield.js'; + import { FilteredList } from '../../../../src/filtered-list.js'; -import { ListItem } from '@material/mwc-list/mwc-list-item'; +import TemplatesPlugin from '../../../../src/editors/Templates.js'; +import { WizardTextField } from '../../../../src/wizard-textfield.js'; describe('EnumType wizards', () => { if (customElements.get('templates-editor') === undefined) @@ -25,7 +27,7 @@ describe('EnumType wizards', () => { templates = parent.querySelector('templates-editor')!; - doc = await fetch('/base/test/testfiles/templates/datypes.scd') + doc = await fetch('/test/testfiles/templates/datypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); templates.doc = doc; @@ -61,8 +63,8 @@ describe('EnumType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('allows to add empty EnumType to the project', async () => { @@ -123,8 +125,8 @@ describe('EnumType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('edits EnumType attributes id', async () => { expect(doc.querySelector('EnumType[id="Dummy_ctlModel"]')).to.exist; @@ -197,8 +199,8 @@ describe('EnumType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('edits EnumVal attributes ord', async () => { expect( @@ -296,8 +298,8 @@ describe('EnumType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('creates a new EnumVal element', async () => { expect( diff --git a/test/integration/editors/templates/lnodetype-wizard.test.ts b/test/integration/editors/templates/lnodetype-wizard.test.ts index f9fc3bcdc8..75fedac8e5 100644 --- a/test/integration/editors/templates/lnodetype-wizard.test.ts +++ b/test/integration/editors/templates/lnodetype-wizard.test.ts @@ -1,14 +1,16 @@ import { html, fixture, expect } from '@open-wc/testing'; -import TemplatesPlugin from '../../../../src/editors/Templates.js'; +import '../../../mock-wizard-editor.js'; import { MockWizardEditor } from '../../../mock-wizard-editor.js'; -import { Select } from '@material/mwc-select'; -import { WizardTextField } from '../../../../src/wizard-textfield.js'; -import { FilteredList } from '../../../../src/filtered-list.js'; import { ListItem } from '@material/mwc-list/mwc-list-item'; +import { Select } from '@material/mwc-select'; import { Switch } from '@material/mwc-switch'; +import { FilteredList } from '../../../../src/filtered-list.js'; +import TemplatesPlugin from '../../../../src/editors/Templates.js'; +import { WizardTextField } from '../../../../src/wizard-textfield.js'; + describe('LNodeType wizards', () => { if (customElements.get('templates-editor') === undefined) customElements.define('templates-editor', TemplatesPlugin); @@ -26,7 +28,7 @@ describe('LNodeType wizards', () => { templates = parent.querySelector('templates-editor')!; - doc = await fetch('/base/test/testfiles/templates/dotypes.scd') + doc = await fetch('/test/testfiles/templates/dotypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); templates.doc = doc; @@ -60,8 +62,8 @@ describe('LNodeType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('edits LNodeType attributes id', async () => { expect(doc.querySelector('LNodeType[id="Dummy.CSWI"]')).to.exist; @@ -119,8 +121,8 @@ describe('LNodeType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('recursively add missing! subsequent DOType elements', async () => { expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.not.exist; @@ -286,8 +288,8 @@ describe('LNodeType wizards', () => { spsId = sps?.getAttribute('id') ?? ''; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('filters the type selection for each DO to fit the cdc', () => { @@ -405,7 +407,7 @@ describe('LNodeType wizards', () => { }); it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + expect(parent.wizardUI.dialog).to; }); it('edits DO attributes name', async () => { expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')) @@ -522,8 +524,8 @@ describe('LNodeType wizards', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('creates a new DO element', async () => { expect( diff --git a/test/integration/editors/triggered/CommunicationMappingPlugin.test.ts b/test/integration/editors/triggered/CommunicationMappingPlugin.test.ts index 41e3b663d0..af7fe5dd32 100644 --- a/test/integration/editors/triggered/CommunicationMappingPlugin.test.ts +++ b/test/integration/editors/triggered/CommunicationMappingPlugin.test.ts @@ -10,7 +10,7 @@ describe('CommunicationMappingPlugin', () => { let element: ZerolinePane; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/comm-map.scd') + doc = await fetch('/test/testfiles/comm-map.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); diff --git a/test/integration/editors/triggered/ImportIedsPlugin.test.ts b/test/integration/editors/triggered/ImportIedsPlugin.test.ts index 998141b1be..a4c4ad7139 100644 --- a/test/integration/editors/triggered/ImportIedsPlugin.test.ts +++ b/test/integration/editors/triggered/ImportIedsPlugin.test.ts @@ -1,11 +1,14 @@ import { expect, fixture, html } from '@open-wc/testing'; -import ImportingIedPlugin from '../../../../src/menu/ImportIEDs.js'; +import '../../../mock-wizard-editor.js'; import { MockWizardEditor } from '../../../mock-wizard-editor.js'; -import { OpenSCD } from '../../../../src/open-scd.js'; import { CheckListItem } from '@material/mwc-list/mwc-check-list-item'; +import '../../../../src/open-scd.js'; +import ImportingIedPlugin from '../../../../src/menu/ImportIEDs.js'; +import { OpenSCD } from '../../../../src/open-scd.js'; + describe('ImportIedsPlugin', () => { customElements.define('import-ieds-plugin', ImportingIedPlugin); @@ -25,13 +28,13 @@ describe('ImportIedsPlugin', () => { element = parent.querySelector('import-ieds-plugin')!; - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element.doc = doc; await element.updateComplete; - importDoc = await fetch('/base/test/testfiles/importieds/valid.iid') + importDoc = await fetch('/test/testfiles/importieds/valid.iid') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); }); @@ -112,14 +115,14 @@ describe('ImportIedsPlugin', () => { expect(element.doc.querySelectorAll('IED').length).to.equal(3); const templateIED1 = await fetch( - '/base/test/testfiles/importieds/template.icd' + '/test/testfiles/importieds/template.icd' ) .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element.prepareImport(templateIED1, doc); const templateIED2 = await fetch( - '/base/test/testfiles/importieds/template.icd' + '/test/testfiles/importieds/template.icd' ) .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); @@ -130,7 +133,7 @@ describe('ImportIedsPlugin', () => { }); it('renders wizard for files containing more than one IED', async () => { const multipleIedDoc = await fetch( - '/base/test/testfiles/importieds/multipleied.scd' + '/test/testfiles/importieds/multipleied.scd' ) .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); @@ -145,7 +148,7 @@ describe('ImportIedsPlugin', () => { }); it('imports selected IED from Import IED wizard', async () => { const multipleIedDoc = await fetch( - '/base/test/testfiles/importieds/multipleied.scd' + '/test/testfiles/importieds/multipleied.scd' ) .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); @@ -184,7 +187,7 @@ describe('ImportIedsPlugin', () => { element = parent.querySelector('import-ieds-plugin')!; - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element.doc = doc; @@ -192,7 +195,7 @@ describe('ImportIedsPlugin', () => { }); it('throws missing ied elements error', async () => { - importDoc = await fetch('/base/test/testfiles/importieds/invalid.iid') + importDoc = await fetch('/test/testfiles/importieds/invalid.iid') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element.prepareImport(importDoc, doc); @@ -201,7 +204,7 @@ describe('ImportIedsPlugin', () => { expect(parent.history[0].title).to.equal('No IED element in the file'); }); it('throws duplicate ied name error', async () => { - importDoc = await fetch('/base/test/testfiles/importieds/dublicate.iid') + importDoc = await fetch('/test/testfiles/importieds/dublicate.iid') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element.prepareImport(importDoc, doc); @@ -212,7 +215,7 @@ describe('ImportIedsPlugin', () => { ); }); it('throws parser error', async () => { - importDoc = await fetch('/base/test/testfiles/importieds/parsererror.iid') + importDoc = await fetch('/test/testfiles/importieds/parsererror.iid') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element.prepareImport(importDoc, doc); diff --git a/test/integration/menu/NewProject.test.ts b/test/integration/menu/NewProject.test.ts index 3d7df4c5c0..b1e1d3147e 100644 --- a/test/integration/menu/NewProject.test.ts +++ b/test/integration/menu/NewProject.test.ts @@ -1,5 +1,6 @@ import { expect, fixture, html } from '@open-wc/testing'; +import '../../../src/open-scd.js'; import NewProjectPlugin from '../../../src/menu/NewProject.js'; import { OpenSCD } from '../../../src/open-scd.js'; @@ -12,9 +13,12 @@ describe('NewProject loader', () => { parent = await fixture(html` - - - + + + `); element = parent.querySelector('new-project-plugin')!; diff --git a/test/integration/menu/UpdateDescritionABB.test.ts b/test/integration/menu/UpdateDescritionABB.test.ts index cbd5c78d4f..cc5a7f0dc5 100644 --- a/test/integration/menu/UpdateDescritionABB.test.ts +++ b/test/integration/menu/UpdateDescritionABB.test.ts @@ -1,9 +1,10 @@ import { expect, fixture, html } from '@open-wc/testing'; import '../../mock-wizard-editor.js'; -import UpdateDescriptionAbb from '../../../src/menu/UpdateDescriptionABB.js'; import { MockWizardEditor } from '../../mock-wizard-editor.js'; +import UpdateDescriptionAbb from '../../../src/menu/UpdateDescriptionABB.js'; + describe('Update method for desc attributes in ABB IEDs', () => { if (customElements.get('update-description-abb') === undefined) customElements.define('update-description-abb', UpdateDescriptionAbb); @@ -13,7 +14,7 @@ describe('Update method for desc attributes in ABB IEDs', () => { let doc: XMLDocument; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/updatedesc/updatedescABB.scd') + doc = await fetch('/test/testfiles/updatedesc/updatedescABB.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); diff --git a/test/integration/open-scd.test.ts b/test/integration/open-scd.test.ts index 3bd706f30f..8f30eed1c1 100644 --- a/test/integration/open-scd.test.ts +++ b/test/integration/open-scd.test.ts @@ -1,8 +1,8 @@ import { html, fixture, expect } from '@open-wc/testing'; -import { OpenSCD } from '../../src/open-scd.js'; import '../../src/open-scd.js'; import { newEmptySCD } from '../../src/schemas.js'; +import { OpenSCD } from '../../src/open-scd.js'; describe('open-scd', () => { let element: OpenSCD; @@ -10,23 +10,26 @@ describe('open-scd', () => { let validSCL: string; beforeEach(async () => { - invalidSCL = await fetch('/base/test/testfiles/invalid2007B.scd').then( + invalidSCL = await fetch('/test/testfiles/invalid2007B.scd').then( response => response.text() ); - validSCL = await fetch('/base/test/testfiles/valid2007B4.scd').then( - response => response.text() + validSCL = await fetch('/test/testfiles/valid2007B4.scd').then(response => + response.text() ); element = await fixture(html` - - - + + + `); }); - it('looks like its snapshot', () => { - expect(element).shadowDom.to.equalSnapshot(); + it('looks like its snapshot', async () => { + await expect(element).shadowDom.to.equalSnapshot(); }); it('opens the menu on navigation icon click', async () => { diff --git a/test/integration/validators/ValidateSchema.test.ts b/test/integration/validators/ValidateSchema.test.ts index 9bbb21dff8..37bdaf3b66 100644 --- a/test/integration/validators/ValidateSchema.test.ts +++ b/test/integration/validators/ValidateSchema.test.ts @@ -1,12 +1,14 @@ import { expect, fixture, html } from '@open-wc/testing'; -import { IssueDetail, LogEntry } from '../../../src/foundation.js'; - +import '../../../src/open-scd.js'; import { OpenSCD } from '../../../src/open-scd.js'; import ValidateSchema from '../../../src/validators/ValidateSchema.js'; +import { IssueDetail, LogEntry } from '../../../src/foundation.js'; describe('ValidateSchema plugin', () => { - customElements.define('validate-schema', ValidateSchema); + if (customElements.get('') === undefined) + customElements.define('validate-schema', ValidateSchema); + let parent: OpenSCD; let element: ValidateSchema; @@ -15,7 +17,7 @@ describe('ValidateSchema plugin', () => { describe('for valid SCL files', () => { beforeEach(async () => { - valid2007B4 = await fetch('/base/test/testfiles/valid2007B.scd') + valid2007B4 = await fetch('/test/testfiles/valid2007B.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); @@ -41,7 +43,7 @@ describe('ValidateSchema plugin', () => { it('zeroissues indication looks like the latest snapshot', async () => { await parent.requestUpdate(); - expect(parent.diagnosticUI).to.equalSnapshot(); + await expect(parent.diagnosticUI).to.equalSnapshot(); }); it('indicates successful schema validation in the diagnoses pane', async () => { @@ -66,7 +68,7 @@ describe('ValidateSchema plugin', () => { describe('for invalid SCL files', () => { beforeEach(async () => { - invalid2007B = await fetch('/base/test/testfiles/invalid2007B.scd') + invalid2007B = await fetch('/test/testfiles/invalid2007B.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); @@ -104,7 +106,7 @@ describe('ValidateSchema plugin', () => { it('pushes issues to the diagnostics pane that look like the latest snapshot', async () => { await parent.requestUpdate(); - expect(parent.diagnosticUI).to.equalSnapshot(); + await expect(parent.diagnosticUI).to.equalSnapshot(); }); it('generates error messages in the log', async () => { diff --git a/test/integration/validators/ValidateTemplates.test.ts b/test/integration/validators/ValidateTemplates.test.ts index cf6b819e07..dc6a5474a4 100644 --- a/test/integration/validators/ValidateTemplates.test.ts +++ b/test/integration/validators/ValidateTemplates.test.ts @@ -1,10 +1,13 @@ import { expect, fixture, html } from '@open-wc/testing'; +import '../../../src/open-scd.js'; import { OpenSCD } from '../../../src/open-scd.js'; import ValidateTemplates from '../../../src/validators/ValidateTemplates.js'; describe('ValidateTemplates OpenSCD integration test ', () => { - customElements.define('validate-templates', ValidateTemplates); + if (customElements.get('validate-templates') === undefined) + customElements.define('validate-templates', ValidateTemplates); + let parent: OpenSCD; let element: ValidateTemplates; @@ -12,9 +15,7 @@ describe('ValidateTemplates OpenSCD integration test ', () => { describe('with issues in the DataTypeTemplates section', () => { beforeEach(async () => { - doc = await fetch( - '/base/test/testfiles/validators/datatypetemplateerrors.scd' - ) + doc = await fetch('/test/testfiles/validators/datatypetemplateerrors.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); @@ -44,12 +45,12 @@ describe('ValidateTemplates OpenSCD integration test ', () => { }).timeout(1000); it('pushes issues to the diagnostics pane that look like the latest snapshot', async () => { await parent.requestUpdate(); - expect(parent.diagnosticUI).to.equalSnapshot(); + await expect(parent.diagnosticUI).to.equalSnapshot(); }); }); describe('with schema version smaller "2007B3"', () => { beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B.scd') + doc = await fetch('/test/testfiles/valid2007B.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); @@ -79,7 +80,7 @@ describe('ValidateTemplates OpenSCD integration test ', () => { }).timeout(1000); it('pushes a specific issue to the diagnostics pane that look like the latest snapshot', async () => { await parent.requestUpdate(); - expect(parent.diagnosticUI).to.equalSnapshot(); + await expect(parent.diagnosticUI).to.equalSnapshot(); }); }); }); diff --git a/__snapshots__/ValidateSchema plugin.md b/test/integration/validators/__snapshots__/ValidateSchema.test.snap.js similarity index 79% rename from __snapshots__/ValidateSchema plugin.md rename to test/integration/validators/__snapshots__/ValidateSchema.test.snap.js index 068099e1a8..0a911c607c 100644 --- a/__snapshots__/ValidateSchema plugin.md +++ b/test/integration/validators/__snapshots__/ValidateSchema.test.snap.js @@ -1,11 +1,8 @@ -# `ValidateSchema plugin` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `for valid SCL files` - -#### `zeroissues indication looks like the latest snapshot` - -```html - @@ -35,15 +32,11 @@ Close +`; +/* end snapshot ValidateSchema plugin for valid SCL files zeroissues indication looks like the latest snapshot */ -``` - -## `for invalid SCL files` - -#### `pushes issues to the diagnostics pane that look like the latest snapshot` - -```html - @@ -104,6 +97,6 @@ invalid2007B:7 Substation key identity-constraint '{http://www.iec.ch/61850/2003 Close - -``` +`; +/* end snapshot ValidateSchema plugin for invalid SCL files pushes issues to the diagnostics pane that look like the latest snapshot */ diff --git a/__snapshots__/ValidateTemplates OpenSCD integration test .md b/test/integration/validators/__snapshots__/ValidateTemplates.test.snap.js similarity index 94% rename from __snapshots__/ValidateTemplates OpenSCD integration test .md rename to test/integration/validators/__snapshots__/ValidateTemplates.test.snap.js index a10021e027..4d0d6750bd 100644 --- a/__snapshots__/ValidateTemplates OpenSCD integration test .md +++ b/test/integration/validators/__snapshots__/ValidateTemplates.test.snap.js @@ -1,11 +1,8 @@ -# `ValidateTemplates OpenSCD integration test ` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `with issues in the DataTypeTemplates section` - -#### `pushes issues to the diagnostics pane that look like the latest snapshot` - -```html - @@ -482,15 +479,11 @@ Close +`; +/* end snapshot ValidateTemplates OpenSCD integration test with issues in the DataTypeTemplates section pushes issues to the diagnostics pane that look like the latest snapshot */ -``` - -## `with schema version smaller "2007B3"` - -#### `pushes a specific issue to the diagnostics pane that look like the latest snapshot` - -```html - @@ -533,6 +526,6 @@ Close - -``` +`; +/* end snapshot ValidateTemplates OpenSCD integration test with schema version smaller "2007B3" pushes a specific issue to the diagnostics pane that look like the latest snapshot */ diff --git a/__snapshots__/BDA wizarding editing integration.md b/test/integration/wizards/__snapshots__/bda-wizarding-editing.test.snap.js similarity index 94% rename from __snapshots__/BDA wizarding editing integration.md rename to test/integration/wizards/__snapshots__/bda-wizarding-editing.test.snap.js index 337f967156..f237f4577a 100644 --- a/__snapshots__/BDA wizarding editing integration.md +++ b/test/integration/wizards/__snapshots__/bda-wizarding-editing.test.snap.js @@ -1,26 +1,23 @@ -# `BDA wizarding editing integration` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `defines a editBDaWizard to edit an existing BDA` - -#### `looks like the latest snapshot` - -```html -
    @@ -363,7 +360,7 @@ @@ -609,7 +606,7 @@ @@ -626,29 +623,25 @@ +`; +/* end snapshot BDA wizarding editing integration defines a editBDaWizard to edit an existing BDA looks like the latest snapshot */ -``` - -## `defines a createBDaWizard to create a new BDA element` - -#### `looks like the latest snapshot` - -```html -
    @@ -988,7 +981,7 @@ @@ -1179,7 +1172,7 @@
    @@ -1187,12 +1180,12 @@
    - -``` +`; +/* end snapshot BDA wizarding editing integration defines a createBDaWizard to create a new BDA element looks like the latest snapshot */ diff --git a/__snapshots__/DA wizarding editing integration.md b/test/integration/wizards/__snapshots__/da-wizarding-editing.test.snap.js similarity index 95% rename from __snapshots__/DA wizarding editing integration.md rename to test/integration/wizards/__snapshots__/da-wizarding-editing.test.snap.js index f01c09241b..c866c561fb 100644 --- a/__snapshots__/DA wizarding editing integration.md +++ b/test/integration/wizards/__snapshots__/da-wizarding-editing.test.snap.js @@ -1,26 +1,23 @@ -# `DA wizarding editing integration` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `defines a editDaWizard to edit an existing DA` - -#### `looks like the latest snapshot` - -```html -
    @@ -363,7 +360,7 @@ @@ -653,7 +650,7 @@ @@ -789,7 +786,7 @@ @@ -878,29 +875,25 @@ +`; +/* end snapshot DA wizarding editing integration defines a editDaWizard to edit an existing DA looks like the latest snapshot */ -``` - -## `defines a createDaWizard to create a new DA element` - -#### `looks like the latest snapshot` - -```html -
    @@ -1240,7 +1233,7 @@ @@ -1595,7 +1588,7 @@ @@ -1684,12 +1677,12 @@ - -``` +`; +/* end snapshot DA wizarding editing integration defines a createDaWizard to create a new DA element looks like the latest snapshot */ diff --git a/test/integration/wizards/bda-wizarding-editing.test.ts b/test/integration/wizards/bda-wizarding-editing.test.ts index c9688c63e0..8a28979cdf 100644 --- a/test/integration/wizards/bda-wizarding-editing.test.ts +++ b/test/integration/wizards/bda-wizarding-editing.test.ts @@ -1,13 +1,14 @@ import { html, fixture, expect } from '@open-wc/testing'; -import TemplatesPlugin from '../../../src/editors/Templates.js'; +import '../../mock-wizard-editor.js'; import { MockWizardEditor } from '../../mock-wizard-editor.js'; -import { Select } from '@material/mwc-select'; -import { WizardTextField } from '../../../src/wizard-textfield.js'; -import { FilteredList } from '../../../src/filtered-list.js'; import { ListItem } from '@material/mwc-list/mwc-list-item'; + +import { FilteredList } from '../../../src/filtered-list.js'; import { WizardSelect } from '../../../src/wizard-select.js'; +import { WizardTextField } from '../../../src/wizard-textfield.js'; +import TemplatesPlugin from '../../../src/editors/Templates.js'; describe('BDA wizarding editing integration', () => { if (customElements.get('templates-editor') === undefined) @@ -26,7 +27,7 @@ describe('BDA wizarding editing integration', () => { templates = parent.querySelector('templates-editor')!; - doc = await fetch('/base/test/testfiles/templates/datypes.scd') + doc = await fetch('/test/testfiles/templates/datypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); templates.doc = doc; @@ -68,8 +69,8 @@ describe('BDA wizarding editing integration', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('edits BDA element', async () => { expect( @@ -162,8 +163,8 @@ describe('BDA wizarding editing integration', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('creates a new BDA element', async () => { expect( diff --git a/test/integration/wizards/da-wizarding-editing.test.ts b/test/integration/wizards/da-wizarding-editing.test.ts index c113507f43..a2d4a7cf5f 100644 --- a/test/integration/wizards/da-wizarding-editing.test.ts +++ b/test/integration/wizards/da-wizarding-editing.test.ts @@ -1,13 +1,13 @@ import { html, fixture, expect } from '@open-wc/testing'; -import TemplatesPlugin from '../../../src/editors/Templates.js'; +import '../../mock-wizard-editor.js'; import { MockWizardEditor } from '../../mock-wizard-editor.js'; -import { Select } from '@material/mwc-select'; -import { WizardTextField } from '../../../src/wizard-textfield.js'; import { FilteredList } from '../../../src/filtered-list.js'; import { ListItem } from '@material/mwc-list/mwc-list-item'; +import TemplatesPlugin from '../../../src/editors/Templates.js'; import { WizardSelect } from '../../../src/wizard-select.js'; +import { WizardTextField } from '../../../src/wizard-textfield.js'; describe('DA wizarding editing integration', () => { if (customElements.get('templates-editor') === undefined) @@ -26,7 +26,7 @@ describe('DA wizarding editing integration', () => { templates = parent.querySelector('templates-editor')!; - doc = await fetch('/base/test/testfiles/templates/dotypes.scd') + doc = await fetch('/test/testfiles/templates/dotypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); templates.doc = doc; @@ -68,8 +68,8 @@ describe('DA wizarding editing integration', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('edits DA attributes name', async () => { expect( @@ -174,8 +174,8 @@ describe('DA wizarding editing integration', () => { ); }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('creates a new DA element', async () => { expect( diff --git a/test/integration/wizards/dataset-wizarding-editing-integration.test.ts b/test/integration/wizards/dataset-wizarding-editing-integration.test.ts index 4256d167c6..80a23a24c8 100644 --- a/test/integration/wizards/dataset-wizarding-editing-integration.test.ts +++ b/test/integration/wizards/dataset-wizarding-editing-integration.test.ts @@ -1,8 +1,10 @@ import { expect, fixture, html } from '@open-wc/testing'; +import '../../mock-wizard-editor.js'; +import { MockWizardEditor } from '../../mock-wizard-editor.js'; + import { WizardTextField } from '../../../src/wizard-textfield.js'; import { editDataSetWizard } from '../../../src/wizards/dataset.js'; -import { MockWizardEditor } from '../../mock-wizard-editor.js'; describe('dataset wizards', () => { let doc: XMLDocument; @@ -10,7 +12,7 @@ describe('dataset wizards', () => { beforeEach(async () => { element = await fixture(html``); - doc = await fetch('/base/test/testfiles/wizards/gsecontrol.scd') + doc = await fetch('/test/testfiles/wizards/gsecontrol.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); }); diff --git a/test/integration/wizards/fcda-wizarding-editing-integration.test.ts b/test/integration/wizards/fcda-wizarding-editing-integration.test.ts index 7383054d8b..1ee858ba2f 100644 --- a/test/integration/wizards/fcda-wizarding-editing-integration.test.ts +++ b/test/integration/wizards/fcda-wizarding-editing-integration.test.ts @@ -1,9 +1,10 @@ import { expect, fixture, html } from '@open-wc/testing'; -import { FinderList } from '../../../src/finder-list.js'; +import '../../mock-wizard-editor.js'; import { MockWizardEditor } from '../../mock-wizard-editor.js'; import { createFCDAsWizard } from '../../../src/wizards/fcda.js'; +import { FinderList } from '../../../src/finder-list.js'; describe('FCDA editing wizarding integration', () => { let doc: XMLDocument; @@ -13,7 +14,7 @@ describe('FCDA editing wizarding integration', () => { beforeEach(async () => { element = await fixture(html``); - doc = await fetch('/base/test/testfiles/wizards/fcda.scd') + doc = await fetch('/test/testfiles/wizards/fcda.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); diff --git a/test/integration/wizards/gse-wizarding-editing-integration.test.ts b/test/integration/wizards/gse-wizarding-editing-integration.test.ts index 0aeac1ab5e..c6e8e370d6 100644 --- a/test/integration/wizards/gse-wizarding-editing-integration.test.ts +++ b/test/integration/wizards/gse-wizarding-editing-integration.test.ts @@ -1,15 +1,18 @@ import { expect, fixture, html } from '@open-wc/testing'; -import { WizardTextField } from '../../../src/wizard-textfield.js'; -import { editGseWizard } from '../../../src/wizards/gse.js'; + +import '../../mock-wizard-editor.js'; import { MockWizardEditor } from '../../mock-wizard-editor.js'; +import { editGseWizard } from '../../../src/wizards/gse.js'; +import { WizardTextField } from '../../../src/wizard-textfield.js'; + describe('gse wizarding editing integration', () => { let doc: XMLDocument; let element: MockWizardEditor; beforeEach(async () => { element = await fixture(html``); - doc = await fetch('/base/test/testfiles/wizards/gsecontrol.scd') + doc = await fetch('/test/testfiles/wizards/gsecontrol.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); }); diff --git a/test/integration/wizards/gsecontrolwizarding-editing.test.ts b/test/integration/wizards/gsecontrolwizarding-editing.test.ts index e445dabc4e..ecd8c9c8de 100644 --- a/test/integration/wizards/gsecontrolwizarding-editing.test.ts +++ b/test/integration/wizards/gsecontrolwizarding-editing.test.ts @@ -1,14 +1,17 @@ +import { expect, fixture, html } from '@open-wc/testing'; + +import '../../mock-wizard-editor.js'; +import { MockWizardEditor } from '../../mock-wizard-editor.js'; + import { Button } from '@material/mwc-button'; import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; -import { expect, fixture, html } from '@open-wc/testing'; -import { FilteredList } from '../../../src/filtered-list.js'; -import { WizardTextField } from '../../../src/wizard-textfield.js'; import { editGseControlWizard, selectGseControlWizard, } from '../../../src/wizards/gsecontrol.js'; -import { MockWizardEditor } from '../../mock-wizard-editor.js'; +import { FilteredList } from '../../../src/filtered-list.js'; +import { WizardTextField } from '../../../src/wizard-textfield.js'; describe('gsecontrol wizarding editing integration', () => { let doc: XMLDocument; @@ -16,7 +19,7 @@ describe('gsecontrol wizarding editing integration', () => { beforeEach(async () => { element = await fixture(html``); - doc = await fetch('/base/test/testfiles/wizards/gsecontrol.scd') + doc = await fetch('/test/testfiles/wizards/gsecontrol.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); }); diff --git a/test/integration/zeroline-pane.test.ts b/test/integration/zeroline-pane.test.ts index 08b19bcfdc..aa60104a52 100644 --- a/test/integration/zeroline-pane.test.ts +++ b/test/integration/zeroline-pane.test.ts @@ -1,12 +1,13 @@ import { expect, fixture, html } from '@open-wc/testing'; +import '../mock-wizard-editor.js'; import { MockWizardEditor } from '../mock-wizard-editor.js'; +import { IconButton } from '@material/mwc-icon-button'; + +import '../../src/zeroline-pane.js'; import { FilteredList } from '../../src/filtered-list.js'; import { ZerolinePane } from '../../src/zeroline-pane.js'; - -import { IconButton } from '@material/mwc-icon-button'; -import { TextField } from '@material/mwc-textfield'; import { WizardTextField } from '../../src/wizard-textfield.js'; describe('zeroline-pane wizarding editing integration', () => { @@ -15,7 +16,7 @@ describe('zeroline-pane wizarding editing integration', () => { let zeroline: ZerolinePane; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/comm-map.scd') + doc = await fetch('/test/testfiles/comm-map.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); diff --git a/__snapshots__/substation-editor wizarding integration.md b/test/integration/zeroline/__snapshots__/bay-editor-wizarding.test.snap.js similarity index 55% rename from __snapshots__/substation-editor wizarding integration.md rename to test/integration/zeroline/__snapshots__/bay-editor-wizarding.test.snap.js index 0bf4375381..4738702beb 100644 --- a/__snapshots__/substation-editor wizarding integration.md +++ b/test/integration/zeroline/__snapshots__/bay-editor-wizarding.test.snap.js @@ -1,24 +1,23 @@ -# `substation-editor wizarding integration` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -#### `looks like the latest snapshot` - -```html -
    @@ -26,7 +25,7 @@
    @@ -34,12 +33,12 @@
    - -``` +`; +/* end snapshot bay-editor wizarding integration looks like the latest snapshot */ diff --git a/__snapshots__/conducting-equipment-editor wizarding integration.md b/test/integration/zeroline/__snapshots__/conducting-equipment-editor-wizarding.test.snap.js similarity index 56% rename from __snapshots__/conducting-equipment-editor wizarding integration.md rename to test/integration/zeroline/__snapshots__/conducting-equipment-editor-wizarding.test.snap.js index afa295bc53..80d1ac9875 100644 --- a/__snapshots__/conducting-equipment-editor wizarding integration.md +++ b/test/integration/zeroline/__snapshots__/conducting-equipment-editor-wizarding.test.snap.js @@ -1,19 +1,18 @@ -# `conducting-equipment-editor wizarding integration` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -#### `looks like the latest snapshot` - -```html -
    @@ -42,7 +41,7 @@
    @@ -50,12 +49,12 @@
    - -``` +`; +/* end snapshot conducting-equipment-editor wizarding integration looks like the latest snapshot */ diff --git a/__snapshots__/bay-editor wizarding integration.md b/test/integration/zeroline/__snapshots__/substation-editor-wizarding.test.snap.js similarity index 53% rename from __snapshots__/bay-editor wizarding integration.md rename to test/integration/zeroline/__snapshots__/substation-editor-wizarding.test.snap.js index 69efe2104a..8d09bdfc93 100644 --- a/__snapshots__/bay-editor wizarding integration.md +++ b/test/integration/zeroline/__snapshots__/substation-editor-wizarding.test.snap.js @@ -1,24 +1,23 @@ -# `bay-editor wizarding integration` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -#### `looks like the latest snapshot` - -```html -
    @@ -26,7 +25,7 @@
    @@ -34,12 +33,12 @@
    - -``` +`; +/* end snapshot substation-editor wizarding integration looks like the latest snapshot */ diff --git a/__snapshots__/voltage-level-editor wizarding integration.md b/test/integration/zeroline/__snapshots__/voltage-level-editor-wizarding.test.snap.js similarity index 52% rename from __snapshots__/voltage-level-editor wizarding integration.md rename to test/integration/zeroline/__snapshots__/voltage-level-editor-wizarding.test.snap.js index 1aea3e20b0..c416a02c52 100644 --- a/__snapshots__/voltage-level-editor wizarding integration.md +++ b/test/integration/zeroline/__snapshots__/voltage-level-editor-wizarding.test.snap.js @@ -1,40 +1,39 @@ -# `voltage-level-editor wizarding integration` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -#### `looks like the latest snapshot` - -```html -
    @@ -66,12 +65,12 @@
    - -``` +`; +/* end snapshot voltage-level-editor wizarding integration looks like the latest snapshot */ diff --git a/test/integration/zeroline/bay-editor-wizarding-editing.test.ts b/test/integration/zeroline/bay-editor-wizarding-editing.test.ts index 15dd06e436..50c586a9ba 100644 --- a/test/integration/zeroline/bay-editor-wizarding-editing.test.ts +++ b/test/integration/zeroline/bay-editor-wizarding-editing.test.ts @@ -1,17 +1,17 @@ import { fixture, html, expect } from '@open-wc/testing'; import '../../mock-wizard-editor.js'; +import { MockWizardEditor } from '../../mock-wizard-editor.js'; +import '../../../src/zeroline/bay-editor.js'; import { BayEditor } from '../../../src/zeroline/bay-editor.js'; -import { EditingElement } from '../../../src/Editing.js'; import { Select } from '@material/mwc-select'; -import { WizardingElement } from '../../../src/Wizarding.js'; import { WizardTextField } from '../../../src/wizard-textfield.js'; describe('bay-editor wizarding editing integration', () => { describe('edit wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: BayEditor | null; let nameField: WizardTextField; @@ -20,10 +20,10 @@ describe('bay-editor wizarding editing integration', () => { let primaryAction: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { describe('open add conducting equipment wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: BayEditor | null; let nameField: WizardTextField; @@ -101,10 +101,10 @@ describe('bay-editor wizarding editing integration', () => { let primaryAction: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('open lnode wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: BayEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('move action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: BayEditor | null; let element2: BayEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html`${Array.from(doc?.querySelectorAll('Bay') ?? []).map( @@ -228,14 +228,14 @@ describe('bay-editor wizarding editing integration', () => { }); describe('remove action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: BayEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('clone action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: BayEditor | null; let copyContentButton: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { )).click(); await parent.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); describe('the first input element', () => { it('edits the attribute name', async () => { diff --git a/test/integration/zeroline/conducting-equipment-editor-wizarding-editing.test.ts b/test/integration/zeroline/conducting-equipment-editor-wizarding-editing.test.ts index 930181cfa0..7d27a349c9 100644 --- a/test/integration/zeroline/conducting-equipment-editor-wizarding-editing.test.ts +++ b/test/integration/zeroline/conducting-equipment-editor-wizarding-editing.test.ts @@ -1,15 +1,16 @@ import { fixture, html, expect } from '@open-wc/testing'; import '../../mock-wizard-editor.js'; -import { EditingElement } from '../../../src/Editing.js'; -import { WizardingElement } from '../../../src/Wizarding.js'; -import { WizardTextField } from '../../../src/wizard-textfield.js'; +import { MockWizardEditor } from '../../mock-wizard-editor.js'; + +import '../../../src/zeroline/conducting-equipment-editor.js'; import { ConductingEquipmentEditor } from '../../../src/zeroline/conducting-equipment-editor.js'; +import { WizardTextField } from '../../../src/wizard-textfield.js'; describe('conducting-equipment-editor wizarding editing integration', () => { describe('edit wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: ConductingEquipmentEditor | null; let nameField: WizardTextField; @@ -18,10 +19,10 @@ describe('conducting-equipment-editor wizarding editing integration', () => { let primaryAction: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('open lnode wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: ConductingEquipmentEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('move action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: ConductingEquipmentEditor | null; let element2: ConductingEquipmentEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html`${Array.from( @@ -177,14 +178,14 @@ describe('conducting-equipment-editor wizarding editing integration', () => { }); describe('remove action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: ConductingEquipmentEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { )).click(); await parent.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); it('the first input element only displaying the type', () => { expect(parent.wizardUI.inputs[0]).to.have.property('disabled', true); diff --git a/test/integration/zeroline/substation-editor-wizarding-editing.test.ts b/test/integration/zeroline/substation-editor-wizarding-editing.test.ts index 23f97ab81a..d7eafbcab3 100644 --- a/test/integration/zeroline/substation-editor-wizarding-editing.test.ts +++ b/test/integration/zeroline/substation-editor-wizarding-editing.test.ts @@ -1,15 +1,16 @@ import { fixture, html, expect } from '@open-wc/testing'; import '../../mock-wizard-editor.js'; -import { EditingElement } from '../../../src/Editing.js'; +import { MockWizardEditor } from '../../mock-wizard-editor.js'; + +import '../../../src/zeroline/substation-editor.js'; import { SubstationEditor } from '../../../src/zeroline/substation-editor.js'; -import { WizardingElement } from '../../../src/Wizarding.js'; import { WizardTextField } from '../../../src/wizard-textfield.js'; describe('substation-editor wizarding editing integration', () => { describe('edit wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: SubstationEditor | null; let nameField: WizardTextField; @@ -18,10 +19,10 @@ describe('substation-editor wizarding editing integration', () => { let primaryAction: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('open add voltage level wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: SubstationEditor | null; let nameField: WizardTextField; let primaryAction: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('open lnode wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: SubstationEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('remove action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: SubstationEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { )).click(); await parent.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); describe('the first input element', () => { it('edits the attribute name', async () => { diff --git a/test/integration/zeroline/voltage-level-editor-wizarding-editing.test.ts b/test/integration/zeroline/voltage-level-editor-wizarding-editing.test.ts index bb09ceff18..a578d17c8f 100644 --- a/test/integration/zeroline/voltage-level-editor-wizarding-editing.test.ts +++ b/test/integration/zeroline/voltage-level-editor-wizarding-editing.test.ts @@ -1,16 +1,16 @@ import { fixture, html, expect } from '@open-wc/testing'; import '../../mock-wizard-editor.js'; +import { MockWizardEditor } from '../../mock-wizard-editor.js'; -import { EditingElement } from '../../../src/Editing.js'; +import '../../../src/zeroline/voltage-level-editor.js'; import { VoltageLevelEditor } from '../../../src/zeroline/voltage-level-editor.js'; -import { WizardingElement } from '../../../src/Wizarding.js'; import { WizardTextField } from '../../../src/wizard-textfield.js'; describe('voltage-level-editor wizarding editing integration', () => { describe('edit wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: VoltageLevelEditor | null; let nameField: WizardTextField; @@ -22,10 +22,10 @@ describe('voltage-level-editor wizarding editing integration', () => { let primaryAction: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('open add bay wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: VoltageLevelEditor | null; let nameField: WizardTextField; let primaryAction: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('open lnode wizard', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: VoltageLevelEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('move action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: VoltageLevelEditor | null; let element2: VoltageLevelEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html`${Array.from(doc?.querySelectorAll('VoltageLevel') ?? []).map( @@ -305,14 +305,14 @@ describe('voltage-level-editor wizarding editing integration', () => { }); describe('remove action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: VoltageLevelEditor | null; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { }); describe('clone action', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockWizardEditor; let element: VoltageLevelEditor | null; let copyContentButton: HTMLElement; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { let doc: XMLDocument; - let parent: WizardingElement; + let parent: MockWizard; beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( + parent = ( await fixture( html` { )).click(); await parent.updateComplete; }); - it('looks like the latest snapshot', () => { - expect(parent.wizardUI.dialog).to.equalSnapshot(); + it('looks like the latest snapshot', async () => { + await expect(parent.wizardUI.dialog).to.equalSnapshot(); }); describe('the first input element', () => { it('edits the attribute name', async () => { diff --git a/test/unit/Editing.test.ts b/test/unit/Editing.test.ts index 56c722a2b3..83195c9042 100644 --- a/test/unit/Editing.test.ts +++ b/test/unit/Editing.test.ts @@ -1,21 +1,21 @@ import { html, fixture, expect } from '@open-wc/testing'; -import { EditingElement } from '../../src/Editing.js'; -import { newActionEvent } from '../../src/foundation.js'; - import './mock-editor.js'; +import { MockEditor } from './mock-editor.js'; + +import { newActionEvent } from '../../src/foundation.js'; describe('EditingElement', () => { - let elm: EditingElement; + let elm: MockEditor; let parent: Element; let element: Element; let reference: Node | null; beforeEach(async () => { - const doc = await fetch('/base/test/testfiles/Editing.scd') + const doc = await fetch('/test/testfiles/Editing.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - elm = ( + elm = ( await fixture(html``) ); diff --git a/test/unit/Logging.test.ts b/test/unit/Logging.test.ts index 81137a409e..4a1623a557 100644 --- a/test/unit/Logging.test.ts +++ b/test/unit/Logging.test.ts @@ -1,6 +1,9 @@ import { expect, fixture, html } from '@open-wc/testing'; -import { LoggingElement } from '../../src/Logging.js'; +import './mock-logger.js'; +import { MockAction } from './mock-actions.js'; +import { MockLogger } from './mock-logger.js'; + import { CommitEntry, newIssueEvent, @@ -8,13 +11,10 @@ import { newOpenDocEvent, } from '../../src/foundation.js'; -import { MockAction } from './mock-actions.js'; -import './mock-logger.js'; - describe('LoggingElement', () => { - let element: LoggingElement; + let element: MockLogger; beforeEach(async () => { - element = await fixture(html``); + element = await fixture(html``); }); it('starts out with an empty history', () => @@ -220,7 +220,7 @@ describe('LoggingElement', () => { describe('when loading file with history items', () => { beforeEach(async () => { - const doc = await fetch('/base/test/testfiles/history.scd') + const doc = await fetch('/test/testfiles/history.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); diff --git a/test/unit/Plugging.test.ts b/test/unit/Plugging.test.ts index 5e2c6a3ae3..f864126e0f 100644 --- a/test/unit/Plugging.test.ts +++ b/test/unit/Plugging.test.ts @@ -1,20 +1,20 @@ import { expect, fixture, html } from '@open-wc/testing'; -import { PluggingElement } from '../../src/Plugging.js'; - import './mock-plugger.js'; +import { MockPlugger } from './mock-plugger.js'; + import { TextField } from '@material/mwc-textfield'; describe('PluggingElement', () => { - let element: PluggingElement; + let element: MockPlugger; let doc: XMLDocument; afterEach(() => localStorage.clear()); beforeEach(async () => { - doc = await fetch('/base/test/testfiles/valid2007B4.scd') + doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - element = ( + element = ( await fixture( html`` ) diff --git a/test/unit/Setting.test.ts b/test/unit/Setting.test.ts index ba5eb4fedb..6747157944 100644 --- a/test/unit/Setting.test.ts +++ b/test/unit/Setting.test.ts @@ -1,17 +1,19 @@ +import { registerTranslateConfig, use } from 'lit-translate'; + import { html, fixture, expect } from '@open-wc/testing'; -import { registerTranslateConfig, use } from 'lit-translate'; +import './mock-setter.js'; +import { MockSetter } from './mock-setter.js'; import { Button } from '@material/mwc-button'; -import { SettingElement, defaults } from '../../src/Setting.js'; -import './mock-setter.js'; +import { defaults } from '../../src/Setting.js'; describe('SettingElement', () => { - let element: SettingElement; + let element: MockSetter; beforeEach(async () => { localStorage.clear(); - element = await fixture(html``); + element = await fixture(html``); }); it('initially has default settings', () => diff --git a/test/unit/Waiting.test.ts b/test/unit/Waiting.test.ts index ef865a1e77..ddc0240587 100644 --- a/test/unit/Waiting.test.ts +++ b/test/unit/Waiting.test.ts @@ -1,14 +1,14 @@ import { html, fixture, expect } from '@open-wc/testing'; -import { newPendingStateEvent } from '../../src/foundation.js'; -import { WaitingElement } from '../../src/Waiting.js'; - import './mock-waiter.js'; +import { MockWaiter } from './mock-waiter.js'; + +import { newPendingStateEvent } from '../../src/foundation.js'; describe('WaitingElement', () => { - let element: WaitingElement; + let element: MockWaiter; beforeEach(async () => { - element = await fixture(html``); + element = await fixture(html``); }); it('does not wait for pending state initially', () => diff --git a/test/unit/Wizarding.test.ts b/test/unit/Wizarding.test.ts index 76660b5615..556819d31f 100644 --- a/test/unit/Wizarding.test.ts +++ b/test/unit/Wizarding.test.ts @@ -1,10 +1,10 @@ import { expect, fixture, html } from '@open-wc/testing'; +import '../mock-wizard.js'; + import { newWizardEvent } from '../../src/foundation.js'; import { WizardingElement } from '../../src/Wizarding.js'; -import '../mock-wizard.js'; - describe('WizardingElement', () => { let element: WizardingElement; beforeEach(async () => { @@ -16,7 +16,8 @@ describe('WizardingElement', () => { it('starts out with an empty workflow', () => expect(element).property('workflow').to.be.empty); - it('shows no wizard-dialog', () => expect(element).shadowDom.to.be.empty); + it('shows no wizard-dialog', async () => + await expect(element).shadowDom.to.be.empty); it('adds a wizard to the workflow on non-null WizardEvent', () => { element.dispatchEvent(newWizardEvent([{ title: 'Test Page 1' }])); diff --git a/__snapshots__/action-pane.md b/test/unit/__snapshots__/action-pane.test.snap.js similarity index 53% rename from __snapshots__/action-pane.md rename to test/unit/__snapshots__/action-pane.test.snap.js index 232e04a63b..374f7295dd 100644 --- a/__snapshots__/action-pane.md +++ b/test/unit/__snapshots__/action-pane.test.snap.js @@ -1,9 +1,8 @@ -# `action-pane` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -#### `looks like the latest snapshot` - -```html -
    +snapshots["action-pane looks like the latest snapshot"] = +`

    @@ -19,15 +18,11 @@

    +`; +/* end snapshot action-pane looks like the latest snapshot */ -``` - -## `with icon property set` - -#### `looks like the latest snapshot` - -```html -
    +snapshots["action-pane with icon property set looks like the latest snapshot"] = +`

    @@ -46,6 +41,6 @@

    - -``` +`; +/* end snapshot action-pane with icon property set looks like the latest snapshot */ diff --git a/__snapshots__/filtered-list.md b/test/unit/__snapshots__/filtered-list.test.snap.js similarity index 59% rename from __snapshots__/filtered-list.md rename to test/unit/__snapshots__/filtered-list.test.snap.js index d58f5cf1f0..18ad1a4f12 100644 --- a/__snapshots__/filtered-list.md +++ b/test/unit/__snapshots__/filtered-list.test.snap.js @@ -1,9 +1,8 @@ -# `filtered-list` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -#### `looks like its latest snapshot` - -```html -
    +snapshots["filtered-list looks like its latest snapshot"] = +`
    - -``` +`; +/* end snapshot filtered-list looks like its latest snapshot */ diff --git a/__snapshots__/finder-list.md b/test/unit/__snapshots__/finder-list.test.snap.js similarity index 83% rename from __snapshots__/finder-list.md rename to test/unit/__snapshots__/finder-list.test.snap.js index a7cb9f5b8f..1d0704d0d5 100644 --- a/__snapshots__/finder-list.md +++ b/test/unit/__snapshots__/finder-list.test.snap.js @@ -1,13 +1,8 @@ -# `finder-list` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -## `given a .path and a .read method` - -## `when provided with .getTitle and .getDisplayString methods` - -#### `looks like its latest snapshot` - -```html -
    +snapshots["finder-list given a .path and a .read method when provided with .getTitle and .getDisplayString methods looks like its latest snapshot"] = +`

    e2 @@ -88,15 +83,11 @@

    +`; +/* end snapshot finder-list given a .path and a .read method when provided with .getTitle and .getDisplayString methods looks like its latest snapshot */ -``` - -## `when an item in the last column is selected` - -#### `looks like its latest snapshot` - -```html -
    +snapshots["finder-list given a .path and a .read method when an item in the last column is selected looks like its latest snapshot"] = +`

    e2 @@ -209,15 +200,11 @@

    +`; +/* end snapshot finder-list given a .path and a .read method when an item in the last column is selected looks like its latest snapshot */ -``` - -## `when an item in the first column is selected` - -#### `looks like its latest snapshot` - -```html -
    +snapshots["finder-list given a .path and a .read method when an item in the first column is selected looks like its latest snapshot"] = +`

    e2 @@ -250,15 +237,11 @@

    +`; +/* end snapshot finder-list given a .path and a .read method when an item in the first column is selected looks like its latest snapshot */ -``` - -## `when the selected item in the first column is deselected` - -#### `looks like its latest snapshot` - -```html -
    +snapshots["finder-list given a .path and a .read method when the selected item in the first column is deselected looks like its latest snapshot"] = +`

    e2 @@ -283,15 +266,11 @@

    +`; +/* end snapshot finder-list given a .path and a .read method when the selected item in the first column is deselected looks like its latest snapshot */ -``` - -## `given the "multi" attribute, some .paths, and a .read method` - -#### `looks like its latest snapshot` - -```html -
    +snapshots["finder-list given the \"multi\" attribute, some .paths, and a .read method looks like its latest snapshot"] = +`

    e2 @@ -428,15 +407,11 @@

    +`; +/* end snapshot finder-list given the "multi" attribute, some .paths, and a .read method looks like its latest snapshot */ -``` - -## `when an item in the first column is selected` - -#### `looks like its latest snapshot` - -```html -
    +snapshots["finder-list given the \"multi\" attribute, some .paths, and a .read method when an item in the first column is selected looks like its latest snapshot"] = +`

    e2 @@ -579,15 +554,11 @@

    +`; +/* end snapshot finder-list given the "multi" attribute, some .paths, and a .read method when an item in the first column is selected looks like its latest snapshot */ -``` - -## `when a selected item in the first column is deselected` - -#### `looks like its latest snapshot` - -```html -
    +snapshots["finder-list given the \"multi\" attribute, some .paths, and a .read method when a selected item in the first column is deselected looks like its latest snapshot"] = +`

    e2 @@ -670,6 +641,6 @@

    - -``` +`; +/* end snapshot finder-list given the "multi" attribute, some .paths, and a .read method when a selected item in the first column is deselected looks like its latest snapshot */ diff --git a/test/unit/__snapshots__/wizard-dialog.test.snap.js b/test/unit/__snapshots__/wizard-dialog.test.snap.js new file mode 100644 index 0000000000..877ecc970c --- /dev/null +++ b/test/unit/__snapshots__/wizard-dialog.test.snap.js @@ -0,0 +1,15 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["wizard-dialog with a nonempty wizard property in pro mode looks like its snapshot"] = +` + +`; +/* end snapshot wizard-dialog with a nonempty wizard property in pro mode looks like its snapshot */ + +snapshots["wizard-dialog with a nonempty wizard property in pro mode switches to code editor view on code toggle button click"] = +` + +`; +/* end snapshot wizard-dialog with a nonempty wizard property in pro mode switches to code editor view on code toggle button click */ + diff --git a/__snapshots__/zeroline-pane.md b/test/unit/__snapshots__/zeroline-pane.test.snap.js similarity index 78% rename from __snapshots__/zeroline-pane.md rename to test/unit/__snapshots__/zeroline-pane.test.snap.js index ac4841d37a..cfd01e8703 100644 --- a/__snapshots__/zeroline-pane.md +++ b/test/unit/__snapshots__/zeroline-pane.test.snap.js @@ -1,9 +1,8 @@ -# `zeroline-pane` +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; -#### `per default looks like the latest snapshot` - -```html -

    +snapshots["zeroline-pane per default looks like the latest snapshot"] = +`

    +`; +/* end snapshot zeroline-pane per default looks like the latest snapshot */ -``` - -#### `readonly looks like the latest snapshot` - -```html -

    +snapshots["zeroline-pane readonly looks like the latest snapshot"] = +`