From e2362043aedc3045c78d7a29c141ffe6e8ca0db1 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Mon, 12 Feb 2024 16:21:19 +0100 Subject: [PATCH 01/27] Feat: Added Waiter addon --- packages/open-scd/.eslintrc.cjs | 23 + packages/open-scd/src/addons/Waiter.ts | 45 + packages/open-scd/src/open-scd.ts | 15 +- .../src/wizards/foundation/references.ts | 2 +- .../__snapshots__/open-scd.test.snap.js | 2649 ++++++++--------- .../test/integration/open-scd.test.ts | 11 +- packages/open-scd/test/unit/Plugging.test.ts | 2 +- packages/open-scd/test/unit/Waiting.test.ts | 11 +- packages/open-scd/test/unit/mock-waiter.ts | 5 - 9 files changed, 1419 insertions(+), 1344 deletions(-) create mode 100644 packages/open-scd/.eslintrc.cjs create mode 100644 packages/open-scd/src/addons/Waiter.ts delete mode 100644 packages/open-scd/test/unit/mock-waiter.ts diff --git a/packages/open-scd/.eslintrc.cjs b/packages/open-scd/.eslintrc.cjs new file mode 100644 index 0000000000..6cae923ce6 --- /dev/null +++ b/packages/open-scd/.eslintrc.cjs @@ -0,0 +1,23 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc', 'import', 'html'], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:import/errors', + 'plugin:import/warnings', + ], + rules: { + // disable the rule for all files + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + 'import/named': 'off', + 'import/no-unresolved': 'off', + 'import/extensions': ['error', 'always', { ignorePackages: true }], + 'import/no-duplicates': 'off', + 'no-duplicate-imports': 'off', + 'tsdoc/syntax': 'warn' + }, +}; diff --git a/packages/open-scd/src/addons/Waiter.ts b/packages/open-scd/src/addons/Waiter.ts new file mode 100644 index 0000000000..7297cc4dab --- /dev/null +++ b/packages/open-scd/src/addons/Waiter.ts @@ -0,0 +1,45 @@ +import { + customElement, + html, + LitElement, + property, + TemplateResult, +} from 'lit-element'; + +import '@material/mwc-linear-progress'; + +import { PendingStateDetail } from '../foundation.js'; + +@customElement('oscd-waiter') +export class OscdWaiter extends LitElement { + /** Whether the element is currently waiting for some async work. */ + @property({ type: Boolean }) + waiting = false; + + private work: Set> = new Set(); + /** A promise which resolves once all currently pending work is done. */ + workDone = Promise.allSettled(this.work); + + private async onPendingState(e: CustomEvent) { + this.waiting = true; + this.work.add(e.detail.promise); + this.workDone = Promise.allSettled(this.work); + await e.detail.promise.catch(reason => console.warn(reason)); + this.work.delete(e.detail.promise); + this.waiting = this.work.size > 0; + } + + constructor() { + super(); + this.onPendingState = this.onPendingState.bind(this); + this.addEventListener('pending-state', this.onPendingState); + } + + render(): TemplateResult { + return html` + `; + } +} diff --git a/packages/open-scd/src/open-scd.ts b/packages/open-scd/src/open-scd.ts index aa463098c7..70f6f2cd78 100644 --- a/packages/open-scd/src/open-scd.ts +++ b/packages/open-scd/src/open-scd.ts @@ -17,14 +17,15 @@ import { Hosting } from './Hosting.js'; import { Historing } from './Historing.js'; import { Plugging } from './Plugging.js'; import { Setting } from './Setting.js'; -import { Waiting } from './Waiting.js'; import { Wizarding } from './Wizarding.js'; +import './addons/Waiter.js'; + /** The `` custom element is the main entry point of the * Open Substation Configuration Designer. */ @customElement('open-scd') -export class OpenSCD extends Waiting( - Hosting(Setting(Wizarding(Plugging(Editing(Historing(LitElement)))))) +export class OpenSCD extends Hosting( + Setting(Wizarding(Plugging(Editing(Historing(LitElement))))) ) { private currentSrc = ''; /** The current file's URL. `blob:` URLs are *revoked after parsing*! */ @@ -37,6 +38,9 @@ export class OpenSCD extends Waiting( this.dispatchEvent(newPendingStateEvent(this.loadDoc(value))); } + @property({ type: Boolean }) + waiting = false; + /** Loads and parses an `XMLDocument` after [[`src`]] has changed. */ private async loadDoc(src: string): Promise { const response = await fetch(src); @@ -88,7 +92,10 @@ export class OpenSCD extends Waiting( } render(): TemplateResult { - return html` ${super.render()} ${getTheme(this.settings.theme)} `; + return html`${super.render()} + ${getTheme(this.settings.theme)} `; } static styles = css` diff --git a/packages/open-scd/src/wizards/foundation/references.ts b/packages/open-scd/src/wizards/foundation/references.ts index d166d43871..71a6b7efb8 100644 --- a/packages/open-scd/src/wizards/foundation/references.ts +++ b/packages/open-scd/src/wizards/foundation/references.ts @@ -290,7 +290,7 @@ function updateVals(element: Element, oldName: string | null, newName: string) { '.' + ref?.getAttribute('srcCBName'); - for (let value of valValues) { + for (const value of valValues) { if (oldName + suffixCBReference === value.textContent!.trim()) { const newElement = cloneElementAndTextContent( value, diff --git a/packages/open-scd/test/integration/__snapshots__/open-scd.test.snap.js b/packages/open-scd/test/integration/__snapshots__/open-scd.test.snap.js index 912262d91a..1e7346dc89 100644 --- a/packages/open-scd/test/integration/__snapshots__/open-scd.test.snap.js +++ b/packages/open-scd/test/integration/__snapshots__/open-scd.test.snap.js @@ -1,1412 +1,1411 @@ /* @web/test-runner snapshot v1 */ export const snapshots = {}; -snapshots['open-scd looks like its snapshot'] = ` - - Menu - - -
  • -
  • - + + + Menu + + +
  • +
  • + + + folder_open + + + Open project + + + + + + + create_new_folder + + + New project + + + + + + + save + + + Save project + + + + +
  • +
  • + + + rule_folder + + + Validate Schema + + + + + + + rule_folder + + + Validate Templates + + + + +
  • +
  • + + + snippet_folder + + + Import IEDs + + + + + + + play_circle + + + Subscriber Update + + + + + + + merge_type + + + Merge Project + + + + + + + merge_type + + + Update Substation + + + + + + + compare_arrows + + + Compare IED + + + + +
  • +
  • + + + settings + + + Settings + + + + + help + + + Help + + + + + + + history_toggle_off + + + Show SCL History + + + + +
  • +
  • + + + extension + + + Extensions + + +
    + + + +
    +
    + + + + + + + + + + +
    +
    +
    + - - folder_open - - +
    Open project - - - - - + + - - create_new_folder - - +
    New project - - - - - - - save - - - Save project - - - - -
  • -
  • - - - rule_folder - - - Validate Schema - - - - - + +
    + + - - rule_folder - - - Validate Templates - -
    - - -
  • + -
  • - + - - snippet_folder - - - Import IEDs - - - - - + - - play_circle - - - Subscriber Update - - - - - + + Errors, warnings and other notifications will show up here. + + + info + + + + - - merge_type - - - Merge Project - - - - - + + + - - merge_type - - - Update Substation - - - - - + + Edits will show up here + + + info + + + + - - compare_arrows - - - Compare IED - - - - -
  • -
  • - - - settings - - - Settings - - - - - help - - - Help - - - - - + - - history_toggle_off - - - Show SCL History - - - - -
  • -
  • - + - - extension - - - Extensions - - - - - + + + - -
    + + Issues found during validation will show up here + + + info + + + + -
    + Close +
    + + - + + - + Show +
    - + + - + Show + - - -
    - -
    - Open project -
    -
    - -
    - New project -
    -
    -
    - - - - - - - - - - - Errors, warnings and other notifications will show up here. - - - info - - - - - Close - - - - + - - - Edits will show up here - - - info - - - - - - - - - Close - - - - - + - - Issues found during validation will show up here - - - info - - - - - Close - - - - - - - - - Show - - - - - - - Show - - - - - - - Show - - - - - - + + - - - Editor tab - - - tab - - -
  • -
  • - - - developer_board - - IED - - - - margin - - Substation - - - - edit - - Single Line Diagram - - - - link - - Subscriber Message Binding (GOOSE) - - - - link - - Subscriber Data Binding (GOOSE) - - - - link - - Subscriber Later Binding (GOOSE) - - - - link - - Subscriber Message Binding (SMV) - - - - link - - Subscriber Data Binding (SMV) - - - - link - - Subscriber Later Binding (SMV) - - - - settings_ethernet - - Communication - - - - settings_ethernet - - 104 - - - - copy_all - - Templates - - - - publish - - Publisher - - - - cleaning_services - - Cleanup - - - - Menu entry - - + + Editor tab + + + tab + + +
  • +
  • + + + developer_board + + IED + + + + margin + + Substation + + + + edit + + Single Line Diagram + + + + link + + Subscriber Message Binding (GOOSE) + + + + link + + Subscriber Data Binding (GOOSE) + + + + link + + Subscriber Later Binding (GOOSE) + + + + link + + Subscriber Message Binding (SMV) + + + + link + + Subscriber Data Binding (SMV) + + + + link + + Subscriber Later Binding (SMV) + + + + settings_ethernet + + Communication + + + + settings_ethernet + + 104 + + + + copy_all + + Templates + + + + publish + + Publisher + + + + cleaning_services + + Cleanup + + + + Menu entry + + + + play_circle + + + +
  • +
  • + - - play_circle - - - -
  • -
  • - - - folder_open - - Open project - - - - create_new_folder - - New project - - - - save - - Save project - -
  • -
  • - - - rule_folder - - Validate Schema - - - - rule_folder - - Validate Templates - -
  • -
  • - - - snippet_folder - - Import IEDs - - - - developer_board - - Create Virtual IED - - - - play_circle - - Subscriber Update - - - - play_circle - - Update desc (ABB) - - - - play_circle - - Update desc (SEL) - - - - merge_type - - Merge Project - - - - merge_type - - Update Substation - - - - compare_arrows - - Compare IED - - - - sim_card_download - - Export Communication Section - -
  • -
  • - - - help - - Help - - - - history_toggle_off - - Show SCL History - -
    - - - - - - -
    - -
    -

    - Here you may add remote extensions directly from a custom URL. - You do this at your own risk. -

    - - - - + folder_open + + Open project + + - Editor tab - tab + create_new_folder - - + - Menu entry - play_circle + save - - - +
  • +
  • + + + rule_folder + + Validate Schema + + - Validator rule_folder -
    + Validate Templates + +
  • +
  • + + + snippet_folder + + Import IEDs + + + + developer_board + + Create Virtual IED + + + + play_circle + + Subscriber Update + + + + play_circle + + Update desc (ABB) + + + + play_circle + + Update desc (SEL) + + + + merge_type + + Merge Project + + + + merge_type + + Update Substation + + + + compare_arrows + + Compare IED + + + + sim_card_download + + Export Communication Section + +
  • +
  • + + + help + + Help + + + + history_toggle_off + + Show SCL History +
    - - -
    - - - + + + + +
    + - - - - - -
    - +

    + Here you may add remote extensions directly from a custom URL. + You do this at your own risk. +

    + + + + + Editor tab + + tab + + + + Menu entry + + play_circle + + + + + Validator + + rule_folder + + + + + +
    + + + + + + + + + + + + English + + + German (Deutsch) + + + + + + + + + + + + + + + + + +
    +

    + Uploaded NSDoc files +

    + + + +
    + - English + + IEC 61850-7-2 + + + close + + + IEC 61850-7-3 + + + close + + + - German (Deutsch) + + IEC 61850-7-4 + + + close + - - - - - - - - - - - - - - - - -
    -

    - Uploaded NSDoc files -

    - + + + IEC 61850-8-1 + + + close + + + + Cancel -
    - - - - IEC 61850-7-2 - - - close - - - - - IEC 61850-7-3 - - - close - - - - - IEC 61850-7-4 - - - close - - - + - - IEC 61850-8-1 - - - close - - - - - Cancel - - - Reset - - - Save - -
    - - + Save + + + `; /* end snapshot open-scd looks like its snapshot */ + diff --git a/packages/open-scd/test/integration/open-scd.test.ts b/packages/open-scd/test/integration/open-scd.test.ts index 4354785629..48730da214 100644 --- a/packages/open-scd/test/integration/open-scd.test.ts +++ b/packages/open-scd/test/integration/open-scd.test.ts @@ -67,10 +67,15 @@ describe('open-scd', () => { expect(element.diagnosticUI).to.have.property('open', true); }); + /** + * @deprecated + * Remove this integration test. It's no longer an integration test but an E2E test. + */ it('renders a progress indicator on `waiting`', async () => { - const progressBar = element.shadowRoot!.querySelector( - 'mwc-linear-progress[indeterminate]' - ); + const progressBar = element + .shadowRoot!.querySelector('oscd-waiter')! + .shadowRoot!.querySelector('mwc-linear-progress[indeterminate]')!; + console.log('progress bar : ', progressBar); expect(progressBar).property('closed').to.be.true; element.waiting = true; await element.updateComplete; diff --git a/packages/open-scd/test/unit/Plugging.test.ts b/packages/open-scd/test/unit/Plugging.test.ts index 9433921668..96647cb5b5 100644 --- a/packages/open-scd/test/unit/Plugging.test.ts +++ b/packages/open-scd/test/unit/Plugging.test.ts @@ -8,7 +8,7 @@ import { TextField } from '@material/mwc-textfield'; describe('PluggingElement', () => { let element: MockPlugger; let doc: XMLDocument; - const docName: string = 'testDoc'; + const docName = 'testDoc'; afterEach(async () => { await new Promise(resolve => setTimeout(resolve, 50)); // await animation diff --git a/packages/open-scd/test/unit/Waiting.test.ts b/packages/open-scd/test/unit/Waiting.test.ts index ddc0240587..08e7f87976 100644 --- a/packages/open-scd/test/unit/Waiting.test.ts +++ b/packages/open-scd/test/unit/Waiting.test.ts @@ -1,14 +1,15 @@ import { html, fixture, expect } from '@open-wc/testing'; -import './mock-waiter.js'; -import { MockWaiter } from './mock-waiter.js'; +import '../../src/addons/Waiter.js'; + +import { OscdWaiter } from '../../src/addons/Waiter.js'; import { newPendingStateEvent } from '../../src/foundation.js'; -describe('WaitingElement', () => { - let element: MockWaiter; +describe('OSCD-Waiter', () => { + let element: OscdWaiter; beforeEach(async () => { - element = await fixture(html``); + element = await fixture(html``); }); it('does not wait for pending state initially', () => diff --git a/packages/open-scd/test/unit/mock-waiter.ts b/packages/open-scd/test/unit/mock-waiter.ts deleted file mode 100644 index 4f46d25d1f..0000000000 --- a/packages/open-scd/test/unit/mock-waiter.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Waiting } from '../../src/Waiting.js'; -import { LitElement, customElement } from 'lit-element'; - -@customElement('mock-waiter') -export class MockWaiter extends Waiting(LitElement) {} From 26a362f7837378d482417f783d953d6b4332d52e Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Mon, 12 Feb 2024 16:24:28 +0100 Subject: [PATCH 02/27] Fix: removed console.log --- packages/open-scd/test/integration/open-scd.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/open-scd/test/integration/open-scd.test.ts b/packages/open-scd/test/integration/open-scd.test.ts index 48730da214..803a4ba9cc 100644 --- a/packages/open-scd/test/integration/open-scd.test.ts +++ b/packages/open-scd/test/integration/open-scd.test.ts @@ -75,7 +75,7 @@ describe('open-scd', () => { const progressBar = element .shadowRoot!.querySelector('oscd-waiter')! .shadowRoot!.querySelector('mwc-linear-progress[indeterminate]')!; - console.log('progress bar : ', progressBar); + expect(progressBar).property('closed').to.be.true; element.waiting = true; await element.updateComplete; From 2a284a25a155e316a76cb2a6c5d02b8719c7b50e Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Mon, 12 Feb 2024 17:21:21 +0100 Subject: [PATCH 03/27] Fix: Removed .workdone --- packages/open-scd/test/integration/open-scd.test.ts | 3 +-- .../test/integration/validators/ValidateTemplates.test.ts | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/open-scd/test/integration/open-scd.test.ts b/packages/open-scd/test/integration/open-scd.test.ts index 803a4ba9cc..6a20264c3b 100644 --- a/packages/open-scd/test/integration/open-scd.test.ts +++ b/packages/open-scd/test/integration/open-scd.test.ts @@ -75,7 +75,6 @@ describe('open-scd', () => { const progressBar = element .shadowRoot!.querySelector('oscd-waiter')! .shadowRoot!.querySelector('mwc-linear-progress[indeterminate]')!; - expect(progressBar).property('closed').to.be.true; element.waiting = true; await element.updateComplete; @@ -96,7 +95,7 @@ describe('open-scd', () => { ); expect(await fetch(emptyBlobURL)).to.be.ok; element.setAttribute('src', emptyBlobURL); - await element.workDone; + await element.updateComplete; expect(element.src).to.be.a('string').and.equal(emptyBlobURL); expect(async () => await fetch(emptyBlobURL)).to.throw; }); diff --git a/packages/open-scd/test/integration/validators/ValidateTemplates.test.ts b/packages/open-scd/test/integration/validators/ValidateTemplates.test.ts index 5691663644..b24bbf679a 100644 --- a/packages/open-scd/test/integration/validators/ValidateTemplates.test.ts +++ b/packages/open-scd/test/integration/validators/ValidateTemplates.test.ts @@ -35,7 +35,7 @@ describe('ValidateTemplates OpenSCD integration test ', () => { element.pluginId = '/src/validators/ValidateTemplates.js'; await element.validate(); - await parent.workDone; + await parent.updateComplete; }); it('shows a "No errors" message in the diagnostics pane', async () => { @@ -67,7 +67,7 @@ describe('ValidateTemplates OpenSCD integration test ', () => { element.pluginId = '/src/validators/ValidateTemplates.js'; await element.validate(); - await parent.workDone; + await parent.updateComplete; }); it('generates issues in the diagnistics pane', async () => { const issues = parent.diagnoses.get( @@ -102,7 +102,7 @@ describe('ValidateTemplates OpenSCD integration test ', () => { element.pluginId = '/src/validators/ValidateTemplates.js'; await element.validate(); - await parent.workDone; + await parent.updateComplete; }); it('shows only one message in the diagnostics pane', async () => { const issues = parent.diagnoses.get( From 55413868ce3d8c1164ec7adf5d40a392029e4e1f Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 13 Feb 2024 10:18:53 +0100 Subject: [PATCH 04/27] Fix: Removed waiting from OpenSCD --- packages/open-scd/src/open-scd.ts | 7 +------ packages/open-scd/src/wizards/foundation/references.ts | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/open-scd/src/open-scd.ts b/packages/open-scd/src/open-scd.ts index 70f6f2cd78..ffb24927ca 100644 --- a/packages/open-scd/src/open-scd.ts +++ b/packages/open-scd/src/open-scd.ts @@ -38,9 +38,6 @@ export class OpenSCD extends Hosting( this.dispatchEvent(newPendingStateEvent(this.loadDoc(value))); } - @property({ type: Boolean }) - waiting = false; - /** Loads and parses an `XMLDocument` after [[`src`]] has changed. */ private async loadDoc(src: string): Promise { const response = await fetch(src); @@ -92,9 +89,7 @@ export class OpenSCD extends Hosting( } render(): TemplateResult { - return html`${super.render()} + return html`${super.render()} ${getTheme(this.settings.theme)} `; } diff --git a/packages/open-scd/src/wizards/foundation/references.ts b/packages/open-scd/src/wizards/foundation/references.ts index 71a6b7efb8..99fcd75a4e 100644 --- a/packages/open-scd/src/wizards/foundation/references.ts +++ b/packages/open-scd/src/wizards/foundation/references.ts @@ -6,7 +6,7 @@ import { } from '../../foundation.js'; const referenceInfoTags = ['IED', 'Substation', 'VoltageLevel', 'Bay'] as const; -type ReferencesInfoTag = typeof referenceInfoTags[number]; +type ReferencesInfoTag = (typeof referenceInfoTags)[number]; type FilterFunction = ( element: Element, @@ -290,7 +290,7 @@ function updateVals(element: Element, oldName: string | null, newName: string) { '.' + ref?.getAttribute('srcCBName'); - for (const value of valValues) { + for (let value of valValues) { if (oldName + suffixCBReference === value.textContent!.trim()) { const newElement = cloneElementAndTextContent( value, From 137612e7dde9c99e29af9a172c6dfd4be6032458 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 13 Feb 2024 10:42:03 +0100 Subject: [PATCH 05/27] Fix: Added deferred promise to open-scd.test --- .../test/integration/open-scd.test.ts | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/packages/open-scd/test/integration/open-scd.test.ts b/packages/open-scd/test/integration/open-scd.test.ts index 6a20264c3b..8cc5fdff3c 100644 --- a/packages/open-scd/test/integration/open-scd.test.ts +++ b/packages/open-scd/test/integration/open-scd.test.ts @@ -3,6 +3,22 @@ import { expect, fixture, html } from '@open-wc/testing'; import '../../src/open-scd.js'; import { newEmptySCD } from '../../src/schemas.js'; import { OpenSCD } from '../../src/open-scd.js'; +import { newPendingStateEvent } from '../../src/foundation.js'; + +class DeferredPromise { + private _promise: Promise; + private resolve!: (value: T) => void; + private reject!: (reason?: any) => void; + + constructor() { + this._promise = new Promise((resolve, reject) => { + // assign the resolve and reject functions to `this` + // making them usable on the class instance + this.resolve = resolve; + this.reject = reject; + }); + } +} describe('open-scd', () => { let element: OpenSCD; @@ -76,10 +92,32 @@ describe('open-scd', () => { .shadowRoot!.querySelector('oscd-waiter')! .shadowRoot!.querySelector('mwc-linear-progress[indeterminate]')!; expect(progressBar).property('closed').to.be.true; - element.waiting = true; + + function defer() { + const deferred: { + promise: Promise | null; + resolve: ((value: T) => void) | null; + reject: ((reason?: any) => void) | null; + } = { + promise: null, + resolve: null, + reject: null, + }; + + deferred.promise = new Promise((resolve, reject) => { + deferred.resolve = resolve; + deferred.reject = reject; + }); + + return deferred; + } + + const deferredPromise = defer(); + + progressBar.dispatchEvent(newPendingStateEvent(deferredPromise.promise!)); await element.updateComplete; expect(progressBar).property('closed').to.be.false; - element.waiting = false; + deferredPromise.resolve!; await element.updateComplete; expect(progressBar).property('closed').to.be.true; }); From 5f11fd8e0988b3e050da1c2df6b433b8b64e1468 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 13 Feb 2024 10:42:12 +0100 Subject: [PATCH 06/27] Fix: Added deferred promise to open-scd.test --- .../open-scd/test/integration/open-scd.test.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/packages/open-scd/test/integration/open-scd.test.ts b/packages/open-scd/test/integration/open-scd.test.ts index 8cc5fdff3c..b4e24d5334 100644 --- a/packages/open-scd/test/integration/open-scd.test.ts +++ b/packages/open-scd/test/integration/open-scd.test.ts @@ -5,21 +5,6 @@ import { newEmptySCD } from '../../src/schemas.js'; import { OpenSCD } from '../../src/open-scd.js'; import { newPendingStateEvent } from '../../src/foundation.js'; -class DeferredPromise { - private _promise: Promise; - private resolve!: (value: T) => void; - private reject!: (reason?: any) => void; - - constructor() { - this._promise = new Promise((resolve, reject) => { - // assign the resolve and reject functions to `this` - // making them usable on the class instance - this.resolve = resolve; - this.reject = reject; - }); - } -} - describe('open-scd', () => { let element: OpenSCD; From 12fc4d71d8c04356884a1163de9efb58db19db75 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 13 Feb 2024 10:56:26 +0100 Subject: [PATCH 07/27] Fix: fixed E2E test --- .../test/integration/open-scd.test.ts | 38 +++++-------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/packages/open-scd/test/integration/open-scd.test.ts b/packages/open-scd/test/integration/open-scd.test.ts index b4e24d5334..18c92cd66c 100644 --- a/packages/open-scd/test/integration/open-scd.test.ts +++ b/packages/open-scd/test/integration/open-scd.test.ts @@ -4,6 +4,7 @@ import '../../src/open-scd.js'; import { newEmptySCD } from '../../src/schemas.js'; import { OpenSCD } from '../../src/open-scd.js'; import { newPendingStateEvent } from '../../src/foundation.js'; +import { OscdWaiter } from '../../src/addons/Waiter.js'; describe('open-scd', () => { let element: OpenSCD; @@ -73,37 +74,18 @@ describe('open-scd', () => { * Remove this integration test. It's no longer an integration test but an E2E test. */ it('renders a progress indicator on `waiting`', async () => { - const progressBar = element - .shadowRoot!.querySelector('oscd-waiter')! - .shadowRoot!.querySelector('mwc-linear-progress[indeterminate]')!; + const waiter: OscdWaiter = + element.shadowRoot!.querySelector('oscd-waiter')!; + const progressBar = waiter.shadowRoot!.querySelector( + 'mwc-linear-progress[indeterminate]' + )!; expect(progressBar).property('closed').to.be.true; - function defer() { - const deferred: { - promise: Promise | null; - resolve: ((value: T) => void) | null; - reject: ((reason?: any) => void) | null; - } = { - promise: null, - resolve: null, - reject: null, - }; - - deferred.promise = new Promise((resolve, reject) => { - deferred.resolve = resolve; - deferred.reject = reject; - }); - - return deferred; - } - - const deferredPromise = defer(); - - progressBar.dispatchEvent(newPendingStateEvent(deferredPromise.promise!)); - await element.updateComplete; + waiter.waiting = true; + await waiter.updateComplete; expect(progressBar).property('closed').to.be.false; - deferredPromise.resolve!; - await element.updateComplete; + waiter.waiting = false; + await waiter.updateComplete; expect(progressBar).property('closed').to.be.true; }); From 563d4c8347cd24e41397d35ca345b1705d48b6a5 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 13 Feb 2024 11:00:56 +0100 Subject: [PATCH 08/27] Removed waiting mixin --- packages/open-scd/src/Waiting.ts | 52 -------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 packages/open-scd/src/Waiting.ts diff --git a/packages/open-scd/src/Waiting.ts b/packages/open-scd/src/Waiting.ts deleted file mode 100644 index 912dd0c397..0000000000 --- a/packages/open-scd/src/Waiting.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { html, property, TemplateResult } from 'lit-element'; - -import '@material/mwc-linear-progress'; - -import { - LitElementConstructor, - Mixin, - PendingStateDetail, - ifImplemented, -} from './foundation.js'; - -/** Mixin implementing - * [Pending State](https://github.com/justinfagnani/pending-state-protocol) */ -export type WaitingElement = Mixin; - -export function Waiting(Base: TBase) { - class WaitingElement extends Base { - /** Whether the element is currently waiting for some async work. */ - @property({ type: Boolean }) - waiting = false; - - private work: Set> = new Set(); - /** A promise which resolves once all currently pending work is done. */ - workDone = Promise.allSettled(this.work); - - private async onPendingState(e: CustomEvent) { - this.waiting = true; - this.work.add(e.detail.promise); - this.workDone = Promise.allSettled(this.work); - await e.detail.promise.catch(reason => console.warn(reason)); - this.work.delete(e.detail.promise); - this.waiting = this.work.size > 0; - } - - constructor(...args: any[]) { - super(...args); - - this.onPendingState = this.onPendingState.bind(this); - this.addEventListener('pending-state', this.onPendingState); - } - - render(): TemplateResult { - return html`${ifImplemented(super.render())} - `; - } - } - - return WaitingElement; -} From 1a1c1955162dec6f7a60f2c2b72386670c8688bd Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 13 Feb 2024 14:38:14 +0100 Subject: [PATCH 09/27] Feat: Settings addon --- packages/open-scd/src/Hosting.ts | 15 +- packages/open-scd/src/addons/Settings.ts | 454 +++++++++++++++++++++++ packages/open-scd/src/addons/Waiter.ts | 9 +- packages/open-scd/src/foundation.ts | 22 ++ packages/open-scd/src/open-scd.ts | 10 +- 5 files changed, 493 insertions(+), 17 deletions(-) create mode 100644 packages/open-scd/src/addons/Settings.ts diff --git a/packages/open-scd/src/Hosting.ts b/packages/open-scd/src/Hosting.ts index 33701eee00..cf220e92c5 100644 --- a/packages/open-scd/src/Hosting.ts +++ b/packages/open-scd/src/Hosting.ts @@ -15,10 +15,13 @@ import { Drawer } from '@material/mwc-drawer'; import { ActionDetail, List } from '@material/mwc-list'; import { ListItem } from '@material/mwc-list/mwc-list-item'; -import { Mixin, newPendingStateEvent } from './foundation.js'; +import { + Mixin, + newPendingStateEvent, + newSettingsUIEvent, +} from './foundation.js'; import { HistoringElement } from './Historing.js'; import { Plugin, PluggingElement, pluginIcons } from './Plugging.js'; -import { SettingElement } from './Setting.js'; interface MenuItem { icon: string; @@ -43,9 +46,7 @@ interface MenuPlugin { export type HostingElement = Mixin; export function Hosting< - TBase extends new (...args: any[]) => PluggingElement & - HistoringElement & - SettingElement + TBase extends new (...args: any[]) => PluggingElement & HistoringElement >(Base: TBase) { class HostingElement extends Base { /** The currently active editor tab. */ @@ -201,7 +202,9 @@ export function Hosting< { icon: 'settings', name: 'settings.title', - action: (): void => this.settingsUI.show(), + action: (): void => { + this.dispatchEvent(newSettingsUIEvent(true)); + }, kind: 'static', }, ...bottomMenu, diff --git a/packages/open-scd/src/addons/Settings.ts b/packages/open-scd/src/addons/Settings.ts new file mode 100644 index 0000000000..eead8071fd --- /dev/null +++ b/packages/open-scd/src/addons/Settings.ts @@ -0,0 +1,454 @@ +import { + html, + property, + query, + TemplateResult, + customElement, + LitElement, +} from 'lit-element'; +import { get, registerTranslateConfig, translate, use } from 'lit-translate'; + +import '@material/mwc-button'; +import '@material/mwc-dialog'; +import '@material/mwc-formfield'; +import '@material/mwc-list/mwc-list-item'; +import '@material/mwc-select'; +import '@material/mwc-switch'; + +import { Dialog } from '@material/mwc-dialog'; +import { Select } from '@material/mwc-select'; +import { Switch } from '@material/mwc-switch'; + +import { getTheme } from '../themes.js'; + +import { newLogEvent, SettingsUIEvent } from '../foundation.js'; +import { Language, languages, loader } from '../translations/loader.js'; + +import '../WizardDivider.js'; +import { WizardDialog } from '../wizard-dialog.js'; + +import { + iec6185072, + iec6185073, + iec6185074, + iec6185081, +} from '../validators/templates/foundation.js'; +import { initializeNsdoc, Nsdoc } from '../foundation/nsdoc.js'; + +export type Settings = { + language: Language; + theme: 'light' | 'dark'; + mode: 'safe' | 'pro'; + showieds: 'on' | 'off'; + 'IEC 61850-7-2': string | undefined; + 'IEC 61850-7-3': string | undefined; + 'IEC 61850-7-4': string | undefined; + 'IEC 61850-8-1': string | undefined; +}; +export const defaults: Settings = { + language: 'en', + theme: 'light', + mode: 'safe', + showieds: 'off', + 'IEC 61850-7-2': undefined, + 'IEC 61850-7-3': undefined, + 'IEC 61850-7-4': undefined, + 'IEC 61850-8-1': undefined, +}; + +type NsdVersion = { + version: string | undefined; + revision: string | undefined; + release: string | undefined; +}; + +type NsdVersions = { + 'IEC 61850-7-2': NsdVersion; + 'IEC 61850-7-3': NsdVersion; + 'IEC 61850-7-4': NsdVersion; + 'IEC 61850-8-1': NsdVersion; +}; + +/** Represents a document to be opened. */ +export interface LoadNsdocDetail { + nsdoc: string; + filename: string; +} +export type LoadNsdocEvent = CustomEvent; +export function newLoadNsdocEvent( + nsdoc: string, + filename: string +): LoadNsdocEvent { + return new CustomEvent('load-nsdoc', { + bubbles: true, + composed: true, + detail: { nsdoc, filename }, + }); +} + +@customElement('oscd-settings') +export class OscdSettings extends LitElement { + /** Current [[`Settings`]] in `localStorage`, default to [[`defaults`]]. */ + @property() + get settings(): Settings { + return { + language: this.getSetting('language'), + theme: this.getSetting('theme'), + mode: this.getSetting('mode'), + showieds: this.getSetting('showieds'), + 'IEC 61850-7-2': this.getSetting('IEC 61850-7-2'), + 'IEC 61850-7-3': this.getSetting('IEC 61850-7-3'), + 'IEC 61850-7-4': this.getSetting('IEC 61850-7-4'), + 'IEC 61850-8-1': this.getSetting('IEC 61850-8-1'), + }; + } + /** Object containing all *.nsdoc files and a function extracting element's label form them*/ + @property({ attribute: false }) + nsdoc: Nsdoc = initializeNsdoc(); + + @property({ + type: Object, + }) + host!: HTMLElement; + + /** + * Get the versions of the current OpenSCD NSD files. + * @returns Current version, revision and release for all current OpenSCD NSD files. + */ + private async nsdVersions(): Promise { + const [nsd72, nsd73, nsd74, nsd81] = await Promise.all([ + iec6185072, + iec6185073, + iec6185074, + iec6185081, + ]); + const [nsd72Ns, nsd73Ns, nsd74Ns, nsd81Ns] = [ + nsd72.querySelector('NS'), + nsd73.querySelector('NS'), + nsd74.querySelector('NS'), + nsd81.querySelector('ServiceNS'), + ]; + + return { + 'IEC 61850-7-2': { + version: nsd72Ns?.getAttribute('version') ?? undefined, + revision: nsd72Ns?.getAttribute('revision') ?? undefined, + release: nsd72Ns?.getAttribute('release') ?? undefined, + }, + 'IEC 61850-7-3': { + version: nsd73Ns?.getAttribute('version') ?? undefined, + revision: nsd73Ns?.getAttribute('revision') ?? undefined, + release: nsd73Ns?.getAttribute('release') ?? undefined, + }, + 'IEC 61850-7-4': { + version: nsd74Ns?.getAttribute('version') ?? undefined, + revision: nsd74Ns?.getAttribute('revision') ?? undefined, + release: nsd74Ns?.getAttribute('release') ?? undefined, + }, + 'IEC 61850-8-1': { + version: nsd81Ns?.getAttribute('version') ?? undefined, + revision: nsd81Ns?.getAttribute('revision') ?? undefined, + release: nsd81Ns?.getAttribute('release') ?? undefined, + }, + }; + } + + @query('#settings') + settingsUI!: Dialog; + @query('#language') + languageUI!: Select; + @query('#dark') + darkThemeUI!: Switch; + @query('#mode') + modeUI!: Switch; + @query('#showieds') + showiedsUI!: Switch; + + @query('#nsdoc-file') + private nsdocFileUI!: HTMLInputElement; + + private getSetting(setting: T): Settings[T] { + return ( + localStorage.getItem(setting) ?? defaults[setting] + ); + } + + /** Update the `value` of `setting`, storing to `localStorage`. */ + setSetting(setting: T, value: Settings[T]): void { + localStorage.setItem(setting, (value)); + this.shadowRoot + ?.querySelector('wizard-dialog') + ?.requestUpdate(); + this.requestUpdate(); + } + + /** Remove the `setting` in `localStorage`. */ + removeSetting(setting: T): void { + localStorage.removeItem(setting); + this.shadowRoot + ?.querySelector('wizard-dialog') + ?.requestUpdate(); + this.requestUpdate(); + + this.nsdoc = initializeNsdoc(); // update nsdoc + } + + private onClosing(ae: CustomEvent<{ action: string } | null>): void { + if (ae.detail?.action === 'reset') { + Object.keys(this.settings).forEach(item => localStorage.removeItem(item)); + this.requestUpdate('settings'); + } else if (ae.detail?.action === 'save') { + this.setSetting('language', this.languageUI.value); + this.setSetting('theme', this.darkThemeUI.checked ? 'dark' : 'light'); + this.setSetting('mode', this.modeUI.checked ? 'pro' : 'safe'); + this.setSetting('showieds', this.showiedsUI.checked ? 'on' : 'off'); + this.requestUpdate('settings'); + } + } + + updated(changedProperties: Map): void { + super.updated(changedProperties); + if (changedProperties.has('settings')) use(this.settings.language); + } + + private renderFileSelect(): TemplateResult { + return html` + + { + const input = ( + this.shadowRoot!.querySelector('#nsdoc-file') + ); + input?.click(); + }} + > + + `; + } + + private async uploadNsdocFile(evt: Event): Promise { + const files = Array.from( + (evt.target)?.files ?? [] + ); + + if (files.length == 0) return; + for (const file of files) { + const text = await file.text(); + this.dispatchEvent(newLoadNsdocEvent(text, file.name)); + } + + this.nsdocFileUI.value = ''; + this.requestUpdate(); + } + + private async onLoadNsdoc(event: LoadNsdocEvent) { + const nsdocElement = this.parseToXmlObject( + event.detail.nsdoc + ).querySelector('NSDoc'); + + const id = nsdocElement?.getAttribute('id'); + if (!id) { + this.dispatchEvent( + newLogEvent({ + kind: 'error', + title: get('settings.invalidFileNoIdFound', { + filename: event.detail.filename, + }), + }) + ); + return; + } + + const nsdVersions = await this.nsdVersions(); + const nsdVersion = nsdVersions[id as keyof NsdVersions]; + const nsdocVersion = { + version: nsdocElement!.getAttribute('version') ?? '', + revision: nsdocElement!.getAttribute('revision') ?? '', + release: nsdocElement!.getAttribute('release') ?? '', + }; + + if (!this.isEqual(nsdVersion, nsdocVersion)) { + this.dispatchEvent( + newLogEvent({ + kind: 'error', + title: get('settings.invalidNsdocVersion', { + id: id, + filename: event.detail.filename, + nsdVersion: `${nsdVersion.version}${nsdVersion.revision}${nsdVersion.release}`, + nsdocVersion: `${nsdocVersion.version}${nsdocVersion.revision}${nsdocVersion.release}`, + }), + }) + ); + return; + } + + this.setSetting(id as keyof Settings, event.detail.nsdoc); + this.nsdoc = initializeNsdoc(); // update nsdoc + } + + /** + * Check the equality of two NsdVersions. + * @param versionA - First version to compare. + * @param versionB - Second version to compare. + * @returns Are they equal or not. + */ + private isEqual(versionA: NsdVersion, versionB: NsdVersion): boolean { + return ( + versionA.version == versionB.version && + versionA.revision == versionB.revision && + versionA.release == versionB.release + ); + } + + /** + * Render one .nsdoc item in the Settings wizard + * @param key - The key of the nsdoc file in the settings. + * @returns a .nsdoc item for the Settings wizard + */ + private renderNsdocItem(key: T): TemplateResult { + const nsdSetting = this.settings[key]; + let nsdVersion: string | undefined | null; + let nsdRevision: string | undefined | null; + let nsdRelease: string | undefined | null; + + if (nsdSetting) { + const nsdoc = this.parseToXmlObject(nsdSetting)!.querySelector('NSDoc'); + nsdVersion = nsdoc?.getAttribute('version'); + nsdRevision = nsdoc?.getAttribute('revision'); + nsdRelease = nsdoc?.getAttribute('release'); + } + + return html` + ${key} + ${nsdSetting + ? html`${nsdVersion}${nsdRevision}${nsdRelease}` + : html``} + ${nsdSetting + ? html`done` + : html`close`} + ${nsdSetting + ? html` { + this.removeSetting(key); + }} + >delete` + : html``} + `; + } + + private parseToXmlObject(text: string): XMLDocument { + return new DOMParser().parseFromString(text, 'application/xml'); + } + + constructor() { + super(); + + registerTranslateConfig({ loader, empty: key => key }); + use(this.settings.language); + } + + connectedCallback(): void { + super.connectedCallback(); + this.host!.addEventListener('oscd-settings', (evt: SettingsUIEvent) => { + evt.detail.show ? this.settingsUI.show() : this.settingsUI.close(); + }); + (this.host).addEventListener('load-nsdoc', this.onLoadNsdoc); + } + + render(): TemplateResult { + return html` +
    + + ${Object.keys(languages).map( + lang => + html`${translate(`settings.languages.${lang}`)}` + )} + + + + + + + + + + +
    + +
    +

    ${translate('settings.loadNsdTranslations')}

    + ${this.renderFileSelect()} +
    + + ${this.renderNsdocItem('IEC 61850-7-2')} + ${this.renderNsdocItem('IEC 61850-7-3')} + ${this.renderNsdocItem('IEC 61850-7-4')} + ${this.renderNsdocItem('IEC 61850-8-1')} + + + ${translate('cancel')} + + + ${translate('reset')} + + + ${translate('save')} + +
    + + ${getTheme(this.settings.theme)}`; + } +} diff --git a/packages/open-scd/src/addons/Waiter.ts b/packages/open-scd/src/addons/Waiter.ts index 7297cc4dab..2296412bf1 100644 --- a/packages/open-scd/src/addons/Waiter.ts +++ b/packages/open-scd/src/addons/Waiter.ts @@ -31,15 +31,12 @@ export class OscdWaiter extends LitElement { constructor() { super(); - this.onPendingState = this.onPendingState.bind(this); this.addEventListener('pending-state', this.onPendingState); } render(): TemplateResult { - return html` - `; + return html` + + `; } } diff --git a/packages/open-scd/src/foundation.ts b/packages/open-scd/src/foundation.ts index 494243b7ed..1b531b1a14 100644 --- a/packages/open-scd/src/foundation.ts +++ b/packages/open-scd/src/foundation.ts @@ -456,6 +456,27 @@ export function newPendingStateEvent( }); } +export interface SettingsUIDetail { + show: boolean; +} + +export type SettingsUIEvent = CustomEvent; + +export function newSettingsUIEvent( + show: boolean, + eventInitDict?: CustomEventInit> +): SettingsUIEvent { + return new CustomEvent('oscd-settings', { + bubbles: true, + composed: true, + ...eventInitDict, + detail: { + show, + ...eventInitDict?.detail, + }, + }); +} + /** Represents a request for validation. */ export type ValidateEvent = CustomEvent; @@ -2881,6 +2902,7 @@ export function minAvailableLogicalNodeInstance( declare global { interface ElementEventMap { ['pending-state']: PendingStateEvent; + ['oscd-settings']: SettingsUIEvent; ['editor-action']: EditorActionEvent; ['open-doc']: OpenDocEvent; ['wizard']: WizardEvent; diff --git a/packages/open-scd/src/open-scd.ts b/packages/open-scd/src/open-scd.ts index ffb24927ca..0899c42900 100644 --- a/packages/open-scd/src/open-scd.ts +++ b/packages/open-scd/src/open-scd.ts @@ -10,22 +10,21 @@ import { import { ListItem } from '@material/mwc-list/mwc-list-item'; import { newOpenDocEvent, newPendingStateEvent } from './foundation.js'; -import { getTheme } from './themes.js'; import { Editing } from './Editing.js'; import { Hosting } from './Hosting.js'; import { Historing } from './Historing.js'; import { Plugging } from './Plugging.js'; -import { Setting } from './Setting.js'; import { Wizarding } from './Wizarding.js'; +import './addons/Settings.js'; import './addons/Waiter.js'; /** The `` custom element is the main entry point of the * Open Substation Configuration Designer. */ @customElement('open-scd') export class OpenSCD extends Hosting( - Setting(Wizarding(Plugging(Editing(Historing(LitElement))))) + Wizarding(Plugging(Editing(Historing(LitElement)))) ) { private currentSrc = ''; /** The current file's URL. `blob:` URLs are *revoked after parsing*! */ @@ -89,8 +88,9 @@ export class OpenSCD extends Hosting( } render(): TemplateResult { - return html`${super.render()} - ${getTheme(this.settings.theme)} `; + return html` + ${super.render()} + `; } static styles = css` From b833f9f991a62f59b82eee73f18b32a454739ec5 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 13 Feb 2024 15:30:16 +0100 Subject: [PATCH 10/27] Fix: fixed test --- packages/open-scd/src/Setting.ts | 447 --- packages/open-scd/src/addons/Settings.ts | 104 +- .../open-scd/test/integration/Setting.test.ts | 55 +- .../__snapshots__/Setting.test.snap.js | 176 ++ .../__snapshots__/open-scd.test.snap.js | 2521 ++++++++--------- packages/open-scd/test/mock-setter-logger.ts | 3 +- packages/open-scd/test/unit/Setting.test.ts | 14 +- .../unit/__snapshots__/Setting.test.snap.js | 366 +++ packages/open-scd/test/unit/mock-setter.ts | 5 - 9 files changed, 1858 insertions(+), 1833 deletions(-) delete mode 100644 packages/open-scd/src/Setting.ts delete mode 100644 packages/open-scd/test/unit/mock-setter.ts diff --git a/packages/open-scd/src/Setting.ts b/packages/open-scd/src/Setting.ts deleted file mode 100644 index a5e27f4735..0000000000 --- a/packages/open-scd/src/Setting.ts +++ /dev/null @@ -1,447 +0,0 @@ -import { html, property, query, TemplateResult } from 'lit-element'; -import { get, registerTranslateConfig, translate, use } from 'lit-translate'; - -import '@material/mwc-button'; -import '@material/mwc-dialog'; -import '@material/mwc-formfield'; -import '@material/mwc-list/mwc-list-item'; -import '@material/mwc-select'; -import '@material/mwc-switch'; - -import { Dialog } from '@material/mwc-dialog'; -import { Select } from '@material/mwc-select'; -import { Switch } from '@material/mwc-switch'; - -import { - ifImplemented, - LitElementConstructor, - Mixin, - newLogEvent, -} from './foundation.js'; -import { Language, languages, loader } from './translations/loader.js'; - -import './WizardDivider.js'; -import { WizardDialog } from './wizard-dialog.js'; - -import { - iec6185072, - iec6185073, - iec6185074, - iec6185081, -} from './validators/templates/foundation.js'; -import { initializeNsdoc, Nsdoc } from './foundation/nsdoc.js'; - -export type Settings = { - language: Language; - theme: 'light' | 'dark'; - mode: 'safe' | 'pro'; - showieds: 'on' | 'off'; - 'IEC 61850-7-2': string | undefined; - 'IEC 61850-7-3': string | undefined; - 'IEC 61850-7-4': string | undefined; - 'IEC 61850-8-1': string | undefined; -}; -export const defaults: Settings = { - language: 'en', - theme: 'light', - mode: 'safe', - showieds: 'off', - 'IEC 61850-7-2': undefined, - 'IEC 61850-7-3': undefined, - 'IEC 61850-7-4': undefined, - 'IEC 61850-8-1': undefined, -}; - -type NsdVersion = { - version: string | undefined; - revision: string | undefined; - release: string | undefined; -}; - -type NsdVersions = { - 'IEC 61850-7-2': NsdVersion; - 'IEC 61850-7-3': NsdVersion; - 'IEC 61850-7-4': NsdVersion; - 'IEC 61850-8-1': NsdVersion; -}; - -/** Represents a document to be opened. */ -export interface LoadNsdocDetail { - nsdoc: string; - filename: string; -} -export type LoadNsdocEvent = CustomEvent; -export function newLoadNsdocEvent( - nsdoc: string, - filename: string -): LoadNsdocEvent { - return new CustomEvent('load-nsdoc', { - bubbles: true, - composed: true, - detail: { nsdoc, filename }, - }); -} - -/** Mixin that saves [[`Settings`]] to `localStorage`, reflecting them in the - * `settings` property, setting them through `setSetting(setting, value)`. */ -export type SettingElement = Mixin; - -export function Setting(Base: TBase) { - class SettingElement extends Base { - /** Current [[`Settings`]] in `localStorage`, default to [[`defaults`]]. */ - @property() - get settings(): Settings { - return { - language: this.getSetting('language'), - theme: this.getSetting('theme'), - mode: this.getSetting('mode'), - showieds: this.getSetting('showieds'), - 'IEC 61850-7-2': this.getSetting('IEC 61850-7-2'), - 'IEC 61850-7-3': this.getSetting('IEC 61850-7-3'), - 'IEC 61850-7-4': this.getSetting('IEC 61850-7-4'), - 'IEC 61850-8-1': this.getSetting('IEC 61850-8-1'), - }; - } - /** Object containing all *.nsdoc files and a function extracting element's label form them*/ - @property({ attribute: false }) - nsdoc: Nsdoc = initializeNsdoc(); - - /** - * Get the versions of the current OpenSCD NSD files. - * @returns Current version, revision and release for all current OpenSCD NSD files. - */ - private async nsdVersions(): Promise { - const [nsd72, nsd73, nsd74, nsd81] = await Promise.all([ - iec6185072, - iec6185073, - iec6185074, - iec6185081, - ]); - const [nsd72Ns, nsd73Ns, nsd74Ns, nsd81Ns] = [ - nsd72.querySelector('NS'), - nsd73.querySelector('NS'), - nsd74.querySelector('NS'), - nsd81.querySelector('ServiceNS'), - ]; - - return { - 'IEC 61850-7-2': { - version: nsd72Ns?.getAttribute('version') ?? undefined, - revision: nsd72Ns?.getAttribute('revision') ?? undefined, - release: nsd72Ns?.getAttribute('release') ?? undefined, - }, - 'IEC 61850-7-3': { - version: nsd73Ns?.getAttribute('version') ?? undefined, - revision: nsd73Ns?.getAttribute('revision') ?? undefined, - release: nsd73Ns?.getAttribute('release') ?? undefined, - }, - 'IEC 61850-7-4': { - version: nsd74Ns?.getAttribute('version') ?? undefined, - revision: nsd74Ns?.getAttribute('revision') ?? undefined, - release: nsd74Ns?.getAttribute('release') ?? undefined, - }, - 'IEC 61850-8-1': { - version: nsd81Ns?.getAttribute('version') ?? undefined, - revision: nsd81Ns?.getAttribute('revision') ?? undefined, - release: nsd81Ns?.getAttribute('release') ?? undefined, - }, - }; - } - - @query('#settings') - settingsUI!: Dialog; - @query('#language') - languageUI!: Select; - @query('#dark') - darkThemeUI!: Switch; - @query('#mode') - modeUI!: Switch; - @query('#showieds') - showiedsUI!: Switch; - - @query('#nsdoc-file') - private nsdocFileUI!: HTMLInputElement; - - private getSetting(setting: T): Settings[T] { - return ( - localStorage.getItem(setting) ?? defaults[setting] - ); - } - - /** Update the `value` of `setting`, storing to `localStorage`. */ - setSetting(setting: T, value: Settings[T]): void { - localStorage.setItem(setting, (value)); - this.shadowRoot - ?.querySelector('wizard-dialog') - ?.requestUpdate(); - this.requestUpdate(); - } - - /** Remove the `setting` in `localStorage`. */ - removeSetting(setting: T): void { - localStorage.removeItem(setting); - this.shadowRoot - ?.querySelector('wizard-dialog') - ?.requestUpdate(); - this.requestUpdate(); - - this.nsdoc = initializeNsdoc(); // update nsdoc - } - - private onClosing(ae: CustomEvent<{ action: string } | null>): void { - if (ae.detail?.action === 'reset') { - Object.keys(this.settings).forEach(item => - localStorage.removeItem(item) - ); - this.requestUpdate('settings'); - } else if (ae.detail?.action === 'save') { - this.setSetting('language', this.languageUI.value); - this.setSetting('theme', this.darkThemeUI.checked ? 'dark' : 'light'); - this.setSetting('mode', this.modeUI.checked ? 'pro' : 'safe'); - this.setSetting('showieds', this.showiedsUI.checked ? 'on' : 'off'); - this.requestUpdate('settings'); - } - } - - updated(changedProperties: Map): void { - super.updated(changedProperties); - if (changedProperties.has('settings')) use(this.settings.language); - } - - private renderFileSelect(): TemplateResult { - return html` - - { - const input = ( - this.shadowRoot!.querySelector('#nsdoc-file') - ); - input?.click(); - }} - > - - `; - } - - private async uploadNsdocFile(evt: Event): Promise { - const files = Array.from( - (evt.target)?.files ?? [] - ); - - if (files.length == 0) return; - for (const file of files) { - const text = await file.text(); - this.dispatchEvent(newLoadNsdocEvent(text, file.name)); - } - - this.nsdocFileUI.value = ''; - this.requestUpdate(); - } - - private async onLoadNsdoc(event: LoadNsdocEvent) { - const nsdocElement = this.parseToXmlObject( - event.detail.nsdoc - ).querySelector('NSDoc'); - - const id = nsdocElement?.getAttribute('id'); - if (!id) { - this.dispatchEvent( - newLogEvent({ - kind: 'error', - title: get('settings.invalidFileNoIdFound', { - filename: event.detail.filename, - }), - }) - ); - return; - } - - const nsdVersions = await this.nsdVersions(); - const nsdVersion = nsdVersions[id as keyof NsdVersions]; - const nsdocVersion = { - version: nsdocElement!.getAttribute('version') ?? '', - revision: nsdocElement!.getAttribute('revision') ?? '', - release: nsdocElement!.getAttribute('release') ?? '', - }; - - if (!this.isEqual(nsdVersion, nsdocVersion)) { - this.dispatchEvent( - newLogEvent({ - kind: 'error', - title: get('settings.invalidNsdocVersion', { - id: id, - filename: event.detail.filename, - nsdVersion: `${nsdVersion.version}${nsdVersion.revision}${nsdVersion.release}`, - nsdocVersion: `${nsdocVersion.version}${nsdocVersion.revision}${nsdocVersion.release}`, - }), - }) - ); - return; - } - - this.setSetting(id as keyof Settings, event.detail.nsdoc); - this.nsdoc = initializeNsdoc(); // update nsdoc - } - - /** - * Check the equality of two NsdVersions. - * @param versionA - First version to compare. - * @param versionB - Second version to compare. - * @returns Are they equal or not. - */ - private isEqual(versionA: NsdVersion, versionB: NsdVersion): boolean { - return ( - versionA.version == versionB.version && - versionA.revision == versionB.revision && - versionA.release == versionB.release - ); - } - - /** - * Render one .nsdoc item in the Settings wizard - * @param key - The key of the nsdoc file in the settings. - * @returns a .nsdoc item for the Settings wizard - */ - private renderNsdocItem(key: T): TemplateResult { - const nsdSetting = this.settings[key]; - let nsdVersion: string | undefined | null; - let nsdRevision: string | undefined | null; - let nsdRelease: string | undefined | null; - - if (nsdSetting) { - const nsdoc = this.parseToXmlObject(nsdSetting)!.querySelector('NSDoc'); - nsdVersion = nsdoc?.getAttribute('version'); - nsdRevision = nsdoc?.getAttribute('revision'); - nsdRelease = nsdoc?.getAttribute('release'); - } - - return html` - ${key} - ${nsdSetting - ? html`${nsdVersion}${nsdRevision}${nsdRelease}` - : html``} - ${nsdSetting - ? html`done` - : html`close`} - ${nsdSetting - ? html` { - this.removeSetting(key); - }} - >delete` - : html``} - `; - } - - private parseToXmlObject(text: string): XMLDocument { - return new DOMParser().parseFromString(text, 'application/xml'); - } - - constructor(...params: any[]) { - super(...params); - - registerTranslateConfig({ loader, empty: key => key }); - use(this.settings.language); - - (this).addEventListener('load-nsdoc', this.onLoadNsdoc); - } - - render(): TemplateResult { - return html`${ifImplemented(super.render())} - -
    - - ${Object.keys(languages).map( - lang => - html`${translate(`settings.languages.${lang}`)}` - )} - - - - - - - - - - -
    - -
    -

    ${translate('settings.loadNsdTranslations')}

    - ${this.renderFileSelect()} -
    - - ${this.renderNsdocItem('IEC 61850-7-2')} - ${this.renderNsdocItem('IEC 61850-7-3')} - ${this.renderNsdocItem('IEC 61850-7-4')} - ${this.renderNsdocItem('IEC 61850-8-1')} - - - ${translate('cancel')} - - - ${translate('reset')} - - - ${translate('save')} - -
    `; - } - } - - return SettingElement; -} diff --git a/packages/open-scd/src/addons/Settings.ts b/packages/open-scd/src/addons/Settings.ts index eead8071fd..53e6dfdacb 100644 --- a/packages/open-scd/src/addons/Settings.ts +++ b/packages/open-scd/src/addons/Settings.ts @@ -5,6 +5,7 @@ import { TemplateResult, customElement, LitElement, + css, } from 'lit-element'; import { get, registerTranslateConfig, translate, use } from 'lit-translate'; @@ -370,10 +371,14 @@ export class OscdSettings extends LitElement { connectedCallback(): void { super.connectedCallback(); - this.host!.addEventListener('oscd-settings', (evt: SettingsUIEvent) => { - evt.detail.show ? this.settingsUI.show() : this.settingsUI.close(); - }); - (this.host).addEventListener('load-nsdoc', this.onLoadNsdoc); + if (this.host) { + this.host!.addEventListener('oscd-settings', (evt: SettingsUIEvent) => { + evt.detail.show ? this.settingsUI.show() : this.settingsUI.close(); + }); + (this.host).addEventListener('load-nsdoc', (evt: LoadNsdocEvent) => + this.onLoadNsdoc(evt) + ); + } } render(): TemplateResult { @@ -451,4 +456,95 @@ export class OscdSettings extends LitElement { ${getTheme(this.settings.theme)}`; } + + static styles = css` + mwc-top-app-bar-fixed { + --mdc-theme-text-disabled-on-light: rgba(255, 255, 255, 0.38); + } /* hack to fix disabled icon buttons rendering black */ + + mwc-tab { + background-color: var(--primary); + --mdc-theme-primary: var(--mdc-theme-on-primary); + } + + input[type='file'] { + display: none; + } + + mwc-dialog { + --mdc-dialog-max-width: 98vw; + } + + mwc-dialog > form { + display: flex; + flex-direction: column; + } + + mwc-dialog > form > * { + display: block; + margin-top: 16px; + } + + mwc-linear-progress { + position: fixed; + --mdc-linear-progress-buffer-color: var(--primary); + --mdc-theme-primary: var(--secondary); + left: 0px; + top: 0px; + width: 100%; + pointer-events: none; + z-index: 1000; + } + + tt { + font-family: 'Roboto Mono', monospace; + font-weight: 300; + } + + .landing { + position: absolute; + text-align: center; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 100%; + } + + .landing_icon:hover { + box-shadow: 0 12px 17px 2px rgba(0, 0, 0, 0.14), + 0 5px 22px 4px rgba(0, 0, 0, 0.12), 0 7px 8px -4px rgba(0, 0, 0, 0.2); + } + + .landing_icon { + margin: 12px; + border-radius: 16px; + width: 160px; + height: 140px; + text-align: center; + color: var(--mdc-theme-on-secondary); + background: var(--secondary); + --mdc-icon-button-size: 100px; + --mdc-icon-size: 100px; + --mdc-ripple-color: rgba(0, 0, 0, 0); + box-shadow: rgb(0 0 0 / 14%) 0px 6px 10px 0px, + rgb(0 0 0 / 12%) 0px 1px 18px 0px, rgb(0 0 0 / 20%) 0px 3px 5px -1px; + transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1); + } + + .landing_label { + width: 160px; + height: 50px; + margin-top: 100px; + margin-left: -30px; + font-family: 'Roboto', sans-serif; + } + + .plugin.menu { + display: flex; + } + + .plugin.validator { + display: flex; + } + `; } diff --git a/packages/open-scd/test/integration/Setting.test.ts b/packages/open-scd/test/integration/Setting.test.ts index e0c40ccb45..34f15d6d54 100644 --- a/packages/open-scd/test/integration/Setting.test.ts +++ b/packages/open-scd/test/integration/Setting.test.ts @@ -3,71 +3,78 @@ import { expect, fixture, html } from '@open-wc/testing'; import '../mock-setter-logger.js'; import { MockSetterLogger } from '../mock-setter-logger.js'; -import { newLoadNsdocEvent } from '../../src/Setting.js'; +import { newLoadNsdocEvent, OscdSettings } from '../../src/addons/Settings.js'; -describe('Setting', () => { - let element: MockSetterLogger; +describe('Oscd-Settings', () => { + let logger: MockSetterLogger; + let settings: OscdSettings; beforeEach(async () => { localStorage.clear(); - element = await fixture(html``); + logger = await fixture( + html` + + ` + ); + + settings = logger.querySelector('oscd-settings')!; }); it('upload .nsdoc file using event and looks like latest snapshot', async () => { - element.settingsUI.show(); - await element.settingsUI.updateComplete; + settings.settingsUI.show(); + await settings.settingsUI.updateComplete; const nsdocFile = await fetch( '/test/testfiles/nsdoc/IEC_61850-7-2.nsdoc' ).then(response => response.text()); - element.dispatchEvent(newLoadNsdocEvent(nsdocFile, 'IEC_61850-7-2.nsdoc')); + settings.dispatchEvent(newLoadNsdocEvent(nsdocFile, 'IEC_61850-7-2.nsdoc')); - await element.requestUpdate(); - await element.updateComplete; + await settings.requestUpdate(); + await settings.updateComplete; expect(localStorage.getItem('IEC 61850-7-2')).to.eql(nsdocFile); // Create a snapshot of the Settings Dialog only, not the whole Mock Component. await expect( - element.shadowRoot!.querySelector('mwc-dialog[id="settings"]') + settings.shadowRoot!.querySelector('mwc-dialog[id="settings"]') ).to.equalSnapshot(); }); it('upload invalid .nsdoc file using event and log event fired', async () => { - element.settingsUI.show(); - await element.settingsUI.updateComplete; + settings.settingsUI.show(); + await settings.settingsUI.updateComplete; const nsdocFile = await fetch('/test/testfiles/nsdoc/invalid.nsdoc').then( response => response.text() ); - element.dispatchEvent(newLoadNsdocEvent(nsdocFile, 'invalid.nsdoc')); + logger.dispatchEvent(newLoadNsdocEvent(nsdocFile, 'invalid.nsdoc')); - await element.requestUpdate(); - await element.updateComplete; + await logger.requestUpdate(); + await logger.updateComplete; - expect(element.log.length).to.be.equal(1); - expect(element.log[0].title).to.be.equal( + expect(logger.log.length).to.be.equal(1); + expect(logger.log[0].title).to.be.equal( "Invalid NSDoc (invalid.nsdoc); no 'id' attribute found in file" ); }); it('upload .nsdoc file with wrong version using event and log event fired', async () => { - element.settingsUI.show(); - await element.settingsUI.updateComplete; + settings.settingsUI.show(); + await settings.settingsUI.updateComplete; const nsdocFile = await fetch( '/test/testfiles/nsdoc/wrong-version.nsdoc' ).then(response => response.text()); - element.dispatchEvent(newLoadNsdocEvent(nsdocFile, 'wrong-version.nsdoc')); + logger.dispatchEvent(newLoadNsdocEvent(nsdocFile, 'wrong-version.nsdoc')); - await element.requestUpdate(); - await element.updateComplete; + await logger.requestUpdate(); + await logger.updateComplete; - expect(element.log.length).to.be.equal(1); - expect(element.log[0].title).to.be.equal( + expect(logger.log.length).to.be.equal(1); + expect(logger.log[0].title).to.be.equal( 'The version of IEC 61850-7-3 NSD (2007B3) does not correlate ' + 'with the version of the corresponding NSDoc (wrong-version.nsdoc, 2007B4)' ); diff --git a/packages/open-scd/test/integration/__snapshots__/Setting.test.snap.js b/packages/open-scd/test/integration/__snapshots__/Setting.test.snap.js index 9e5186252e..8537c0b79e 100644 --- a/packages/open-scd/test/integration/__snapshots__/Setting.test.snap.js +++ b/packages/open-scd/test/integration/__snapshots__/Setting.test.snap.js @@ -185,3 +185,179 @@ snapshots["Setting upload .nsdoc file using event and looks like latest snapshot `; /* end snapshot Setting upload .nsdoc file using event and looks like latest snapshot */ +snapshots["Oscd-Settings upload .nsdoc file using event and looks like latest snapshot"] = +` +
    + + + English + + + German (Deutsch) + + + + + + + + + + + + + + +
    + + +
    +

    + Uploaded NSDoc files +

    + + + +
    + + + + IEC 61850-7-2 + + + close + + + + + IEC 61850-7-3 + + + close + + + + + IEC 61850-7-4 + + + close + + + + + IEC 61850-8-1 + + + close + + + + + Cancel + + + Reset + + + Save + +
    +`; +/* end snapshot Oscd-Settings upload .nsdoc file using event and looks like latest snapshot */ + diff --git a/packages/open-scd/test/integration/__snapshots__/open-scd.test.snap.js b/packages/open-scd/test/integration/__snapshots__/open-scd.test.snap.js index 1e7346dc89..88ad873c88 100644 --- a/packages/open-scd/test/integration/__snapshots__/open-scd.test.snap.js +++ b/packages/open-scd/test/integration/__snapshots__/open-scd.test.snap.js @@ -3,1408 +3,1239 @@ export const snapshots = {}; snapshots["open-scd looks like its snapshot"] = ` - - - Menu - - -
  • -
  • - + + + Menu + + +
  • +
  • + + + folder_open + + + Open project + + + + + + + create_new_folder + + + New project + + + + + + + save + + + Save project + + + + +
  • +
  • + + + rule_folder + + + Validate Schema + + + + + + + rule_folder + + + Validate Templates + + + + +
  • +
  • + + + snippet_folder + + + Import IEDs + + + + + + + play_circle + + + Subscriber Update + + + + + + + merge_type + + + Merge Project + + + + + + + merge_type + + + Update Substation + + + + + + + compare_arrows + + + Compare IED + + + + +
  • +
  • + + + settings + + + Settings + + + + + help + + + Help + + + + + + + history_toggle_off + + + Show SCL History + + + + +
  • +
  • + + + extension + + + Extensions + + +
    + + + +
    +
    + + + + + + + + + + +
    +
    +
    + - - folder_open - - +
    Open project - - - - - + + - - create_new_folder - - +
    New project - - - - - + +
    + + - - save - - - Save project - -
    - - -
  • + + + + + + + + Errors, warnings and other notifications will show up here. + + + info + + + + + Close + + + + -
  • - + + Edits will show up here + + + info + + + + - - rule_folder - - - Validate Schema - - - - - + + + + Close + + + + + + + Issues found during validation will show up here + + + info + + + + + Close + + + + + + + + + Show + + + + + + + Show + + - - rule_folder - - + + + + + Show + + + + + + + + + Editor tab + + + tab + + +
  • +
  • + + + developer_board + + IED + + + + margin + + Substation + + + + edit + + Single Line Diagram + + + + link + + Subscriber Message Binding (GOOSE) + + + + link + + Subscriber Data Binding (GOOSE) + + + + link + + Subscriber Later Binding (GOOSE) + + + + link + + Subscriber Message Binding (SMV) + + + + link + + Subscriber Data Binding (SMV) + + + + link + + Subscriber Later Binding (SMV) + + + + settings_ethernet + + Communication + + + + settings_ethernet + + 104 + + + + copy_all + + Templates + + + + publish + + Publisher + + + + cleaning_services + + Cleanup + + + + Menu entry + + + + play_circle + + + +
  • +
  • + + + folder_open + + Open project + + + + create_new_folder + + New project + + + + save + + Save project + +
  • +
  • + + + rule_folder + + Validate Schema + + + + rule_folder + Validate Templates - -
    - - -
  • -
  • - - - snippet_folder - - + +
  • +
  • + + + snippet_folder + Import IEDs -
    -
    - - - - - play_circle - - + + + + developer_board + + Create Virtual IED + + + + play_circle + Subscriber Update - - - - - - - merge_type - - - Merge Project - - - - - - - merge_type - - - Update Substation - - - - - - - compare_arrows - - - Compare IED - - - - -
  • -
  • - - - settings - - - Settings - - - - - help - - - Help - - - - - - - history_toggle_off - - - Show SCL History - - - - -
  • -
  • - - - extension - - - Extensions - - - - - - -
    -
    - - - - - - - - - - -
    - -
    - -
    - Open project -
    -
    - -
    - New project -
    -
    -
    - - - - - - - - - - - Errors, warnings and other notifications will show up here. - - - info - - - - - Close - - - - - - - Edits will show up here - - - info - - - - - - - - - Close - - - - - - - Issues found during validation will show up here - - - info - - - - - Close - - - - - - - - - Show - - - - - - - Show - - - - - - - Show - - - - - - - - - Editor tab - - - tab - - -
  • -
  • - - - developer_board - - IED - - - - margin - - Substation - - - - edit - - Single Line Diagram - - - - link - - Subscriber Message Binding (GOOSE) - - - - link - - Subscriber Data Binding (GOOSE) - - - - link - - Subscriber Later Binding (GOOSE) - - - - link - - Subscriber Message Binding (SMV) - - - - link - - Subscriber Data Binding (SMV) - - - - link - - Subscriber Later Binding (SMV) - - - - settings_ethernet - - Communication - - - - settings_ethernet - - 104 - - - - copy_all - - Templates - - - - publish - - Publisher - - - - cleaning_services - - Cleanup - - - - Menu entry - - + - + play_circle - - - -
  • -
  • - - - folder_open - - Open project - - - - create_new_folder - - New project - - - - save - - Save project - -
  • -
  • - - - rule_folder - - Validate Schema - - - - rule_folder - - Validate Templates - -
  • -
  • - - - snippet_folder - - Import IEDs - - - - developer_board - - Create Virtual IED - - - - play_circle - - Subscriber Update - - - - play_circle - - Update desc (ABB) - - - - play_circle - - Update desc (SEL) - - - - merge_type - - Merge Project - - - - merge_type - - Update Substation - - - - compare_arrows - - Compare IED - - - - sim_card_download - - Export Communication Section - -
  • -
  • - - - help - - Help - - - - history_toggle_off - - Show SCL History - -
    - - - - - - -
    - -
    -

    - Here you may add remote extensions directly from a custom URL. - You do this at your own risk. -

    - - - - + Update desc (ABB) + + + + play_circle + + Update desc (SEL) + + - Editor tab - tab + merge_type - - + - Menu entry - play_circle + merge_type - - - + - Validator - rule_folder + compare_arrows - - - - -
    - - - - -
    - - - -
    - - + + + sim_card_download + + Export Communication Section + +
  • +
  • + - English -
    - + help + + Help + + - German (Deutsch) - -
    - - - - - - - - - - - - -
    - - -
    -

    - Uploaded NSDoc files -

    - + + history_toggle_off + + Show SCL History + + -
    - - - - IEC 61850-7-2 - - - close - - - + - - IEC 61850-7-3 - - - close - - - +
    + +
    +

    + Here you may add remote extensions directly from a custom URL. + You do this at your own risk. +

    + + + + + Editor tab + + tab + + + + Menu entry + + play_circle + + + + + Validator + + rule_folder + + + + + +
    + - - IEC 61850-7-4 - - - close - - - + - - IEC 61850-8-1 - - - close - - - - - Cancel - - - Reset - - - Save - -
    +
    + + + + `; /* end snapshot open-scd looks like its snapshot */ diff --git a/packages/open-scd/test/mock-setter-logger.ts b/packages/open-scd/test/mock-setter-logger.ts index a7bfc22318..c80b3ddadd 100644 --- a/packages/open-scd/test/mock-setter-logger.ts +++ b/packages/open-scd/test/mock-setter-logger.ts @@ -1,7 +1,6 @@ import { LitElement, customElement } from 'lit-element'; -import { Setting } from '../src/Setting.js'; import { Editing } from '../src/Editing.js'; import { Historing } from '../src/Historing.js'; @customElement('mock-setter-logger') -export class MockSetterLogger extends Setting(Editing(Historing(LitElement))) {} +export class MockSetterLogger extends Editing(Historing(LitElement)) {} diff --git a/packages/open-scd/test/unit/Setting.test.ts b/packages/open-scd/test/unit/Setting.test.ts index 170ca854c2..9a7d431273 100644 --- a/packages/open-scd/test/unit/Setting.test.ts +++ b/packages/open-scd/test/unit/Setting.test.ts @@ -2,17 +2,19 @@ import { registerTranslateConfig, use } from 'lit-translate'; import { html, fixture, expect } from '@open-wc/testing'; -import './mock-setter.js'; -import { MockSetter } from './mock-setter.js'; +import '../../src/addons/Settings.js'; +import { OscdSettings, defaults } from '../../src/addons/Settings.js'; import { Button } from '@material/mwc-button'; -import { defaults } from '../../src/Setting.js'; -describe('SettingElement', () => { - let element: MockSetter; +describe('OSCD-Settings', () => { + let element: OscdSettings; beforeEach(async () => { localStorage.clear(); - element = await fixture(html``); + + element = ( + await fixture(html``) + ); }); it('initially has default settings', () => diff --git a/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js b/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js index deee613a9b..6433cc078a 100644 --- a/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js +++ b/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js @@ -363,3 +363,369 @@ snapshots["SettingElement deletes a chosen .nsdoc file and looks like latest sna `; /* end snapshot SettingElement deletes a chosen .nsdoc file and looks like latest snapshot */ +snapshots["OSCD-Settings saves chosen .nsdoc file and looks like latest snapshot"] = +` +
    + + + English + + + German (Deutsch) + + + + + + + + + + + + + + +
    + + +
    +

    + Uploaded NSDoc files +

    + + + +
    + + + + IEC 61850-7-2 + + + 2007B3 + + + done + + + delete + + + + + IEC 61850-7-3 + + + close + + + + + IEC 61850-7-4 + + + close + + + + + IEC 61850-8-1 + + + close + + + + + Cancel + + + Reset + + + Save + +
    + + +`; +/* end snapshot OSCD-Settings saves chosen .nsdoc file and looks like latest snapshot */ + +snapshots["OSCD-Settings deletes a chosen .nsdoc file and looks like latest snapshot"] = +` +
    + + + English + + + German (Deutsch) + + + + + + + + + + + + + + +
    + + +
    +

    + Uploaded NSDoc files +

    + + + +
    + + + + IEC 61850-7-2 + + + close + + + + + IEC 61850-7-3 + + + close + + + + + IEC 61850-7-4 + + + close + + + + + IEC 61850-8-1 + + + close + + + + + Cancel + + + Reset + + + Save + +
    + + +`; +/* end snapshot OSCD-Settings deletes a chosen .nsdoc file and looks like latest snapshot */ + diff --git a/packages/open-scd/test/unit/mock-setter.ts b/packages/open-scd/test/unit/mock-setter.ts deleted file mode 100644 index 925d49b85d..0000000000 --- a/packages/open-scd/test/unit/mock-setter.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { LitElement, customElement } from 'lit-element'; -import { Setting } from '../../src/Setting.js'; - -@customElement('mock-setter') -export class MockSetter extends Setting(LitElement) {} From e3d151552a5a12b87cde10d98c15fa2691f0f7d3 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 13 Feb 2024 16:48:08 +0100 Subject: [PATCH 11/27] Fix: updated import in themes.ts --- packages/open-scd/src/addons/Wizards.ts | 50 +++++++++++++++++++++++++ packages/open-scd/src/themes.ts | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 packages/open-scd/src/addons/Wizards.ts diff --git a/packages/open-scd/src/addons/Wizards.ts b/packages/open-scd/src/addons/Wizards.ts new file mode 100644 index 0000000000..fe43b53667 --- /dev/null +++ b/packages/open-scd/src/addons/Wizards.ts @@ -0,0 +1,50 @@ +import { + html, + state, + TemplateResult, + query, + LitElement, + customElement, +} from 'lit-element'; +import { WizardEvent, WizardFactory } from '../foundation.js'; + +import '../wizard-dialog.js'; +import { WizardDialog } from '../wizard-dialog.js'; + +/** `LitElement` that adds a `workflow` property which [[`Wizard`]]s are + * queued onto on incoming [[`WizardEvent`]]s, first come first displayed. */ +@customElement('oscd-wizard') +export class OscdWizard extends LitElement { + /** FIFO queue of [[`Wizard`]]s to display. */ + @state() + workflow: WizardFactory[] = []; + + @query('wizard-dialog') + wizardUI!: WizardDialog; + + private onWizard(we: WizardEvent) { + const wizard = we.detail.wizard; + if (wizard === null) this.workflow.shift(); + else if (we.detail.subwizard) this.workflow.unshift(wizard); + else this.workflow.push(wizard); + this.requestUpdate('workflow'); + this.updateComplete.then(() => + this.wizardUI.updateComplete.then(() => + this.wizardUI.dialog?.updateComplete.then(() => + this.wizardUI.dialog?.focus() + ) + ) + ); + } + + connectedCallback(): void { + super.connectedCallback(); + this.addEventListener('wizard', this.onWizard); + this.addEventListener('editor-action', () => this.wizardUI.requestUpdate()); + } + + render(): TemplateResult { + return html` + `; + } +} diff --git a/packages/open-scd/src/themes.ts b/packages/open-scd/src/themes.ts index 845d6ecb55..50d76618b3 100644 --- a/packages/open-scd/src/themes.ts +++ b/packages/open-scd/src/themes.ts @@ -1,5 +1,5 @@ import { html, TemplateResult } from 'lit-element'; -import { Settings } from './Setting.js'; +import { Settings } from './addons/Settings.js'; export function getTheme(theme: Settings['theme']): TemplateResult { document.body.style.cssText = bodyStyles[theme]; From 4960d042c1eee631d496889114d47c064a42219f Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 13 Feb 2024 16:48:32 +0100 Subject: [PATCH 12/27] Fix: updated import in themes.ts --- packages/open-scd/src/addons/Wizards.ts | 50 ------------------------- 1 file changed, 50 deletions(-) delete mode 100644 packages/open-scd/src/addons/Wizards.ts diff --git a/packages/open-scd/src/addons/Wizards.ts b/packages/open-scd/src/addons/Wizards.ts deleted file mode 100644 index fe43b53667..0000000000 --- a/packages/open-scd/src/addons/Wizards.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { - html, - state, - TemplateResult, - query, - LitElement, - customElement, -} from 'lit-element'; -import { WizardEvent, WizardFactory } from '../foundation.js'; - -import '../wizard-dialog.js'; -import { WizardDialog } from '../wizard-dialog.js'; - -/** `LitElement` that adds a `workflow` property which [[`Wizard`]]s are - * queued onto on incoming [[`WizardEvent`]]s, first come first displayed. */ -@customElement('oscd-wizard') -export class OscdWizard extends LitElement { - /** FIFO queue of [[`Wizard`]]s to display. */ - @state() - workflow: WizardFactory[] = []; - - @query('wizard-dialog') - wizardUI!: WizardDialog; - - private onWizard(we: WizardEvent) { - const wizard = we.detail.wizard; - if (wizard === null) this.workflow.shift(); - else if (we.detail.subwizard) this.workflow.unshift(wizard); - else this.workflow.push(wizard); - this.requestUpdate('workflow'); - this.updateComplete.then(() => - this.wizardUI.updateComplete.then(() => - this.wizardUI.dialog?.updateComplete.then(() => - this.wizardUI.dialog?.focus() - ) - ) - ); - } - - connectedCallback(): void { - super.connectedCallback(); - this.addEventListener('wizard', this.onWizard); - this.addEventListener('editor-action', () => this.wizardUI.requestUpdate()); - } - - render(): TemplateResult { - return html` - `; - } -} From d051c911d0da92f9b8ab81a3bb70708260578a35 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Wed, 14 Feb 2024 16:28:30 +0100 Subject: [PATCH 13/27] Feat: Moved hosting into OpenSCD class --- packages/open-scd/src/addons/Settings.ts | 4 +- packages/open-scd/src/addons/Waiter.ts | 2 +- .../src/editors/substation/zeroline-pane.ts | 2 +- packages/open-scd/src/open-scd.ts | 358 ++++++++++++++++- .../unit/__snapshots__/Setting.test.snap.js | 374 +----------------- 5 files changed, 362 insertions(+), 378 deletions(-) diff --git a/packages/open-scd/src/addons/Settings.ts b/packages/open-scd/src/addons/Settings.ts index 53e6dfdacb..715f036f15 100644 --- a/packages/open-scd/src/addons/Settings.ts +++ b/packages/open-scd/src/addons/Settings.ts @@ -382,7 +382,8 @@ export class OscdSettings extends LitElement { } render(): TemplateResult { - return html` + - ${getTheme(this.settings.theme)}`; } diff --git a/packages/open-scd/src/addons/Waiter.ts b/packages/open-scd/src/addons/Waiter.ts index 2296412bf1..5f7e4c82ed 100644 --- a/packages/open-scd/src/addons/Waiter.ts +++ b/packages/open-scd/src/addons/Waiter.ts @@ -35,7 +35,7 @@ export class OscdWaiter extends LitElement { } render(): TemplateResult { - return html` + return html` `; } diff --git a/packages/open-scd/src/editors/substation/zeroline-pane.ts b/packages/open-scd/src/editors/substation/zeroline-pane.ts index 3b79df1fd9..1a324c02dd 100644 --- a/packages/open-scd/src/editors/substation/zeroline-pane.ts +++ b/packages/open-scd/src/editors/substation/zeroline-pane.ts @@ -27,10 +27,10 @@ import { selectGseControlWizard } from '../../wizards/gsecontrol.js'; import { emptyWizard, wizards } from '../../wizards/wizard-library.js'; import { getAttachedIeds } from './foundation.js'; import { selectSampledValueControlWizard } from '../../wizards/sampledvaluecontrol.js'; -import { Settings } from '../../Setting.js'; import { selectReportControlWizard } from '../../wizards/reportcontrol.js'; import { SCLTag, tags } from '../../foundation.js'; +import { Settings } from '../../addons/Settings.js'; function shouldShowIEDs(): boolean { return localStorage.getItem('showieds') === 'on'; diff --git a/packages/open-scd/src/open-scd.ts b/packages/open-scd/src/open-scd.ts index 0899c42900..238a502748 100644 --- a/packages/open-scd/src/open-scd.ts +++ b/packages/open-scd/src/open-scd.ts @@ -5,26 +5,65 @@ import { LitElement, property, TemplateResult, + query, } from 'lit-element'; import { ListItem } from '@material/mwc-list/mwc-list-item'; -import { newOpenDocEvent, newPendingStateEvent } from './foundation.js'; +import '@material/mwc-icon'; +import '@material/mwc-icon-button'; +import '@material/mwc-linear-progress'; +import '@material/mwc-list'; +import '@material/mwc-list/mwc-list-item'; +import '@material/mwc-tab'; +import '@material/mwc-tab-bar'; +import '@material/mwc-top-app-bar-fixed'; +import '@material/mwc-drawer'; + +import { + newOpenDocEvent, + newPendingStateEvent, + newSettingsUIEvent, +} from './foundation.js'; import { Editing } from './Editing.js'; -import { Hosting } from './Hosting.js'; import { Historing } from './Historing.js'; -import { Plugging } from './Plugging.js'; +import { Plugging, Plugin, pluginIcons } from './Plugging.js'; import { Wizarding } from './Wizarding.js'; import './addons/Settings.js'; import './addons/Waiter.js'; +import { ActionDetail, List } from '@material/mwc-list'; +import { Drawer } from '@material/mwc-drawer'; +import { translate } from 'lit-translate'; + +// HOSTING INTERFACES + +interface MenuItem { + icon: string; + name: string; + hint?: string; + actionItem?: boolean; + action?: (event: CustomEvent) => void; + disabled?: () => boolean; + content?: TemplateResult; + kind: string; +} + +interface Validator { + validate: () => Promise; +} + +interface MenuPlugin { + run: () => Promise; +} + /** The `` custom element is the main entry point of the * Open Substation Configuration Designer. */ @customElement('open-scd') -export class OpenSCD extends Hosting( - Wizarding(Plugging(Editing(Historing(LitElement)))) +export class OpenSCD extends Wizarding( + Plugging(Editing(Historing(LitElement))) ) { private currentSrc = ''; /** The current file's URL. `blob:` URLs are *revoked after parsing*! */ @@ -87,9 +126,39 @@ export class OpenSCD extends Hosting( document.onkeydown = this.handleKeyPress; } + connectedCallback(): void { + super.connectedCallback(); + 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 => + ((item.nextElementSibling)).validate() + ) + ).then(); + this.dispatchEvent(newPendingStateEvent(this.validated)); + }); + this.addEventListener('close-drawer', async () => { + this.menuUI.open = false; + }); + } + + protected renderMain(): TemplateResult { + return html`${this.renderHosting()}${super.render()}`; + } + render(): TemplateResult { return html` - ${super.render()} + ${this.renderMain()} `; } @@ -183,4 +252,281 @@ export class OpenSCD extends Hosting( display: flex; } `; + + // HOSTING + /** The currently active editor tab. */ + @property({ type: Number }) + activeTab = 0; + @property({ attribute: false }) + validated: Promise = Promise.resolve(); + + private shouldValidate = false; + + @query('#menu') menuUI!: Drawer; + + get menu(): (MenuItem | 'divider')[] { + const topMenu: (MenuItem | 'divider')[] = []; + const middleMenu: (MenuItem | 'divider')[] = []; + const bottomMenu: (MenuItem | 'divider')[] = []; + const validators: (MenuItem | 'divider')[] = []; + + this.topMenu.forEach(plugin => + topMenu.push({ + icon: plugin.icon || pluginIcons['menu'], + name: plugin.name, + action: ae => { + this.dispatchEvent( + newPendingStateEvent( + (( + (( + (ae.target).items[ae.detail.index].nextElementSibling + )) + )).run() + ) + ); + }, + disabled: (): boolean => plugin.requireDoc! && this.doc === null, + content: plugin.content, + kind: 'top', + }) + ); + + this.middleMenu.forEach(plugin => + middleMenu.push({ + icon: plugin.icon || pluginIcons['menu'], + name: plugin.name, + action: ae => { + this.dispatchEvent( + newPendingStateEvent( + (( + (( + (ae.target).items[ae.detail.index].nextElementSibling + )) + )).run() + ) + ); + }, + disabled: (): boolean => plugin.requireDoc! && this.doc === null, + content: plugin.content, + kind: 'middle', + }) + ); + + this.bottomMenu.forEach(plugin => + bottomMenu.push({ + icon: plugin.icon || pluginIcons['menu'], + name: plugin.name, + action: ae => { + this.dispatchEvent( + newPendingStateEvent( + (( + (( + (ae.target).items[ae.detail.index].nextElementSibling + )) + )).run() + ) + ); + }, + disabled: (): boolean => plugin.requireDoc! && this.doc === null, + content: plugin.content, + kind: 'middle', + }) + ); + + this.validators.forEach(plugin => + validators.push({ + 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].nextElementSibling + )) + )).validate() + ) + ); + }, + disabled: (): boolean => this.doc === null, + content: plugin.content, + kind: 'validator', + }) + ); + + if (middleMenu.length > 0) middleMenu.push('divider'); + if (bottomMenu.length > 0) bottomMenu.push('divider'); + + console.log('menu'); + return [ + 'divider', + ...topMenu, + 'divider', + { + icon: 'undo', + name: 'undo', + actionItem: true, + action: this.undo, + disabled: (): boolean => !this.canUndo, + kind: 'static', + }, + { + icon: 'redo', + name: 'redo', + actionItem: true, + action: this.redo, + disabled: (): boolean => !this.canRedo, + kind: 'static', + }, + ...validators, + { + icon: 'list', + name: 'menu.viewLog', + actionItem: true, + action: (): void => this.logUI.show(), + kind: 'static', + }, + { + icon: 'history', + name: 'menu.viewHistory', + actionItem: true, + action: (): void => this.historyUI.show(), + kind: 'static', + }, + { + icon: 'rule', + name: 'menu.viewDiag', + actionItem: true, + action: (): void => this.diagnosticUI.show(), + kind: 'static', + }, + 'divider', + ...middleMenu, + { + icon: 'settings', + name: 'settings.title', + action: (): void => { + this.dispatchEvent(newSettingsUIEvent(true)); + }, + kind: 'static', + }, + ...bottomMenu, + { + icon: 'extension', + name: 'plugins.heading', + action: (): void => this.pluginUI.show(), + kind: 'static', + }, + ]; + } + + renderMenuItem(me: MenuItem | 'divider'): TemplateResult { + if (me === 'divider') + return html`
  • `; + if (me.actionItem) return html``; + return html` + ${me.icon} + ${translate(me.name)} + ${me.hint + ? html`${me.hint}` + : ''} + + ${me.content ?? ''} + `; + } + + renderActionItem(me: MenuItem | 'divider'): TemplateResult { + if (me !== 'divider' && me.actionItem) + return html``; + else return html``; + } + + renderEditorTab({ name, icon }: Plugin): TemplateResult { + return html` + `; + } + + renderHosting(): TemplateResult { + return html` + ${translate('menu.title')} + ${this.docName + ? html`${this.docName}` + : ''} + ) => { + //FIXME: dirty hack to be fixed in open-scd-core + // if clause not necessary when oscd... components in open-scd not list + if (ae.target instanceof List) + (( + this.menu.filter( + item => item !== 'divider' && !item.actionItem + )[ae.detail.index] + ))?.action?.(ae); + }} + > + ${this.menu.map(this.renderMenuItem)} + + + + (this.menuUI.open = true)} + > +
    ${this.docName}
    + ${this.menu.map(this.renderActionItem)} + ${this.doc + ? html` + (this.activeTab = e.detail.index)} + > + ${this.editors.map(this.renderEditorTab)} + ` + : ``} +
    +
    + + ${this.doc && this.editors[this.activeTab]?.content + ? this.editors[this.activeTab].content + : html`
    + ${(this.menu.filter(mi => mi !== 'divider')).map( + (mi: MenuItem, index) => + mi.kind === 'top' && !mi.disabled?.() + ? html` + +
    ${mi.name}
    +
    + ` + : html`` + )} +
    `}`; + } } diff --git a/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js b/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js index 6433cc078a..25a8d6a9f0 100644 --- a/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js +++ b/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js @@ -1,370 +1,10 @@ /* @web/test-runner snapshot v1 */ export const snapshots = {}; -snapshots["SettingElement saves chosen .nsdoc file and looks like latest snapshot"] = -` -
    - - - English - - - German (Deutsch) - - - - - - - - - - - - - - -
    - - -
    -

    - Uploaded NSDoc files -

    - - - -
    - - - - IEC 61850-7-2 - - - 2007B3 - - - done - - - delete - - - - - IEC 61850-7-3 - - - close - - - - - IEC 61850-7-4 - - - close - - - - - IEC 61850-8-1 - - - close - - - - - Cancel - - - Reset - - - Save - -
    -`; -/* end snapshot SettingElement saves chosen .nsdoc file and looks like latest snapshot */ - -snapshots["SettingElement deletes a chosen .nsdoc file and looks like latest snapshot"] = -` -
    - - - English - - - German (Deutsch) - - - - - - - - - - - - - - -
    - - -
    -

    - Uploaded NSDoc files -

    - - - -
    - - - - IEC 61850-7-2 - - - close - - - - - IEC 61850-7-3 - - - close - - - - - IEC 61850-7-4 - - - close - - - - - IEC 61850-8-1 - - - close - - - - - Cancel - - - Reset - - - Save - -
    -`; -/* end snapshot SettingElement deletes a chosen .nsdoc file and looks like latest snapshot */ - snapshots["OSCD-Settings saves chosen .nsdoc file and looks like latest snapshot"] = -` + + - - `; /* end snapshot OSCD-Settings saves chosen .nsdoc file and looks like latest snapshot */ snapshots["OSCD-Settings deletes a chosen .nsdoc file and looks like latest snapshot"] = -` + + - - `; /* end snapshot OSCD-Settings deletes a chosen .nsdoc file and looks like latest snapshot */ From 7a84fa2142aa2a57dcd7568a147014274abc5d5f Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Thu, 15 Feb 2024 12:03:07 +0100 Subject: [PATCH 14/27] Removed Hosting Mixin --- packages/open-scd/src/Hosting.ts | 358 ------------------------------- 1 file changed, 358 deletions(-) delete mode 100644 packages/open-scd/src/Hosting.ts diff --git a/packages/open-scd/src/Hosting.ts b/packages/open-scd/src/Hosting.ts deleted file mode 100644 index cf220e92c5..0000000000 --- a/packages/open-scd/src/Hosting.ts +++ /dev/null @@ -1,358 +0,0 @@ -import { html, property, query, TemplateResult } from 'lit-element'; -import { translate } from 'lit-translate'; - -import '@material/mwc-drawer'; -import '@material/mwc-icon'; -import '@material/mwc-icon-button'; -import '@material/mwc-linear-progress'; -import '@material/mwc-list'; -import '@material/mwc-list/mwc-list-item'; -import '@material/mwc-tab'; -import '@material/mwc-tab-bar'; -import '@material/mwc-top-app-bar-fixed'; - -import { Drawer } from '@material/mwc-drawer'; -import { ActionDetail, List } from '@material/mwc-list'; -import { ListItem } from '@material/mwc-list/mwc-list-item'; - -import { - Mixin, - newPendingStateEvent, - newSettingsUIEvent, -} from './foundation.js'; -import { HistoringElement } from './Historing.js'; -import { Plugin, PluggingElement, pluginIcons } from './Plugging.js'; - -interface MenuItem { - icon: string; - name: string; - hint?: string; - actionItem?: boolean; - action?: (event: CustomEvent) => void; - disabled?: () => boolean; - content?: TemplateResult; - kind: string; -} - -interface Validator { - validate: () => Promise; -} - -interface MenuPlugin { - run: () => Promise; -} - -/** Mixin that hosts the UI for Plugins, Settings and Historing */ -export type HostingElement = Mixin; - -export function Hosting< - TBase extends new (...args: any[]) => PluggingElement & HistoringElement ->(Base: TBase) { - class HostingElement extends Base { - /** The currently active editor tab. */ - @property({ type: Number }) - activeTab = 0; - @property({ attribute: false }) - validated: Promise = Promise.resolve(); - - private shouldValidate = false; - - @query('#menu') menuUI!: Drawer; - - get menu(): (MenuItem | 'divider')[] { - const topMenu: (MenuItem | 'divider')[] = []; - const middleMenu: (MenuItem | 'divider')[] = []; - const bottomMenu: (MenuItem | 'divider')[] = []; - const validators: (MenuItem | 'divider')[] = []; - - this.topMenu.forEach(plugin => - topMenu.push({ - icon: plugin.icon || pluginIcons['menu'], - name: plugin.name, - action: ae => { - this.dispatchEvent( - newPendingStateEvent( - (( - (( - (ae.target).items[ae.detail.index].nextElementSibling - )) - )).run() - ) - ); - }, - disabled: (): boolean => plugin.requireDoc! && this.doc === null, - content: plugin.content, - kind: 'top', - }) - ); - - this.middleMenu.forEach(plugin => - middleMenu.push({ - icon: plugin.icon || pluginIcons['menu'], - name: plugin.name, - action: ae => { - this.dispatchEvent( - newPendingStateEvent( - (( - (( - (ae.target).items[ae.detail.index].nextElementSibling - )) - )).run() - ) - ); - }, - disabled: (): boolean => plugin.requireDoc! && this.doc === null, - content: plugin.content, - kind: 'middle', - }) - ); - - this.bottomMenu.forEach(plugin => - bottomMenu.push({ - icon: plugin.icon || pluginIcons['menu'], - name: plugin.name, - action: ae => { - this.dispatchEvent( - newPendingStateEvent( - (( - (( - (ae.target).items[ae.detail.index].nextElementSibling - )) - )).run() - ) - ); - }, - disabled: (): boolean => plugin.requireDoc! && this.doc === null, - content: plugin.content, - kind: 'middle', - }) - ); - - this.validators.forEach(plugin => - validators.push({ - 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].nextElementSibling - )) - )).validate() - ) - ); - }, - disabled: (): boolean => this.doc === null, - content: plugin.content, - kind: 'validator', - }) - ); - - if (middleMenu.length > 0) middleMenu.push('divider'); - if (bottomMenu.length > 0) bottomMenu.push('divider'); - - return [ - 'divider', - ...topMenu, - 'divider', - { - icon: 'undo', - name: 'undo', - actionItem: true, - action: this.undo, - disabled: (): boolean => !this.canUndo, - kind: 'static', - }, - { - icon: 'redo', - name: 'redo', - actionItem: true, - action: this.redo, - disabled: (): boolean => !this.canRedo, - kind: 'static', - }, - ...validators, - { - icon: 'list', - name: 'menu.viewLog', - actionItem: true, - action: (): void => this.logUI.show(), - kind: 'static', - }, - { - icon: 'history', - name: 'menu.viewHistory', - actionItem: true, - action: (): void => this.historyUI.show(), - kind: 'static', - }, - { - icon: 'rule', - name: 'menu.viewDiag', - actionItem: true, - action: (): void => this.diagnosticUI.show(), - kind: 'static', - }, - 'divider', - ...middleMenu, - { - icon: 'settings', - name: 'settings.title', - action: (): void => { - this.dispatchEvent(newSettingsUIEvent(true)); - }, - kind: 'static', - }, - ...bottomMenu, - { - icon: 'extension', - name: 'plugins.heading', - action: (): void => this.pluginUI.show(), - kind: 'static', - }, - ]; - } - - constructor(...args: any[]) { - super(...args); - - 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 => - ((item.nextElementSibling)).validate() - ) - ).then(); - this.dispatchEvent(newPendingStateEvent(this.validated)); - }); - this.addEventListener('close-drawer', async () => { - this.menuUI.open = false; - }); - } - - renderMenuItem(me: MenuItem | 'divider'): TemplateResult { - if (me === 'divider') - return html`
  • `; - if (me.actionItem) return html``; - return html` - ${me.icon} - ${translate(me.name)} - ${me.hint - ? html`${me.hint}` - : ''} - - ${me.content ?? ''} - `; - } - - renderActionItem(me: MenuItem | 'divider'): TemplateResult { - if (me !== 'divider' && me.actionItem) - return html``; - else return html``; - } - - renderEditorTab({ name, icon }: Plugin): TemplateResult { - return html` - `; - } - - render(): TemplateResult { - return html` - ${translate('menu.title')} - ${this.docName - ? html`${this.docName}` - : ''} - ) => { - //FIXME: dirty hack to be fixed in open-scd-core - // if clause not necessary when oscd... components in open-scd not list - if (ae.target instanceof List) - (( - this.menu.filter( - item => item !== 'divider' && !item.actionItem - )[ae.detail.index] - ))?.action?.(ae); - }} - > - ${this.menu.map(this.renderMenuItem)} - - - - (this.menuUI.open = true)} - > -
    ${this.docName}
    - ${this.menu.map(this.renderActionItem)} - ${this.doc - ? html` - (this.activeTab = e.detail.index)} - > - ${this.editors.map(this.renderEditorTab)} - ` - : ``} -
    -
    - - ${this.doc && this.editors[this.activeTab]?.content - ? this.editors[this.activeTab].content - : html`
    - ${(this.menu.filter(mi => mi !== 'divider')).map( - (mi: MenuItem, index) => - mi.kind === 'top' && !mi.disabled?.() - ? html` - -
    ${mi.name}
    -
    - ` - : html`` - )} -
    `} - ${super.render()}`; - } - } - return HostingElement; -} From e997916d662ef98c448b8226d1eb8dcb2c4f1948 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Thu, 15 Feb 2024 16:23:55 +0100 Subject: [PATCH 15/27] Removed console.log --- packages/open-scd/src/open-scd.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/open-scd/src/open-scd.ts b/packages/open-scd/src/open-scd.ts index 238a502748..c0fafd427c 100644 --- a/packages/open-scd/src/open-scd.ts +++ b/packages/open-scd/src/open-scd.ts @@ -360,7 +360,6 @@ export class OpenSCD extends Wizarding( if (middleMenu.length > 0) middleMenu.push('divider'); if (bottomMenu.length > 0) bottomMenu.push('divider'); - console.log('menu'); return [ 'divider', ...topMenu, From 2a5bc49b666aaf9c8a09fb21e89c5c58fd33c8c7 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Thu, 15 Feb 2024 21:12:02 +0100 Subject: [PATCH 16/27] Feat: Removed custom webcomponent definition in tests --- .../test/integration/editors/IED.test.ts | 53 +- .../integration/editors/Protocol104.test.ts | 24 +- .../integration/editors/Substation.test.ts | 37 +- .../editors/__snapshots__/IED.test.snap.js | 13 +- .../__snapshots__/Protocol104.test.snap.js | 12 +- .../__snapshots__/Substation.test.snap.js | 2 - .../control-blocks-container.test.snap.js | 10 +- .../cleanup/control-blocks-container.test.ts | 34 +- .../cleanup/datasets-container.test.ts | 29 +- .../cleanup/datatypes-container.test.ts | 41 +- .../cleanup/dist/datasets-container.test.js | 158 ++++ .../cleanup/dist/datatypes-container.test.js | 444 +++++++++++ .../communication/Communication.test.ts | 69 +- .../communication/dist/Communication.test.js | 176 +++++ .../editors/dist/Substation.test.js | 141 ++++ .../editors/templates/Templates.test.ts | 50 +- .../templates/datype-wizarding.test.ts | 12 +- .../editors/templates/dist/Templates.test.js | 365 +++++++++ .../templates/dist/datype-wizarding.test.js | 333 ++++++++ .../templates/dist/dotype-wizarding.test.js | 612 +++++++++++++++ .../templates/dist/enumtype-wizarding.test.js | 510 ++++++++++++ .../templates/dist/lnodetype-wizard.test.js | 727 ++++++++++++++++++ .../templates/dotype-wizarding.test.ts | 12 +- .../templates/enumtype-wizarding.test.ts | 12 +- .../templates/lnodetype-wizard.test.ts | 12 +- .../triggered/ImportIedsPlugin.test.ts | 65 +- .../triggered/dist/ImportIedsPlugin.test.js | 538 +++++++++++++ .../test/integration/menu/NewProject.test.ts | 12 +- .../menu/UpdateDescritionABB.test.ts | 14 +- .../integration/menu/dist/NewProject.test.js | 139 ++++ .../menu/dist/UpdateDescritionABB.test.js | 104 +++ .../validators/ValidateSchema.test.ts | 14 +- .../validators/ValidateTemplates.test.ts | 25 +- .../validators/dist/ValidateSchema.test.js | 185 +++++ .../validators/dist/ValidateTemplates.test.js | 184 +++++ .../wizards/bda-wizarding-editing.test.ts | 12 +- .../wizards/da-wizarding-editing.test.ts | 12 +- .../dist/bda-wizarding-editing.test.js | 255 ++++++ .../wizards/dist/da-wizarding-editing.test.js | 274 +++++++ packages/open-scd/test/mock-open-scd.ts | 27 + .../cleanup/control-blocks-container.test.ts | 13 +- .../cleanup/datasets-container.test.ts | 30 +- .../cleanup/datatypes-container.test.ts | 26 +- .../dist/control-blocks-container.test.js | 181 +++++ .../cleanup/dist/datasets-container.test.js | 191 +++++ .../cleanup/dist/datatypes-container.test.js | 130 ++++ .../dist/fcda-binding-list.test.js | 434 +++++++++++ .../subscription/fcda-binding-list.test.ts | 30 +- .../test/unit/menu/SclHistory.test.ts | 2 + .../unit/menu/UpdateDescriptionSEL.test.ts | 10 +- .../unit/menu/UpdateDescritionABB.test.ts | 14 +- .../test/unit/menu/dist/SclHistory.test.js | 158 ++++ .../menu/dist/UpdateDescriptionSEL.test.js | 236 ++++++ .../menu/dist/UpdateDescritionABB.test.js | 150 ++++ .../unit/validators/ValidateTemplates.test.ts | 20 +- .../validators/dist/ValidateTemplates.test.js | 212 +++++ 56 files changed, 7213 insertions(+), 372 deletions(-) create mode 100644 packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js create mode 100644 packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js create mode 100644 packages/open-scd/test/integration/editors/communication/dist/Communication.test.js create mode 100644 packages/open-scd/test/integration/editors/dist/Substation.test.js create mode 100644 packages/open-scd/test/integration/editors/templates/dist/Templates.test.js create mode 100644 packages/open-scd/test/integration/editors/templates/dist/datype-wizarding.test.js create mode 100644 packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js create mode 100644 packages/open-scd/test/integration/editors/templates/dist/enumtype-wizarding.test.js create mode 100644 packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js create mode 100644 packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js create mode 100644 packages/open-scd/test/integration/menu/dist/NewProject.test.js create mode 100644 packages/open-scd/test/integration/menu/dist/UpdateDescritionABB.test.js create mode 100644 packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js create mode 100644 packages/open-scd/test/integration/validators/dist/ValidateTemplates.test.js create mode 100644 packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js create mode 100644 packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js create mode 100644 packages/open-scd/test/mock-open-scd.ts create mode 100644 packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js create mode 100644 packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js create mode 100644 packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js create mode 100644 packages/open-scd/test/unit/editors/subscription/dist/fcda-binding-list.test.js create mode 100644 packages/open-scd/test/unit/menu/dist/SclHistory.test.js create mode 100644 packages/open-scd/test/unit/menu/dist/UpdateDescriptionSEL.test.js create mode 100644 packages/open-scd/test/unit/menu/dist/UpdateDescritionABB.test.js create mode 100644 packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js diff --git a/packages/open-scd/test/integration/editors/IED.test.ts b/packages/open-scd/test/integration/editors/IED.test.ts index e8c7f47cea..66929035fa 100644 --- a/packages/open-scd/test/integration/editors/IED.test.ts +++ b/packages/open-scd/test/integration/editors/IED.test.ts @@ -4,10 +4,9 @@ import '../../mock-wizard.js'; import { LitElement } from 'lit-element'; +import '../../mock-open-scd.js'; import '../../../src/editors/IED.js'; -import { Editing } from '../../../src/Editing.js'; -import { Wizarding, WizardingElement } from '../../../src/Wizarding.js'; import { initializeNsdoc, Nsdoc } from '../../../src/foundation/nsdoc.js'; import { FilterButton } from '../../../src/oscd-filter-button.js'; @@ -16,16 +15,21 @@ import { LDeviceContainer } from '../../../src/editors/ied/ldevice-container.js' import { LNContainer } from '../../../src/editors/ied/ln-container.js'; import { DOContainer } from '../../../src/editors/ied/do-container.js'; import { DAContainer } from '../../../src/editors/ied/da-container.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; describe('IED Plugin', () => { if (customElements.get('ied-plugin') === undefined) - customElements.define('ied-plugin', Wizarding(Editing(IED))); + customElements.define('ied-plugin', IED); let element: IED; + let parent: MockOpenSCD; let nsdoc: Nsdoc; describe('without a doc loaded', () => { beforeEach(async () => { - element = await fixture(html``); + parent = await fixture( + html`` + ); + element = parent.getActivePlugin(); await element.requestUpdate(); await element.updateComplete; }); @@ -44,9 +48,12 @@ describe('IED Plugin', () => { .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); nsdoc = await initializeNsdoc(); - element = await fixture( - html` ` + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); await element.requestUpdate(); await element.updateComplete; }); @@ -64,9 +71,12 @@ describe('IED Plugin', () => { nsdoc = await initializeNsdoc(); - element = await fixture( - html`` + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); await element.requestUpdate(); await element.updateComplete; @@ -85,7 +95,7 @@ describe('IED Plugin', () => { await element.requestUpdate(); - expect((element as any as WizardingElement).wizardUI).to.exist; + expect(parent.wizardUI).to.exist; }); }); @@ -95,9 +105,12 @@ describe('IED Plugin', () => { .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); nsdoc = await initializeNsdoc(); - element = await fixture( - html`` + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); await element.requestUpdate(); await element.updateComplete; }); @@ -241,9 +254,12 @@ describe('IED Plugin', () => { new DOMParser().parseFromString(str, 'application/xml') ); nsdoc = await initializeNsdoc(); - element = await fixture( - html`` + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); await element.requestUpdate(); await element.updateComplete; }); @@ -283,15 +299,12 @@ describe('IED Plugin', () => { 'mwc-icon-button[icon="add"]' ) as HTMLElement)!.click(); - await element.updateComplete; + await parent.updateComplete; + expect(parent.wizardUI.dialogs.length).to.equal(1); expect( - (element as any as WizardingElement).wizardUI.dialogs.length - ).to.equal(1); - expect( - ( - element as any as WizardingElement - ).wizardUI.dialogs[0]!.querySelectorAll('wizard-textfield').length + parent.wizardUI.dialogs[0]!.querySelectorAll('wizard-textfield') + .length ).to.equal(3); }); }); diff --git a/packages/open-scd/test/integration/editors/Protocol104.test.ts b/packages/open-scd/test/integration/editors/Protocol104.test.ts index 4b27c64ae8..512114a830 100644 --- a/packages/open-scd/test/integration/editors/Protocol104.test.ts +++ b/packages/open-scd/test/integration/editors/Protocol104.test.ts @@ -1,17 +1,14 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../mock-wizard.js'; +import '../../mock-open-scd.js'; import Protocol104 from '../../../src/editors/Protocol104.js'; -import { Editing } from '../../../src/Editing.js'; -import { Wizarding } from '../../../src/Wizarding.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; describe('Protocol 104 Plugin', () => { - customElements.define( - 'protocol104-plugin', - Wizarding(Editing(Protocol104)) - ); + customElements.define('protocol104-plugin', Protocol104); let element: Protocol104; + let parent: MockOpenSCD; let doc: XMLDocument; beforeEach(async () => { @@ -19,15 +16,18 @@ describe('Protocol 104 Plugin', () => { .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - element = await fixture( - html`` + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); }); describe('in Values view', () => { - it('the plugin looks like the latest snapshot', async () => { - await expect(element).shadowDom.to.equalSnapshot(); - }); + it('the plugin looks like the latest snapshot', async () => { + await expect(element).shadowDom.to.equalSnapshot(); + }); }); describe('in Network view', () => { diff --git a/packages/open-scd/test/integration/editors/Substation.test.ts b/packages/open-scd/test/integration/editors/Substation.test.ts index 42e8715887..7eb90d766e 100644 --- a/packages/open-scd/test/integration/editors/Substation.test.ts +++ b/packages/open-scd/test/integration/editors/Substation.test.ts @@ -1,17 +1,21 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../mock-wizard.js'; -import { MockWizard } from '../../mock-wizard.js'; +import '../../mock-open-scd.js'; -import { Editing } from '../../../src/Editing.js'; import Substation from '../../../src/editors/Substation.js'; -import { Wizarding } from '../../../src/Wizarding.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; describe('Substation Plugin', () => { - customElements.define('substation-plugin', Wizarding(Editing(Substation))); + customElements.define('substation-plugin', Substation); let element: Substation; + let parent: MockOpenSCD; beforeEach(async () => { - element = await fixture(html``); + parent = await fixture( + html`` + ); + element = parent.getActivePlugin(); }); describe('without a doc loaded', () => { @@ -23,13 +27,17 @@ describe('Substation Plugin', () => { describe('with a doc loaded including substation section', () => { let doc: XMLDocument; let element: Substation; + let parent: MockOpenSCD; beforeEach(async () => { doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - element = await fixture( - html`` + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); }); it('constains a zeroline-pane rendering the substation sections', () => { expect(element.shadowRoot?.querySelector('zeroline-pane')).to.exist; @@ -38,19 +46,18 @@ describe('Substation Plugin', () => { describe('with a doc loaded missing a substation section', () => { let doc: XMLDocument; - let parent: MockWizard; + let parent: MockOpenSCD; beforeEach(async () => { doc = await fetch('/test/testfiles/missingSubstation.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( - await fixture( - html`` - ) + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); await element.updateComplete; }); it('has a mwc-fab', () => { diff --git a/packages/open-scd/test/integration/editors/__snapshots__/IED.test.snap.js b/packages/open-scd/test/integration/editors/__snapshots__/IED.test.snap.js index b07ca79296..2e0ad05334 100644 --- a/packages/open-scd/test/integration/editors/__snapshots__/IED.test.snap.js +++ b/packages/open-scd/test/integration/editors/__snapshots__/IED.test.snap.js @@ -4,22 +4,18 @@ export const snapshots = {}; snapshots["IED Plugin without a doc loaded looks like the latest snapshot"] = `

    - [iededitor.missing] + No IED

    - - `; /* end snapshot IED Plugin without a doc loaded looks like the latest snapshot */ snapshots["IED Plugin with a doc loaded containing no IEDs looks like the latest snapshot"] = `

    - [iededitor.missing] + No IED

    - - `; /* end snapshot IED Plugin with a doc loaded containing no IEDs looks like the latest snapshot */ @@ -27,7 +23,7 @@ snapshots["IED Plugin with a doc loaded containing IEDs looks like the latest sn `

    - [filters]: + Filters:

    - - `; /* end snapshot IED Plugin with a doc loaded containing IEDs looks like the latest snapshot */ diff --git a/packages/open-scd/test/integration/editors/__snapshots__/Protocol104.test.snap.js b/packages/open-scd/test/integration/editors/__snapshots__/Protocol104.test.snap.js index 2e48e6a02d..eeb9bbded1 100644 --- a/packages/open-scd/test/integration/editors/__snapshots__/Protocol104.test.snap.js +++ b/packages/open-scd/test/integration/editors/__snapshots__/Protocol104.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["Protocol 104 Plugin in Values view the plugin looks like the latest snapshot"] = `
    - + - +
    - - `; /* end snapshot Protocol 104 Plugin in Values view the plugin looks like the latest snapshot */ snapshots["Protocol 104 Plugin in Network view the plugin looks like the latest snapshot"] = `
    - + - +
    - - `; /* end snapshot Protocol 104 Plugin in Network view the plugin looks like the latest snapshot */ diff --git a/packages/open-scd/test/integration/editors/__snapshots__/Substation.test.snap.js b/packages/open-scd/test/integration/editors/__snapshots__/Substation.test.snap.js index b385e4d863..ac79c3ceea 100644 --- a/packages/open-scd/test/integration/editors/__snapshots__/Substation.test.snap.js +++ b/packages/open-scd/test/integration/editors/__snapshots__/Substation.test.snap.js @@ -12,8 +12,6 @@ snapshots["Substation Plugin without a doc loaded looks like the latest snapshot > - - `; /* end snapshot Substation Plugin without a doc loaded looks like the latest snapshot */ diff --git a/packages/open-scd/test/integration/editors/cleanup/__snapshots__/control-blocks-container.test.snap.js b/packages/open-scd/test/integration/editors/cleanup/__snapshots__/control-blocks-container.test.snap.js index c1d6cc71b5..7c7518639c 100644 --- a/packages/open-scd/test/integration/editors/cleanup/__snapshots__/control-blocks-container.test.snap.js +++ b/packages/open-scd/test/integration/editors/cleanup/__snapshots__/control-blocks-container.test.snap.js @@ -5,12 +5,12 @@ snapshots["cleanup-editor integration: unreferenced control blocks without a doc `

    - [cleanup.unreferencedControls.title] + Control Blocks with a Missing or Invalid Dataset (0) @@ -53,13 +53,13 @@ snapshots["cleanup-editor integration: unreferenced control blocks without a doc class="deleteButton" disabled="" icon="delete" - label="[cleanup.unreferencedControls.deleteButton] (0)" + label="Remove Selected Control Blocks (0)" outlined="" >

    - - `; /* end snapshot cleanup-editor integration: unreferenced control blocks without a doc loaded looks like the latest snapshot */ diff --git a/packages/open-scd/test/integration/editors/cleanup/control-blocks-container.test.ts b/packages/open-scd/test/integration/editors/cleanup/control-blocks-container.test.ts index fde24a1008..95aa73eec6 100644 --- a/packages/open-scd/test/integration/editors/cleanup/control-blocks-container.test.ts +++ b/packages/open-scd/test/integration/editors/cleanup/control-blocks-container.test.ts @@ -1,27 +1,26 @@ 'use strict'; import { html, fixture, expect } from '@open-wc/testing'; -import { Editing } from '../../../../src/Editing.js'; -import { Wizarding } from '../../../../src/Wizarding.js'; +import '../../../mock-open-scd.js'; +import '../../../../src/editors/cleanup/control-blocks-container.js'; import { CleanupControlBlocks } from '../../../../src/editors/cleanup/control-blocks-container.js'; import { cleanSCLItems } from '../../../../src/editors/cleanup/foundation.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('cleanup-editor integration: unreferenced control blocks', () => { - customElements.define( - 'cleanup-plugin-controlblocks', - Wizarding(Editing(CleanupControlBlocks)) - ); let element: CleanupControlBlocks; + let parent: MockOpenSCD; describe('without a doc loaded', () => { beforeEach(async () => { - element = await fixture( - html`` + parent = await fixture( + html`` ); - await element.updateComplete; + element = parent.getActivePlugin(); + await parent.updateComplete; }); it('looks like the latest snapshot', async () => { @@ -35,15 +34,18 @@ describe('cleanup-editor integration: unreferenced control blocks', () => { doc = await fetch('/test/testfiles/cleanup.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - element = await fixture( - html`` + parent = await fixture( + html`` ); - await element.updateComplete; + element = parent.getActivePlugin(); + await parent.updateComplete; + console.log('foo'); }); it('correctly removes all LogControl entries from the SCL', async () => { + console.log('error here'); await element.cleanupGSEControlFilter.click(); await element.cleanupSampledValueControlFilter.click(); // select all items and update list diff --git a/packages/open-scd/test/integration/editors/cleanup/datasets-container.test.ts b/packages/open-scd/test/integration/editors/cleanup/datasets-container.test.ts index 0dde819f9e..afdadf138d 100644 --- a/packages/open-scd/test/integration/editors/cleanup/datasets-container.test.ts +++ b/packages/open-scd/test/integration/editors/cleanup/datasets-container.test.ts @@ -1,26 +1,28 @@ 'use strict'; import { html, fixture, expect } from '@open-wc/testing'; -import { Editing } from '../../../../src/Editing.js'; -import { Wizarding } from '../../../../src/Wizarding.js'; +import '../../../mock-open-scd.js'; import { CleanupDatasets } from '../../../../src/editors/cleanup/datasets-container.js'; import { cleanSCLItems } from '../../../../src/editors/cleanup/foundation.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; + describe('cleanup-editor integration: dataset removal', () => { - customElements.define( - 'cleanup-plugin-datasets', - Wizarding(Editing(CleanupDatasets)) - ); + customElements.define('cleanup-plugin-datasets', CleanupDatasets); let element: CleanupDatasets; + let parent: MockOpenSCD; describe('without a doc loaded', () => { beforeEach(async () => { const doc = null; - element = await fixture( - html`` + parent = await fixture( + html`` ); - await element.updateComplete; + element = parent.getActivePlugin(); + await parent.updateComplete; }); it('looks like the latest snapshot', async () => { @@ -34,10 +36,13 @@ describe('cleanup-editor integration: dataset removal', () => { doc = await fetch('/test/testfiles/cleanup.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - element = await fixture( - html`` + parent = await fixture( + html`` ); - await element.updateComplete; + element = parent.getActivePlugin(); + await parent.updateComplete; }); it('looks like the latest snapshot', async () => { diff --git a/packages/open-scd/test/integration/editors/cleanup/datatypes-container.test.ts b/packages/open-scd/test/integration/editors/cleanup/datatypes-container.test.ts index 7964527239..9a7ef225c0 100644 --- a/packages/open-scd/test/integration/editors/cleanup/datatypes-container.test.ts +++ b/packages/open-scd/test/integration/editors/cleanup/datatypes-container.test.ts @@ -1,27 +1,26 @@ 'use strict'; import { html, fixture, expect } from '@open-wc/testing'; -import { Editing } from '../../../../src/Editing.js'; -import { Wizarding } from '../../../../src/Wizarding.js'; +import '../../../mock-open-scd.js'; import { CleanupDataTypes } from '../../../../src/editors/cleanup/datatypes-container.js'; import { cleanSCLItems } from '../../../../src/editors/cleanup/foundation.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('cleanup-editor integration: unreferenced control blocks', () => { - customElements.define( - 'cleanup-plugin-data-types', - Wizarding(Editing(CleanupDataTypes)) - ); + customElements.define('cleanup-plugin-data-types', CleanupDataTypes); let element: CleanupDataTypes; + let parent: MockOpenSCD; describe('without a doc loaded', () => { beforeEach(async () => { - element = await fixture( - html`` + parent = await fixture( + html`` ); - await element.updateComplete; + element = parent.getActivePlugin(); + await parent.updateComplete; }); it('looks like the latest snapshot', async () => { @@ -35,12 +34,13 @@ describe('cleanup-editor integration: unreferenced control blocks', () => { doc = await fetch('/test/testfiles/cleanup.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - element = await fixture( - html`` + parent = await fixture( + html`` ); - await element.updateComplete; + element = parent.getActivePlugin(); + await parent.updateComplete; }); it('correctly removes a LNodeType entry from the SCL', async () => { @@ -125,13 +125,10 @@ describe('cleanup-editor integration: unreferenced control blocks', () => { expect(element.doc.querySelectorAll('EnumType')).to.have.lengthOf(11); expect( - element.doc.querySelectorAll( - 'EnumType[id="NotUsedDir"]' - ) + element.doc.querySelectorAll('EnumType[id="NotUsedDir"]') ).to.have.lengthOf(0); }); - describe('if the Remove subtypes checkbox is unchecked', () => { beforeEach(async () => { element.cleanSubTypesCheckbox!.checked = false; @@ -159,7 +156,9 @@ describe('cleanup-editor integration: unreferenced control blocks', () => { 'DOType[id="NotUsedDummy.SPS"], DOType[id="WYE_2_3"], DOType[id="Dummy.LLN0.Health.Unused]' ) ).to.have.lengthOf(0); - expect(element.doc.querySelectorAll('DOType[id="CMV_1"]')).to.have.lengthOf(1); + expect( + element.doc.querySelectorAll('DOType[id="CMV_1"]') + ).to.have.lengthOf(1); }); it('correctly removes DATypes and _not_ those referenced via a BDA from the SCL', async () => { diff --git a/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js b/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js new file mode 100644 index 0000000000..8ed25a5bf2 --- /dev/null +++ b/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js @@ -0,0 +1,158 @@ +'use strict'; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +var datasets_container_js_1 = require("../../../../src/editors/cleanup/datasets-container.js"); +var foundation_js_1 = require("../../../../src/editors/cleanup/foundation.js"); +describe('cleanup-editor integration: dataset removal', function () { + customElements.define('cleanup-plugin-datasets', datasets_container_js_1.CleanupDatasets); + var element; + var parent; + describe('without a doc loaded', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var doc; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + doc = null; + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('With a test file loaded', function () { + var doc; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates two delete actions', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox, cleanItems, deleteActions; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + checkbox = element + .shadowRoot.querySelector('.dataSetList') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 1: + _b.sent(); + (_a = element.dataSetList) === null || _a === void 0 ? void 0 : _a.layout(); + cleanItems = Array.from(element.dataSetList.index.values()).map(function (index) { return element.unreferencedDataSets[index]; }); + deleteActions = foundation_js_1.cleanSCLItems(cleanItems); + testing_1.expect(deleteActions.length).to.equal(2); + return [2 /*return*/]; + } + }); + }); }); + it('correctly removes the datasets from the SCL file', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox, remainingDataSetCountCheck, datasetsCorrectlyRemoved; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + checkbox = element + .shadowRoot.querySelector('.dataSetList') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 1: + _b.sent(); + (_a = element.dataSetList) === null || _a === void 0 ? void 0 : _a.layout(); + return [4 /*yield*/, element.cleanupButton.click()]; + case 2: + _b.sent(); + remainingDataSetCountCheck = element.doc.querySelectorAll(':root > IED > AccessPoint > Server > LDevice > LN0 > DataSet, :root > IED > AccessPoint > Server > LDevice > LN > DataSet').length === 6; + datasetsCorrectlyRemoved = element.doc.querySelectorAll('DataSet[name="GooseDataSet2"], DataSet[name="PhsMeas2"]').length === 0; + testing_1.expect(remainingDataSetCountCheck && datasetsCorrectlyRemoved).to.equal(true); + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js b/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js new file mode 100644 index 0000000000..b4eca26da2 --- /dev/null +++ b/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js @@ -0,0 +1,444 @@ +'use strict'; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +var datatypes_container_js_1 = require("../../../../src/editors/cleanup/datatypes-container.js"); +var foundation_js_1 = require("../../../../src/editors/cleanup/foundation.js"); +describe('cleanup-editor integration: unreferenced control blocks', function () { + customElements.define('cleanup-plugin-data-types', datatypes_container_js_1.CleanupDataTypes); + var element; + var parent; + describe('without a doc loaded', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), null))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with a test file loaded', function () { + var doc; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('correctly removes a LNodeType entry from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; + case 1: + _b.sent(); + return [4 /*yield*/, element.cleanupDATypeFilter.click()]; + case 2: + _b.sent(); + return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; + case 3: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 4: + _b.sent(); + return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 5: + _b.sent(); + return [4 /*yield*/, element.cleanButton.click()]; + case 6: + _b.sent(); + // the correct number of LNodeTypes should remain + testing_1.expect(element.doc.querySelectorAll('LNodeType')).to.have.length(12); + testing_1.expect(element.doc.querySelectorAll('LNodeType[id="NotUsedTVTR"]')).to.have.length(0); + return [2 /*return*/]; + } + }); + }); }); + it('correctly removes DOTypes and SDOs from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; + case 1: + _b.sent(); + return [4 /*yield*/, element.cleanupDATypeFilter.click()]; + case 2: + _b.sent(); + return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; + case 3: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 4: + _b.sent(); + return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 5: + _b.sent(); + return [4 /*yield*/, element.cleanButton.click()]; + case 6: + _b.sent(); + // the correct number of DOTypes should remain + testing_1.expect(element.doc.querySelectorAll('DOType')).to.have.lengthOf(32); + testing_1.expect(element.doc.querySelectorAll('DOType[id="NotUsedDummy.SPS"], DOType[name="WYE_2_3"], DOType[id="CMV_1"]')).to.have.lengthOf(0); + return [2 /*return*/]; + } + }); + }); }); + it('correctly removes DATypes and those referenced via BDAs from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; + case 1: + _b.sent(); + return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; + case 2: + _b.sent(); + return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; + case 3: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 4: + _b.sent(); + return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 5: + _b.sent(); + return [4 /*yield*/, element.cleanButton.click()]; + case 6: + _b.sent(); + testing_1.expect(element.doc.querySelectorAll('DAType')).to.have.lengthOf(15); + testing_1.expect(element.doc.querySelectorAll('DAType[id="NotUsedDummy.LPHD1.Sim.Cancel"], DAType[id="OnlySubUsedVector_0"], DAType[id="AnalogValue_0"]')).to.have.lengthOf(0); + return [2 /*return*/]; + } + }); + }); }); + it('correctly removes EnumTypes', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; + case 1: + _b.sent(); + return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; + case 2: + _b.sent(); + return [4 /*yield*/, element.cleanupDATypeFilter.click()]; + case 3: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 4: + _b.sent(); + return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 5: + _b.sent(); + return [4 /*yield*/, element.cleanButton.click()]; + case 6: + _b.sent(); + testing_1.expect(element.doc.querySelectorAll('EnumType')).to.have.lengthOf(11); + testing_1.expect(element.doc.querySelectorAll('EnumType[id="NotUsedDir"]')).to.have.lengthOf(0); + return [2 /*return*/]; + } + }); + }); }); + describe('if the Remove subtypes checkbox is unchecked', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + element.cleanSubTypesCheckbox.checked = false; + return [4 /*yield*/, element.cleanSubTypesCheckbox.requestUpdate()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('correctly removes two DOTypes and not those referenced via an SDO from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; + case 1: + _b.sent(); + return [4 /*yield*/, element.cleanupDATypeFilter.click()]; + case 2: + _b.sent(); + return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; + case 3: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 4: + _b.sent(); + return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 5: + _b.sent(); + return [4 /*yield*/, element.cleanButton.click()]; + case 6: + _b.sent(); + // the correct number of DOTypes should remain + testing_1.expect(element.doc.querySelectorAll('DOType')).to.have.lengthOf(33); + testing_1.expect(element.doc.querySelectorAll('DOType[id="NotUsedDummy.SPS"], DOType[id="WYE_2_3"], DOType[id="Dummy.LLN0.Health.Unused]')).to.have.lengthOf(0); + testing_1.expect(element.doc.querySelectorAll('DOType[id="CMV_1"]')).to.have.lengthOf(1); + return [2 /*return*/]; + } + }); + }); }); + it('correctly removes DATypes and _not_ those referenced via a BDA from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; + case 1: + _b.sent(); + return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; + case 2: + _b.sent(); + return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; + case 3: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 4: + _b.sent(); + return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 5: + _b.sent(); + return [4 /*yield*/, element.cleanButton.click()]; + case 6: + _b.sent(); + // the correct number of DATypes should remain + testing_1.expect(element.doc.querySelectorAll('DAType')).to.have.lengthOf(16); + testing_1.expect(element.doc.querySelectorAll('DAType[id="NotUsedDummy.LPHD1.Sim.Cancel"], DAType[id="OnlySubUsedVector_0"]')).to.have.lengthOf(0); + testing_1.expect(element.doc.querySelectorAll('DAType[id="AnalogValue_0"]')).to.have.lengthOf(1); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('if the LN filter is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; + case 1: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 2: + _b.sent(); + return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 3: + _b.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates the correct number of Delete actions', function () { + var deleteActions = foundation_js_1.cleanSCLItems(element.getCleanItems()); + testing_1.expect(deleteActions.length).to.equal(14); + }); + return [2 /*return*/]; + }); + }); }); + describe('if the DO filter is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; + case 1: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 2: + _b.sent(); + (_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout(); + return [2 /*return*/]; + } + }); + }); }); + it('creates the correct number of Delete actions (LNx1, DAx3, ENx1)', function () { + var deleteActions = foundation_js_1.cleanSCLItems(element.getCleanItems()); + testing_1.expect(deleteActions.length).to.equal(26); + }); + return [2 /*return*/]; + }); + }); }); + describe('if the DA filter is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupDATypeFilter.click()]; + case 1: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 2: + _b.sent(); + (_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout(); + return [2 /*return*/]; + } + }); + }); }); + it('creates the correct number of Delete Actions', function () { return __awaiter(void 0, void 0, void 0, function () { + var deleteActions; + return __generator(this, function (_a) { + deleteActions = foundation_js_1.cleanSCLItems(element.getCleanItems()); + testing_1.expect(deleteActions.length).to.equal(29); + return [2 /*return*/]; + }); + }); }); + return [2 /*return*/]; + }); + }); }); + describe('if the EN filter is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; + case 1: + _b.sent(); + checkbox = element + .shadowRoot.querySelector('.cleanup-list') + .shadowRoot.querySelector('mwc-formfield') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 2: + _b.sent(); + (_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout(); + return [2 /*return*/]; + } + }); + }); }); + it('creates the correct number of Delete Actions', function () { return __awaiter(void 0, void 0, void 0, function () { + var deleteActions; + return __generator(this, function (_a) { + deleteActions = foundation_js_1.cleanSCLItems(element.getCleanItems()); + testing_1.expect(deleteActions.length).to.equal(33); + return [2 /*return*/]; + }); + }); }); + return [2 /*return*/]; + }); + }); }); + }); +}); +var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/integration/editors/communication/Communication.test.ts b/packages/open-scd/test/integration/editors/communication/Communication.test.ts index f3288693fb..f1b6daf2af 100644 --- a/packages/open-scd/test/integration/editors/communication/Communication.test.ts +++ b/packages/open-scd/test/integration/editors/communication/Communication.test.ts @@ -1,17 +1,14 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import '../../../mock-open-scd.js'; -import Communication from '../../../../src/editors/Communication.js'; +import Communication from '../../../../src/editors/Communication.js'; import { Dialog } from '@material/mwc-dialog'; import { WizardTextField } from '../../../../src/wizard-textfield.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('Communication Plugin', () => { - customElements.define( - 'communication-plugin', - Communication - ); + customElements.define('communication-plugin', Communication); let element: Communication; beforeEach(async () => { element = await fixture( @@ -43,7 +40,7 @@ describe('Communication Plugin', () => { describe('with a doc loaded missing a communication section', () => { let doc: XMLDocument; - let parent: MockWizardEditor; + let parent: MockOpenSCD; let fab: HTMLElement; let element: Communication; @@ -51,18 +48,14 @@ describe('Communication Plugin', () => { doc = await fetch('/test/testfiles/missingCommunication.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - - element = await fixture( - html`` - ); - parent = ( - await fixture( - html`${element}/mock-wizard-editor>` - ) + parent = await fixture( + html`` ); - await element.updateComplete; + element = parent.getActivePlugin(); + await parent.updateComplete; fab = ( parent ?.querySelector('communication-plugin') @@ -78,28 +71,34 @@ describe('Communication Plugin', () => { await parent.updateComplete; expect(parent.wizardUI.dialogs.length).to.equal(1); }); - + it('Should create a Communication Element', async () => { - expect(parent.wizardUI.dialogs.length).to.equal(0); - expect(element.doc.querySelector('Communication')).is.null; + expect(parent.wizardUI.dialogs.length).to.equal(0); + expect(element.doc.querySelector('Communication')).is.null; + + await fab.click(); + await new Promise(resolve => setTimeout(resolve, 100)); // await animation + await parent.updateComplete; - await fab.click(); - await new Promise(resolve => setTimeout(resolve, 100)); // await animation - await parent.updateComplete; - - const dialog: Dialog = parent.wizardUI.dialog!; - expect(dialog).to.not.be.undefined; + const dialog: Dialog = parent.wizardUI.dialog!; + expect(dialog).to.not.be.undefined; - const nameInput: WizardTextField = dialog.querySelector('wizard-textfield[label="name"]')!; - nameInput.value = 'Test'; - await new Promise(resolve => setTimeout(resolve, 100)); // await animation + const nameInput: WizardTextField = dialog.querySelector( + 'wizard-textfield[label="name"]' + )!; + nameInput.value = 'Test'; + await new Promise(resolve => setTimeout(resolve, 100)); // await animation - const saveButton: HTMLElement = dialog.querySelector('mwc-button[slot="primaryAction"]')!; - await saveButton.click(); - await new Promise(resolve => setTimeout(resolve, 100)); // await animation + const saveButton: HTMLElement = dialog.querySelector( + 'mwc-button[slot="primaryAction"]' + )!; + await saveButton.click(); + await new Promise(resolve => setTimeout(resolve, 100)); // await animation - expect(element.doc.querySelector('Communication')).not.is.null; - expect(element.doc.querySelector('Communication > SubNetwork[name="Test"]')).to.exist; + expect(element.doc.querySelector('Communication')).not.is.null; + expect( + element.doc.querySelector('Communication > SubNetwork[name="Test"]') + ).to.exist; }); }); }); diff --git a/packages/open-scd/test/integration/editors/communication/dist/Communication.test.js b/packages/open-scd/test/integration/editors/communication/dist/Communication.test.js new file mode 100644 index 0000000000..3cc8560cf1 --- /dev/null +++ b/packages/open-scd/test/integration/editors/communication/dist/Communication.test.js @@ -0,0 +1,176 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +var Communication_js_1 = require("../../../../src/editors/Communication.js"); +describe('Communication Plugin', function () { + customElements.define('communication-plugin', Communication_js_1["default"]); + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + element = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + describe('without a doc loaded', function () { + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with a doc loaded including communication section', function () { + var doc; + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B4.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + case 2: + element = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('constains a subnetwork-editor rendering the communication section', function () { + var _a; + testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('subnetwork-editor')).to.exist; + }); + }); + describe('with a doc loaded missing a communication section', function () { + var doc; + var parent; + var fab; + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/missingCommunication.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _c.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _c.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _c.sent(); + fab = ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('communication-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-fab')); + return [2 /*return*/]; + } + }); + }); }); + it('has a mwc-fab', function () { + var _a; + testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-fab')).to.exist; + }); + it('that opens a add subnetwork wizard on mwc-fab click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(parent.wizardUI.dialogs.length).to.equal(0); + fab.click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + testing_1.expect(parent.wizardUI.dialogs.length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }); + it('Should create a Communication Element', function () { return __awaiter(void 0, void 0, void 0, function () { + var dialog, nameInput, saveButton; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(parent.wizardUI.dialogs.length).to.equal(0); + testing_1.expect(element.doc.querySelector('Communication')).is["null"]; + return [4 /*yield*/, fab.click()]; + case 1: + _a.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _a.sent(); // await animation + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + dialog = parent.wizardUI.dialog; + testing_1.expect(dialog).to.not.be.undefined; + nameInput = dialog.querySelector('wizard-textfield[label="name"]'); + nameInput.value = 'Test'; + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _a.sent(); // await animation + saveButton = dialog.querySelector('mwc-button[slot="primaryAction"]'); + return [4 /*yield*/, saveButton.click()]; + case 5: + _a.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 6: + _a.sent(); // await animation + testing_1.expect(element.doc.querySelector('Communication')).not.is["null"]; + testing_1.expect(element.doc.querySelector('Communication > SubNetwork[name="Test"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/editors/dist/Substation.test.js b/packages/open-scd/test/integration/editors/dist/Substation.test.js new file mode 100644 index 0000000000..deebbf8234 --- /dev/null +++ b/packages/open-scd/test/integration/editors/dist/Substation.test.js @@ -0,0 +1,141 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../mock-open-scd.js"); +var Substation_js_1 = require("../../../src/editors/Substation.js"); +describe('Substation Plugin', function () { + customElements.define('substation-plugin', Substation_js_1["default"]); + var element; + var parent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [2 /*return*/]; + } + }); + }); }); + describe('without a doc loaded', function () { + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with a doc loaded including substation section', function () { + var doc; + var element; + var parent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B4.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [2 /*return*/]; + } + }); + }); }); + it('constains a zeroline-pane rendering the substation sections', function () { + var _a; + testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('zeroline-pane')).to.exist; + }); + }); + describe('with a doc loaded missing a substation section', function () { + var doc; + var parent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/missingSubstation.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, element.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('has a mwc-fab', function () { + var _a; + testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-fab')).to.exist; + }); + it('that opens an add substation wizard on click', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect(parent.wizardUI.dialogs.length).to.equal(0); + ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('substation-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-fab')).click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect(parent.wizardUI.dialogs.length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/editors/templates/Templates.test.ts b/packages/open-scd/test/integration/editors/templates/Templates.test.ts index e2e61ce680..755b26d9a6 100644 --- a/packages/open-scd/test/integration/editors/templates/Templates.test.ts +++ b/packages/open-scd/test/integration/editors/templates/Templates.test.ts @@ -1,32 +1,24 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; import TemplatesPlugin from '../../../../src/editors/Templates.js'; -import { Editing, EditingElement } from '../../../../src/Editing.js'; -import { Wizarding, WizardingElement } from '../../../../src/Wizarding.js'; +import { EditingElement } from '../../../../src/Editing.js'; import { newWizardEvent } from '../../../../src/foundation.js'; describe('Templates Plugin', () => { - customElements.define( - 'templates-plugin', - Wizarding(Editing(TemplatesPlugin)) - ); + customElements.define('templates-plugin', TemplatesPlugin); let element: TemplatesPlugin; - let parent: MockWizardEditor; + let parent: MockOpenSCD; beforeEach(async () => { - parent = ( - await fixture( - html`` - ) + parent = await fixture( + html`` ); - element = parent.querySelector('templates-plugin')!; + element = parent.getActivePlugin(); }); describe('without a doc loaded', () => { @@ -189,20 +181,19 @@ describe('Templates Plugin', () => { describe('with a doc loaded missing a datatypetemplates section', () => { let doc: XMLDocument; - let parent: MockWizardEditor; + let parent: MockOpenSCD; beforeEach(async () => { doc = await fetch('/test/testfiles/templates/missingdatatypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( - await fixture( - html`` - ) + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); await element.updateComplete; }); @@ -228,19 +219,18 @@ describe('Templates Plugin', () => { describe('with a doc loaded having a datatypetemplates section', () => { let doc: XMLDocument; - let parent: WizardingElement & EditingElement; + let parent: MockOpenSCD; beforeEach(async () => { doc = await fetch('/test/testfiles/templates/datypes.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent = ( - await fixture( - html`` - ) + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); await element.updateComplete; }); diff --git a/packages/open-scd/test/integration/editors/templates/datype-wizarding.test.ts b/packages/open-scd/test/integration/editors/templates/datype-wizarding.test.ts index 83a81f1542..7a21031e7c 100644 --- a/packages/open-scd/test/integration/editors/templates/datype-wizarding.test.ts +++ b/packages/open-scd/test/integration/editors/templates/datype-wizarding.test.ts @@ -1,7 +1,6 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import '../../../mock-open-scd'; import { ListItem } from '@material/mwc-list/mwc-list-item'; import { Select } from '@material/mwc-select'; @@ -10,23 +9,22 @@ import { FilteredList } from '../../../../src/filtered-list.js'; import { WizardTextField } from '../../../../src/wizard-textfield.js'; import TemplatesPlugin from '../../../../src/editors/Templates.js'; import { patterns } from '../../../../src/foundation.js'; +import { MockOpenSCD } from '../../../mock-open-scd'; describe('DAType wizards', () => { if (customElements.get('templates-editor') === undefined) customElements.define('templates-editor', TemplatesPlugin); let doc: Document; - let parent: MockWizardEditor; + let parent: MockOpenSCD; let templates: TemplatesPlugin; let dATypeList: FilteredList; beforeEach(async () => { parent = await fixture( - html`` + html`` ); - templates = parent.querySelector('templates-editor')!; + templates = parent.getActivePlugin(); doc = await fetch('/test/testfiles/templates/datypes.scd') .then(response => response.text()) diff --git a/packages/open-scd/test/integration/editors/templates/dist/Templates.test.js b/packages/open-scd/test/integration/editors/templates/dist/Templates.test.js new file mode 100644 index 0000000000..431ce9557b --- /dev/null +++ b/packages/open-scd/test/integration/editors/templates/dist/Templates.test.js @@ -0,0 +1,365 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +var Templates_js_1 = require("../../../../src/editors/Templates.js"); +var foundation_js_1 = require("../../../../src/foundation.js"); +describe('Templates Plugin', function () { + customElements.define('templates-plugin', Templates_js_1["default"]); + var element; + var parent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [2 /*return*/]; + } + }); + }); }); + describe('without a doc loaded', function () { + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with a doc loaded', function () { + var doc; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + element.doc = doc; + return [4 /*yield*/, element.requestUpdate()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + describe('having a LNodeType element list that', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + parent.workflow.length = 0; + ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[0].querySelector('mwc-list-item')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _b.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('opens a LNodeType edit wizard on list element click', function () { + var _a; + return testing_1.expect((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="lnClass"]')).to.exist; + }); + it('allows to reopen the LNodeType edit wizard for the same element', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + parent.dispatchEvent(foundation_js_1.newWizardEvent()); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _c.sent(); + ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list:nth-of-type(1) > mwc-list-item')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _c.sent(); + testing_1.expect((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="lnClass"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('having a DOType element list that', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + parent.workflow.length = 0; + ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[1].querySelector('mwc-list-item')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _b.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('opens a DOType edit wizard on list element click', function () { + var _a; + return testing_1.expect((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="CDC"]')).to.exist; + }); + it('allows to reopen the DOType edit wizard for the same element', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + parent.dispatchEvent(foundation_js_1.newWizardEvent()); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _c.sent(); + ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[1].querySelector('mwc-list-item')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _c.sent(); + testing_1.expect((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="CDC"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('having a DAType element list that', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + parent.workflow.length = 0; + ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[2].querySelector('mwc-list-item')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _b.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('opens a DAType edit wizard on list element click', function () { + return testing_1.expect(parent.wizardUI.dialog).to.exist; + }); + it('allows to reopen the DAType edit wizard for the same element', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + parent.dispatchEvent(foundation_js_1.newWizardEvent()); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _b.sent(); + ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[3].querySelector('mwc-list-item')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _b.sent(); + testing_1.expect(parent.wizardUI.dialog).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('having a EnumType element list that', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + parent.workflow.length = 0; + ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[3].querySelector('mwc-list-item')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _b.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('opens a EnumType edit wizard on list element click', function () { + return testing_1.expect(parent.wizardUI.dialog).to.exist; + }); + it('allows to reopen the EnumType edit wizard for the same element', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + parent.dispatchEvent(foundation_js_1.newWizardEvent()); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _b.sent(); + ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[3].querySelector('mwc-list-item')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _b.sent(); + testing_1.expect(parent.wizardUI.dialog).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); + }); + describe('with a doc loaded missing a datatypetemplates section', function () { + var doc; + var parent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/missingdatatypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, element.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('has a mwc-fab', function () { + var _a; + testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-fab')).to.exist; + }); + it('adds a DataTypeTemplates on floating action button click', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect(doc.querySelector('DataTypeTemplates')).to.not.exist; + ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('templates-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-fab')).click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect(parent + .querySelector('templates-plugin') + .doc.querySelector('DataTypeTemplates')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with a doc loaded having a datatypetemplates section', function () { + var doc; + var parent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, element.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('opens an add enumtype wizard', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect(parent.wizardUI.dialogs.length).to.equal(0); + ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('templates-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[2]).click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _c.sent(); // await animation + testing_1.expect(parent.wizardUI.dialogs.length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }); + it('adding an EnumType with the enumtype wizard', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + testing_1.expect(doc.querySelectorAll('EnumType').length).to.equal(4); + ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('templates-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('section:last-child mwc-icon-button[icon="playlist_add"]')).click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _d.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _d.sent(); // await animation + parent.wizardUI.inputs[1].value = 'myID'; + return [4 /*yield*/, parent.updateComplete]; + case 3: + _d.sent(); + ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-button[slot="primaryAction"]')).click(); + return [4 /*yield*/, parent.updateComplete]; + case 4: + _d.sent(); + testing_1.expect(doc.querySelectorAll('EnumType').length).to.equal(5); + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/editors/templates/dist/datype-wizarding.test.js b/packages/open-scd/test/integration/editors/templates/dist/datype-wizarding.test.js new file mode 100644 index 0000000000..a41452e66e --- /dev/null +++ b/packages/open-scd/test/integration/editors/templates/dist/datype-wizarding.test.js @@ -0,0 +1,333 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd"); +var Templates_js_1 = require("../../../../src/editors/Templates.js"); +var foundation_js_1 = require("../../../../src/foundation.js"); +describe('DAType wizards', function () { + if (customElements.get('templates-editor') === undefined) + customElements.define('templates-editor', Templates_js_1["default"]); + var doc; + var parent; + var templates; + var dATypeList; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _b.sent(); + templates = parent.getActivePlugin(); + return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 2: + doc = _b.sent(); + templates.doc = doc; + return [4 /*yield*/, templates.updateComplete]; + case 3: + _b.sent(); + dATypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="datypelist"]')); + return [2 /*return*/]; + } + }); + }); }); + describe('defines a createDATypeWizard', function () { + var selector; + var idField; + var primayAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var button; + var _a, _b, _c, _d; + return __generator(this, function (_e) { + switch (_e.label) { + case 0: + button = ((_a = templates === null || templates === void 0 ? void 0 : templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[2]); + button.click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _e.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _e.sent(); // await animation + selector = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-select[label="values"]')); + idField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="id"]')); + primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + //work around, because the escapes get removed in snapshot + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + var pattern; + return __generator(this, function (_a) { + pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(2); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(pattern); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); + return [2 /*return*/]; + }); + }); }); + it('allows to add empty DATypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DAType[id="myGeneralDAType"]')).to.not.exist; + idField.maybeValue = 'myGeneralDAType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="myGeneralDAType"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('respects the sequence defined in the standard', function () { return __awaiter(void 0, void 0, void 0, function () { + var element; + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + idField.maybeValue = 'myGeneralDAType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _c.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _c.sent(); + element = doc.querySelector('DAType[id="myGeneralDAType"]'); + testing_1.expect((_a = element === null || element === void 0 ? void 0 : element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.tagName).to.equal('DAType'); + testing_1.expect((_b = element === null || element === void 0 ? void 0 : element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.tagName).to.equal('DOType'); + return [2 /*return*/]; + } + }); + }); }); + it('recursively add missing! subsequent EnumType elements', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DAType[id="myOriginator"]')).to.not.exist; + selector.value = 'OpenSCD_Originator'; + idField.maybeValue = 'myOriginator'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="myOriginator"]')).to.exist; + testing_1.expect(doc.querySelector('EnumType[id="OriginatorCategoryKind"]')).to + .exist; + testing_1.expect(doc.querySelectorAll('EnumType[id="OriginatorCategoryKind"]').length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }); + it('recursively add missing! subsequent DAType elements', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_AnalogueValue_FLOAT32"]')).to + .not.exist; + selector.value = 'OpenSCD_RangeConfig'; + idField.maybeValue = 'myOriginator'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_AnalogueValue_FLOAT32"]')).to + .exist; + testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_AnalogueValue_FLOAT32"]') + .length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('defines a dATypeWizard', function () { + var idField; + var primayAction; + var deleteButton; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + (dATypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod.SBOw"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _d.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _d.sent(); // await animation + idField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="id"]')); + primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); + deleteButton = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-menu > mwc-list-item')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + //work around, because the escapes get removed in snapshot + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + var pattern; + return __generator(this, function (_a) { + pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(2); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(pattern); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); + return [2 /*return*/]; + }); + }); }); + it('edits DAType attributes id', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).to.exist; + idField.value = 'changedDAType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).to.not + .exist; + testing_1.expect(doc.querySelector('DAType[id="changedDAType"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('deletes the DAType attribute on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).to.exist; + testing_1.expect(doc.querySelectorAll('DAType').length).to.equal(5); + deleteButton.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).to.not + .exist; + testing_1.expect(doc.querySelectorAll('DAType').length).to.equal(4); + return [2 /*return*/]; + } + }); + }); }); + it('does not edit DAType element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { + var originData; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + originData = (doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).cloneNode(true); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(originData.isEqualNode(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]'))).to.be["true"]; + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js b/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js new file mode 100644 index 0000000000..585287fbb0 --- /dev/null +++ b/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js @@ -0,0 +1,612 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +var Templates_js_1 = require("../../../../src/editors/Templates.js"); +var limits_js_1 = require("../../../../src/wizards/foundation/limits.js"); +describe('DOType wizards', function () { + if (customElements.get('templates-editor') === undefined) + customElements.define('templates-editor', Templates_js_1["default"]); + var doc; + var parent; + var templates; + var dOTypeList; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _b.sent(); + templates = parent.getActivePlugin(); + return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 2: + doc = _b.sent(); + templates.doc = doc; + return [4 /*yield*/, templates.updateComplete]; + case 3: + _b.sent(); + dOTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="dotypelist"]')); + return [2 /*return*/]; + } + }); + }); }); + describe('defines a createDOTypeWizard', function () { + var selector; + var idField; + var cdcField; + var primayAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var button; + var _a, _b, _c, _d, _e; + return __generator(this, function (_f) { + switch (_f.label) { + case 0: + button = ((_a = templates === null || templates === void 0 ? void 0 : templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[1]); + button.click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _f.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _f.sent(); // await animation + selector = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-select[label="values"]')); + idField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="id"]')); + cdcField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="cdc"]')); + primayAction = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-button[slot="primaryAction"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + // prettier does not support escaping in regexes of the /v flag + return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + // prettier does not support escaping in regexes of the /v flag + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + // work around, because the escapes get removed in snapshot by prettier + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(3); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.nmToken); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[2] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.cdc); + return [2 /*return*/]; + }); + }); }); + it('allows to add empty DOTypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="myGeneralDOType"]')).to.not.exist; + idField.maybeValue = 'myGeneralDOType'; + cdcField.maybeValue = 'SPS'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="myGeneralDOType"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('allows to define CDC only for empty DOType creation', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, cdcField.updateComplete]; + case 1: + _a.sent(); + testing_1.expect(cdcField.disabled).to.not.be["true"]; + selector.value = 'OpenSCD_ENS_Health'; + return [4 /*yield*/, cdcField.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(cdcField.disabled).to.be["true"]; + return [2 /*return*/]; + } + }); + }); }); + it('requires CDC definition for empty DOTypes', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="myGeneralDOType"]')).to.not.exist; + idField.maybeValue = 'myGeneralDOType'; + cdcField.maybeValue = null; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="myGeneralDOType"]')).to.not.exist; + return [2 /*return*/]; + } + }); + }); }); + it('respects the sequence defined in the standard', function () { return __awaiter(void 0, void 0, void 0, function () { + var element; + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + idField.maybeValue = 'myGeneralDOType'; + cdcField.maybeValue = 'SPS'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _c.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _c.sent(); + element = doc.querySelector('DOType[id="myGeneralDOType"]'); + testing_1.expect((_a = element === null || element === void 0 ? void 0 : element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.tagName).to.equal('DOType'); + testing_1.expect((_b = element === null || element === void 0 ? void 0 : element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.tagName).to.equal('LNodeType'); + return [2 /*return*/]; + } + }); + }); }); + it('recursively add missing! subsequent EnumType elements', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="myENSHealth"]')).to.not.exist; + testing_1.expect(doc.querySelector('EnumType[id="HealthKind"]')).to.not.exist; + selector.value = 'OpenSCD_ENS_Health'; + idField.maybeValue = 'myENSHealth'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="myENSHealth"]')).to.exist; + testing_1.expect(doc.querySelector('EnumType[id="HealthKind"]')).to.exist; + testing_1.expect(doc.querySelectorAll('EnumType[id="HealthKind"]').length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }); + it('recursively add missing! subsequent DAType elements', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_AnalogueValue_INT32"]')).to + .not.exist; + selector.value = 'OpenSCD_MV_int'; + idField.maybeValue = 'myMV'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_AnalogueValue_INT32"]')).to + .exist; + testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_AnalogueValue_INT32"]').length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('defines a dOTypeWizard', function () { + var idField; + var primayAction; + var deleteButton; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + (dOTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _c.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _c.sent(); //recursive call takes time + idField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="id"]')); + primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); + deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes("[remove]"); })); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + // prettier does not support escaping in regexes of the /v flag + return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + // prettier does not support escaping in regexes of the /v flag + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + // work around, because the escapes get removed in snapshot by prettier + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(3); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.nmToken); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[2] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); + return [2 /*return*/]; + }); + }); }); + it('edits DOType attributes id', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.exist; + idField.value = 'changedDOType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.not.exist; + testing_1.expect(doc.querySelector('DOType[id="changedDOType"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('deletes the DOType attribute on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.exist; + testing_1.expect(doc.querySelectorAll('DOType').length).to.equal(15); + deleteButton.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod"]')).to.not.exist; + testing_1.expect(doc.querySelectorAll('DOType').length).to.equal(14); + return [2 /*return*/]; + } + }); + }); }); + it('does not edit DOType element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { + var originData; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + originData = (doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).cloneNode(true); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(originData.isEqualNode(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]'))).to.be["true"]; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('defines a sDOWizard to edit an existing SDO', function () { + var nameField; + var primayAction; + var deleteButton; + var typeSelect; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e, _f; + return __generator(this, function (_g) { + switch (_g.label) { + case 0: + (dOTypeList.querySelector('mwc-list-item[value="#Dummy.WYE"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _g.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _g.sent(); // await animation + ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy.WYE>phsA"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _g.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _g.sent(); // await animation + nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); + primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); + deleteButton = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-menu > mwc-list-item')); + typeSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('mwc-select[label="type"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + // prettier does not support escaping in regexes of the /v flag + return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + // prettier does not support escaping in regexes of the /v flag + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + // work around, because the escapes get removed in snapshot by prettier + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(2); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.tRestrName1stL); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); + return [2 /*return*/]; + }); + }); }); + it('edits SDO attributes name', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).to + .exist; + nameField.value = 'newPhsA'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).to + .not.exist; + testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="newPhsA"]')) + .to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('deletes the SDO element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).to + .exist; + testing_1.expect(doc.querySelectorAll('DOType[id="Dummy.WYE"] > SDO').length).to.equal(3); + deleteButton.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).to + .not.exist; + testing_1.expect(doc.querySelectorAll('DOType[id="Dummy.WYE"] > SDO').length).to.equal(2); + return [2 /*return*/]; + } + }); + }); }); + it('does not edit SDO element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { + var originData; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + originData = (doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).cloneNode(true); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(originData.isEqualNode(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]'))).to.be["true"]; + return [2 /*return*/]; + } + }); + }); }); + it('filters the type selector to DOTypes', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + testing_1.expect(typeSelect.querySelectorAll('mwc-list-item').length).to.equal(doc.querySelectorAll('DOType').length); + return [2 /*return*/]; + }); + }); }); + }); + describe('defines a sDOWizard to create a new SDO element', function () { + var nameField; + var descField; + var typeSelect; + var primaryAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e; + return __generator(this, function (_f) { + switch (_f.label) { + case 0: + (dOTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _f.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _f.sent(); // await animation + (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes("[scl.DO]"); })).click(); + return [4 /*yield*/, ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.requestUpdate())]; + case 3: + _f.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _f.sent(); // await animation + nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); + descField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="desc"]')); + typeSelect = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-select[label="type"]')); + primaryAction = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-button[slot="primaryAction"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + // prettier does not support escaping in regexes of the /v flag + return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + // prettier does not support escaping in regexes of the /v flag + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + // work around, because the escapes get removed in snapshot by prettier + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(2); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.tRestrName1stL); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); + return [2 /*return*/]; + }); + }); }); + it('creates a new SDO element', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > SDO[name="newSDOElement"]')).to.not.exist; + nameField.value = 'newSDOElement'; + typeSelect.value = 'Dummy.CMV'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primaryAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > SDO[name="newSDOElement"]:not([desc])[type="Dummy.CMV"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('creates yet another new SDO element', function () { return __awaiter(void 0, void 0, void 0, function () { + var name, desc; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + name = 'newSDOElement2'; + desc = 'newSDOdesc'; + testing_1.expect(doc.querySelector('DOType[id="#Dummy.LLN0.Mod"] > SDO[name="newSDOElement2"]')).to.not.exist; + nameField.value = name; + descField.nullable = false; + descField.value = desc; + typeSelect.value = 'Dummy.CMV'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primaryAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector("DOType[id=\"Dummy.LLN0.Mod\"] >" + + ("SDO[name=\"" + name + "\"][desc=\"" + desc + "\"][type=\"Dummy.CMV\"]"))).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/integration/editors/templates/dist/enumtype-wizarding.test.js b/packages/open-scd/test/integration/editors/templates/dist/enumtype-wizarding.test.js new file mode 100644 index 0000000000..b0bb64e910 --- /dev/null +++ b/packages/open-scd/test/integration/editors/templates/dist/enumtype-wizarding.test.js @@ -0,0 +1,510 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +var Templates_js_1 = require("../../../../src/editors/Templates.js"); +var foundation_js_1 = require("../../../../src/foundation.js"); +describe('EnumType wizards', function () { + if (customElements.get('templates-editor') === undefined) + customElements.define('templates-editor', Templates_js_1["default"]); + var doc; + var parent; + var templates; + var eNumTypeList; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _b.sent(); + templates = parent.getActivePlugin(); + return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 2: + doc = _b.sent(); + templates.doc = doc; + return [4 /*yield*/, templates.updateComplete]; + case 3: + _b.sent(); + eNumTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="enumtypelist"]')); + return [2 /*return*/]; + } + }); + }); }); + describe('defines a createEnumTypeWizard', function () { + var selector; + var idField; + var primayAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var button; + var _a, _b, _c, _d; + return __generator(this, function (_e) { + switch (_e.label) { + case 0: + button = ((_a = templates === null || templates === void 0 ? void 0 : templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[3]); + button.click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _e.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _e.sent(); // await animation + selector = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-select[label="values"]')); + idField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="id"]')); + primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + //work around, because the escapes get removed in snapshot + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + var pattern; + return __generator(this, function (_a) { + pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(2); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(pattern); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); + return [2 /*return*/]; + }); + }); }); + it('allows to add empty EnumType to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('EnumType[id="myGeneralEnumType"]')).to.not + .exist; + idField.maybeValue = 'myGeneralEnumType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('EnumType[id="myGeneralEnumType"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('respects the sequence defined in the standard', function () { return __awaiter(void 0, void 0, void 0, function () { + var element; + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + idField.maybeValue = 'myGeneralEnumType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _c.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _c.sent(); + element = doc.querySelector('EnumType[id="myGeneralEnumType"]'); + testing_1.expect((_a = element === null || element === void 0 ? void 0 : element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.tagName).to.equal('EnumType'); + testing_1.expect((_b = element === null || element === void 0 ? void 0 : element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.tagName).to.equal('DAType'); + return [2 /*return*/]; + } + }); + }); }); + it('allows to add a predefined EnumType', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('EnumType[id="myGeneralEnumType"]')).to.not + .exist; + selector.value = 'AdjustmentKind'; + idField.maybeValue = 'myGeneralEnumType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('EnumType[id="myGeneralEnumType"]')).to.exist; + testing_1.expect(doc.querySelectorAll('EnumType[id="myGeneralEnumType"] > EnumVal') + .length).to.equal(4); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('defines an eNumTypeEditWizard', function () { + var idField; + var primayAction; + var deleteButton; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + (eNumTypeList.querySelector('mwc-list-item[value="#Dummy_ctlModel"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _d.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _d.sent(); // await animation + idField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="id"]')); + primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); + deleteButton = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelectorAll('mwc-menu > mwc-list-item')[0]); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + //work around, because the escapes get removed in snapshot + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + var pattern; + return __generator(this, function (_a) { + pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(2); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(pattern); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); + return [2 /*return*/]; + }); + }); }); + it('edits EnumType attributes id', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"]')).to.exist; + idField.value = 'changedEnumType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"]')).to.not.exist; + testing_1.expect(doc.querySelector('EnumType[id="changedEnumType"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('deletes the EnumVal element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"]')).to.exist; + testing_1.expect(doc.querySelectorAll('EnumType').length).to.equal(4); + deleteButton.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"]')).to.not.exist; + testing_1.expect(doc.querySelectorAll('EnumType').length).to.equal(3); + return [2 /*return*/]; + } + }); + }); }); + it('does not edit EnumType element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { + var originData; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + originData = (doc.querySelector('EnumType[id="Dummy_ctlModel"]')).cloneNode(true); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(originData.isEqualNode(doc.querySelector('EnumType[id="Dummy_ctlModel"]'))).to.be["true"]; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('defines a eNumValWizard to edit an existing EnumVal', function () { + var ordField; + var valueField; + var descField; + var primayAction; + var deleteButton; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e, _f, _g; + return __generator(this, function (_h) { + switch (_h.label) { + case 0: + (eNumTypeList.querySelector('mwc-list-item[value="#Dummy_ctlModel"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _h.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _h.sent(); // await animation + ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy_ctlModel>1"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _h.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _h.sent(); // await animation + ordField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="ord"]')); + valueField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="value"]')); + descField = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('wizard-textfield[label="desc"]')); + primayAction = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('mwc-button[slot="primaryAction"]')); + deleteButton = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelectorAll('mwc-menu > mwc-list-item')[0]); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('edits EnumVal attributes ord', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')).to.exist; + ordField.value = '10'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')).to.not.exist; + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="10"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('edits EnumVal attributes value', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect((_a = doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('direct-with-normal-security'); + valueField.value = 'direct-with-normal-security-test'; + descField.nullable = false; + descField.maybeValue = 'myDesc'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _c.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _c.sent(); + testing_1.expect((_b = doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"][desc="myDesc"]')) === null || _b === void 0 ? void 0 : _b.textContent).to.equal('direct-with-normal-security-test'); + return [2 /*return*/]; + } + }); + }); }); + it('deletes the EnumVal element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')).to.exist; + testing_1.expect(doc.querySelectorAll('EnumType[id="Dummy_ctlModel"] > EnumVal').length).to.equal(5); + deleteButton.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[name="1"]')).to.not.exist; + testing_1.expect(doc.querySelectorAll('EnumType[id="Dummy_ctlModel"] > EnumVal').length).to.equal(4); + return [2 /*return*/]; + } + }); + }); }); + it('does not edit EnumVal element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { + var originData; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + originData = (doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')).cloneNode(true); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(originData.isEqualNode(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]'))).to.be["true"]; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('defines a eNumValWizard to create a new EnumVal element', function () { + var ordField; + var valueField; + var descField; + var primayAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e; + return __generator(this, function (_f) { + switch (_f.label) { + case 0: + (eNumTypeList.querySelector('mwc-list-item[value="#Dummy_ctlModel"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _f.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _f.sent(); // await animation + ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-menu > mwc-list-item')[1]).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _f.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _f.sent(); // await animation + ordField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="ord"]')); + descField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="desc"]')); + valueField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="value"]')); + primayAction = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-button[slot="primaryAction"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates a new EnumVal element', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="9"]')).to.not.exist; + ordField.value = '9'; + valueField.value = 'newValue'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _b.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _b.sent(); + testing_1.expect((_a = doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="9"]:not([desc])')) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('newValue'); + return [2 /*return*/]; + } + }); + }); }); + it('creates yet another new EnumVal element', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="9"]')).to.not.exist; + ordField.value = '9'; + valueField.value = 'newValue'; + descField.nullable = false; + descField.maybeValue = 'myDesc'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _b.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _b.sent(); + testing_1.expect((_a = doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="9"][desc="myDesc"]')) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('newValue'); + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js b/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js new file mode 100644 index 0000000000..54963a23d1 --- /dev/null +++ b/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js @@ -0,0 +1,727 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +var Templates_js_1 = require("../../../../src/editors/Templates.js"); +var foundation_js_1 = require("../../../../src/foundation.js"); +describe('LNodeType wizards', function () { + if (customElements.get('templates-editor') === undefined) + customElements.define('templates-editor', Templates_js_1["default"]); + var doc; + var parent; + var templates; + var lNodeTypeList; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _b.sent(); + templates = parent.getActivePlugin(); + return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 2: + doc = _b.sent(); + templates.doc = doc; + return [4 /*yield*/, templates.updateComplete]; + case 3: + _b.sent(); + lNodeTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="lnodetypelist"]')); + return [2 /*return*/]; + } + }); + }); }); + describe('defines a lNodeTypeHelperWizard', function () { + var idField; + var primayAction; + var deleteButton; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + (lNodeTypeList.querySelector('mwc-list-item[value="#Dummy.CSWI"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _d.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _d.sent(); //recursive call takes time + idField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="id"]')); + primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); + deleteButton = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-menu > mwc-list-item')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + //work around, because the escapes get removed in snapshot + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + var pattern; + return __generator(this, function (_a) { + pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(3); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(pattern); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[2] + .getAttribute('pattern')).to.equal(foundation_js_1.patterns.lnClass); + return [2 /*return*/]; + }); + }); }); + it('edits LNodeType attributes id', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.CSWI"]')).to.exist; + idField.value = 'changedLNodeType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.CSWI"]')).to.not.exist; + testing_1.expect(doc.querySelector('LNodeType[id="changedLNodeType"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('deletes the LNodeType attribute on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.CSWI"]')).to.exist; + testing_1.expect(doc.querySelectorAll('LNodeType').length).to.equal(8); + deleteButton.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.CSWI"]')).to.not.exist; + testing_1.expect(doc.querySelectorAll('LNodeType').length).to.equal(7); + return [2 /*return*/]; + } + }); + }); }); + it('does not edit LNodeType element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { + var originData; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + originData = (doc.querySelector('LNodeType[id="Dummy.CSWI"]')).cloneNode(true); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(originData.isEqualNode(doc.querySelector('LNodeType[id="Dummy.CSWI"]'))).to.be["true"]; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('defines a createLNodeTypeWizard', function () { + var selector; + var idField; + var primayAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var button; + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + button = ((_a = templates === null || templates === void 0 ? void 0 : templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[0]); + button.click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _c.sent(); // await animation + selector = parent.wizardUI.dialog.querySelector('mwc-select[label="lnClass"]'); + idField = parent.wizardUI.dialog.querySelector('wizard-textfield[label="id"]'); + primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ + ignoreAttributes: [ + { + tags: ['wizard-textfield'], + attributes: ['pattern'] + }, + ] + })]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + //work around, because the escapes get removed in snapshot + it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { + var pattern; + return __generator(this, function (_a) { + pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; + testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') + .length).to.equal(2); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[0] + .getAttribute('pattern')).to.equal(pattern); + testing_1.expect(parent.wizardUI + .dialog.querySelectorAll('wizard-textfield[pattern]')[1] + .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); + return [2 /*return*/]; + }); + }); }); + it('uses -7-4 and -7-420 namespace for lnClass suggestion', function () { + return testing_1.expect(selector.items.filter(function (item) { return !item.noninteractive && !item.twoline; })).to.have.lengthOf(215); + }); + it('recursively add missing! subsequent DOType elements', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.not.exist; + testing_1.expect(doc.querySelector('DOType[id="OpenSCD_ENC_Mod"]')).to.not.exist; + testing_1.expect(doc.querySelector('DOType[id="OpenSCD_ENS_Beh"]')).to.not.exist; + testing_1.expect(doc.querySelector('DOType[id="OpenSCD_ENS_Health"]')).to.not.exist; + testing_1.expect(doc.querySelector('DOType[id="OpenSCD_LPL_noLD"]')).to.not.exist; + testing_1.expect(doc.querySelector('DOType[id="OpenSCD_SPS_simple"]')).to.not.exist; + testing_1.expect(doc.querySelector('DOType[id="OpenSCD_DPC"]')).to.not.exist; + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 1: + _a.sent(); //recursive call takes time + selector.value = '#OpenSCD_CSWI_noPB'; + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); // selector updates autoimport + idField.maybeValue = 'myCSWI'; + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 4: + _a.sent(); + testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.exist; + testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_ENC_Mod"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_ENS_Beh"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_ENS_Health"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_LPL_noLD"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_SPS_simple"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_DPC"]').length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }).timeout(5000); + it('recursively add missing! subsequent DAType elements', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.not.exist; + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_Originator"]')).to.not.exist; + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_OperSBOw_Dbpos"]')).to.not + .exist; + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_Cancel_Dbpos"]')).to.not + .exist; + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_OperSBOw_BehaviourModeKind"]')).to.not.exist; + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_Cancel_BehaviourModeKind"]')) + .to.not.exist; + testing_1.expect(doc.querySelector('DAType[id="OpenSCD_PulseConfig"]')).to.not + .exist; + selector.value = '#OpenSCD_CSWI_noPB'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); // selector updates autoimport + idField.maybeValue = 'myCSWI'; + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.exist; + testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_Originator"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_OperSBOw_Dbpos"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_Cancel_Dbpos"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_OperSBOw_BehaviourModeKind"]') + .length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_Cancel_BehaviourModeKind"]') + .length).to.equal(1); + testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_PulseConfig"]').length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }).timeout(5000); + it('recursively add missing! subsequent EnumType elements', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.not.exist; + testing_1.expect(doc.querySelector('EnumType[id="OriginatorCategoryKind"]')).to.not + .exist; + testing_1.expect(doc.querySelector('EnumType[id="BehaviourModeKind"]')).to.not + .exist; + testing_1.expect(doc.querySelector('EnumType[id="CtlModelKind"]')).to.not.exist; + testing_1.expect(doc.querySelector('EnumType[id="HealthKind"]')).to.not.exist; + testing_1.expect(doc.querySelector('EnumType[id="OutputSignalKind"]')).to.not.exist; + selector.value = '#OpenSCD_CSWI_noPB'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); // selector updates autoimport + idField.maybeValue = 'myCSWI'; + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.exist; + testing_1.expect(doc.querySelectorAll('EnumType[id="OriginatorCategoryKind"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('EnumType[id="BehaviourModeKind"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('EnumType[id="CtlModelKind"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('EnumType[id="HealthKind"]').length).to.equal(1); + testing_1.expect(doc.querySelectorAll('EnumType[id="OutputSignalKind"]').length).to.equal(1); + return [2 /*return*/]; + } + }); + }); }).timeout(5000); + it('respects the sequence defined in the standard', function () { return __awaiter(void 0, void 0, void 0, function () { + var element; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + selector.value = '#OpenSCD_CSWI_noPB'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _b.sent(); // selector updates autoimport + idField.maybeValue = 'myGeneralLNodeType'; + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _b.sent(); + primayAction.click(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _b.sent(); + element = doc.querySelector('LNodeType[id="myGeneralLNodeType"]'); + testing_1.expect((_a = element === null || element === void 0 ? void 0 : element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.tagName).to.equal('LNodeType'); + testing_1.expect(element === null || element === void 0 ? void 0 : element.previousElementSibling).to.be["null"]; + return [2 /*return*/]; + } + }); + }); }).timeout(5000); + describe('opens a createLNodeTypeHelperWizard', function () { + var saveButton; + var beh; + var enaOpn; + var enaCls; + var ens; + var sps; + var ensId; + var spsId; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + selector.value = 'CILO'; + idField.maybeValue = 'myGeneralLNodeType'; + return [4 /*yield*/, parent.updateComplete]; + case 1: + _d.sent(); + ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-button[slot="primaryAction"]')).click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _d.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 3: + _d.sent(); // await animation + saveButton = parent.wizardUI.shadowRoot.querySelector('mwc-button[slot="primaryAction"]'); + beh = parent.wizardUI.shadowRoot.querySelector('wizard-select:nth-child(2)'); + enaOpn = parent.wizardUI.shadowRoot.querySelector('wizard-select:nth-child(21)'); + enaCls = parent.wizardUI.shadowRoot.querySelector('wizard-select:nth-child(22)'); + ens = doc.querySelector('DOType[cdc="ENS"]'); + sps = doc.querySelector('DOType[cdc="SPS"]'); + ensId = (_b = ens === null || ens === void 0 ? void 0 : ens.getAttribute('id')) !== null && _b !== void 0 ? _b : ''; + spsId = (_c = sps === null || sps === void 0 ? void 0 : sps.getAttribute('id')) !== null && _c !== void 0 ? _c : ''; + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('filters the type selection for each DO to fit the cdc', function () { + testing_1.expect(beh.querySelectorAll('mwc-list-item').length).to.equal(doc.querySelectorAll('DOType[cdc="ENS"]').length); + }); + it('requires all mandatory DOs to be defined', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + beh.value = ensId; + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + saveButton.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 3: + _a.sent(); // await animation + testing_1.expect(parent.wizardUI.dialog).to.exist; + testing_1.expect(doc.querySelector('LNodeType[id="myGeneralLNodeType"][lnClass="CILO"]')).to.not.exist; + return [2 /*return*/]; + } + }); + }); }); + it('adds new LNodeType with correct id and lnClass', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + beh.value = ensId; + enaOpn.value = spsId; + enaCls.value = spsId; + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + saveButton.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 3: + _a.sent(); // await animation + testing_1.expect(parent.wizardUI.dialog).to.not.exist; + testing_1.expect(doc.querySelector('LNodeType[id="myGeneralLNodeType"][lnClass="CILO"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('adds selected DOs to new LNodeType', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + beh.value = ensId; + enaOpn.value = spsId; + enaCls.value = spsId; + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + saveButton.click(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 3: + _a.sent(); // await animation + testing_1.expect(doc.querySelector("LNodeType[id=\"myGeneralLNodeType\"][lnClass=\"CILO\"] > DO[name=\"Beh\"]:not([bType])[type=\"" + ensId + "\"]")).to.exist; + testing_1.expect(doc.querySelector("LNodeType[id=\"myGeneralLNodeType\"][lnClass=\"CILO\"] > DO[name=\"EnaOpn\"]:not([bType])[type=\"" + spsId + "\"]")).to.exist; + testing_1.expect(doc.querySelector("LNodeType[id=\"myGeneralLNodeType\"][lnClass=\"CILO\"] > DO[name=\"EnaCls\"]:not([bType])[type=\"" + spsId + "\"]")).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); + }); + describe('defines a dOWizard to edit an existing DO', function () { + var nameField; + var descField; + var typeSelect; + var accessControlField; + var transientSelect; + var primaryAction; + var deleteButton; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e, _f, _g, _h, _j; + return __generator(this, function (_k) { + switch (_k.label) { + case 0: + (lNodeTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _k.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _k.sent(); // await animation + ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy.LLN0>Mod"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _k.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _k.sent(); // await animation + nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); + descField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="desc"]')); + accessControlField = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('wizard-textfield[label="accessControl"]')); + typeSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('mwc-select[label="type"]')); + transientSelect = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelector('wizard-checkbox[label="transient"]')); + primaryAction = ((_h = parent.wizardUI.dialog) === null || _h === void 0 ? void 0 : _h.querySelector('mwc-button[slot="primaryAction"]')); + deleteButton = ((_j = parent.wizardUI.dialog) === null || _j === void 0 ? void 0 : _j.querySelector('mwc-menu > mwc-list-item')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { + testing_1.expect(parent.wizardUI.dialog).to; + }); + it('edits DO attributes name', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')) + .to.exist; + nameField.value = 'NewMod'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primaryAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')) + .to.not.exist; + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('edits yet another attribute of the DO element', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]')).to.not.exist; + nameField.value = 'NewMod'; + descField.nullable = false; + descField.value = 'myDesc'; + typeSelect.value = 'Dummy.CMV'; + accessControlField.nullable = false; + accessControlField.maybeValue = 'myAccessControl'; + transientSelect.maybeValue = 'true'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primaryAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector("LNodeType[id=\"Dummy.LLN0\"] >" + + "DO[name=\"NewMod\"][desc=\"myDesc\"][type=\"Dummy.CMV\"][accessControl=\"myAccessControl\"][transient=\"true\"]")).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('deletes the DO element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')) + .to.exist; + testing_1.expect(doc.querySelectorAll('LNodeType[id="Dummy.LLN0"] > DO').length).to.equal(4); + deleteButton.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')) + .to.not.exist; + testing_1.expect(doc.querySelectorAll('LNodeType[id="Dummy.LLN0"] > DO').length).to.equal(3); + return [2 /*return*/]; + } + }); + }); }); + it('does not edit DO element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { + var originData; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + originData = (doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')).cloneNode(true); + primaryAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(originData.isEqualNode(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]'))).to.be["true"]; + return [2 /*return*/]; + } + }); + }); }); + it('filters the type selector to DOTypes', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + testing_1.expect(typeSelect.querySelectorAll('mwc-list-item').length).to.equal(doc.querySelectorAll('DOType').length); + return [2 /*return*/]; + }); + }); }); + }); + describe('defines a dOWizard to create a new DO element', function () { + var nameField; + var descField; + var typeSelect; + var accessControlField; + var transientSelect; + var primaryAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e, _f, _g; + return __generator(this, function (_h) { + switch (_h.label) { + case 0: + (lNodeTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _h.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _h.sent(); // await animation + ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-menu > mwc-list-item')[1]).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _h.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _h.sent(); // await animation + nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); + descField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="desc"]')); + accessControlField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="accessControl"]')); + typeSelect = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-select[label="type"]')); + transientSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('wizard-checkbox[label="transient"]')); + primaryAction = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelector('mwc-button[slot="primaryAction"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates a new DO element', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]')).to.not.exist; + nameField.value = 'NewMod'; + typeSelect.value = 'Dummy.CMV'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primaryAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]:not([desc])[type="Dummy.CMV"]:not([accessControl]):not([transient])')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('creates yet another new DO element', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]')).to.not.exist; + nameField.value = 'NewMod'; + descField.nullable = false; + descField.value = 'myDesc'; + typeSelect.value = 'Dummy.CMV'; + accessControlField.nullable = false; + accessControlField.maybeValue = 'myAccessControl'; + transientSelect.maybeValue = 'true'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primaryAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector("LNodeType[id=\"Dummy.LLN0\"] >" + + "DO[name=\"NewMod\"][desc=\"myDesc\"][type=\"Dummy.CMV\"][accessControl=\"myAccessControl\"][transient=\"true\"]")).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts b/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts index 7bdd43e34b..12770985a0 100644 --- a/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts +++ b/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts @@ -1,7 +1,6 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import '../../../mock-open-scd.js'; import { ListItem } from '@material/mwc-list/mwc-list-item'; import { Select } from '@material/mwc-select'; @@ -12,23 +11,22 @@ import { WizardTextField } from '../../../../src/wizard-textfield.js'; import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; import { patterns } from '../../../../src/wizards/foundation/limits.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('DOType wizards', () => { if (customElements.get('templates-editor') === undefined) customElements.define('templates-editor', TemplatesPlugin); let doc: Document; - let parent: MockWizardEditor; + let parent: MockOpenSCD; let templates: TemplatesPlugin; let dOTypeList: FilteredList; beforeEach(async () => { parent = await fixture( - html`` + html`` ); - templates = parent.querySelector('templates-editor')!; + templates = parent.getActivePlugin(); doc = await fetch('/test/testfiles/templates/dotypes.scd') .then(response => response.text()) diff --git a/packages/open-scd/test/integration/editors/templates/enumtype-wizarding.test.ts b/packages/open-scd/test/integration/editors/templates/enumtype-wizarding.test.ts index 24db4625eb..5220b26447 100644 --- a/packages/open-scd/test/integration/editors/templates/enumtype-wizarding.test.ts +++ b/packages/open-scd/test/integration/editors/templates/enumtype-wizarding.test.ts @@ -1,7 +1,7 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; import { ListItem } from '@material/mwc-list/mwc-list-item'; import { Select } from '@material/mwc-select'; @@ -15,18 +15,16 @@ describe('EnumType wizards', () => { if (customElements.get('templates-editor') === undefined) customElements.define('templates-editor', TemplatesPlugin); let doc: Document; - let parent: MockWizardEditor; + let parent: MockOpenSCD; let templates: TemplatesPlugin; let eNumTypeList: FilteredList; beforeEach(async () => { parent = await fixture( - html`` + html`` ); - templates = parent.querySelector('templates-editor')!; + templates = parent.getActivePlugin(); doc = await fetch('/test/testfiles/templates/datypes.scd') .then(response => response.text()) diff --git a/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts b/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts index 187ba82ee7..f0ba602a47 100644 --- a/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts +++ b/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts @@ -1,7 +1,7 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; import { ListItem } from '@material/mwc-list/mwc-list-item'; import { Select } from '@material/mwc-select'; @@ -16,18 +16,16 @@ describe('LNodeType wizards', () => { if (customElements.get('templates-editor') === undefined) customElements.define('templates-editor', TemplatesPlugin); let doc: Document; - let parent: MockWizardEditor; + let parent: MockOpenSCD; let templates: TemplatesPlugin; let lNodeTypeList: FilteredList; beforeEach(async () => { parent = await fixture( - html`` + html`` ); - templates = parent.querySelector('templates-editor')!; + templates = parent.getActivePlugin(); doc = await fetch('/test/testfiles/templates/dotypes.scd') .then(response => response.text()) diff --git a/packages/open-scd/test/integration/editors/triggered/ImportIedsPlugin.test.ts b/packages/open-scd/test/integration/editors/triggered/ImportIedsPlugin.test.ts index 8b2f89b784..2eedd48df8 100644 --- a/packages/open-scd/test/integration/editors/triggered/ImportIedsPlugin.test.ts +++ b/packages/open-scd/test/integration/editors/triggered/ImportIedsPlugin.test.ts @@ -3,45 +3,40 @@ import { LitElement, TemplateResult } from 'lit-element'; import { CheckListItem } from '@material/mwc-list/mwc-check-list-item'; -import '../../../mock-editor-logger.js'; -import { MockEditorLogger } from '../../../mock-editor-logger.js'; +import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; import ImportingIedPlugin from '../../../../src/menu/ImportIEDs.js'; import { Editing } from '../../../../src/Editing.js'; -class MockImportIed extends Editing(LitElement) { - render(): TemplateResult { - return html``; - } -} - describe('ImportIedsPlugin', () => { customElements.define('import-ied-plugin', ImportingIedPlugin); - customElements.define('mock-import-ied', MockImportIed); describe('imports valid ied elements to empty projects', () => { let doc: XMLDocument; let importDoc: XMLDocument; - let parent: MockImportIed; + let parent: MockOpenSCD; let element: ImportingIedPlugin; beforeEach(async () => { - parent = (await fixture( - html`` - )) as MockImportIed; - - element = parent.shadowRoot!.querySelector('import-ied-plugin')!; - doc = await fetch('/test/testfiles/importieds/emptyproject.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent.doc = doc; importDoc = await fetch('/test/testfiles/importieds/valid.iid') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - await element.updateComplete; + + parent = await fixture( + html`` + ); + + element = parent.getActivePlugin(); + + await parent.updateComplete; }); it('loads ied element to the project', async () => { @@ -161,18 +156,21 @@ describe('ImportIedsPlugin', () => { let doc: XMLDocument; let importDoc: XMLDocument; - let parent: MockImportIed; + let parent: MockOpenSCD; let element: ImportingIedPlugin; beforeEach(async () => { - parent = await fixture(html``); - - element = parent.shadowRoot!.querySelector('import-ied-plugin')!; - doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - parent.doc = doc; + + parent = await fixture( + html`` + ); + + element = parent.getActivePlugin(); await parent.updateComplete; importDoc = await fetch('/test/testfiles/importieds/valid.iid') @@ -388,23 +386,20 @@ describe('ImportIedsPlugin', () => { let doc: XMLDocument; let importDoc: XMLDocument; - let parent: MockEditorLogger; + let parent: MockOpenSCD; let element: ImportingIedPlugin; beforeEach(async () => { - parent = (await fixture( - html`` - )) as MockEditorLogger; - - element = parent.querySelector('import-ied-plugin')!; - 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; + + parent = await fixture(html``); + + element = parent.getActivePlugin(); + await parent.updateComplete; }); it('throws missing ied elements error', async () => { diff --git a/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js b/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js new file mode 100644 index 0000000000..a15b1ecacd --- /dev/null +++ b/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js @@ -0,0 +1,538 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +var ImportIEDs_js_1 = require("../../../../src/menu/ImportIEDs.js"); +describe('ImportIedsPlugin', function () { + customElements.define('import-ied-plugin', ImportIEDs_js_1["default"]); + describe('imports valid ied elements to empty projects', function () { + var doc; + var importDoc; + var parent; + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/emptyproject.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, fetch('/test/testfiles/importieds/valid.iid') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 2: + importDoc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; + case 3: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 4: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('loads ied element to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelector(':root > IED[name="TestImportIED"]')).to + .not.exist; + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelector(':root > IED[name="TestImportIED"]')).to + .exist; + return [2 /*return*/]; + } + }); + }); }); + it('adds the connectedap of the imported ied', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"] > ConnectedAP[iedName="TestImportIED"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('creates new subnetwork if not present in the doc', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')).to + .not.exist; + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')).to + .exist; + return [2 /*return*/]; + } + }); + }); }); + it('renames TEMPLATE IED element if manufacturer/type has illegal characters', function () { return __awaiter(void 0, void 0, void 0, function () { + var ied; + var _a, _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + importDoc = _d.sent(); + ied = importDoc.querySelector('IED'); + ied.setAttribute('manufacturer', 'Fancy-Vendy'); + ied.setAttribute('type', 'Z#Mega$Y'); + return [4 /*yield*/, element.updateComplete]; + case 2: + _d.sent(); + element.prepareImport(importDoc, 'template.icd'); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _d.sent(); + console.log((_b = (_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelector(':root > IED')) === null || _b === void 0 ? void 0 : _b.getAttribute('name')); + testing_1.expect((_c = element.doc) === null || _c === void 0 ? void 0 : _c.querySelector(':root > IED[name="FancyVendy_ZMegaY_001"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('allows multiple import of TEMPLATE IEDs', function () { return __awaiter(void 0, void 0, void 0, function () { + var templateIED1, templateIED2; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + templateIED1 = _a.sent(); + element.prepareImport(templateIED1, 'template.icd'); + return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 2: + templateIED2 = _a.sent(); + return [4 /*yield*/, element.updateComplete]; + case 3: + _a.sent(); + element.prepareImport(templateIED2, 'template.icd'); + return [4 /*yield*/, parent.updateComplete]; + case 4: + _a.sent(); + testing_1.expect(element.doc.querySelector('IED[name="FancyVendy_ZMegaY_001"]')).to + .exist; + testing_1.expect(element.doc.querySelector('IED[name="FancyVendy_ZMegaY_002"]')).to + .exist; + return [2 /*return*/]; + } + }); + }); }); + it('imports the ConnectedAPs for a TEMPLATE IED', function () { return __awaiter(void 0, void 0, void 0, function () { + var templateIED1; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + templateIED1 = _b.sent(); + element.prepareImport(templateIED1, 'template.icd'); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _b.sent(); + testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > Communication > SubNetwork > ConnectedAP[iedName="FancyVendy_ZMegaY_001"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('loads unique lnodetypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > LNodeType').length).to.equal(0); + element.prepareImport(importDoc, 'template.icd'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > LNodeType').length).to.equal(5); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('imports valid ied elements', function () { + var doc; + var importDoc; + var parent; + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B4.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + return [4 /*yield*/, fetch('/test/testfiles/importieds/valid.iid') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 4: + importDoc = _a.sent(); + return [4 /*yield*/, element.updateComplete]; + case 5: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('loads ied element to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelector(':root > IED[name="TestImportIED"]')).to + .not.exist; + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelector(':root > IED[name="TestImportIED"]')).to + .exist; + return [2 /*return*/]; + } + }); + }); }); + it('loads unique lnodetypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > LNodeType').length).to.equal(11); + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > LNodeType').length).to.equal(16); + return [2 /*return*/]; + } + }); + }); }); + it('loads unique dotypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > DOType').length).to.equal(16); + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > DOType').length).to.equal(26); + return [2 /*return*/]; + } + }); + }); }); + it('loads unique datypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > DAType').length).to.equal(7); + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > DAType').length).to.equal(11); + return [2 /*return*/]; + } + }); + }); }); + it('loads unique enumtypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > EnumType').length).to.equal(4); + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > EnumType').length).to.equal(10); + return [2 /*return*/]; + } + }); + }); }); + it('adds the connectedap of the imported ied', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + testing_1.expect(element.doc.querySelector('ConnectedAP[iedName="TestImportIED"]')) + .to.not.exist; + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _b.sent(); + testing_1.expect(element.doc.querySelector('ConnectedAP[iedName="TestImportIED"]')) + .to.exist; + testing_1.expect((_a = element.doc.querySelector('ConnectedAP[iedName="TestImportIED"]')) === null || _a === void 0 ? void 0 : _a.parentElement).to.equal(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')); + return [2 /*return*/]; + } + }); + }); }); + it('creates new subnetwork if not present in the doc', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')).to + .not.exist; + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')).to + .exist; + return [2 /*return*/]; + } + }); + }); }); + it('correctly transfers document element namespaces', function () { return __awaiter(void 0, void 0, void 0, function () { + var output, lineFeedAndSpacesReplace; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + element.prepareImport(importDoc, 'valid.iid'); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + testing_1.expect(element.doc.querySelector('SCL').getAttribute('xmlns:eTest1')).to.equal('http://www.eTest1.com/2022/Better61850'); + testing_1.expect(element.doc.querySelector('SCL').getAttribute('xmlns:eTest2')).to.equal('http://www.eTest2.com/2032/Better61850ForReal'); + output = new XMLSerializer().serializeToString(element.doc); + testing_1.expect(output).to.contain('xmlns:eTest1="http://www.eTest1.com/2022/Better61850"'); + testing_1.expect(output).to.contain('xmlns:eTest2="http://www.eTest2.com/2032/Better61850ForReal"'); + lineFeedAndSpacesReplace = /[\s\n\r]+/g; + testing_1.expect(output.replace(lineFeedAndSpacesReplace, '')).to.include("\n\n

    \n".replace(lineFeedAndSpacesReplace, '')); + return [2 /*return*/]; + } + }); + }); }); + it('allows multiple import of TEMPLATE IEDs', function () { return __awaiter(void 0, void 0, void 0, function () { + var templateIED1, templateIED2; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(element.doc.querySelectorAll('IED').length).to.equal(3); + return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + templateIED1 = _a.sent(); + element.prepareImport(templateIED1, 'template.icd'); + return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 2: + templateIED2 = _a.sent(); + element.prepareImport(templateIED2, 'template.icd'); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + testing_1.expect(element.doc.querySelector('IED[name="FancyVendy_ZMegaY_001"]')).to + .exist; + testing_1.expect(element.doc.querySelector('IED[name="FancyVendy_ZMegaY_002"]')).to + .exist; + return [2 /*return*/]; + } + }); + }); }); + it('renders wizard for files containing more than one IED', function () { return __awaiter(void 0, void 0, void 0, function () { + var multipleIedDoc; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/multipleied.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + multipleIedDoc = _b.sent(); + element.prepareImport(multipleIedDoc, 'multipleied.scd'); + return [4 /*yield*/, element.updateComplete]; + case 2: + _b.sent(); + testing_1.expect(element.dialog).to.exist; + testing_1.expect(element.dialog.open).to.be["true"]; + testing_1.expect((_a = element.dialog) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-check-list-item').length).to.equal(3); + return [2 /*return*/]; + } + }); + }); }); + it('imports selected IEDs from Import IED wizard', function () { return __awaiter(void 0, void 0, void 0, function () { + var multipleIedDoc; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/multipleied.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + multipleIedDoc = _b.sent(); + element.prepareImport(multipleIedDoc, 'multipleied.scd'); + return [4 /*yield*/, element.updateComplete]; + case 2: + _b.sent(); + (element.dialog.querySelectorAll('mwc-check-list-item')[1]).setAttribute('selected', 'true'); + (element.dialog.querySelectorAll('mwc-check-list-item')[2]).setAttribute('selected', 'true'); + return [4 /*yield*/, element.dialog.updateComplete]; + case 3: + _b.sent(); + ((_a = element.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-button[slot="primaryAction"]')).click(); + return [4 /*yield*/, parent.updateComplete]; + case 4: + _b.sent(); + return [4 /*yield*/, element.requestUpdate()]; + case 5: + _b.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 6: + _b.sent(); // await complex action + testing_1.expect(element.doc.querySelectorAll('IED[name="IED3"]').length).to.equal(1); + testing_1.expect(element.doc.querySelector('IED[name="IED4"]')).to.exist; + testing_1.expect(element.doc.querySelector('IED[name="IED5"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('importing invalid ieds', function () { + var doc; + var importDoc; + var parent; + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B4.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('throws missing ied elements error', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/invalid.iid') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + importDoc = _a.sent(); + element.prepareImport(importDoc, 'invalid.iid'); + testing_1.expect(parent.log[0].kind).to.equal('error'); + testing_1.expect(parent.log[0].title).to.equal('[import.log.missingied]'); + return [2 /*return*/]; + } + }); + }); }); + it('throws duplicate ied name error', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/duplicate.iid') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + importDoc = _a.sent(); + element.prepareImport(importDoc, 'duplicate.iid'); + testing_1.expect(parent.log[0].kind).to.equal('error'); + testing_1.expect(parent.log[0].title).to.equal('[import.log.nouniqueied]'); + return [2 /*return*/]; + } + }); + }); }); + it('throws parser error', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/parsererror.iid') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + importDoc = _a.sent(); + return [4 /*yield*/, element.updateComplete]; + case 2: + _a.sent(); + element.prepareImport(importDoc, 'parsererror.iid'); + testing_1.expect(parent.log[0].kind).to.equal('error'); + testing_1.expect(parent.log[0].title).to.equal('[import.log.parsererror]'); + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/menu/NewProject.test.ts b/packages/open-scd/test/integration/menu/NewProject.test.ts index 7f2a6b6c13..d37c79d948 100644 --- a/packages/open-scd/test/integration/menu/NewProject.test.ts +++ b/packages/open-scd/test/integration/menu/NewProject.test.ts @@ -1,23 +1,21 @@ import { expect, fixture, html } from '@open-wc/testing'; -import '../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../mock-wizard-editor.js'; +import '../../mock-open-scd.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; import NewProjectPlugin from '../../../src/menu/NewProject.js'; describe('NewProject loader', () => { customElements.define('new-project-plugin', NewProjectPlugin); - let parent: MockWizardEditor; + let parent: MockOpenSCD; let element: NewProjectPlugin; beforeEach(async () => { parent = await fixture(html` - + `); - element = parent.querySelector('new-project-plugin')!; + element = parent.getActivePlugin(); }); it('creates an empty Edition 2.1 project on wizard primary button click', async () => { diff --git a/packages/open-scd/test/integration/menu/UpdateDescritionABB.test.ts b/packages/open-scd/test/integration/menu/UpdateDescritionABB.test.ts index cc5a7f0dc5..88052b75b4 100644 --- a/packages/open-scd/test/integration/menu/UpdateDescritionABB.test.ts +++ b/packages/open-scd/test/integration/menu/UpdateDescritionABB.test.ts @@ -1,7 +1,7 @@ import { expect, fixture, html } from '@open-wc/testing'; -import '../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../mock-wizard-editor.js'; +import '../../mock-open-scd.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; import UpdateDescriptionAbb from '../../../src/menu/UpdateDescriptionABB.js'; @@ -9,7 +9,7 @@ describe('Update method for desc attributes in ABB IEDs', () => { if (customElements.get('update-description-abb') === undefined) customElements.define('update-description-abb', UpdateDescriptionAbb); - let parent: MockWizardEditor; + let parent: MockOpenSCD; let element: UpdateDescriptionAbb; let doc: XMLDocument; @@ -19,14 +19,12 @@ describe('Update method for desc attributes in ABB IEDs', () => { .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = await fixture(html` - + > `); - element = ( - parent.querySelector('update-description-abb')! - ); + element = parent.getActivePlugin(); element.doc = doc; element.run(); diff --git a/packages/open-scd/test/integration/menu/dist/NewProject.test.js b/packages/open-scd/test/integration/menu/dist/NewProject.test.js new file mode 100644 index 0000000000..ed1efe6294 --- /dev/null +++ b/packages/open-scd/test/integration/menu/dist/NewProject.test.js @@ -0,0 +1,139 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../mock-open-scd.js"); +var NewProject_js_1 = require("../../../src/menu/NewProject.js"); +describe('NewProject loader', function () { + customElements.define('new-project-plugin', NewProject_js_1["default"]); + var parent; + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [2 /*return*/]; + } + }); + }); }); + it('creates an empty Edition 2.1 project on wizard primary button click', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; + return __generator(this, function (_m) { + switch (_m.label) { + case 0: + element.run(); + return [4 /*yield*/, element.updateComplete]; + case 1: + _m.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _m.sent(); // await animation + (parent.wizardUI.shadowRoot.querySelector('mwc-button[slot="primaryAction"]')).click(); + testing_1.expect((_a = parent.doc) === null || _a === void 0 ? void 0 : _a.querySelector('Header')).to.exist; + testing_1.expect((_c = (_b = parent.doc) === null || _b === void 0 ? void 0 : _b.querySelector('Header')) === null || _c === void 0 ? void 0 : _c.getAttribute('id')).to.equal(parent.docName.slice(0, -4)); + testing_1.expect((_e = (_d = parent.doc) === null || _d === void 0 ? void 0 : _d.querySelector('SCL')) === null || _e === void 0 ? void 0 : _e.getAttribute('xmlns')).to.equal('http://www.iec.ch/61850/2003/SCL'); + testing_1.expect((_g = (_f = parent.doc) === null || _f === void 0 ? void 0 : _f.querySelector('SCL')) === null || _g === void 0 ? void 0 : _g.getAttribute('version')).to.equal('2007'); + testing_1.expect((_j = (_h = parent.doc) === null || _h === void 0 ? void 0 : _h.querySelector('SCL')) === null || _j === void 0 ? void 0 : _j.getAttribute('revision')).to.equal('B'); + testing_1.expect((_l = (_k = parent.doc) === null || _k === void 0 ? void 0 : _k.querySelector('SCL')) === null || _l === void 0 ? void 0 : _l.getAttribute('release')).to.equal('4'); + return [2 /*return*/]; + } + }); + }); }); + it('creates an empty Edition 2 project on wizard primary button click', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; + return __generator(this, function (_m) { + switch (_m.label) { + case 0: + element.run(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _m.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _m.sent(); // await animation + (parent.wizardUI.dialog.querySelector('mwc-radio-list-item:nth-child(2)')).click(); + return [4 /*yield*/, element.updateComplete]; + case 3: + _m.sent(); + (parent.wizardUI.shadowRoot.querySelector('mwc-button[slot="primaryAction"]')).click(); + testing_1.expect((_a = parent.doc) === null || _a === void 0 ? void 0 : _a.querySelector('Header')).to.exist; + testing_1.expect((_c = (_b = parent.doc) === null || _b === void 0 ? void 0 : _b.querySelector('Header')) === null || _c === void 0 ? void 0 : _c.getAttribute('id')).to.equal(parent.docName.slice(0, -4)); + testing_1.expect((_e = (_d = parent.doc) === null || _d === void 0 ? void 0 : _d.querySelector('SCL')) === null || _e === void 0 ? void 0 : _e.getAttribute('xmlns')).to.equal('http://www.iec.ch/61850/2003/SCL'); + testing_1.expect((_g = (_f = parent.doc) === null || _f === void 0 ? void 0 : _f.querySelector('SCL')) === null || _g === void 0 ? void 0 : _g.getAttribute('version')).to.equal('2007'); + testing_1.expect((_j = (_h = parent.doc) === null || _h === void 0 ? void 0 : _h.querySelector('SCL')) === null || _j === void 0 ? void 0 : _j.getAttribute('revision')).to.equal('B'); + testing_1.expect((_l = (_k = parent.doc) === null || _k === void 0 ? void 0 : _k.querySelector('SCL')) === null || _l === void 0 ? void 0 : _l.getAttribute('release')).to.be["null"]; + return [2 /*return*/]; + } + }); + }); }); + it('creates an empty Edition 1 project on wizard primary button click', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; + return __generator(this, function (_m) { + switch (_m.label) { + case 0: + element.run(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _m.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _m.sent(); // await animation + (parent.wizardUI.dialog.querySelector('mwc-radio-list-item:nth-child(1)')).click(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _m.sent(); + (parent.wizardUI.shadowRoot.querySelector('mwc-button[slot="primaryAction"]')).click(); + testing_1.expect((_a = parent.doc) === null || _a === void 0 ? void 0 : _a.querySelector('Header')).to.exist; + testing_1.expect((_c = (_b = parent.doc) === null || _b === void 0 ? void 0 : _b.querySelector('Header')) === null || _c === void 0 ? void 0 : _c.getAttribute('id')).to.equal(parent.docName.slice(0, -4)); + testing_1.expect((_e = (_d = parent.doc) === null || _d === void 0 ? void 0 : _d.querySelector('SCL')) === null || _e === void 0 ? void 0 : _e.getAttribute('xmlns')).to.equal('http://www.iec.ch/61850/2003/SCL'); + testing_1.expect((_g = (_f = parent.doc) === null || _f === void 0 ? void 0 : _f.querySelector('SCL')) === null || _g === void 0 ? void 0 : _g.getAttribute('version')).to.be["null"]; + testing_1.expect((_j = (_h = parent.doc) === null || _h === void 0 ? void 0 : _h.querySelector('SCL')) === null || _j === void 0 ? void 0 : _j.getAttribute('revision')).to.be["null"]; + testing_1.expect((_l = (_k = parent.doc) === null || _k === void 0 ? void 0 : _k.querySelector('SCL')) === null || _l === void 0 ? void 0 : _l.getAttribute('release')).to.be["null"]; + return [2 /*return*/]; + } + }); + }); }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/integration/menu/dist/UpdateDescritionABB.test.js b/packages/open-scd/test/integration/menu/dist/UpdateDescritionABB.test.js new file mode 100644 index 0000000000..02f687838c --- /dev/null +++ b/packages/open-scd/test/integration/menu/dist/UpdateDescritionABB.test.js @@ -0,0 +1,104 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../mock-open-scd.js"); +var UpdateDescriptionABB_js_1 = require("../../../src/menu/UpdateDescriptionABB.js"); +describe('Update method for desc attributes in ABB IEDs', function () { + if (customElements.get('update-description-abb') === undefined) + customElements.define('update-description-abb', UpdateDescriptionABB_js_1["default"]); + var parent; + var element; + var doc; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/updatedesc/updatedescABB.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + element.doc = doc; + element.run(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates desc attributes for ExtRef elements with existing intAddr attribute', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect(doc.querySelector('IED[name="IED1"] LN[lnClass="CSWI"][inst="1"] ExtRef:not([desc])')).to.exist; + (_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]').click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect(doc.querySelector('IED[name="IED1"] LN[lnClass="CSWI"][inst="1"] ExtRef[desc="GOOSERCV_BIN.3.I1"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('does not create desc attributes for ExtRef elements with missing intAddr attribute', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + testing_1.expect(doc.querySelector('IED[name="IED1"] LN[lnClass="CSWI"][inst="2"] ExtRef:not([desc])')).to.exist; + (_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]').click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _c.sent(); + testing_1.expect(doc.querySelector('IED[name="IED1"] LN[lnClass="CSWI"][inst="2"] ExtRef:not([desc])')).to.exist; + return [2 /*return*/]; + } + }); + }); }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/integration/validators/ValidateSchema.test.ts b/packages/open-scd/test/integration/validators/ValidateSchema.test.ts index 4b2b55d546..fcb1176d31 100644 --- a/packages/open-scd/test/integration/validators/ValidateSchema.test.ts +++ b/packages/open-scd/test/integration/validators/ValidateSchema.test.ts @@ -1,7 +1,7 @@ import { expect, fixture, html } from '@open-wc/testing'; -import '../../mock-editor-logger.js'; -import { MockEditorLogger } from '../../mock-editor-logger.js'; +import '../../mock-open-scd.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; import ValidateSchema from '../../../src/validators/ValidateSchema.js'; import { IssueDetail, LogEntry } from '../../../src/foundation.js'; @@ -10,7 +10,7 @@ describe('ValidateSchema plugin', () => { if (customElements.get('') === undefined) customElements.define('validate-schema', ValidateSchema); - let parent: MockEditorLogger; + let parent: MockOpenSCD; let element: ValidateSchema; let valid2007B4: XMLDocument; @@ -18,14 +18,12 @@ describe('ValidateSchema plugin', () => { before(async () => { parent = await fixture(html` - + `); - element = parent.querySelector('validate-schema')!; + element = parent.getActivePlugin(); element.pluginId = '/src/validators/ValidateSchema.js'; - await element.updateComplete; + await parent.updateComplete; }); describe('for valid SCL files', () => { diff --git a/packages/open-scd/test/integration/validators/ValidateTemplates.test.ts b/packages/open-scd/test/integration/validators/ValidateTemplates.test.ts index b24bbf679a..502874d456 100644 --- a/packages/open-scd/test/integration/validators/ValidateTemplates.test.ts +++ b/packages/open-scd/test/integration/validators/ValidateTemplates.test.ts @@ -1,14 +1,15 @@ import { expect, fixture, html } from '@open-wc/testing'; -import '../../../src/open-scd.js'; -import { OpenSCD } from '../../../src/open-scd.js'; +import '../../mock-open-scd.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; + import ValidateTemplates from '../../../src/validators/ValidateTemplates.js'; describe('ValidateTemplates OpenSCD integration test ', () => { if (customElements.get('validate-templates') === undefined) customElements.define('validate-templates', ValidateTemplates); - let parent: OpenSCD; + let parent: MockOpenSCD; let element: ValidateTemplates; let doc: XMLDocument; @@ -20,9 +21,9 @@ describe('ValidateTemplates OpenSCD integration test ', () => { .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = await fixture(html` - + > @@ -31,7 +32,7 @@ describe('ValidateTemplates OpenSCD integration test ', () => { rel="stylesheet" /> `); - element = parent.querySelector('validate-templates')!; + element = parent.getActivePlugin(); element.pluginId = '/src/validators/ValidateTemplates.js'; await element.validate(); @@ -52,9 +53,9 @@ describe('ValidateTemplates OpenSCD integration test ', () => { .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = await fixture(html` - + > @@ -63,7 +64,7 @@ describe('ValidateTemplates OpenSCD integration test ', () => { rel="stylesheet" /> `); - element = parent.querySelector('validate-templates')!; + element = parent.getActivePlugin(); element.pluginId = '/src/validators/ValidateTemplates.js'; await element.validate(); @@ -87,9 +88,9 @@ describe('ValidateTemplates OpenSCD integration test ', () => { .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = await fixture(html` - + > @@ -98,7 +99,7 @@ describe('ValidateTemplates OpenSCD integration test ', () => { rel="stylesheet" /> `); - element = parent.querySelector('validate-templates')!; + element = parent.getActivePlugin(); element.pluginId = '/src/validators/ValidateTemplates.js'; await element.validate(); diff --git a/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js b/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js new file mode 100644 index 0000000000..93d2f408bb --- /dev/null +++ b/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js @@ -0,0 +1,185 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../mock-open-scd.js"); +var ValidateSchema_js_1 = require("../../../src/validators/ValidateSchema.js"); +describe('ValidateSchema plugin', function () { + if (customElements.get('') === undefined) + customElements.define('validate-schema', ValidateSchema_js_1["default"]); + var parent; + var element; + var valid2007B4; + var invalid2007B; + before(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + element.pluginId = '/src/validators/ValidateSchema.js'; + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + describe('for valid SCL files', function () { + before(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + valid2007B4 = _a.sent(); + element.doc = valid2007B4; + element.docName = 'valid2007B'; + return [2 /*return*/]; + } + }); + }); }); + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + parent.diagnoses.clear(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + return [4 /*yield*/, element.validate()]; + case 2: + _a.sent(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('zeroissues indication looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); }); }); + it('indicates successful schema validation in the diagnoses pane', function () { return __awaiter(void 0, void 0, void 0, function () { + var lastEntry; + return __generator(this, function (_a) { + lastEntry = (parent.diagnoses.get('/src/validators/ValidateSchema.js')); + testing_1.expect(lastEntry.length).to.equal(1); + testing_1.expect(lastEntry[0].title).to.contain('[validator.schema.valid]'); + return [2 /*return*/]; + }); + }); }); + it('indicates successful schema validation in the log', function () { return __awaiter(void 0, void 0, void 0, function () { + var lastEntry; + return __generator(this, function (_a) { + lastEntry = parent.log.pop(); + testing_1.expect(lastEntry.kind).to.equal('info'); + testing_1.expect(lastEntry.title).to.contain('[validator.schema.valid]'); + return [2 /*return*/]; + }); + }); }); + }); + describe('for invalid SCL files', function () { + before(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/invalid2007B.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + invalid2007B = _a.sent(); + element.doc = invalid2007B; + element.docName = 'invalid2007B'; + return [4 /*yield*/, element.requestUpdate()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + parent.diagnoses.clear(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _a.sent(); + return [4 /*yield*/, element.validate()]; + case 2: + _a.sent(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('pushes issues to the diagnostics pane that look like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; + case 1: return [2 /*return*/, _a.sent()]; + } + }); }); }); + it('create issues in diagnose', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, testing_1.expect(parent.diagnoses.get('/src/validators/ValidateSchema.js')).to.not + .be.undefined]; + }); + }); }); + it('generates error messages in the log', function () { return __awaiter(void 0, void 0, void 0, function () { + var lastLogEntry; + return __generator(this, function (_a) { + lastLogEntry = parent.log.pop(); + testing_1.expect(lastLogEntry.kind).to.equal('warning'); + testing_1.expect(lastLogEntry.title).to.contain('[validator.schema.invalid]'); + return [2 /*return*/]; + }); + }); }); + }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/integration/validators/dist/ValidateTemplates.test.js b/packages/open-scd/test/integration/validators/dist/ValidateTemplates.test.js new file mode 100644 index 0000000000..cf105af454 --- /dev/null +++ b/packages/open-scd/test/integration/validators/dist/ValidateTemplates.test.js @@ -0,0 +1,184 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../mock-open-scd.js"); +var ValidateTemplates_js_1 = require("../../../src/validators/ValidateTemplates.js"); +describe('ValidateTemplates OpenSCD integration test ', function () { + if (customElements.get('validate-templates') === undefined) + customElements.define('validate-templates', ValidateTemplates_js_1["default"]); + var parent; + var element; + var doc; + describe('with a valid DataTypeTemplates section', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/zeroissues.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n\n \n \n \n "], ["\n \n\n \n \n \n "])), doc, doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + element.pluginId = '/src/validators/ValidateTemplates.js'; + return [4 /*yield*/, element.validate()]; + case 3: + _a.sent(); + return [4 /*yield*/, parent.updateComplete]; + case 4: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('shows a "No errors" message in the diagnostics pane', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(parent.diagnosticUI).to.contain.text('No errors'); + return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with issues in the DataTypeTemplates section', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/datatypetemplateerrors.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n \n\n \n \n \n "], ["\n \n\n \n \n \n "])), doc, doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + element.pluginId = '/src/validators/ValidateTemplates.js'; + return [4 /*yield*/, element.validate()]; + case 3: + _a.sent(); + return [4 /*yield*/, parent.updateComplete]; + case 4: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('generates issues in the diagnistics pane', function () { return __awaiter(void 0, void 0, void 0, function () { + var issues; + return __generator(this, function (_a) { + issues = parent.diagnoses.get('/src/validators/ValidateTemplates.js'); + testing_1.expect(issues === null || issues === void 0 ? void 0 : issues.length).to.equal(28); + return [2 /*return*/]; + }); + }); }).timeout(1000); + it('pushes issues to the diagnostics pane that look like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with schema version smaller "2007B3"', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n \n\n \n \n \n "], ["\n \n\n \n \n \n "])), doc, doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + element.pluginId = '/src/validators/ValidateTemplates.js'; + return [4 /*yield*/, element.validate()]; + case 3: + _a.sent(); + return [4 /*yield*/, parent.updateComplete]; + case 4: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('shows only one message in the diagnostics pane', function () { return __awaiter(void 0, void 0, void 0, function () { + var issues; + return __generator(this, function (_a) { + issues = parent.diagnoses.get('/src/validators/ValidateTemplates.js'); + testing_1.expect(issues === null || issues === void 0 ? void 0 : issues.length).to.equal(1); + return [2 /*return*/]; + }); + }); }).timeout(1000); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/wizards/bda-wizarding-editing.test.ts b/packages/open-scd/test/integration/wizards/bda-wizarding-editing.test.ts index 4032c96ada..1ef7cb47db 100644 --- a/packages/open-scd/test/integration/wizards/bda-wizarding-editing.test.ts +++ b/packages/open-scd/test/integration/wizards/bda-wizarding-editing.test.ts @@ -1,7 +1,7 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../mock-wizard-editor.js'; +import '../../mock-open-scd.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; import { ListItem } from '@material/mwc-list/mwc-list-item'; import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; @@ -16,18 +16,16 @@ describe('BDA wizarding editing integration', () => { if (customElements.get('templates-editor') === undefined) customElements.define('templates-editor', TemplatesPlugin); let doc: Document; - let parent: MockWizardEditor; + let parent: MockOpenSCD; let templates: TemplatesPlugin; let dATypeList: FilteredList; beforeEach(async () => { parent = await fixture( - html`` + html`` ); - templates = parent.querySelector('templates-editor')!; + templates = parent.getActivePlugin(); doc = await fetch('/test/testfiles/templates/datypes.scd') .then(response => response.text()) diff --git a/packages/open-scd/test/integration/wizards/da-wizarding-editing.test.ts b/packages/open-scd/test/integration/wizards/da-wizarding-editing.test.ts index 473b7a69e0..ac4e622594 100644 --- a/packages/open-scd/test/integration/wizards/da-wizarding-editing.test.ts +++ b/packages/open-scd/test/integration/wizards/da-wizarding-editing.test.ts @@ -1,7 +1,7 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../mock-wizard-editor.js'; +import '../../mock-open-sc.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; @@ -16,18 +16,16 @@ describe('DA wizarding editing integration', () => { if (customElements.get('templates-editor') === undefined) customElements.define('templates-editor', TemplatesPlugin); let doc: Document; - let parent: MockWizardEditor; + let parent: MockOpenSCD; let templates: TemplatesPlugin; let dOTypeList: FilteredList; beforeEach(async () => { parent = await fixture( - html`` + html`` ); - templates = parent.querySelector('templates-editor')!; + templates = parent.getActivePlugin(); doc = await fetch('/test/testfiles/templates/dotypes.scd') .then(response => response.text()) diff --git a/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js b/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js new file mode 100644 index 0000000000..add3ee5f05 --- /dev/null +++ b/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js @@ -0,0 +1,255 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../mock-open-scd.js"); +var Templates_js_1 = require("../../../src/editors/Templates.js"); +describe('BDA wizarding editing integration', function () { + if (customElements.get('templates-editor') === undefined) + customElements.define('templates-editor', Templates_js_1["default"]); + var doc; + var parent; + var templates; + var dATypeList; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _b.sent(); + templates = parent.getActivePlugin(); + return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 2: + doc = _b.sent(); + templates.doc = doc; + return [4 /*yield*/, templates.updateComplete]; + case 3: + _b.sent(); + dATypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="datypelist"]')); + return [2 /*return*/]; + } + }); + }); }); + describe('defines a editBDaWizard to edit an existing BDA', function () { + var nameField; + var primayAction; + var deleteButton; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d; + return __generator(this, function (_e) { + switch (_e.label) { + case 0: + (dATypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod.SBOw"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _e.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _e.sent(); // await animation + ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod.SBOw>ctlVal"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _e.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _e.sent(); // await animation + nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); + primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); + deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('[remove]'); })); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('edits BDA element', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="ctlVal"]')).to.exist; + nameField.value = 'newCtlVal'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="ctlVal"]')).to.not.exist; + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="newCtlVal"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('deletes the BDA element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="ctlVal"]')).to.exist; + testing_1.expect(doc.querySelectorAll('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA').length).to.equal(6); + deleteButton.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="ctlVal"]')).to.not.exist; + testing_1.expect(doc.querySelectorAll('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA').length).to.equal(5); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('defines a createBDaWizard to create a new BDA element', function () { + var nameField; + var descField; + var sAddrField; + var bTypeSelect; + var valKindSelect; + var valImportSelect; + var primayAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e, _f, _g, _h; + return __generator(this, function (_j) { + switch (_j.label) { + case 0: + (dATypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod.SBOw"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _j.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _j.sent(); // await animation + ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-menu > mwc-list-item')[1]).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _j.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _j.sent(); // await animation + nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); + descField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="desc"]')); + sAddrField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="sAddr"]')); + bTypeSelect = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('wizard-select[label="bType"]')); + valKindSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('wizard-select[label="valKind"]')); + valImportSelect = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelector('wizard-checkbox[label="valImport"]')); + primayAction = ((_h = parent.wizardUI.dialog) === null || _h === void 0 ? void 0 : _h.querySelector('mwc-button[slot="primaryAction"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates a new BDA element', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="newBDAElement"]')).to.not.exist; + nameField.value = 'newBDAElement'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + bTypeSelect.value = 'BOOLEAN'; + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _a.sent(); + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="newBDAElement"]:not([desc]):not([sAddr])[bType="BOOLEAN"]:not([valKind]):not([valImport])')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('creates yet another new BDA element', function () { return __awaiter(void 0, void 0, void 0, function () { + var name, desc, sAddr; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + name = 'newBDAElement2'; + desc = 'newBDAdesc'; + sAddr = 'myNewAddr'; + testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="newBDAElement2"]')).to.not.exist; + nameField.value = name; + descField.nullable = false; + descField.value = desc; + sAddrField.nullable = false; + sAddrField.value = sAddr; + bTypeSelect.value = 'BOOLEAN'; + valKindSelect.nullable = false; + valKindSelect.value = 'RO'; + valImportSelect.nullable = false; + valImportSelect.maybeValue = 'true'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector("DAType[id=\"Dummy.LLN0.Mod.SBOw\"] >" + + ("BDA[name=\"" + name + "\"][desc=\"" + desc + "\"][sAddr=\"" + sAddr + "\"][bType=\"BOOLEAN\"]:not([type])[valKind=\"RO\"][valImport=\"true\"]"))).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js b/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js new file mode 100644 index 0000000000..b40461bef7 --- /dev/null +++ b/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js @@ -0,0 +1,274 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../mock-open-sc.js"); +var Templates_js_1 = require("../../../src/editors/Templates.js"); +describe('DA wizarding editing integration', function () { + if (customElements.get('templates-editor') === undefined) + customElements.define('templates-editor', Templates_js_1["default"]); + var doc; + var parent; + var templates; + var dOTypeList; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _b.sent(); + templates = parent.getActivePlugin(); + return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 2: + doc = _b.sent(); + templates.doc = doc; + return [4 /*yield*/, templates.updateComplete]; + case 3: + _b.sent(); + dOTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="dotypelist"]')); + return [2 /*return*/]; + } + }); + }); }); + describe('defines a editDaWizard to edit an existing DA', function () { + var nameField; + var primayAction; + var deleteButton; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d; + return __generator(this, function (_e) { + switch (_e.label) { + case 0: + (dOTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _e.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _e.sent(); // await animation + ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod>stVal"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _e.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _e.sent(); // await animation + nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); + primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); + deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('[remove]'); })); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('edits DA attributes name', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).to.exist; + nameField.value = 'newCtlVal'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).to.not.exist; + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="newCtlVal"]')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('deletes the DA element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).to.exist; + testing_1.expect(doc.querySelectorAll('DOType[id="Dummy.LLN0.Mod"] > DA').length).to.equal(14); + deleteButton.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).to.not.exist; + testing_1.expect(doc.querySelectorAll('DOType[id="Dummy.LLN0.Mod"] > DA').length).to.equal(13); + return [2 /*return*/]; + } + }); + }); }); + it('does not edit DA element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { + var originData; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + originData = (doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).cloneNode(true); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + testing_1.expect(originData.isEqualNode(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]'))).to.be["true"]; + return [2 /*return*/]; + } + }); + }); }); + }); + describe('defines a createDaWizard to create a new DA element', function () { + var nameField; + var descField; + var sAddrField; + var bTypeSelect; + var valKindSelect; + var valImportSelect; + var fcSelect; + var primayAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b, _c, _d, _e, _f, _g, _h; + return __generator(this, function (_j) { + switch (_j.label) { + case 0: + (dOTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod"]')).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _j.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 2: + _j.sent(); // await animation + (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('[scl.DA]'); })).click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _j.sent(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + case 4: + _j.sent(); // await animation + nameField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="name"]')); + descField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="desc"]')); + sAddrField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="sAddr"]')); + bTypeSelect = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-select[label="bType"]')); + valKindSelect = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('wizard-select[label="valKind"]')); + valImportSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('wizard-checkbox[label="valImport"]')); + fcSelect = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelector('wizard-select[label="fc"]')); + primayAction = ((_h = parent.wizardUI.dialog) === null || _h === void 0 ? void 0 : _h.querySelector('mwc-button[slot="primaryAction"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates a new DA element', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="newDAElement"]')).to.not.exist; + nameField.value = 'newDAElement'; + fcSelect.value = 'ST'; + bTypeSelect.value = 'Struct'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > ' + + 'DA[name="newDAElement"]:not([desc]):not([sAddr])[bType="Struct"]' + + '[type="Dummy_origin"]:not([valKind]):not([valImport])')).to.exist; + return [2 /*return*/]; + } + }); + }); }); + it('creates yet another new DA element', function () { return __awaiter(void 0, void 0, void 0, function () { + var name, desc, sAddr; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + name = 'newDAElement2'; + desc = 'newDAdesc'; + sAddr = 'myNewAddr'; + testing_1.expect(doc.querySelector('DAType[id="#Dummy.LLN0.Mod"] > DA[name="newDAElement2"]')).to.not.exist; + nameField.value = name; + descField.nullable = false; + descField.value = desc; + sAddrField.nullable = false; + sAddrField.value = sAddr; + bTypeSelect.value = 'BOOLEAN'; + valKindSelect.nullable = false; + valKindSelect.value = 'RO'; + valImportSelect.nullable = false; + valImportSelect.maybeValue = 'true'; + fcSelect.value = 'ST'; + return [4 /*yield*/, parent.requestUpdate()]; + case 1: + _a.sent(); + primayAction.click(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + testing_1.expect(doc.querySelector("DOType[id=\"Dummy.LLN0.Mod\"] >" + + ("DA[name=\"" + name + "\"][desc=\"" + desc + "\"][sAddr=\"" + sAddr + "\"][bType=\"BOOLEAN\"]") + + ":not([type])[valKind=\"RO\"][valImport=\"true\"]")).to.exist; + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/mock-open-scd.ts b/packages/open-scd/test/mock-open-scd.ts new file mode 100644 index 0000000000..cc4df952f4 --- /dev/null +++ b/packages/open-scd/test/mock-open-scd.ts @@ -0,0 +1,27 @@ +import { + customElement, + TemplateResult, + html, + queryAssignedNodes, +} from 'lit-element'; +import { OpenSCD } from '../src/open-scd.js'; + +@customElement('mock-open-scd') +export class MockOpenSCD extends OpenSCD { + @queryAssignedNodes() + _plugins!: Array; + + renderHosting(): TemplateResult { + return html``; + } + + getPlugin(name: string): T | undefined { + return this._plugins.find( + p => p.tagName.toLowerCase() === name.toLowerCase() + ) as T | undefined; + } + + getActivePlugin(): T { + return this._plugins[0]! as T; + } +} diff --git a/packages/open-scd/test/unit/editors/cleanup/control-blocks-container.test.ts b/packages/open-scd/test/unit/editors/cleanup/control-blocks-container.test.ts index 5fc0929bf3..0fdc3043da 100644 --- a/packages/open-scd/test/unit/editors/cleanup/control-blocks-container.test.ts +++ b/packages/open-scd/test/unit/editors/cleanup/control-blocks-container.test.ts @@ -1,23 +1,16 @@ 'use strict'; import { html, fixture, expect } from '@open-wc/testing'; -import { Editing } from '../../../../src/Editing.js'; -import { Wizarding } from '../../../../src/Wizarding.js'; - import { CleanupControlBlocks } from '../../../../src/editors/cleanup/control-blocks-container.js'; import { ListItem } from '@material/mwc-list/mwc-list-item.js'; describe('Cleanup: Control Blocks Container', () => { - customElements.define( - 'cleanup-plugin-controlblocks', - Wizarding(Editing(CleanupControlBlocks)) - ); let element: CleanupControlBlocks; beforeEach(async () => { element = await fixture( - html`` + html`` ); }); @@ -34,9 +27,7 @@ describe('Cleanup: Control Blocks Container', () => { .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); element = await fixture( - html`` + html`` ); await element.updateComplete; }); diff --git a/packages/open-scd/test/unit/editors/cleanup/datasets-container.test.ts b/packages/open-scd/test/unit/editors/cleanup/datasets-container.test.ts index 868a28d074..987249f1c8 100644 --- a/packages/open-scd/test/unit/editors/cleanup/datasets-container.test.ts +++ b/packages/open-scd/test/unit/editors/cleanup/datasets-container.test.ts @@ -1,22 +1,25 @@ 'use strict'; import { html, fixture, expect } from '@open-wc/testing'; -import { Editing } from '../../../../src/Editing.js'; -import { Wizarding } from '../../../../src/Wizarding.js'; +import '../../../mock-open-scd.js'; import { CleanupDatasets } from '../../../../src/editors/cleanup/datasets-container.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('Cleanup: Datasets Container', () => { - customElements.define( - 'cleanup-plugin-datasets', - Wizarding(Editing(CleanupDatasets)) - ); + customElements.define('cleanup-plugin-datasets', CleanupDatasets); let element: CleanupDatasets; - + let parent: MockOpenSCD; beforeEach(async () => { - element = await fixture( - html`` + parent = await fixture( + html`` ); + + element = parent.getActivePlugin(); + + await parent.updateComplete(); }); describe('without a doc loaded', () => { @@ -31,10 +34,13 @@ describe('Cleanup: Datasets Container', () => { doc = await fetch('/test/testfiles/cleanup.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - element = await fixture( - html`` + parent = await fixture( + html`` ); - await element.updateComplete; + element = parent.getActivePlugin(); + await parent.updateComplete; }); it('looks like the latest snapshot', async () => { diff --git a/packages/open-scd/test/unit/editors/cleanup/datatypes-container.test.ts b/packages/open-scd/test/unit/editors/cleanup/datatypes-container.test.ts index 41b21ccd77..41d7b4c282 100644 --- a/packages/open-scd/test/unit/editors/cleanup/datatypes-container.test.ts +++ b/packages/open-scd/test/unit/editors/cleanup/datatypes-container.test.ts @@ -1,24 +1,25 @@ 'use strict'; import { html, fixture, expect } from '@open-wc/testing'; -import { Editing } from '../../../../src/Editing.js'; -import { Wizarding } from '../../../../src/Wizarding.js'; +import '../../../mock-open-scd.js'; import { CleanupDataTypes } from '../../../../src/editors/cleanup/datatypes-container.js'; import { ListItem } from '@material/mwc-list/mwc-list-item.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('Cleanup: DataTypes Container', () => { - customElements.define( - 'cleanup-plugin-data-types', - Wizarding(Editing(CleanupDataTypes)) - ); let element: CleanupDataTypes; + let parent: MockOpenSCD; beforeEach(async () => { - element = await fixture( - html`` + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); + await parent.updateComplete; }); describe('without a doc loaded', () => { @@ -33,11 +34,12 @@ describe('Cleanup: DataTypes Container', () => { doc = await fetch('/test/testfiles/cleanup.scd') .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - element = await fixture( - html`` + parent = await fixture( + html`` ); + element = parent.getActivePlugin(); await element.updateComplete; }); diff --git a/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js b/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js new file mode 100644 index 0000000000..c5d820a7aa --- /dev/null +++ b/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js @@ -0,0 +1,181 @@ +'use strict'; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +describe('Cleanup: Control Blocks Container', function () { + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + element = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + describe('without a doc loaded', function () { + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('With a test file loaded', function () { + var doc; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + case 2: + element = _a.sent(); + return [4 /*yield*/, element.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates correct number of checkboxes for the expected unreferenced control blocks', function () { + testing_1.expect(Array.from(element.unreferencedControls).length).to.equal(5); + }); + it('has the remove button disabled by default', function () { + testing_1.expect(element.cleanButton).to.have.property('disabled', true); + }); + it('has the remove button enabled after selecting an item', function () { return __awaiter(void 0, void 0, void 0, function () { + var firstCheckListItem; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + firstCheckListItem = element.cleanupListItems[0]; + return [4 /*yield*/, firstCheckListItem.click()]; + case 1: + _a.sent(); + return [4 /*yield*/, element.cleanupList.layout()]; + case 2: + _a.sent(); + testing_1.expect(element.cleanButton).to.have.property('disabled', false); + return [2 /*return*/]; + } + }); + }); }); + it('after selecting and deselecting an item the remove button is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { + var firstCheckListItem; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + firstCheckListItem = element.cleanupListItems[0]; + return [4 /*yield*/, firstCheckListItem.click()]; + case 1: + _a.sent(); + return [4 /*yield*/, element.cleanupList.layout()]; + case 2: + _a.sent(); + return [4 /*yield*/, firstCheckListItem.click()]; + case 3: + _a.sent(); + return [4 /*yield*/, element.cleanupList.layout()]; + case 4: + _a.sent(); + testing_1.expect(element.cleanButton).to.have.property('disabled', true); + return [2 /*return*/]; + } + }); + }); }); + it('after clicking select all the button is not disabled', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + checkbox = element + .shadowRoot.querySelector('.cleanupList') + .shadowRoot.querySelector('.checkall') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 1: + _b.sent(); + return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 2: + _b.sent(); + testing_1.expect(element.cleanButton).to.have.property('disabled', false); + return [2 /*return*/]; + } + }); + }); }); + /* This test is currently failing and has been commented out + TODO: Investigate further. It appears that a filtered list will not + unselect all if there are hidden items. */ + // it('after clicking select all twice the button is disabled', async () => { + // const checkbox = element + // .shadowRoot!.querySelector('.cleanupList')! + // .shadowRoot!.querySelector('.checkall')! + // .querySelector('mwc-checkbox')!; + // await checkbox.click(); + // await element.cleanupList?.layout(); + // await checkbox.click(); + // await element.cleanupList?.layout(); + // expect(element.cleanButton).to.have.property('disabled', true); + // }); + }); +}); +var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js b/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js new file mode 100644 index 0000000000..a5b57b885f --- /dev/null +++ b/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js @@ -0,0 +1,191 @@ +'use strict'; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +var datasets_container_js_1 = require("../../../../src/editors/cleanup/datasets-container.js"); +describe('Cleanup: Datasets Container', function () { + customElements.define('cleanup-plugin-datasets', datasets_container_js_1.CleanupDatasets); + var element; + var parent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + describe('without a doc loaded', function () { + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with a test file loaded', function () { + var doc; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates correct number of checkboxes for the expected unreferenced datasets', function () { + testing_1.expect(Array.from(element.dataSetItems).length).to.equal(2); + }); + it('has the remove button disabled by default', function () { + testing_1.expect(element.cleanupButton).to.have.property('disabled', true); + }); + it('has the remove button enabled after selecting an item', function () { return __awaiter(void 0, void 0, void 0, function () { + var firstCheckListItem; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + firstCheckListItem = element.dataSetItems[0]; + return [4 /*yield*/, firstCheckListItem.click()]; + case 1: + _a.sent(); + testing_1.expect(element.cleanupButton).to.have.property('disabled', false); + return [2 /*return*/]; + } + }); + }); }); + it('after selecting and deselecting an item the remove button is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { + var firstCheckListItem; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + firstCheckListItem = element.dataSetItems[0]; + return [4 /*yield*/, firstCheckListItem.click()]; + case 1: + _a.sent(); + return [4 /*yield*/, firstCheckListItem.click()]; + case 2: + _a.sent(); + testing_1.expect(element.cleanupButton).to.have.property('disabled', true); + return [2 /*return*/]; + } + }); + }); }); + it('after clicking select all the button is not disabled', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + checkbox = element + .shadowRoot.querySelector('.dataSetList') + .shadowRoot.querySelector('.checkall') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 1: + _b.sent(); + return [4 /*yield*/, ((_a = element.dataSetList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 2: + _b.sent(); + testing_1.expect(element.cleanupButton).to.have.property('disabled', false); + return [2 /*return*/]; + } + }); + }); }); + it('after clicking select all twice the button is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { + var checkbox; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + checkbox = element + .shadowRoot.querySelector('.dataSetList') + .shadowRoot.querySelector('.checkall') + .querySelector('mwc-checkbox'); + return [4 /*yield*/, checkbox.click()]; + case 1: + _b.sent(); + return [4 /*yield*/, checkbox.click()]; + case 2: + _b.sent(); + return [4 /*yield*/, ((_a = element.dataSetList) === null || _a === void 0 ? void 0 : _a.layout())]; + case 3: + _b.sent(); + testing_1.expect(element.cleanupButton).to.have.property('disabled', true); + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js b/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js new file mode 100644 index 0000000000..0a02761784 --- /dev/null +++ b/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js @@ -0,0 +1,130 @@ +'use strict'; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +describe('Cleanup: DataTypes Container', function () { + var element; + var parent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + describe('without a doc loaded', function () { + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('With a test file loaded', function () { + var doc; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, element.updateComplete]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates correct number of checkboxes for the expected unreferenced datatypes', function () { + testing_1.expect(Array.from(element.unreferencedDataTypes).length).to.equal(9); + }); + it('has the remove button disabled by default', function () { + testing_1.expect(element.cleanButton).to.have.property('disabled', true); + }); + it('has the remove button enabled after selecting an item', function () { return __awaiter(void 0, void 0, void 0, function () { + var firstCheckListItem; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + firstCheckListItem = element.cleanupListItems[0]; + return [4 /*yield*/, firstCheckListItem.click()]; + case 1: + _a.sent(); + return [4 /*yield*/, element.cleanupList.layout()]; + case 2: + _a.sent(); + testing_1.expect(element.cleanButton).to.have.property('disabled', false); + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/unit/editors/subscription/dist/fcda-binding-list.test.js b/packages/open-scd/test/unit/editors/subscription/dist/fcda-binding-list.test.js new file mode 100644 index 0000000000..4f8d513abd --- /dev/null +++ b/packages/open-scd/test/unit/editors/subscription/dist/fcda-binding-list.test.js @@ -0,0 +1,434 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +require("../../../mock-open-scd.js"); +require("../../../../src/editors/subscription/fcda-binding-list.js"); +var sinon_1 = require("sinon"); +describe('fcda-binding-list', function () { + var parent; + var element; + var doc; + var selectEvent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + localStorage.clear(); + selectEvent = sinon_1.spy(); + window.addEventListener('fcda-select', selectEvent); + return [2 /*return*/]; + }); + }); }); + describe('without a doc loaded', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n \n \n "], ["\n \n \n \n "]))))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('no event is fired, because no property are changed', function () { + testing_1.expect(selectEvent).to.not.have.been.called; + }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""]))))]; + case 1: + element = _a.sent(); + return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with a SampledValueControl doc loaded', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + localStorage.clear(); + return [4 /*yield*/, fetch('/test/testfiles/editors/LaterBindingSMV2007B4.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n \n \n \n "], ["\n \n \n \n "])), doc, true))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('the SVC editor is opened', function () { return __awaiter(void 0, void 0, void 0, function () { + var nameField; + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + // Select the first list item that has an edit button, this should be an SVC Element. + return [4 /*yield*/, ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-list-item > mwc-icon-button[icon="edit"]')).click()]; + case 1: + // Select the first list item that has an edit button, this should be an SVC Element. + _c.sent(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _c.sent(); + nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); + testing_1.expect(nameField.value).to.be.equal('fullSmv'); + return [2 /*return*/]; + } + }); + }); }); + it('event is fired, but properties are undefined', function () { + testing_1.expect(selectEvent).to.have.been.calledOnce; + testing_1.expect(selectEvent.args[0][0].detail.selectedSvcElement).to.be.undefined; + testing_1.expect(selectEvent.args[0][0].detail.selectedFcdaElement).to.be.undefined; + }); + it('event is fired with selected elements', function () { return __awaiter(void 0, void 0, void 0, function () { + var listItem; + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + selectEvent.resetHistory(); + listItem = Array.from((_b = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-list-item.subitem')) !== null && _b !== void 0 ? _b : []).filter(function (listItem) { + var _a; + var value = (_a = listItem.getAttribute('value')) !== null && _a !== void 0 ? _a : ''; + return (value.includes('currentOnly') && value.includes('AmpSv instMag.i')); + })[0]; + listItem.click(); + return [4 /*yield*/, element.updateComplete]; + case 1: + _c.sent(); + testing_1.expect(selectEvent).to.have.been.called; + testing_1.expect(selectEvent.args[0][0].detail.control).to.equal(doc.querySelector('IED[name="SMV_Publisher"] LN0 > SampledValueControl[name="currentOnly"]')); + testing_1.expect(selectEvent.args[0][0].detail.fcda).to.equal(doc.querySelector('IED[name="SMV_Publisher"] LN0 > DataSet[name="currentOnlysDataSet"] > ' + + 'FCDA[ldInst="CurrentTransformer"][prefix="L1"][lnClass="TCTR"][lnInst="1"][doName="AmpSv"][daName="instMag.i"][fc="MX"]')); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('is initially unfiltered', function () { return __awaiter(void 0, void 0, void 0, function () { + var displayedElements; + return __generator(this, function (_a) { + displayedElements = Array.from(element.shadowRoot.querySelectorAll('mwc-list-item')).filter(function (item) { + var displayStyle = getComputedStyle(item).display; + return displayStyle !== 'none' || displayStyle === undefined; + }); + testing_1.expect(displayedElements.length).to.equal(27); + return [2 /*return*/]; + }); + }); }); + it('allows filtering of only not subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { + var fcdaList, displayedElements; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + element.actionsMenuIcon.click(); + return [4 /*yield*/, element.updateComplete]; + case 1: + _b.sent(); + (element.actionsMenu.querySelector('.filter-subscribed')).click(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 200); })]; + case 2: + _b.sent(); // await animation + return [4 /*yield*/, element.updateComplete]; + case 3: + _b.sent(); + fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); + displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { + var displayStyle = getComputedStyle(item).display; + return displayStyle !== 'none' || displayStyle === undefined; + }); + testing_1.expect(displayedElements.length).to.equal(24); + return [2 /*return*/]; + } + }); + }); }); + it('allows filtering of only subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { + var fcdaList, displayedElements; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + element.actionsMenuIcon.click(); + return [4 /*yield*/, element.updateComplete]; + case 1: + _b.sent(); + (element.actionsMenu.querySelector('.filter-not-subscribed')).click(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 200); })]; + case 2: + _b.sent(); // await animation + return [4 /*yield*/, element.updateComplete]; + case 3: + _b.sent(); + fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); + displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { + var displayStyle = getComputedStyle(item).display; + return displayStyle !== 'none' || displayStyle === undefined; + }); + testing_1.expect(displayedElements.length).to.equal(5); + return [2 /*return*/]; + } + }); + }); }); + it('allows filtering out of all subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { + var fcdaList, displayedElements; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + element.actionsMenuIcon.click(); + return [4 /*yield*/, element.updateComplete]; + case 1: + _b.sent(); + (element.actionsMenu.querySelector('.filter-subscribed')).click(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; + case 2: + _b.sent(); // await animation + return [4 /*yield*/, element.updateComplete]; + case 3: + _b.sent(); + element.actionsMenuIcon.click(); + return [4 /*yield*/, element.updateComplete]; + case 4: + _b.sent(); + (element.actionsMenu.querySelector('.filter-not-subscribed')).click(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; + case 5: + _b.sent(); // await animation + return [4 /*yield*/, element.updateComplete]; + case 6: + _b.sent(); + fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); + displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { + var displayStyle = getComputedStyle(item).display; + return displayStyle !== 'none' || displayStyle === undefined; + }); + testing_1.expect(displayedElements.length).to.equal(0); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('with a GSEControl doc loaded', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + localStorage.clear(); + return [4 /*yield*/, fetch('/test/testfiles/editors/LaterBindingGOOSE2007B4.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n \n \n \n "], ["\n \n \n \n "])), doc, true))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('the GOOSE editor is opened', function () { return __awaiter(void 0, void 0, void 0, function () { + var nameField; + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + // Select the first list item that has an edit button, this should be an GOOSE Element. + return [4 /*yield*/, ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-list-item > mwc-icon-button[icon="edit"]')).click()]; + case 1: + // Select the first list item that has an edit button, this should be an GOOSE Element. + _c.sent(); + return [4 /*yield*/, parent.updateComplete]; + case 2: + _c.sent(); + nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); + testing_1.expect(nameField.value).to.be.equal('GOOSE2'); + return [2 /*return*/]; + } + }); + }); }); + it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('is initially unfiltered', function () { return __awaiter(void 0, void 0, void 0, function () { + var displayedElements; + return __generator(this, function (_a) { + displayedElements = Array.from(element.shadowRoot.querySelectorAll('mwc-list-item')).filter(function (item) { + var displayStyle = getComputedStyle(item).display; + return displayStyle !== 'none' || displayStyle === undefined; + }); + testing_1.expect(displayedElements.length).to.equal(9); + return [2 /*return*/]; + }); + }); }); + it('allows filtering of only not subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { + var fcdaList, displayedElements; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + element.actionsMenuIcon.click(); + return [4 /*yield*/, element.updateComplete]; + case 1: + _b.sent(); + (element.actionsMenu.querySelector('.filter-subscribed')).click(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; + case 2: + _b.sent(); // await animation + return [4 /*yield*/, element.updateComplete]; + case 3: + _b.sent(); + fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); + displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { + var displayStyle = getComputedStyle(item).display; + return displayStyle !== 'none' || displayStyle === undefined; + }); + testing_1.expect(displayedElements.length).to.equal(3); + return [2 /*return*/]; + } + }); + }); }); + it('allows filtering of only subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { + var fcdaList, displayedElements; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + element.actionsMenuIcon.click(); + return [4 /*yield*/, element.updateComplete]; + case 1: + _b.sent(); + (element.actionsMenu.querySelector('.filter-not-subscribed')).click(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; + case 2: + _b.sent(); // await animation + return [4 /*yield*/, element.updateComplete]; + case 3: + _b.sent(); + fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); + displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { + var displayStyle = getComputedStyle(item).display; + return displayStyle !== 'none' || displayStyle === undefined; + }); + testing_1.expect(displayedElements.length).to.equal(6); + return [2 /*return*/]; + } + }); + }); }); + it('allows filtering out of all subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { + var fcdaList, displayedElements; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + element.actionsMenuIcon.click(); + return [4 /*yield*/, element.updateComplete]; + case 1: + _b.sent(); + (element.actionsMenu.querySelector('.filter-subscribed')).click(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; + case 2: + _b.sent(); // await animation + return [4 /*yield*/, element.updateComplete]; + case 3: + _b.sent(); + element.actionsMenuIcon.click(); + return [4 /*yield*/, element.updateComplete]; + case 4: + _b.sent(); + (element.actionsMenu.querySelector('.filter-not-subscribed')).click(); + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; + case 5: + _b.sent(); // await animation + return [4 /*yield*/, element.updateComplete]; + case 6: + _b.sent(); + fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); + displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { + var displayStyle = getComputedStyle(item).display; + return displayStyle !== 'none' || displayStyle === undefined; + }); + testing_1.expect(displayedElements.length).to.equal(0); + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2, templateObject_3, templateObject_4; diff --git a/packages/open-scd/test/unit/editors/subscription/fcda-binding-list.test.ts b/packages/open-scd/test/unit/editors/subscription/fcda-binding-list.test.ts index 594821b6f6..f3cb22b83d 100644 --- a/packages/open-scd/test/unit/editors/subscription/fcda-binding-list.test.ts +++ b/packages/open-scd/test/unit/editors/subscription/fcda-binding-list.test.ts @@ -1,7 +1,7 @@ import { expect, fixture, html } from '@open-wc/testing'; -import '../../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../../mock-wizard-editor.js'; +import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; import { WizardTextField } from '../../../../src/wizard-textfield.js'; @@ -11,7 +11,7 @@ import { SinonSpy, spy } from 'sinon'; import { ListItem } from '@material/mwc-list/mwc-list-item.js'; describe('fcda-binding-list', () => { - let parent: MockWizardEditor; + let parent: MockOpenSCD; let element: FcdaBindingList; let doc: XMLDocument; @@ -26,13 +26,13 @@ describe('fcda-binding-list', () => { describe('without a doc loaded', () => { beforeEach(async () => { parent = await fixture(html` - + - + `); - element = parent.querySelector('fcda-binding-list')!; - await element.requestUpdate(); + element = parent.getActivePlugin(); + await parent.requestUpdate(); }); it('no event is fired, because no property are changed', () => { @@ -53,17 +53,17 @@ describe('fcda-binding-list', () => { .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = await fixture(html` - + - + `); - element = parent.querySelector('fcda-binding-list')!; - await element.requestUpdate(); + element = parent.getActivePlugin(); + await parent.requestUpdate(); }); it('the SVC editor is opened', async () => { @@ -203,17 +203,17 @@ describe('fcda-binding-list', () => { .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = await fixture(html` - + - + `); - element = parent.querySelector('fcda-binding-list')!; - await element.requestUpdate(); + element = parent.getActivePlugin(); + await parent.requestUpdate(); }); it('the GOOSE editor is opened', async () => { diff --git a/packages/open-scd/test/unit/menu/SclHistory.test.ts b/packages/open-scd/test/unit/menu/SclHistory.test.ts index 6553157ec4..449609f0a1 100644 --- a/packages/open-scd/test/unit/menu/SclHistory.test.ts +++ b/packages/open-scd/test/unit/menu/SclHistory.test.ts @@ -1,5 +1,7 @@ import { expect, fixture, html } from '@open-wc/testing'; + import SclHistoryPlugin from '../../../src/menu/SclHistory.js'; + describe('testing sclHistory dialog', () => { if (customElements.get('scl-history') === undefined) customElements.define('scl-history', SclHistoryPlugin); diff --git a/packages/open-scd/test/unit/menu/UpdateDescriptionSEL.test.ts b/packages/open-scd/test/unit/menu/UpdateDescriptionSEL.test.ts index 6d09898af0..07b5d4804a 100644 --- a/packages/open-scd/test/unit/menu/UpdateDescriptionSEL.test.ts +++ b/packages/open-scd/test/unit/menu/UpdateDescriptionSEL.test.ts @@ -1,8 +1,8 @@ import { expect, fixture, html } from '@open-wc/testing'; import { SinonSpy, spy } from 'sinon'; -import '../../mock-wizard-editor.js'; -import { MockWizardEditor } from '../../mock-wizard-editor.js'; +import '../../mock-open-scd.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; import { ComplexAction, isSimple, isReplace } from '../../../src/foundation.js'; import UpdateDescriptionSel from '../../../src/menu/UpdateDescriptionSEL.js'; @@ -11,7 +11,7 @@ describe('Update method for desc attributes in SEL IEDs', () => { if (customElements.get('update-description-sel') === undefined) customElements.define('update-description-sel', UpdateDescriptionSel); - let parent: MockWizardEditor; + let parent: MockOpenSCD; let element: UpdateDescriptionSel; let wizardAction: SinonSpy; @@ -21,9 +21,9 @@ describe('Update method for desc attributes in SEL IEDs', () => { beforeEach(async () => { parent = await fixture(html` - + > `); element = ( diff --git a/packages/open-scd/test/unit/menu/UpdateDescritionABB.test.ts b/packages/open-scd/test/unit/menu/UpdateDescritionABB.test.ts index 637a340afa..9f2fcd6a3f 100644 --- a/packages/open-scd/test/unit/menu/UpdateDescritionABB.test.ts +++ b/packages/open-scd/test/unit/menu/UpdateDescritionABB.test.ts @@ -1,8 +1,8 @@ import { expect, fixture, html } from '@open-wc/testing'; import sinon, { SinonSpy } from 'sinon'; -import '../../mock-wizard.js'; -import { MockWizard } from '../../mock-wizard.js'; +import '../../mock-open-scd.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; import { ComplexAction, isSimple, isReplace } from '../../../src/foundation.js'; import UpdateDescriptionAbb from '../../../src/menu/UpdateDescriptionABB.js'; @@ -11,21 +11,19 @@ describe('Update method for desc attributes in ABB IEDs', () => { if (customElements.get('update-description-abb') === undefined) customElements.define('update-description-abb', UpdateDescriptionAbb); - let parent: MockWizard; + let parent: MockOpenSCD; let element: UpdateDescriptionAbb; let editorAction: SinonSpy; beforeEach(async () => { parent = await fixture(html` - + > `); - element = ( - parent.querySelector('update-description-abb')! - ); + element = parent.getActivePlugin(); editorAction = sinon.spy(); window.addEventListener('editor-action', editorAction); diff --git a/packages/open-scd/test/unit/menu/dist/SclHistory.test.js b/packages/open-scd/test/unit/menu/dist/SclHistory.test.js new file mode 100644 index 0000000000..71cbb53ff7 --- /dev/null +++ b/packages/open-scd/test/unit/menu/dist/SclHistory.test.js @@ -0,0 +1,158 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +var SclHistory_js_1 = require("../../../src/menu/SclHistory.js"); +describe('testing sclHistory dialog', function () { + if (customElements.get('scl-history') === undefined) + customElements.define('scl-history', SclHistory_js_1["default"]); + var plugin; + var doc; + describe('with a document loaded containing SCL history items', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/history.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([" "], [" "])), doc))]; + case 2: + plugin = _a.sent(); + plugin.run(); + return [4 /*yield*/, plugin.requestUpdate()]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like its latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(plugin.historyLog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('has 7 items in the history list', function () { + testing_1.expect(plugin.sclHistory.length).to.be.equal(7); + }); + describe('testing createMessage function', function () { + it('creates a message with two valid strings', function () { + testing_1.expect(plugin['createMessage']('string who', 'string why')).to.be.equal('string who : string why'); + }); + it('creates a message with one valid string or returns undefined', function () { + testing_1.expect(plugin['createMessage']('string who', null)).to.be.equal('string who'); + testing_1.expect(plugin['createMessage'](null, 'string why')).to.be.equal('string why'); + testing_1.expect(plugin['createMessage'](null, null)).to.be.undefined; + }); + }); + }); + describe('with no document', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([" "], [" "]))))]; + case 1: + plugin = _a.sent(); + plugin.run(); + return [4 /*yield*/, plugin.requestUpdate()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like its latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(plugin.historyLog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('has no items in the history list', function () { + testing_1.expect(plugin.sclHistory).to.be.empty; + }); + }); + describe('with a document without SCL history items', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/no-history.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([" "], [" "])), doc))]; + case 2: + plugin = _a.sent(); + plugin.run(); + return [4 /*yield*/, plugin.requestUpdate()]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('looks like its latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(plugin.historyLog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('has no items in the history list', function () { + testing_1.expect(plugin.sclHistory).to.be.empty; + }); + }); +}); +var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/unit/menu/dist/UpdateDescriptionSEL.test.js b/packages/open-scd/test/unit/menu/dist/UpdateDescriptionSEL.test.js new file mode 100644 index 0000000000..ceea54498a --- /dev/null +++ b/packages/open-scd/test/unit/menu/dist/UpdateDescriptionSEL.test.js @@ -0,0 +1,236 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +var sinon_1 = require("sinon"); +require("../../mock-open-scd.js"); +var foundation_js_1 = require("../../../src/foundation.js"); +var UpdateDescriptionSEL_js_1 = require("../../../src/menu/UpdateDescriptionSEL.js"); +describe('Update method for desc attributes in SEL IEDs', function () { + if (customElements.get('update-description-sel') === undefined) + customElements.define('update-description-sel', UpdateDescriptionSEL_js_1["default"]); + var parent; + var element; + var wizardAction; + var editorAction; + var signalList; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; + case 1: + parent = _a.sent(); + element = (parent.querySelector('update-description-sel')); + return [4 /*yield*/, element.requestUpdate()]; + case 2: + _a.sent(); + editorAction = sinon_1.spy(); + window.addEventListener('editor-action', editorAction); + wizardAction = sinon_1.spy(); + window.addEventListener('wizard', wizardAction); + return [2 /*return*/]; + } + }); + }); }); + it('allows to select signal list only as csv file', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + testing_1.expect(element.pluginFileUI).to.have.property('accept', '.csv'); + testing_1.expect(element.pluginFileUI).to.have.property('type', 'file'); + return [2 /*return*/]; + }); + }); }); + it('allows to select signal list as csv file', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, element.run()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + describe('working on SCL files without manufacturer SEL', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var doc; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('test/testfiles/validators/zeroissues.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + element.doc = doc; + return [4 /*yield*/, fetch('test/testfiles/updatedesc/testSignalListSemicolon.csv').then(function (response) { return response.text(); })]; + case 2: + signalList = _a.sent(); + element.processSignalList(signalList); + return [4 /*yield*/, parent.requestUpdate()]; + case 3: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('cannot find any desc fields to update', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + testing_1.expect(wizardAction).to.have.been.calledOnce; + testing_1.expect((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-checked-list-item')).to + .be["null"]; + return [2 /*return*/]; + }); + }); }); + }); + describe('working on SCL files containing manufacturer SEL', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var doc; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('test/testfiles/updatedesc/updatedescSEL.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + element.doc = doc; + return [2 /*return*/]; + } + }); + }); }); + describe('using a semicolon separated file', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('test/testfiles/updatedesc/testSignalListSemicolon.csv').then(function (response) { return response.text(); })]; + case 1: + signalList = _a.sent(); + element.processSignalList(signalList); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates filtered list with all proposed desc attribute updates', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('allows to update selected desc attributes updates', function () { return __awaiter(void 0, void 0, void 0, function () { + var complexAction, _i, _a, action; + var _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + (_c = (_b = parent.wizardUI) === null || _b === void 0 ? void 0 : _b.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-button[slot="primaryAction"]').click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _d.sent(); + testing_1.expect(editorAction).to.have.been.calledOnce; + testing_1.expect(editorAction.args[0][0].detail.action).to.not.satisfy(foundation_js_1.isSimple); + complexAction = (editorAction.args[0][0].detail.action); + testing_1.expect(complexAction.actions.length).to.equal(7); + for (_i = 0, _a = complexAction.actions; _i < _a.length; _i++) { + action = _a[_i]; + testing_1.expect(action).to.satisfy(foundation_js_1.isReplace); + } + return [2 /*return*/]; + } + }); + }); }); + }); + describe('using a comma separated (CSV) file', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('test/testfiles/updatedesc/testSignalListComma.csv').then(function (response) { return response.text(); })]; + case 1: + signalList = _a.sent(); + element.processSignalList(signalList); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates filtered list with all proposed desc attribute updates', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('allows to update selected desc attributes updates', function () { return __awaiter(void 0, void 0, void 0, function () { + var complexAction, _i, _a, action; + var _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + (_c = (_b = parent.wizardUI) === null || _b === void 0 ? void 0 : _b.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-button[slot="primaryAction"]').click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _d.sent(); + testing_1.expect(editorAction).to.have.been.calledOnce; + testing_1.expect(editorAction.args[0][0].detail.action).to.not.satisfy(foundation_js_1.isSimple); + complexAction = (editorAction.args[0][0].detail.action); + testing_1.expect(complexAction.actions.length).to.equal(7); + for (_i = 0, _a = complexAction.actions; _i < _a.length; _i++) { + action = _a[_i]; + testing_1.expect(action).to.satisfy(foundation_js_1.isReplace); + } + return [2 /*return*/]; + } + }); + }); }); + }); + }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/unit/menu/dist/UpdateDescritionABB.test.js b/packages/open-scd/test/unit/menu/dist/UpdateDescritionABB.test.js new file mode 100644 index 0000000000..62a8a5e2d4 --- /dev/null +++ b/packages/open-scd/test/unit/menu/dist/UpdateDescritionABB.test.js @@ -0,0 +1,150 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +var sinon_1 = require("sinon"); +require("../../mock-open-scd.js"); +var foundation_js_1 = require("../../../src/foundation.js"); +var UpdateDescriptionABB_js_1 = require("../../../src/menu/UpdateDescriptionABB.js"); +describe('Update method for desc attributes in ABB IEDs', function () { + if (customElements.get('update-description-abb') === undefined) + customElements.define('update-description-abb', UpdateDescriptionABB_js_1["default"]); + var parent; + var element; + var editorAction; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; + case 1: + parent = _a.sent(); + element = parent.getActivePlugin(); + editorAction = sinon_1["default"].spy(); + window.addEventListener('editor-action', editorAction); + return [2 /*return*/]; + } + }); + }); }); + describe('working on SCL files without manufacturer ABB', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var doc; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/zeroissues.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + element.doc = doc; + element.run(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates an empty wizard indicating not found desc updates', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + describe('working on SCL files containing manufacturer ABB', function () { + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var doc; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/updatedesc/updatedescABB.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + element.doc = doc; + element.run(); + return [4 /*yield*/, parent.requestUpdate()]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates a wizard with all valid desc update possibilities', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it('creates wizard that on save triggers a complex action containing selected desc updates', function () { return __awaiter(void 0, void 0, void 0, function () { + var complexAction, _i, _a, action; + var _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + (_c = (_b = parent.wizardUI) === null || _b === void 0 ? void 0 : _b.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-button[slot="primaryAction"]').click(); + return [4 /*yield*/, parent.updateComplete]; + case 1: + _d.sent(); + testing_1.expect(editorAction).to.have.been.calledOnce; + testing_1.expect(editorAction.args[0][0].detail.action).to.not.satisfy(foundation_js_1.isSimple); + complexAction = (editorAction.args[0][0].detail.action); + testing_1.expect(complexAction.actions.length).to.equal(2); + for (_i = 0, _a = complexAction.actions; _i < _a.length; _i++) { + action = _a[_i]; + testing_1.expect(action).to.satisfy(foundation_js_1.isReplace); + } + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1; diff --git a/packages/open-scd/test/unit/validators/ValidateTemplates.test.ts b/packages/open-scd/test/unit/validators/ValidateTemplates.test.ts index f47a7d967f..d297da3e0d 100644 --- a/packages/open-scd/test/unit/validators/ValidateTemplates.test.ts +++ b/packages/open-scd/test/unit/validators/ValidateTemplates.test.ts @@ -1,8 +1,8 @@ import { expect, fixture, html } from '@open-wc/testing'; import { SinonSpy, spy } from 'sinon'; -import '../../mock-editor-logger.js'; -import { MockEditorLogger } from '../../mock-editor-logger.js'; +import '../../mock-open-scd.js'; +import { MockOpenSCD } from '../../mock-open-scd.js'; import ValidateTemplates from '../../../src/validators/ValidateTemplates.js'; @@ -29,16 +29,16 @@ describe('ValidateTemplates', () => { .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - const parent = await fixture(html` - + > `); - element = parent.querySelector('validate-templates')!; + element = parent.getActivePlugin(); }); it('triggers as newIssuesEvent for detail not containing kind', () => { @@ -106,13 +106,13 @@ describe('ValidateTemplates', () => { .then(response => response.text()) .then(str => new DOMParser().parseFromString(str, 'application/xml')); - const parent: MockEditorLogger = await fixture(html` - + > `); - element = parent.querySelector('validate-templates')!; + element = parent.getActivePlugin(); }); it('pushes only diag.zeroissues issue to diagnostics when no issues found', async () => { diff --git a/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js b/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js new file mode 100644 index 0000000000..6c99ed63e6 --- /dev/null +++ b/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js @@ -0,0 +1,212 @@ +"use strict"; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var testing_1 = require("@open-wc/testing"); +var sinon_1 = require("sinon"); +require("../../mock-open-scd.js"); +var ValidateTemplates_js_1 = require("../../../src/validators/ValidateTemplates.js"); +describe('ValidateTemplates', function () { + if (customElements.get('validate-templates') === undefined) + customElements.define('validate-templates', ValidateTemplates_js_1["default"]); + var logEvent; + var issueEvent; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + logEvent = sinon_1.spy(); + issueEvent = sinon_1.spy(); + window.addEventListener('log', logEvent); + window.addEventListener('issue', issueEvent); + return [2 /*return*/]; + }); + }); }); + describe('dispatch', function () { + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var doc, parent; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/zeroissues.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "])), doc, '/src/validators/ValidateTemplates.js'))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [2 /*return*/]; + } + }); + }); }); + it('triggers as newIssuesEvent for detail not containing kind', function () { + var detail = { + title: 'title', + message: 'message' + }; + element.dispatch(detail); + testing_1.expect(issueEvent).to.have.been.called; + testing_1.expect(logEvent).to.not.have.been.called; + testing_1.expect(issueEvent.args[0][0].type).to.equal('issue'); + testing_1.expect(issueEvent.args[0][0].detail.validatorId).to.equal('/src/validators/ValidateTemplates.js'); + testing_1.expect(issueEvent.args[0][0].detail.message).to.equal('message'); + testing_1.expect(issueEvent.args[0][0].detail.title).to.equal('title'); + }); + it('triggers as newLogEvent for detail containing kind info', function () { + var detail = { + kind: 'info', + title: 'title', + message: 'message' + }; + element.dispatch(detail); + testing_1.expect(logEvent).to.have.been.called; + testing_1.expect(issueEvent).to.not.have.been.called; + testing_1.expect(logEvent.args[0][0].type).to.equal('log'); + testing_1.expect(logEvent.args[0][0].detail.kind).to.equal('info'); + testing_1.expect(logEvent.args[0][0].detail.message).to.equal('message'); + testing_1.expect(logEvent.args[0][0].detail.title).to.equal('title'); + }); + it('triggers as newLogEvent for detail containing kind warning', function () { + var detail = { + kind: 'warning', + title: 'title', + message: 'message' + }; + element.dispatch(detail); + testing_1.expect(logEvent).to.have.been.called; + testing_1.expect(issueEvent).to.not.have.been.called; + testing_1.expect(logEvent.args[0][0].type).to.equal('log'); + testing_1.expect(logEvent.args[0][0].detail.kind).to.equal('warning'); + }); + it('triggers as newLogEvent for detail containing kind error', function () { + var detail = { + kind: 'error', + title: 'title', + message: 'message' + }; + element.dispatch(detail); + testing_1.expect(logEvent).to.have.been.called; + testing_1.expect(issueEvent).to.not.have.been.called; + testing_1.expect(logEvent.args[0][0].type).to.equal('log'); + testing_1.expect(logEvent.args[0][0].detail.kind).to.equal('error'); + }); + }); + describe('validate', function () { + var element; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var doc, parent; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/zeroissues.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; + case 1: + doc = _a.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n \n "], ["\n \n "])), doc))]; + case 2: + parent = _a.sent(); + element = parent.getActivePlugin(); + return [2 /*return*/]; + } + }); + }); }); + it('pushes only diag.zeroissues issue to diagnostics when no issues found', function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, element.validate()]; + case 1: + _a.sent(); + testing_1.expect(issueEvent).to.have.been.calledOnce; + testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('[diag.zeroissues]'); + return [2 /*return*/]; + } + }); + }); }); + it('pushes only diag.missingnsd issue to diagnostics pane for SCL version < 2007B3', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + (_a = element.doc.querySelector('SCL')) === null || _a === void 0 ? void 0 : _a.setAttribute('version', '2003'); + return [4 /*yield*/, element.validate()]; + case 1: + _b.sent(); + testing_1.expect(issueEvent).to.have.been.calledOnce; + testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('[diag.missingnsd]'); + return [2 /*return*/]; + } + }); + }); }); + it('pushes only diag.missingnsd issue to diagnostics pane for SCL not having version information', function () { return __awaiter(void 0, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + (_a = element.doc.querySelector('SCL')) === null || _a === void 0 ? void 0 : _a.removeAttribute('version'); + (_b = element.doc.querySelector('SCL')) === null || _b === void 0 ? void 0 : _b.removeAttribute('revision'); + return [4 /*yield*/, element.validate()]; + case 1: + _c.sent(); + testing_1.expect(issueEvent).to.have.been.calledOnce; + testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('[diag.missingnsd]'); + return [2 /*return*/]; + } + }); + }); }); + it('does not trigger anything for SCL missing DataTypeTemplates', function () { return __awaiter(void 0, void 0, void 0, function () { + var data; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + data = element.doc.querySelector('DataTypeTemplates'); + (_a = element.doc.querySelector('SCL')) === null || _a === void 0 ? void 0 : _a.removeChild(data); + return [4 /*yield*/, element.validate()]; + case 1: + _b.sent(); + testing_1.expect(issueEvent).to.not.have.been.calledOnce; + return [2 /*return*/]; + } + }); + }); }); + }); +}); +var templateObject_1, templateObject_2; From 7d4a6be59c5d36141accdbe0a2441c27d9215f1c Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Thu, 15 Feb 2024 21:55:34 +0100 Subject: [PATCH 17/27] Fixed some tests --- .../subscription/dist/fcda-binding-list.js | 273 +++++ .../editors/subscription/fcda-binding-list.ts | 1 + .../__snapshots__/Templates.test.snap.js | 24 +- .../datype-wizarding.test.snap.js | 24 +- .../dotype-wizarding.test.snap.js | 58 +- .../enumtype-wizarding.test.snap.js | 46 +- .../lnodetype-wizard.test.snap.js | 432 +++---- .../templates/dist/dotype-wizarding.test.js | 20 +- .../templates/dist/lnodetype-wizard.test.js | 15 +- .../templates/dotype-wizarding.test.ts | 21 +- .../templates/lnodetype-wizard.test.ts | 15 +- .../triggered/ImportIedsPlugin.test.ts | 9 +- .../triggered/dist/ImportIedsPlugin.test.js | 6 +- .../validators/ValidateSchema.test.ts | 12 +- .../__snapshots__/ValidateSchema.test.snap.js | 12 +- .../validators/dist/ValidateSchema.test.js | 6 +- .../bda-wizarding-editing.test.snap.js | 50 +- .../da-wizarding-editing.test.snap.js | 66 +- .../wizards/bda-wizarding-editing.test.ts | 2 +- .../wizards/da-wizarding-editing.test.ts | 21 +- .../dist/bda-wizarding-editing.test.js | 2 +- .../wizards/dist/da-wizarding-editing.test.js | 21 +- .../control-blocks-container.test.snap.js | 4 - .../datasets-container.test.snap.js | 16 +- .../datatypes-container.test.snap.js | 20 +- .../cleanup/control-blocks-container.test.ts | 1 + .../cleanup/datasets-container.test.ts | 12 +- .../cleanup/datatypes-container.test.ts | 3 +- .../dist/control-blocks-container.test.js | 1 + .../cleanup/dist/datasets-container.test.js | 9 +- .../cleanup/dist/datatypes-container.test.js | 1 + .../fcda-binding-list.test.snap.js | 1009 +---------------- .../subscription/fcda-binding-list.test.ts | 1 + .../UpdateDescriptionSEL.test.snap.js | 12 +- .../UpdateDescritionABB.test.snap.js | 12 +- .../unit/validators/ValidateTemplates.test.ts | 10 +- .../validators/dist/ValidateTemplates.test.js | 12 +- 37 files changed, 768 insertions(+), 1491 deletions(-) create mode 100644 packages/open-scd/src/editors/subscription/dist/fcda-binding-list.js diff --git a/packages/open-scd/src/editors/subscription/dist/fcda-binding-list.js b/packages/open-scd/src/editors/subscription/dist/fcda-binding-list.js new file mode 100644 index 0000000000..9ce27fb982 --- /dev/null +++ b/packages/open-scd/src/editors/subscription/dist/fcda-binding-list.js @@ -0,0 +1,273 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +exports.__esModule = true; +exports.FcdaBindingList = void 0; +var lit_element_1 = require("lit-element"); +var lit_html_1 = require("lit-html"); +var class_map_js_1 = require("lit-html/directives/class-map.js"); +var lit_translate_1 = require("lit-translate"); +require("@material/mwc-icon"); +require("@material/mwc-list"); +require("@material/mwc-list/mwc-list-item"); +require("@material/mwc-list/mwc-check-list-item"); +require("@material/mwc-menu"); +require("@material/mwc-icon-button"); +var foundation_js_1 = require("../../foundation.js"); +var icons_js_1 = require("../../icons/icons.js"); +var wizard_library_js_1 = require("../../wizards/wizard-library.js"); +var foundation_js_2 = require("./foundation.js"); +var foundation_js_3 = require("./later-binding/foundation.js"); +/** + * A sub element for showing all Goose/Sampled Value Controls. + * A control can be edited using the standard wizard. + * And when selecting a FCDA Element a custom event is fired, so other list can be updated. + */ +var FcdaBindingList = /** @class */ (function (_super) { + __extends(FcdaBindingList, _super); + function FcdaBindingList() { + var _this = _super.call(this) || this; + _this.editCount = -1; + _this.extRefCounters = new Map(); + _this.iconControlLookup = { + SampledValueControl: icons_js_1.smvIcon, + GSEControl: icons_js_1.gooseIcon + }; + _this.resetSelection = _this.resetSelection.bind(_this); + parent.addEventListener('open-doc', _this.resetSelection); + var parentDiv = _this.closest('.container'); + if (parentDiv) { + _this.resetExtRefCount = _this.resetExtRefCount.bind(_this); + parentDiv.addEventListener('subscription-changed', _this.resetExtRefCount); + } + return _this; + } + Object.defineProperty(FcdaBindingList.prototype, "hideSubscribed", { + get: function () { + var _a; + return ((_a = localStorage.getItem("fcda-binding-list-" + (this.includeLaterBinding ? 'later-binding' : 'data-binding') + "-" + this.controlTag + "$hideSubscribed") === 'true') !== null && _a !== void 0 ? _a : false); + }, + set: function (value) { + var oldValue = this.hideSubscribed; + localStorage.setItem("fcda-binding-list-" + (this.includeLaterBinding ? 'later-binding' : 'data-binding') + "-" + this.controlTag + "$hideSubscribed", "" + value); + this.requestUpdate('hideSubscribed', oldValue); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(FcdaBindingList.prototype, "hideNotSubscribed", { + get: function () { + var _a; + return ((_a = localStorage.getItem("fcda-binding-list-" + (this.includeLaterBinding ? 'later-binding' : 'data-binding') + "-" + this.controlTag + "$hideNotSubscribed") === 'true') !== null && _a !== void 0 ? _a : false); + }, + set: function (value) { + var oldValue = this.hideNotSubscribed; + localStorage.setItem("fcda-binding-list-" + (this.includeLaterBinding ? 'later-binding' : 'data-binding') + "-" + this.controlTag + "$hideNotSubscribed", "" + value); + this.requestUpdate('hideNotSubscribed', oldValue); + }, + enumerable: false, + configurable: true + }); + FcdaBindingList.prototype.getControlElements = function () { + if (this.doc) { + return Array.from(this.doc.querySelectorAll("LN0 > " + this.controlTag)); + } + return []; + }; + FcdaBindingList.prototype.getFcdaElements = function (controlElement) { + var lnElement = controlElement.parentElement; + if (lnElement) { + return Array.from(lnElement.querySelectorAll(":scope > DataSet[name=" + controlElement.getAttribute('datSet') + "] > FCDA")); + } + return []; + }; + FcdaBindingList.prototype.resetExtRefCount = function (event) { + if (event.detail.control && event.detail.fcda) { + var controlBlockFcdaId = foundation_js_1.identity(event.detail.control) + " " + foundation_js_1.identity(event.detail.fcda); + this.extRefCounters["delete"](controlBlockFcdaId); + } + }; + FcdaBindingList.prototype.getExtRefCount = function (fcdaElement, controlElement) { + var controlBlockFcdaId = foundation_js_1.identity(controlElement) + " " + foundation_js_1.identity(fcdaElement); + if (!this.extRefCounters.has(controlBlockFcdaId)) { + var extRefCount = foundation_js_3.getSubscribedExtRefElements(this.doc.getRootNode(), this.controlTag, fcdaElement, controlElement, this.includeLaterBinding).length; + this.extRefCounters.set(controlBlockFcdaId, extRefCount); + } + return this.extRefCounters.get(controlBlockFcdaId); + }; + FcdaBindingList.prototype.openEditWizard = function (controlElement) { + var wizard = wizard_library_js_1.wizards[this.controlTag].edit(controlElement); + if (wizard) + this.dispatchEvent(foundation_js_1.newWizardEvent(wizard)); + }; + FcdaBindingList.prototype.resetSelection = function () { + this.selectedControlElement = undefined; + this.selectedFcdaElement = undefined; + }; + FcdaBindingList.prototype.onFcdaSelect = function (controlElement, fcdaElement) { + this.resetSelection(); + this.selectedControlElement = controlElement; + this.selectedFcdaElement = fcdaElement; + }; + FcdaBindingList.prototype.updated = function (_changedProperties) { + _super.prototype.updated.call(this, _changedProperties); + // When a new document is loaded or the selection is changed + // we will fire the FCDA Select Event. + if (_changedProperties.has('doc') || + _changedProperties.has('selectedControlElement') || + _changedProperties.has('selectedFcdaElement')) { + this.dispatchEvent(foundation_js_2.newFcdaSelectEvent(this.selectedControlElement, this.selectedFcdaElement)); + } + // When a new document is loaded we will reset the Map to clear old entries. + if (_changedProperties.has('doc')) { + this.extRefCounters = new Map(); + } + }; + FcdaBindingList.prototype.renderFCDA = function (controlElement, fcdaElement) { + var _this = this; + var fcdaCount = this.getExtRefCount(fcdaElement, controlElement); + var filterClasses = { + subitem: true, + 'show-subscribed': fcdaCount !== 0, + 'show-not-subscribed': fcdaCount === 0 + }; + return lit_element_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n ", "\n subdirectory_arrow_right\n ", "\n "], ["\n ", "\n ", "\n subdirectory_arrow_right\n ", "\n "])), fcdaCount !== 0, class_map_js_1.classMap(filterClasses), function () { return _this.onFcdaSelect(controlElement, fcdaElement); }, foundation_js_1.identity(controlElement), foundation_js_1.identity(fcdaElement), foundation_js_2.getFcdaTitleValue(fcdaElement), foundation_js_2.getFcdaSubtitleValue(fcdaElement), fcdaCount !== 0 ? lit_element_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), fcdaCount) : lit_html_1.nothing); + }; + FcdaBindingList.prototype.updateBaseFilterState = function () { + !this.hideSubscribed + ? this.controlBlockList.classList.add('show-subscribed') + : this.controlBlockList.classList.remove('show-subscribed'); + !this.hideNotSubscribed + ? this.controlBlockList.classList.add('show-not-subscribed') + : this.controlBlockList.classList.remove('show-not-subscribed'); + }; + FcdaBindingList.prototype.firstUpdated = function () { + var _this = this; + this.actionsMenu.anchor = this.actionsMenuIcon; + this.actionsMenu.addEventListener('closed', function () { + _this.hideSubscribed = !_this.actionsMenu.index.has(0); + _this.hideNotSubscribed = !_this.actionsMenu.index.has(1); + _this.updateBaseFilterState(); + }); + this.updateBaseFilterState(); + }; + FcdaBindingList.prototype.renderTitle = function () { + var _this = this; + var menuClasses = { + 'filter-off': this.hideSubscribed || this.hideNotSubscribed + }; + return lit_element_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject(["

    \n ", "\n \n \n \n ", "\n \n \n ", "\n \n \n

    "], ["

    \n ", "\n \n \n \n ", "\n \n \n ", "\n \n \n

    "])), lit_translate_1.translate("subscription." + this.controlTag + ".controlBlockList.title"), class_map_js_1.classMap(menuClasses), function () { + if (!_this.actionsMenu.open) + _this.actionsMenu.show(); + else + _this.actionsMenu.close(); + }, !this.hideSubscribed, lit_translate_1.translate('subscription.subscriber.subscribed'), !this.hideNotSubscribed, lit_translate_1.translate('subscription.subscriber.notSubscribed')); + }; + FcdaBindingList.prototype.renderControls = function (controlElements) { + var _this = this; + return lit_element_1.html(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", "\n "], ["\n ", + "\n "])), controlElements + .filter(function (controlElement) { return _this.getFcdaElements(controlElement).length; }) + .map(function (controlElement) { + var fcdaElements = _this.getFcdaElements(controlElement); + var showSubscribed = fcdaElements.some(function (fcda) { return _this.getExtRefCount(fcda, controlElement) !== 0; }); + var showNotSubscribed = fcdaElements.some(function (fcda) { return _this.getExtRefCount(fcda, controlElement) === 0; }); + var filterClasses = { + control: true, + 'show-subscribed': showSubscribed, + 'show-not-subscribed': showNotSubscribed + }; + return lit_element_1.html(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n \n \n ", "\n ", "\n ", "\n ", "\n \n
  • \n ", "\n "], ["\n \n \n ", "\n ", + "\n ", "\n ", "\n \n
  • \n ", + "\n "])), class_map_js_1.classMap(filterClasses), foundation_js_1.identity(controlElement), fcdaElements + .map(function (fcdaElement) { return "\n " + foundation_js_2.getFcdaTitleValue(fcdaElement) + "\n " + foundation_js_2.getFcdaSubtitleValue(fcdaElement) + "\n " + foundation_js_1.identity(fcdaElement); }) + .join(''), function () { return _this.openEditWizard(controlElement); }, foundation_js_1.getNameAttribute(controlElement), foundation_js_1.getDescriptionAttribute(controlElement) + ? lit_element_1.html(templateObject_4 || (templateObject_4 = __makeTemplateObject(["", ""], ["", ""])), foundation_js_1.getDescriptionAttribute(controlElement)) : lit_html_1.nothing, foundation_js_1.identity(controlElement), _this.iconControlLookup[_this.controlTag], fcdaElements.map(function (fcdaElement) { + return _this.renderFCDA(controlElement, fcdaElement); + })); + })); + }; + FcdaBindingList.prototype.render = function () { + var controlElements = this.getControlElements(); + return lit_element_1.html(templateObject_8 || (templateObject_8 = __makeTemplateObject(["
    \n ", "\n ", "\n
    "], ["
    \n ", "\n ", + "\n
    "])), this.renderTitle(), controlElements + ? this.renderControls(controlElements) + : lit_element_1.html(templateObject_7 || (templateObject_7 = __makeTemplateObject(["

    ", "

    "], ["

    ", "

    "])), lit_translate_1.translate('subscription.subscriber.notSubscribed'))); + }; + FcdaBindingList.styles = lit_element_1.css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n ", "\n\n mwc-list-item.hidden[noninteractive] + li[divider] {\n display: none;\n }\n\n mwc-list-item {\n --mdc-list-item-meta-size: 48px;\n }\n\n section {\n position: relative;\n }\n\n .actions-menu-icon {\n float: right;\n }\n\n .actions-menu-icon.filter-off {\n color: var(--secondary);\n background-color: var(--mdc-theme-background);\n }\n\n /* Filtering rules for control blocks end up implementing logic to allow\n very fast CSS response. The following rules appear to be minimal but can be\n hard to understand intuitively for the multiple conditions. If modifying,\n it is suggested to create a truth-table to check for side-effects */\n\n /* remove all control blocks if no filters */\n filtered-list.control-block-list:not(.show-subscribed, .show-not-subscribed)\n mwc-list-item {\n display: none;\n }\n\n /* remove control blocks taking care to respect multiple conditions */\n filtered-list.control-block-list.show-not-subscribed:not(.show-subscribed)\n mwc-list-item.control.show-subscribed:not(.show-not-subscribed) {\n display: none;\n }\n\n filtered-list.control-block-list.show-subscribed:not(.show-not-subscribed)\n mwc-list-item.control.show-not-subscribed:not(.show-subscribed) {\n display: none;\n }\n\n /* remove fcdas if not part of filter */\n filtered-list.control-block-list:not(.show-not-subscribed)\n mwc-list-item.subitem.show-not-subscribed {\n display: none;\n }\n\n filtered-list.control-block-list:not(.show-subscribed)\n mwc-list-item.subitem.show-subscribed {\n display: none;\n }\n\n .interactive {\n pointer-events: all;\n }\n\n .subitem {\n padding-left: var(--mdc-list-side-padding, 16px);\n }\n "], ["\n ", "\n\n mwc-list-item.hidden[noninteractive] + li[divider] {\n display: none;\n }\n\n mwc-list-item {\n --mdc-list-item-meta-size: 48px;\n }\n\n section {\n position: relative;\n }\n\n .actions-menu-icon {\n float: right;\n }\n\n .actions-menu-icon.filter-off {\n color: var(--secondary);\n background-color: var(--mdc-theme-background);\n }\n\n /* Filtering rules for control blocks end up implementing logic to allow\n very fast CSS response. The following rules appear to be minimal but can be\n hard to understand intuitively for the multiple conditions. If modifying,\n it is suggested to create a truth-table to check for side-effects */\n\n /* remove all control blocks if no filters */\n filtered-list.control-block-list:not(.show-subscribed, .show-not-subscribed)\n mwc-list-item {\n display: none;\n }\n\n /* remove control blocks taking care to respect multiple conditions */\n filtered-list.control-block-list.show-not-subscribed:not(.show-subscribed)\n mwc-list-item.control.show-subscribed:not(.show-not-subscribed) {\n display: none;\n }\n\n filtered-list.control-block-list.show-subscribed:not(.show-not-subscribed)\n mwc-list-item.control.show-not-subscribed:not(.show-subscribed) {\n display: none;\n }\n\n /* remove fcdas if not part of filter */\n filtered-list.control-block-list:not(.show-not-subscribed)\n mwc-list-item.subitem.show-not-subscribed {\n display: none;\n }\n\n filtered-list.control-block-list:not(.show-subscribed)\n mwc-list-item.subitem.show-subscribed {\n display: none;\n }\n\n .interactive {\n pointer-events: all;\n }\n\n .subitem {\n padding-left: var(--mdc-list-side-padding, 16px);\n }\n "])), foundation_js_2.styles); + __decorate([ + lit_element_1.property({ attribute: false }) + ], FcdaBindingList.prototype, "doc"); + __decorate([ + lit_element_1.property({ type: Number }) + ], FcdaBindingList.prototype, "editCount"); + __decorate([ + lit_element_1.property() + ], FcdaBindingList.prototype, "controlTag"); + __decorate([ + lit_element_1.property() + ], FcdaBindingList.prototype, "includeLaterBinding"); + __decorate([ + lit_element_1.state() + ], FcdaBindingList.prototype, "selectedControlElement"); + __decorate([ + lit_element_1.state() + ], FcdaBindingList.prototype, "selectedFcdaElement"); + __decorate([ + lit_element_1.state() + ], FcdaBindingList.prototype, "extRefCounters"); + __decorate([ + lit_element_1.property({ + type: Boolean, + hasChanged: function () { + return false; + } + }) + ], FcdaBindingList.prototype, "hideSubscribed"); + __decorate([ + lit_element_1.property({ + type: Boolean, + hasChanged: function () { + return false; + } + }) + ], FcdaBindingList.prototype, "hideNotSubscribed"); + __decorate([ + lit_element_1.query('.actions-menu') + ], FcdaBindingList.prototype, "actionsMenu"); + __decorate([ + lit_element_1.query('.actions-menu-icon') + ], FcdaBindingList.prototype, "actionsMenuIcon"); + __decorate([ + lit_element_1.query('.control-block-list') + ], FcdaBindingList.prototype, "controlBlockList"); + FcdaBindingList = __decorate([ + lit_element_1.customElement('fcda-binding-list') + ], FcdaBindingList); + return FcdaBindingList; +}(lit_element_1.LitElement)); +exports.FcdaBindingList = FcdaBindingList; +var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9; diff --git a/packages/open-scd/src/editors/subscription/fcda-binding-list.ts b/packages/open-scd/src/editors/subscription/fcda-binding-list.ts index 3ec10122cf..2bd0265ad8 100644 --- a/packages/open-scd/src/editors/subscription/fcda-binding-list.ts +++ b/packages/open-scd/src/editors/subscription/fcda-binding-list.ts @@ -18,6 +18,7 @@ import '@material/mwc-list'; import '@material/mwc-list/mwc-list-item'; import '@material/mwc-list/mwc-check-list-item'; import '@material/mwc-menu'; +import '@material/mwc-icon-button'; import { Icon } from '@material/mwc-icon'; import { List } from '@material/mwc-list'; diff --git a/packages/open-scd/test/integration/editors/templates/__snapshots__/Templates.test.snap.js b/packages/open-scd/test/integration/editors/templates/__snapshots__/Templates.test.snap.js index 76682bf27a..a6009fef81 100644 --- a/packages/open-scd/test/integration/editors/templates/__snapshots__/Templates.test.snap.js +++ b/packages/open-scd/test/integration/editors/templates/__snapshots__/Templates.test.snap.js @@ -4,17 +4,15 @@ export const snapshots = {}; snapshots["Templates Plugin without a doc loaded looks like the latest snapshot"] = `

    - [templates.missing] + DataTypeTemplates missing

    - - `; /* end snapshot Templates Plugin without a doc loaded looks like the latest snapshot */ @@ -22,9 +20,9 @@ snapshots["Templates Plugin with a doc loaded looks like the latest snapshot"] = `

    - [scl.LNodeType] + Logical Node Type

    - [scl.DOType] + Data Object Type

    - [scl.DAType] + Data Attribute Type

    - [scl.EnumType] + Enum Type

    - - `; /* end snapshot Templates Plugin with a doc loaded looks like the latest snapshot */ diff --git a/packages/open-scd/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js b/packages/open-scd/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js index 69e2fb7c33..80f5d8d85c 100644 --- a/packages/open-scd/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js +++ b/packages/open-scd/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["DAType wizards defines a createDATypeWizard looks like the latest snapshot"] = ` @@ -579,7 +579,7 @@ snapshots["DAType wizards defines a createDATypeWizard looks like the latest sna @@ -596,14 +596,14 @@ snapshots["DAType wizards defines a createDATypeWizard looks like the latest sna
    @@ -615,7 +615,7 @@ snapshots["DAType wizards defines a createDATypeWizard looks like the latest sna snapshots["DAType wizards defines a dATypeWizard looks like the latest snapshot"] = ` @@ -635,7 +635,7 @@ snapshots["DAType wizards defines a dATypeWizard looks like the latest snapshot" tabindex="0" > - [remove] + Remove delete @@ -649,7 +649,7 @@ snapshots["DAType wizards defines a dATypeWizard looks like the latest snapshot" tabindex="-1" > - [scl.DA] + Data attribute playlist_add @@ -660,7 +660,7 @@ snapshots["DAType wizards defines a dATypeWizard looks like the latest snapshot"
    @@ -763,14 +763,14 @@ snapshots["DAType wizards defines a dATypeWizard looks like the latest snapshot"
    diff --git a/packages/open-scd/test/integration/editors/templates/__snapshots__/dotype-wizarding.test.snap.js b/packages/open-scd/test/integration/editors/templates/__snapshots__/dotype-wizarding.test.snap.js index d05a9d4040..d913e90429 100644 --- a/packages/open-scd/test/integration/editors/templates/__snapshots__/dotype-wizarding.test.snap.js +++ b/packages/open-scd/test/integration/editors/templates/__snapshots__/dotype-wizarding.test.snap.js @@ -4,14 +4,14 @@ export const snapshots = {}; snapshots["DOType wizards defines a createDOTypeWizard looks like the latest snapshot"] = `
    @@ -698,14 +698,14 @@ snapshots["DOType wizards defines a createDOTypeWizard looks like the latest sna
    @@ -717,7 +717,7 @@ snapshots["DOType wizards defines a createDOTypeWizard looks like the latest sna snapshots["DOType wizards defines a dOTypeWizard looks like the latest snapshot"] = ` @@ -737,7 +737,7 @@ snapshots["DOType wizards defines a dOTypeWizard looks like the latest snapshot" tabindex="0" > - [remove] + Remove delete @@ -751,7 +751,7 @@ snapshots["DOType wizards defines a dOTypeWizard looks like the latest snapshot" tabindex="-1" > - [scl.DO] + Data object playlist_add @@ -765,7 +765,7 @@ snapshots["DOType wizards defines a dOTypeWizard looks like the latest snapshot" tabindex="-1" > - [scl.DA] + Data attribute playlist_add @@ -776,7 +776,7 @@ snapshots["DOType wizards defines a dOTypeWizard looks like the latest snapshot"
    @@ -1010,14 +1010,14 @@ snapshots["DOType wizards defines a dOTypeWizard looks like the latest snapshot"
    @@ -1029,7 +1029,7 @@ snapshots["DOType wizards defines a dOTypeWizard looks like the latest snapshot" snapshots["DOType wizards defines a sDOWizard to edit an existing SDO looks like the latest snapshot"] = ` @@ -1049,7 +1049,7 @@ snapshots["DOType wizards defines a sDOWizard to edit an existing SDO looks like tabindex="0" > - [remove] + Remove delete @@ -1060,7 +1060,7 @@ snapshots["DOType wizards defines a sDOWizard to edit an existing SDO looks like
    @@ -1068,14 +1068,14 @@ snapshots["DOType wizards defines a sDOWizard to edit an existing SDO looks like @@ -1220,14 +1220,14 @@ snapshots["DOType wizards defines a sDOWizard to edit an existing SDO looks like
    @@ -1239,14 +1239,14 @@ snapshots["DOType wizards defines a sDOWizard to edit an existing SDO looks like snapshots["DOType wizards defines a sDOWizard to create a new SDO element looks like the latest snapshot"] = `
    @@ -1254,14 +1254,14 @@ snapshots["DOType wizards defines a sDOWizard to create a new SDO element looks @@ -1404,14 +1404,14 @@ snapshots["DOType wizards defines a sDOWizard to create a new SDO element looks
    diff --git a/packages/open-scd/test/integration/editors/templates/__snapshots__/enumtype-wizarding.test.snap.js b/packages/open-scd/test/integration/editors/templates/__snapshots__/enumtype-wizarding.test.snap.js index acc499b925..73368af11c 100644 --- a/packages/open-scd/test/integration/editors/templates/__snapshots__/enumtype-wizarding.test.snap.js +++ b/packages/open-scd/test/integration/editors/templates/__snapshots__/enumtype-wizarding.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["EnumType wizards defines a createEnumTypeWizard looks like the latest snapshot"] = ` @@ -1331,7 +1331,7 @@ snapshots["EnumType wizards defines a createEnumTypeWizard looks like the latest @@ -1348,14 +1348,14 @@ snapshots["EnumType wizards defines a createEnumTypeWizard looks like the latest
    @@ -1367,7 +1367,7 @@ snapshots["EnumType wizards defines a createEnumTypeWizard looks like the latest snapshots["EnumType wizards defines an eNumTypeEditWizard looks like the latest snapshot"] = ` @@ -1387,7 +1387,7 @@ snapshots["EnumType wizards defines an eNumTypeEditWizard looks like the latest tabindex="0" > - [remove] + Remove delete @@ -1401,7 +1401,7 @@ snapshots["EnumType wizards defines an eNumTypeEditWizard looks like the latest tabindex="-1" > - [scl.EnumVal] + Enum Value playlist_add @@ -1412,7 +1412,7 @@ snapshots["EnumType wizards defines an eNumTypeEditWizard looks like the latest
    @@ -1506,14 +1506,14 @@ snapshots["EnumType wizards defines an eNumTypeEditWizard looks like the latest
    @@ -1525,7 +1525,7 @@ snapshots["EnumType wizards defines an eNumTypeEditWizard looks like the latest snapshots["EnumType wizards defines a eNumValWizard to edit an existing EnumVal looks like the latest snapshot"] = ` @@ -1545,7 +1545,7 @@ snapshots["EnumType wizards defines a eNumValWizard to edit an existing EnumVal tabindex="0" > - [remove] + Remove delete @@ -1555,7 +1555,7 @@ snapshots["EnumType wizards defines a eNumValWizard to edit an existing EnumVal
    @@ -1599,13 +1599,13 @@ snapshots["EnumType wizards defines a eNumValWizard to edit an existing EnumVal snapshots["EnumType wizards defines a eNumValWizard to create a new EnumVal element looks like the latest snapshot"] = `
    diff --git a/packages/open-scd/test/integration/editors/templates/__snapshots__/lnodetype-wizard.test.snap.js b/packages/open-scd/test/integration/editors/templates/__snapshots__/lnodetype-wizard.test.snap.js index 17a711b4da..2f56575d35 100644 --- a/packages/open-scd/test/integration/editors/templates/__snapshots__/lnodetype-wizard.test.snap.js +++ b/packages/open-scd/test/integration/editors/templates/__snapshots__/lnodetype-wizard.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["LNodeType wizards defines a lNodeTypeHelperWizard looks like the latest snapshot"] = ` @@ -24,7 +24,7 @@ snapshots["LNodeType wizards defines a lNodeTypeHelperWizard looks like the late tabindex="0" > - [remove] + Remove delete @@ -38,7 +38,7 @@ snapshots["LNodeType wizards defines a lNodeTypeHelperWizard looks like the late tabindex="-1" > - [scl.DO] + Data object playlist_add @@ -49,7 +49,7 @@ snapshots["LNodeType wizards defines a lNodeTypeHelperWizard looks like the late
    @@ -144,14 +144,14 @@ snapshots["LNodeType wizards defines a lNodeTypeHelperWizard looks like the late
    @@ -160,10 +160,210 @@ snapshots["LNodeType wizards defines a lNodeTypeHelperWizard looks like the late `; /* end snapshot LNodeType wizards defines a lNodeTypeHelperWizard looks like the latest snapshot */ +snapshots["LNodeType wizards defines a dOWizard to create a new DO element looks like the latest snapshot"] = +` +
    + + > + + + + + + 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 + + + + + + +
    + + + + +
    +`; +/* end snapshot LNodeType wizards defines a dOWizard to create a new DO element looks like the latest snapshot */ + snapshots["LNodeType wizards defines a createLNodeTypeWizard looks like the latest snapshot"] = ` @@ -4312,7 +4512,7 @@ snapshots["LNodeType wizards defines a createLNodeTypeWizard looks like the late @@ -4329,14 +4529,14 @@ snapshots["LNodeType wizards defines a createLNodeTypeWizard looks like the late
    @@ -4348,7 +4548,7 @@ snapshots["LNodeType wizards defines a createLNodeTypeWizard looks like the late snapshots["LNodeType wizards defines a createLNodeTypeWizard opens a createLNodeTypeHelperWizard looks like the latest snapshot"] = ` @@ -4664,14 +4864,14 @@ snapshots["LNodeType wizards defines a createLNodeTypeWizard opens a createLNode
    @@ -4680,203 +4880,3 @@ snapshots["LNodeType wizards defines a createLNodeTypeWizard opens a createLNode `; /* end snapshot LNodeType wizards defines a createLNodeTypeWizard opens a createLNodeTypeHelperWizard looks like the latest snapshot */ -snapshots["LNodeType wizards defines a dOWizard to create a new DO element looks like the latest snapshot"] = -` -
    - - > - - - - - - 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 - - - - - - -
    - - - - -
    -`; -/* end snapshot LNodeType wizards defines a dOWizard to create a new DO element looks like the latest snapshot */ - diff --git a/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js b/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js index 585287fbb0..178ca881d1 100644 --- a/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js +++ b/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js @@ -55,17 +55,16 @@ describe('DOType wizards', function () { var _a; return __generator(this, function (_b) { switch (_b.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; case 1: + doc = _b.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; + case 2: parent = _b.sent(); templates = parent.getActivePlugin(); - return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 2: - doc = _b.sent(); - templates.doc = doc; - return [4 /*yield*/, templates.updateComplete]; + return [4 /*yield*/, parent.updateComplete]; case 3: _b.sent(); dOTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="dotypelist"]')); @@ -276,7 +275,7 @@ describe('DOType wizards', function () { _c.sent(); //recursive call takes time idField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="id"]')); primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes("[remove]"); })); + deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes("Remove"); })); return [2 /*return*/]; } }); @@ -343,6 +342,7 @@ describe('DOType wizards', function () { case 0: testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.exist; testing_1.expect(doc.querySelectorAll('DOType').length).to.equal(15); + console.log('del button'); deleteButton.click(); return [4 /*yield*/, parent.requestUpdate()]; case 1: @@ -514,7 +514,7 @@ describe('DOType wizards', function () { return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; case 2: _f.sent(); // await animation - (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes("[scl.DO]"); })).click(); + (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes("Data object"); })).click(); return [4 /*yield*/, ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.requestUpdate())]; case 3: _f.sent(); diff --git a/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js b/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js index 54963a23d1..88c7917b07 100644 --- a/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js +++ b/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js @@ -55,17 +55,16 @@ describe('LNodeType wizards', function () { var _a; return __generator(this, function (_b) { switch (_b.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; case 1: + doc = _b.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; + case 2: parent = _b.sent(); templates = parent.getActivePlugin(); - return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 2: - doc = _b.sent(); - templates.doc = doc; - return [4 /*yield*/, templates.updateComplete]; + return [4 /*yield*/, parent.updateComplete]; case 3: _b.sent(); lNodeTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="lnodetypelist"]')); diff --git a/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts b/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts index 12770985a0..d8c68b6010 100644 --- a/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts +++ b/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts @@ -1,6 +1,7 @@ import { html, fixture, expect } from '@open-wc/testing'; import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; import { ListItem } from '@material/mwc-list/mwc-list-item'; import { Select } from '@material/mwc-select'; @@ -11,7 +12,6 @@ import { WizardTextField } from '../../../../src/wizard-textfield.js'; import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; import { patterns } from '../../../../src/wizards/foundation/limits.js'; -import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('DOType wizards', () => { if (customElements.get('templates-editor') === undefined) @@ -22,17 +22,19 @@ describe('DOType wizards', () => { let dOTypeList: FilteredList; beforeEach(async () => { + doc = await fetch('/test/testfiles/templates/dotypes.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + parent = await fixture( - html`` + html`` ); templates = parent.getActivePlugin(); - doc = await fetch('/test/testfiles/templates/dotypes.scd') - .then(response => response.text()) - .then(str => new DOMParser().parseFromString(str, 'application/xml')); - templates.doc = doc; - await templates.updateComplete; + await parent.updateComplete; dOTypeList = ( templates.shadowRoot?.querySelector('filtered-list[id="dotypelist"]') ); @@ -200,7 +202,7 @@ describe('DOType wizards', () => { parent.wizardUI.dialog!.querySelectorAll( 'mwc-menu > mwc-list-item' ) - ).find(item => item.innerHTML.includes(`[remove]`)) + ).find(item => item.innerHTML.includes(`Remove`)) ); }); @@ -255,6 +257,7 @@ describe('DOType wizards', () => { it('deletes the DOType attribute on delete button click', async () => { expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.exist; expect(doc.querySelectorAll('DOType').length).to.equal(15); + console.log('del button'); deleteButton.click(); await parent.requestUpdate(); expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod"]')).to.not.exist; @@ -404,7 +407,7 @@ describe('DOType wizards', () => { parent.wizardUI.dialog!.querySelectorAll( 'mwc-menu > mwc-list-item' ) - ).find(item => item.innerHTML.includes(`[scl.DO]`)) + ).find(item => item.innerHTML.includes(`Data object`)) )).click(); await parent.wizardUI.dialog?.requestUpdate(); diff --git a/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts b/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts index f0ba602a47..c057372f4a 100644 --- a/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts +++ b/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts @@ -21,17 +21,18 @@ describe('LNodeType wizards', () => { let lNodeTypeList: FilteredList; beforeEach(async () => { + doc = await fetch('/test/testfiles/templates/dotypes.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + parent = await fixture( - html`` + html`` ); templates = parent.getActivePlugin(); - - doc = await fetch('/test/testfiles/templates/dotypes.scd') - .then(response => response.text()) - .then(str => new DOMParser().parseFromString(str, 'application/xml')); - templates.doc = doc; - await templates.updateComplete; + await parent.updateComplete; lNodeTypeList = ( templates.shadowRoot?.querySelector('filtered-list[id="lnodetypelist"]') ); diff --git a/packages/open-scd/test/integration/editors/triggered/ImportIedsPlugin.test.ts b/packages/open-scd/test/integration/editors/triggered/ImportIedsPlugin.test.ts index 2eedd48df8..5a1f9cb253 100644 --- a/packages/open-scd/test/integration/editors/triggered/ImportIedsPlugin.test.ts +++ b/packages/open-scd/test/integration/editors/triggered/ImportIedsPlugin.test.ts @@ -7,7 +7,6 @@ import '../../../mock-open-scd.js'; import { MockOpenSCD } from '../../../mock-open-scd.js'; import ImportingIedPlugin from '../../../../src/menu/ImportIEDs.js'; -import { Editing } from '../../../../src/Editing.js'; describe('ImportIedsPlugin', () => { customElements.define('import-ied-plugin', ImportingIedPlugin); @@ -409,7 +408,7 @@ describe('ImportIedsPlugin', () => { element.prepareImport(importDoc, 'invalid.iid'); expect(parent.log[0].kind).to.equal('error'); - expect(parent.log[0].title).to.equal('[import.log.missingied]'); + expect(parent.log[0].title).to.equal('No IED element in the file'); }); it('throws duplicate ied name error', async () => { @@ -419,7 +418,9 @@ describe('ImportIedsPlugin', () => { element.prepareImport(importDoc, 'duplicate.iid'); expect(parent.log[0].kind).to.equal('error'); - expect(parent.log[0].title).to.equal('[import.log.nouniqueied]'); + expect(parent.log[0].title).to.equal( + 'IED element IED2 already in the file' + ); }); it('throws parser error', async () => { @@ -431,7 +432,7 @@ describe('ImportIedsPlugin', () => { element.prepareImport(importDoc, 'parsererror.iid'); expect(parent.log[0].kind).to.equal('error'); - expect(parent.log[0].title).to.equal('[import.log.parsererror]'); + expect(parent.log[0].title).to.equal('Parser error'); }); }); }); diff --git a/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js b/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js index a15b1ecacd..b8e24f9844 100644 --- a/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js +++ b/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js @@ -495,7 +495,7 @@ describe('ImportIedsPlugin', function () { importDoc = _a.sent(); element.prepareImport(importDoc, 'invalid.iid'); testing_1.expect(parent.log[0].kind).to.equal('error'); - testing_1.expect(parent.log[0].title).to.equal('[import.log.missingied]'); + testing_1.expect(parent.log[0].title).to.equal('No IED element in the file'); return [2 /*return*/]; } }); @@ -510,7 +510,7 @@ describe('ImportIedsPlugin', function () { importDoc = _a.sent(); element.prepareImport(importDoc, 'duplicate.iid'); testing_1.expect(parent.log[0].kind).to.equal('error'); - testing_1.expect(parent.log[0].title).to.equal('[import.log.nouniqueied]'); + testing_1.expect(parent.log[0].title).to.equal('IED element IED2 already in the file'); return [2 /*return*/]; } }); @@ -528,7 +528,7 @@ describe('ImportIedsPlugin', function () { _a.sent(); element.prepareImport(importDoc, 'parsererror.iid'); testing_1.expect(parent.log[0].kind).to.equal('error'); - testing_1.expect(parent.log[0].title).to.equal('[import.log.parsererror]'); + testing_1.expect(parent.log[0].title).to.equal('Parser error'); return [2 /*return*/]; } }); diff --git a/packages/open-scd/test/integration/validators/ValidateSchema.test.ts b/packages/open-scd/test/integration/validators/ValidateSchema.test.ts index fcb1176d31..282bf1715f 100644 --- a/packages/open-scd/test/integration/validators/ValidateSchema.test.ts +++ b/packages/open-scd/test/integration/validators/ValidateSchema.test.ts @@ -52,13 +52,17 @@ describe('ValidateSchema plugin', () => { parent.diagnoses.get('/src/validators/ValidateSchema.js') ); expect(lastEntry.length).to.equal(1); - expect(lastEntry[0].title).to.contain('[validator.schema.valid]'); + expect(lastEntry[0].title).to.contain( + 'valid2007B XML schema validation successful' + ); }); it('indicates successful schema validation in the log', async () => { const lastEntry = parent.log.pop(); expect(lastEntry.kind).to.equal('info'); - expect(lastEntry.title).to.contain('[validator.schema.valid]'); + expect(lastEntry.title).to.contain( + 'valid2007B XML schema validation successful' + ); }); }); @@ -92,7 +96,9 @@ describe('ValidateSchema plugin', () => { it('generates error messages in the log', async () => { const lastLogEntry = parent.log.pop(); expect(lastLogEntry.kind).to.equal('warning'); - expect(lastLogEntry.title).to.contain('[validator.schema.invalid]'); + expect(lastLogEntry.title).to.contain( + 'invalid2007B XML schema validation failed' + ); }); }); }); diff --git a/packages/open-scd/test/integration/validators/__snapshots__/ValidateSchema.test.snap.js b/packages/open-scd/test/integration/validators/__snapshots__/ValidateSchema.test.snap.js index 9a87eb7dad..38746b66a3 100644 --- a/packages/open-scd/test/integration/validators/__snapshots__/ValidateSchema.test.snap.js +++ b/packages/open-scd/test/integration/validators/__snapshots__/ValidateSchema.test.snap.js @@ -3,7 +3,7 @@ export const snapshots = {}; snapshots["ValidateSchema plugin for valid SCL files zeroissues indication looks like the latest snapshot"] = ` - tabindex="-1" > - [validator.schema.valid] + valid2007B XML schema validation successful @@ -42,7 +42,7 @@ undefined"> dialogaction="close" slot="primaryAction" > - [close] + Close
    `; @@ -50,7 +50,7 @@ undefined"> snapshots["ValidateSchema plugin for invalid SCL files pushes issues to the diagnostics pane that look like the latest snapshot"] = ` - [close] + Close
    `; diff --git a/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js b/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js index 93d2f408bb..ba825c796c 100644 --- a/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js +++ b/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js @@ -109,7 +109,7 @@ describe('ValidateSchema plugin', function () { return __generator(this, function (_a) { lastEntry = (parent.diagnoses.get('/src/validators/ValidateSchema.js')); testing_1.expect(lastEntry.length).to.equal(1); - testing_1.expect(lastEntry[0].title).to.contain('[validator.schema.valid]'); + testing_1.expect(lastEntry[0].title).to.contain('valid2007B XML schema validation successful'); return [2 /*return*/]; }); }); }); @@ -118,7 +118,7 @@ describe('ValidateSchema plugin', function () { return __generator(this, function (_a) { lastEntry = parent.log.pop(); testing_1.expect(lastEntry.kind).to.equal('info'); - testing_1.expect(lastEntry.title).to.contain('[validator.schema.valid]'); + testing_1.expect(lastEntry.title).to.contain('valid2007B XML schema validation successful'); return [2 /*return*/]; }); }); }); @@ -176,7 +176,7 @@ describe('ValidateSchema plugin', function () { return __generator(this, function (_a) { lastLogEntry = parent.log.pop(); testing_1.expect(lastLogEntry.kind).to.equal('warning'); - testing_1.expect(lastLogEntry.title).to.contain('[validator.schema.invalid]'); + testing_1.expect(lastLogEntry.title).to.contain('invalid2007B XML schema validation failed'); return [2 /*return*/]; }); }); }); diff --git a/packages/open-scd/test/integration/wizards/__snapshots__/bda-wizarding-editing.test.snap.js b/packages/open-scd/test/integration/wizards/__snapshots__/bda-wizarding-editing.test.snap.js index aad0783d3d..12983eb7dc 100644 --- a/packages/open-scd/test/integration/wizards/__snapshots__/bda-wizarding-editing.test.snap.js +++ b/packages/open-scd/test/integration/wizards/__snapshots__/bda-wizarding-editing.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["BDA wizarding editing integration defines a editBDaWizard to edit an existing BDA looks like the latest snapshot"] = ` @@ -24,7 +24,7 @@ snapshots["BDA wizarding editing integration defines a editBDaWizard to edit an tabindex="0" > - [remove] + Remove delete @@ -35,7 +35,7 @@ snapshots["BDA wizarding editing integration defines a editBDaWizard to edit an
    @@ -405,7 +405,7 @@ snapshots["BDA wizarding editing integration defines a editBDaWizard to edit an @@ -631,7 +631,7 @@ snapshots["BDA wizarding editing integration defines a editBDaWizard to edit an @@ -659,14 +659,14 @@ snapshots["BDA wizarding editing integration defines a editBDaWizard to edit an snapshots["BDA wizarding editing integration defines a createBDaWizard to create a new BDA element looks like the latest snapshot"] = `
    @@ -1033,7 +1033,7 @@ snapshots["BDA wizarding editing integration defines a createBDaWizard to create @@ -1204,14 +1204,14 @@ snapshots["BDA wizarding editing integration defines a createBDaWizard to create
    diff --git a/packages/open-scd/test/integration/wizards/__snapshots__/da-wizarding-editing.test.snap.js b/packages/open-scd/test/integration/wizards/__snapshots__/da-wizarding-editing.test.snap.js index 9047d8601c..c7548f305c 100644 --- a/packages/open-scd/test/integration/wizards/__snapshots__/da-wizarding-editing.test.snap.js +++ b/packages/open-scd/test/integration/wizards/__snapshots__/da-wizarding-editing.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["DA wizarding editing integration defines a editDaWizard to edit an existing DA looks like the latest snapshot"] = ` @@ -24,7 +24,7 @@ snapshots["DA wizarding editing integration defines a editDaWizard to edit an ex tabindex="0" > - [remove] + Remove delete @@ -35,7 +35,7 @@ snapshots["DA wizarding editing integration defines a editDaWizard to edit an ex
    @@ -405,7 +405,7 @@ snapshots["DA wizarding editing integration defines a editDaWizard to edit an ex @@ -675,7 +675,7 @@ snapshots["DA wizarding editing integration defines a editDaWizard to edit an ex @@ -809,19 +809,19 @@ snapshots["DA wizarding editing integration defines a editDaWizard to edit an ex @@ -829,14 +829,14 @@ snapshots["DA wizarding editing integration defines a editDaWizard to edit an ex
    @@ -848,14 +848,14 @@ snapshots["DA wizarding editing integration defines a editDaWizard to edit an ex snapshots["DA wizarding editing integration defines a createDaWizard to create a new DA element looks like the latest snapshot"] = `
    @@ -1222,7 +1222,7 @@ snapshots["DA wizarding editing integration defines a createDaWizard to create a @@ -1555,19 +1555,19 @@ snapshots["DA wizarding editing integration defines a createDaWizard to create a @@ -1575,14 +1575,14 @@ snapshots["DA wizarding editing integration defines a createDaWizard to create a
    diff --git a/packages/open-scd/test/integration/wizards/bda-wizarding-editing.test.ts b/packages/open-scd/test/integration/wizards/bda-wizarding-editing.test.ts index 1ef7cb47db..0b07b1e36b 100644 --- a/packages/open-scd/test/integration/wizards/bda-wizarding-editing.test.ts +++ b/packages/open-scd/test/integration/wizards/bda-wizarding-editing.test.ts @@ -69,7 +69,7 @@ describe('BDA wizarding editing integration', () => { parent.wizardUI.dialog!.querySelectorAll( 'mwc-menu > mwc-list-item' ) - ).find(item => item.innerHTML.includes('[remove]')) + ).find(item => item.innerHTML.includes('Remove')) ); }); diff --git a/packages/open-scd/test/integration/wizards/da-wizarding-editing.test.ts b/packages/open-scd/test/integration/wizards/da-wizarding-editing.test.ts index ac4e622594..676ea1fa29 100644 --- a/packages/open-scd/test/integration/wizards/da-wizarding-editing.test.ts +++ b/packages/open-scd/test/integration/wizards/da-wizarding-editing.test.ts @@ -1,6 +1,6 @@ import { html, fixture, expect } from '@open-wc/testing'; -import '../../mock-open-sc.js'; +import '../../mock-open-scd.js'; import { MockOpenSCD } from '../../mock-open-scd.js'; import { ListItemBase } from '@material/mwc-list/mwc-list-item-base'; @@ -21,17 +21,18 @@ describe('DA wizarding editing integration', () => { let dOTypeList: FilteredList; beforeEach(async () => { + doc = await fetch('/test/testfiles/templates/dotypes.scd') + .then(response => response.text()) + .then(str => new DOMParser().parseFromString(str, 'application/xml')); + parent = await fixture( - html`` + html`` ); templates = parent.getActivePlugin(); - - doc = await fetch('/test/testfiles/templates/dotypes.scd') - .then(response => response.text()) - .then(str => new DOMParser().parseFromString(str, 'application/xml')); - templates.doc = doc; - await templates.updateComplete; + await parent.updateComplete; dOTypeList = ( templates.shadowRoot?.querySelector('filtered-list[id="dotypelist"]') ); @@ -69,7 +70,7 @@ describe('DA wizarding editing integration', () => { parent.wizardUI.dialog!.querySelectorAll( 'mwc-menu > mwc-list-item' ) - ).find(item => item.innerHTML.includes('[remove]')) + ).find(item => item.innerHTML.includes('Remove')) ); }); @@ -152,7 +153,7 @@ describe('DA wizarding editing integration', () => { parent.wizardUI.dialog!.querySelectorAll( 'mwc-menu > mwc-list-item' ) - ).find(item => item.innerHTML.includes('[scl.DA]')) + ).find(item => item.innerHTML.includes('Data attribute')) )).click(); await parent.requestUpdate(); diff --git a/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js b/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js index add3ee5f05..d6c6610ec1 100644 --- a/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js +++ b/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js @@ -97,7 +97,7 @@ describe('BDA wizarding editing integration', function () { _e.sent(); // await animation nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('[remove]'); })); + deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('Remove'); })); return [2 /*return*/]; } }); diff --git a/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js b/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js index b40461bef7..d369f9a937 100644 --- a/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js +++ b/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js @@ -41,7 +41,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; exports.__esModule = true; var testing_1 = require("@open-wc/testing"); -require("../../mock-open-sc.js"); +require("../../mock-open-scd.js"); var Templates_js_1 = require("../../../src/editors/Templates.js"); describe('DA wizarding editing integration', function () { if (customElements.get('templates-editor') === undefined) @@ -54,17 +54,16 @@ describe('DA wizarding editing integration', function () { var _a; return __generator(this, function (_b) { switch (_b.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') + .then(function (response) { return response.text(); }) + .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; case 1: + doc = _b.sent(); + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; + case 2: parent = _b.sent(); templates = parent.getActivePlugin(); - return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 2: - doc = _b.sent(); - templates.doc = doc; - return [4 /*yield*/, templates.updateComplete]; + return [4 /*yield*/, parent.updateComplete]; case 3: _b.sent(); dOTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="dotypelist"]')); @@ -97,7 +96,7 @@ describe('DA wizarding editing integration', function () { _e.sent(); // await animation nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('[remove]'); })); + deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('Remove'); })); return [2 /*return*/]; } }); @@ -184,7 +183,7 @@ describe('DA wizarding editing integration', function () { return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; case 2: _j.sent(); // await animation - (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('[scl.DA]'); })).click(); + (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('Data attribute'); })).click(); return [4 /*yield*/, parent.requestUpdate()]; case 3: _j.sent(); diff --git a/packages/open-scd/test/unit/editors/cleanup/__snapshots__/control-blocks-container.test.snap.js b/packages/open-scd/test/unit/editors/cleanup/__snapshots__/control-blocks-container.test.snap.js index 219800932a..40fd10bd46 100644 --- a/packages/open-scd/test/unit/editors/cleanup/__snapshots__/control-blocks-container.test.snap.js +++ b/packages/open-scd/test/unit/editors/cleanup/__snapshots__/control-blocks-container.test.snap.js @@ -70,8 +70,6 @@ snapshots["Cleanup: Control Blocks Container without a doc loaded looks like the - - `; /* end snapshot Cleanup: Control Blocks Container without a doc loaded looks like the latest snapshot */ @@ -344,8 +342,6 @@ snapshots["Cleanup: Control Blocks Container With a test file loaded looks like - - `; /* end snapshot Cleanup: Control Blocks Container With a test file loaded looks like the latest snapshot */ diff --git a/packages/open-scd/test/unit/editors/cleanup/__snapshots__/datasets-container.test.snap.js b/packages/open-scd/test/unit/editors/cleanup/__snapshots__/datasets-container.test.snap.js index 37fd92cdbc..5ece2f8ef5 100644 --- a/packages/open-scd/test/unit/editors/cleanup/__snapshots__/datasets-container.test.snap.js +++ b/packages/open-scd/test/unit/editors/cleanup/__snapshots__/datasets-container.test.snap.js @@ -5,12 +5,12 @@ snapshots["Cleanup: Datasets Container without a doc loaded looks like the lates `

    - [cleanup.unreferencedDataSets.title] + Unreferenced Datasets (0) @@ -26,14 +26,12 @@ snapshots["Cleanup: Datasets Container without a doc loaded looks like the lates class="cleanupDeleteButton deleteButton" disabled="" icon="delete" - label="[cleanup.unreferencedDataSets.deleteButton] (0)" + label="Remove Selected Datasets (0)" outlined="" >

    - - `; /* end snapshot Cleanup: Datasets Container without a doc loaded looks like the latest snapshot */ @@ -41,12 +39,12 @@ snapshots["Cleanup: Datasets Container with a test file loaded looks like the la `

    - [cleanup.unreferencedDataSets.title] + Unreferenced Datasets (2) @@ -116,14 +114,12 @@ snapshots["Cleanup: Datasets Container with a test file loaded looks like the la class="cleanupDeleteButton deleteButton" disabled="" icon="delete" - label="[cleanup.unreferencedDataSets.deleteButton] (0)" + label="Remove Selected Datasets (0)" outlined="" >

    - - `; /* end snapshot Cleanup: Datasets Container with a test file loaded looks like the latest snapshot */ diff --git a/packages/open-scd/test/unit/editors/cleanup/__snapshots__/datatypes-container.test.snap.js b/packages/open-scd/test/unit/editors/cleanup/__snapshots__/datatypes-container.test.snap.js index 386e32903c..2b920cb725 100644 --- a/packages/open-scd/test/unit/editors/cleanup/__snapshots__/datatypes-container.test.snap.js +++ b/packages/open-scd/test/unit/editors/cleanup/__snapshots__/datatypes-container.test.snap.js @@ -5,12 +5,12 @@ snapshots["Cleanup: DataTypes Container without a doc loaded looks like the late `

    - [cleanup.unreferencedDataTypes.title] + Unreferenced Data Types (0) @@ -54,13 +54,13 @@ snapshots["Cleanup: DataTypes Container without a doc loaded looks like the late class="delete-button" disabled="" icon="delete" - label="[cleanup.unreferencedDataTypes.deleteButton] (0)" + label="Remove Selected Data Types (0)" outlined="" >

    - - `; /* end snapshot Cleanup: DataTypes Container without a doc loaded looks like the latest snapshot */ @@ -79,12 +77,12 @@ snapshots["Cleanup: DataTypes Container With a test file loaded looks like the l `

    - [cleanup.unreferencedDataTypes.title] + Unreferenced Data Types (9) @@ -359,13 +357,13 @@ snapshots["Cleanup: DataTypes Container With a test file loaded looks like the l class="delete-button" disabled="" icon="delete" - label="[cleanup.unreferencedDataTypes.deleteButton] (0)" + label="Remove Selected Data Types (0)" outlined="" >

    - - `; /* end snapshot Cleanup: DataTypes Container With a test file loaded looks like the latest snapshot */ diff --git a/packages/open-scd/test/unit/editors/cleanup/control-blocks-container.test.ts b/packages/open-scd/test/unit/editors/cleanup/control-blocks-container.test.ts index 0fdc3043da..fa5c9eda1d 100644 --- a/packages/open-scd/test/unit/editors/cleanup/control-blocks-container.test.ts +++ b/packages/open-scd/test/unit/editors/cleanup/control-blocks-container.test.ts @@ -1,6 +1,7 @@ 'use strict'; import { html, fixture, expect } from '@open-wc/testing'; +import '../../../../src/editors/cleanup/control-blocks-container.js'; import { CleanupControlBlocks } from '../../../../src/editors/cleanup/control-blocks-container.js'; import { ListItem } from '@material/mwc-list/mwc-list-item.js'; diff --git a/packages/open-scd/test/unit/editors/cleanup/datasets-container.test.ts b/packages/open-scd/test/unit/editors/cleanup/datasets-container.test.ts index 987249f1c8..8320506f62 100644 --- a/packages/open-scd/test/unit/editors/cleanup/datasets-container.test.ts +++ b/packages/open-scd/test/unit/editors/cleanup/datasets-container.test.ts @@ -2,24 +2,22 @@ import { html, fixture, expect } from '@open-wc/testing'; import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; +import '../../../../src/editors/cleanup/datasets-container.js'; import { CleanupDatasets } from '../../../../src/editors/cleanup/datasets-container.js'; -import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('Cleanup: Datasets Container', () => { - customElements.define('cleanup-plugin-datasets', CleanupDatasets); let element: CleanupDatasets; let parent: MockOpenSCD; beforeEach(async () => { parent = await fixture( - html`` + html`` ); element = parent.getActivePlugin(); - await parent.updateComplete(); + await parent.updateComplete; }); describe('without a doc loaded', () => { @@ -36,7 +34,7 @@ describe('Cleanup: Datasets Container', () => { .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = await fixture( html`` ); element = parent.getActivePlugin(); diff --git a/packages/open-scd/test/unit/editors/cleanup/datatypes-container.test.ts b/packages/open-scd/test/unit/editors/cleanup/datatypes-container.test.ts index 41d7b4c282..7a7d1eda8d 100644 --- a/packages/open-scd/test/unit/editors/cleanup/datatypes-container.test.ts +++ b/packages/open-scd/test/unit/editors/cleanup/datatypes-container.test.ts @@ -2,11 +2,12 @@ import { html, fixture, expect } from '@open-wc/testing'; import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; +import '../../../../src/editors/cleanup/datatypes-container.js'; import { CleanupDataTypes } from '../../../../src/editors/cleanup/datatypes-container.js'; import { ListItem } from '@material/mwc-list/mwc-list-item.js'; -import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('Cleanup: DataTypes Container', () => { let element: CleanupDataTypes; diff --git a/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js b/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js index c5d820a7aa..3cf8ef12a1 100644 --- a/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js +++ b/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js @@ -41,6 +41,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; exports.__esModule = true; var testing_1 = require("@open-wc/testing"); +require("../../../../src/editors/cleanup/control-blocks-container.js"); describe('Cleanup: Control Blocks Container', function () { var element; beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { diff --git a/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js b/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js index a5b57b885f..6cac5d73ff 100644 --- a/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js +++ b/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js @@ -42,19 +42,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) { exports.__esModule = true; var testing_1 = require("@open-wc/testing"); require("../../../mock-open-scd.js"); -var datasets_container_js_1 = require("../../../../src/editors/cleanup/datasets-container.js"); +require("../../../../src/editors/cleanup/datasets-container.js"); describe('Cleanup: Datasets Container', function () { - customElements.define('cleanup-plugin-datasets', datasets_container_js_1.CleanupDatasets); var element; var parent; beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; case 1: parent = _a.sent(); element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete()]; + return [4 /*yield*/, parent.updateComplete]; case 2: _a.sent(); return [2 /*return*/]; @@ -83,7 +82,7 @@ describe('Cleanup: Datasets Container', function () { .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; case 1: doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; case 2: parent = _a.sent(); element = parent.getActivePlugin(); diff --git a/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js b/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js index 0a02761784..d7a0e298ad 100644 --- a/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js +++ b/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js @@ -42,6 +42,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { exports.__esModule = true; var testing_1 = require("@open-wc/testing"); require("../../../mock-open-scd.js"); +require("../../../../src/editors/cleanup/datatypes-container.js"); describe('Cleanup: DataTypes Container', function () { var element; var parent; diff --git a/packages/open-scd/test/unit/editors/subscription/__snapshots__/fcda-binding-list.test.snap.js b/packages/open-scd/test/unit/editors/subscription/__snapshots__/fcda-binding-list.test.snap.js index 4312a96a62..7c87aa6066 100644 --- a/packages/open-scd/test/unit/editors/subscription/__snapshots__/fcda-binding-list.test.snap.js +++ b/packages/open-scd/test/unit/editors/subscription/__snapshots__/fcda-binding-list.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["fcda-binding-list without a doc loaded looks like the latest snapshot"] = `

    - [subscription.undefined.controlBlockList.title] + subscription.undefined.controlBlockList.title - [subscription.subscriber.subscribed] + Subscribed - [subscription.subscriber.notSubscribed] + Not Subscribed @@ -55,1006 +55,3 @@ snapshots["fcda-binding-list without a doc loaded looks like the latest snapshot `; /* end snapshot fcda-binding-list without a doc loaded looks like the latest snapshot */ -snapshots["fcda-binding-list with a SampledValueControl doc loaded looks like the latest snapshot"] = -`
    -

    - [subscription.SampledValueControl.controlBlockList.title] - - - - - - [subscription.subscriber.subscribed] - - - - - [subscription.subscriber.notSubscribed] - - - -

    - - - - - - fullSmv - - - SMV_Publisher>>CurrentTransformer>fullSmv - - - - -
  • -
  • - - - AmpSv.instMag.i - - - CurrentTransformer / L3 TCTR 1 - - - subdirectory_arrow_right - - - - - AmpSv.q - - - CurrentTransformer / L3 TCTR 1 - - - subdirectory_arrow_right - - - - - AmpSv.instMag.i - - - CurrentTransformer / L2 TCTR 1 - - - subdirectory_arrow_right - - - - - AmpSv.q - - - CurrentTransformer / L2 TCTR 1 - - - subdirectory_arrow_right - - - - - AmpSv.instMag.i - - - CurrentTransformer / L1 TCTR 1 - - - subdirectory_arrow_right - - - - - AmpSv.q - - - CurrentTransformer / L1 TCTR 1 - - - subdirectory_arrow_right - - - - - VolSv.instMag.i - - - VoltageTransformer / L3 TVTR 1 - - - subdirectory_arrow_right - - - - - VolSv.q - - - VoltageTransformer / L3 TVTR 1 - - - subdirectory_arrow_right - - - - - VolSv.instMag.i - - - VoltageTransformer / L2 TVTR 1 - - - subdirectory_arrow_right - - - - - VolSv.q - - - VoltageTransformer / L2 TVTR 1 - - - subdirectory_arrow_right - - - - - VolSv.instMag.i - - - VoltageTransformer / L1 TVTR 1 - - - subdirectory_arrow_right - - - - - VolSv.q - - - VoltageTransformer / L1 TVTR 1 - - - subdirectory_arrow_right - - - - - - - voltageOnly - - - SMV_Publisher>>CurrentTransformer>voltageOnly - - - - -
  • -
  • - - - VolSv.instMag.i - - - VoltageTransformer / L1 TVTR 1 - - - subdirectory_arrow_right - - - 1 - - - - - VolSv.q - - - VoltageTransformer / L1 TVTR 1 - - - subdirectory_arrow_right - - - - - VolSv.instMag.i - - - VoltageTransformer / L2 TVTR 1 - - - subdirectory_arrow_right - - - - - VolSv.q - - - VoltageTransformer / L2 TVTR 1 - - - subdirectory_arrow_right - - - - - VolSv.instMag.i - - - VoltageTransformer / L3 TVTR 1 - - - subdirectory_arrow_right - - - - - VolSv.q - - - VoltageTransformer / L3 TVTR 1 - - - subdirectory_arrow_right - - - - - - - currentOnly - - - SMV_Publisher>>CurrentTransformer>currentOnly - - - - -
  • -
  • - - - AmpSv.instMag.i - - - CurrentTransformer / L1 TCTR 1 - - - subdirectory_arrow_right - - - 1 - - - - - AmpSv.q - - - CurrentTransformer / L1 TCTR 1 - - - subdirectory_arrow_right - - - 3 - - - - - AmpSv.instMag.i - - - CurrentTransformer / L2 TCTR 1 - - - subdirectory_arrow_right - - - - - AmpSv.q - - - CurrentTransformer / L2 TCTR 1 - - - subdirectory_arrow_right - - - - - AmpSv.instMag.i - - - CurrentTransformer / L3 TCTR 1 - - - subdirectory_arrow_right - - - - - AmpSv.q - - - CurrentTransformer / L3 TCTR 1 - - - subdirectory_arrow_right - - -
    -
    -`; -/* end snapshot fcda-binding-list with a SampledValueControl doc loaded looks like the latest snapshot */ - -snapshots["fcda-binding-list with a GSEControl doc loaded looks like the latest snapshot"] = -`
    -

    - [subscription.GSEControl.controlBlockList.title] - - - - - - [subscription.subscriber.subscribed] - - - - - [subscription.subscriber.notSubscribed] - - - -

    - - - - - - GOOSE2 - - - GOOSE_Publisher>>QB2_Disconnector>GOOSE2 - - - - -
  • -
  • - - - Pos.stVal - - - QB2_Disconnector / CSWI 1 - - - subdirectory_arrow_right - - - 1 - - - - - Pos.q - - - QB2_Disconnector / CSWI 1 - - - subdirectory_arrow_right - - - 2 - - - - - EnaOpn.stVal - - - QB1_Disconnector / CILO 1 - - - subdirectory_arrow_right - - - 1 - - - - - EnaCls.stVal - - - QB1_Disconnector / CILO 1 - - - subdirectory_arrow_right - - - 1 - - - - - EnaOpn.stVal - - - QB2_Disconnector / CILO 1 - - - subdirectory_arrow_right - - - 1 - - - - - - - GOOSE1 - - - GOOSE_Publisher>>QB2_Disconnector>GOOSE1 - - - - -
  • -
  • - - - Pos.stVal - - - QB1_Disconnector / CSWI 1 - - - subdirectory_arrow_right - - - - - Pos.q - - - QB1_Disconnector / CSWI 1 - - - subdirectory_arrow_right - - -
    -
    -`; -/* end snapshot fcda-binding-list with a GSEControl doc loaded looks like the latest snapshot */ - diff --git a/packages/open-scd/test/unit/editors/subscription/fcda-binding-list.test.ts b/packages/open-scd/test/unit/editors/subscription/fcda-binding-list.test.ts index f3cb22b83d..3e175e6e9d 100644 --- a/packages/open-scd/test/unit/editors/subscription/fcda-binding-list.test.ts +++ b/packages/open-scd/test/unit/editors/subscription/fcda-binding-list.test.ts @@ -7,6 +7,7 @@ import { WizardTextField } from '../../../../src/wizard-textfield.js'; import '../../../../src/editors/subscription/fcda-binding-list.js'; import { FcdaBindingList } from '../../../../src/editors/subscription/fcda-binding-list.js'; + import { SinonSpy, spy } from 'sinon'; import { ListItem } from '@material/mwc-list/mwc-list-item.js'; diff --git a/packages/open-scd/test/unit/menu/__snapshots__/UpdateDescriptionSEL.test.snap.js b/packages/open-scd/test/unit/menu/__snapshots__/UpdateDescriptionSEL.test.snap.js index 36f16fffa5..6db5470cc7 100644 --- a/packages/open-scd/test/unit/menu/__snapshots__/UpdateDescriptionSEL.test.snap.js +++ b/packages/open-scd/test/unit/menu/__snapshots__/UpdateDescriptionSEL.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["Update method for desc attributes in SEL IEDs working on SCL files containing manufacturer SEL using a semicolon separated file creates filtered list with all proposed desc attribute updates"] = ` @@ -126,14 +126,14 @@ snapshots["Update method for desc attributes in SEL IEDs working on SCL files co

    @@ -145,7 +145,7 @@ snapshots["Update method for desc attributes in SEL IEDs working on SCL files co snapshots["Update method for desc attributes in SEL IEDs working on SCL files containing manufacturer SEL using a comma separated (CSV) file creates filtered list with all proposed desc attribute updates"] = ` @@ -267,14 +267,14 @@ snapshots["Update method for desc attributes in SEL IEDs working on SCL files co
    diff --git a/packages/open-scd/test/unit/menu/__snapshots__/UpdateDescritionABB.test.snap.js b/packages/open-scd/test/unit/menu/__snapshots__/UpdateDescritionABB.test.snap.js index 7bff6c2dd2..665efe7e9d 100644 --- a/packages/open-scd/test/unit/menu/__snapshots__/UpdateDescritionABB.test.snap.js +++ b/packages/open-scd/test/unit/menu/__snapshots__/UpdateDescritionABB.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["Update method for desc attributes in ABB IEDs working on SCL files without manufacturer ABB creates an empty wizard indicating not found desc updates"] = ` @@ -14,14 +14,14 @@ snapshots["Update method for desc attributes in ABB IEDs working on SCL files wi @@ -33,7 +33,7 @@ snapshots["Update method for desc attributes in ABB IEDs working on SCL files wi snapshots["Update method for desc attributes in ABB IEDs working on SCL files containing manufacturer ABB creates a wizard with all valid desc update possibilities"] = ` @@ -75,14 +75,14 @@ snapshots["Update method for desc attributes in ABB IEDs working on SCL files co diff --git a/packages/open-scd/test/unit/validators/ValidateTemplates.test.ts b/packages/open-scd/test/unit/validators/ValidateTemplates.test.ts index d297da3e0d..a8ba257bf6 100644 --- a/packages/open-scd/test/unit/validators/ValidateTemplates.test.ts +++ b/packages/open-scd/test/unit/validators/ValidateTemplates.test.ts @@ -39,6 +39,8 @@ describe('ValidateTemplates', () => { `); element = parent.getActivePlugin(); + + await parent.updateComplete; }); it('triggers as newIssuesEvent for detail not containing kind', () => { @@ -113,13 +115,15 @@ describe('ValidateTemplates', () => { `); element = parent.getActivePlugin(); + + await parent.updateComplete; }); 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( - '[diag.zeroissues]' + 'No errors found in the project' ); }); @@ -128,7 +132,7 @@ describe('ValidateTemplates', () => { await element.validate(); expect(issueEvent).to.have.been.calledOnce; expect(issueEvent.args[0][0].detail.title).to.contain( - '[diag.missingnsd]' + 'Cannot validate DataTypeTemplates. The version of the project must be higher than or equal to 2007B3' ); }); @@ -138,7 +142,7 @@ describe('ValidateTemplates', () => { await element.validate(); expect(issueEvent).to.have.been.calledOnce; expect(issueEvent.args[0][0].detail.title).to.contain( - '[diag.missingnsd]' + 'Cannot validate DataTypeTemplates. The version of the project must be higher than or equal to 2007B3' ); }); diff --git a/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js b/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js index 6c99ed63e6..1574112c7a 100644 --- a/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js +++ b/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js @@ -73,6 +73,9 @@ describe('ValidateTemplates', function () { case 2: parent = _a.sent(); element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); return [2 /*return*/]; } }); @@ -144,6 +147,9 @@ describe('ValidateTemplates', function () { case 2: parent = _a.sent(); element = parent.getActivePlugin(); + return [4 /*yield*/, parent.updateComplete]; + case 3: + _a.sent(); return [2 /*return*/]; } }); @@ -155,7 +161,7 @@ describe('ValidateTemplates', function () { case 1: _a.sent(); testing_1.expect(issueEvent).to.have.been.calledOnce; - testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('[diag.zeroissues]'); + testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('No errors found in the project'); return [2 /*return*/]; } }); @@ -170,7 +176,7 @@ describe('ValidateTemplates', function () { case 1: _b.sent(); testing_1.expect(issueEvent).to.have.been.calledOnce; - testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('[diag.missingnsd]'); + testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('Cannot validate DataTypeTemplates. The version of the project must be higher than or equal to 2007B3'); return [2 /*return*/]; } }); @@ -186,7 +192,7 @@ describe('ValidateTemplates', function () { case 1: _c.sent(); testing_1.expect(issueEvent).to.have.been.calledOnce; - testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('[diag.missingnsd]'); + testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('Cannot validate DataTypeTemplates. The version of the project must be higher than or equal to 2007B3'); return [2 /*return*/]; } }); From 1d81b5a4a372fd88cb863848ae1d0ef9b7c055cf Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Thu, 15 Feb 2024 22:15:14 +0100 Subject: [PATCH 18/27] Fixed more tests --- .../datasets-container.test.snap.js | 16 +- .../datatypes-container.test.snap.js | 10 +- .../cleanup/datasets-container.test.ts | 9 +- .../cleanup/datatypes-container.test.ts | 8 +- .../cleanup/dist/datasets-container.test.js | 7 +- .../cleanup/dist/datatypes-container.test.js | 7 +- .../templates/dist/lnodetype-wizard.test.js | 2 +- .../templates/lnodetype-wizard.test.ts | 2 +- .../fcda-binding-list.test.snap.js | 1003 +++++++++++++++++ .../dist/fcda-binding-list.test.js | 12 +- .../subscription/fcda-binding-list.test.ts | 26 +- 11 files changed, 1047 insertions(+), 55 deletions(-) diff --git a/packages/open-scd/test/integration/editors/cleanup/__snapshots__/datasets-container.test.snap.js b/packages/open-scd/test/integration/editors/cleanup/__snapshots__/datasets-container.test.snap.js index 73101cef5c..87b8453528 100644 --- a/packages/open-scd/test/integration/editors/cleanup/__snapshots__/datasets-container.test.snap.js +++ b/packages/open-scd/test/integration/editors/cleanup/__snapshots__/datasets-container.test.snap.js @@ -5,12 +5,12 @@ snapshots["cleanup-editor integration: dataset removal without a doc loaded look `

    - [cleanup.unreferencedDataSets.title] + Unreferenced Datasets (0) @@ -26,14 +26,12 @@ snapshots["cleanup-editor integration: dataset removal without a doc loaded look class="cleanupDeleteButton deleteButton" disabled="" icon="delete" - label="[cleanup.unreferencedDataSets.deleteButton] (0)" + label="Remove Selected Datasets (0)" outlined="" >

    - - `; /* end snapshot cleanup-editor integration: dataset removal without a doc loaded looks like the latest snapshot */ @@ -41,12 +39,12 @@ snapshots["cleanup-editor integration: dataset removal With a test file loaded l `

    - [cleanup.unreferencedDataSets.title] + Unreferenced Datasets (2) @@ -116,14 +114,12 @@ snapshots["cleanup-editor integration: dataset removal With a test file loaded l class="cleanupDeleteButton deleteButton" disabled="" icon="delete" - label="[cleanup.unreferencedDataSets.deleteButton] (0)" + label="Remove Selected Datasets (0)" outlined="" >

    - - `; /* end snapshot cleanup-editor integration: dataset removal With a test file loaded looks like the latest snapshot */ diff --git a/packages/open-scd/test/integration/editors/cleanup/__snapshots__/datatypes-container.test.snap.js b/packages/open-scd/test/integration/editors/cleanup/__snapshots__/datatypes-container.test.snap.js index f0a9e4fd31..5f1fc7e25e 100644 --- a/packages/open-scd/test/integration/editors/cleanup/__snapshots__/datatypes-container.test.snap.js +++ b/packages/open-scd/test/integration/editors/cleanup/__snapshots__/datatypes-container.test.snap.js @@ -5,12 +5,12 @@ snapshots["cleanup-editor integration: unreferenced control blocks without a doc `

    - [cleanup.unreferencedDataTypes.title] + Unreferenced Data Types (0) @@ -54,13 +54,13 @@ snapshots["cleanup-editor integration: unreferenced control blocks without a doc class="delete-button" disabled="" icon="delete" - label="[cleanup.unreferencedDataTypes.deleteButton] (0)" + label="Remove Selected Data Types (0)" outlined="" >

    - - `; /* end snapshot cleanup-editor integration: unreferenced control blocks without a doc loaded looks like the latest snapshot */ diff --git a/packages/open-scd/test/integration/editors/cleanup/datasets-container.test.ts b/packages/open-scd/test/integration/editors/cleanup/datasets-container.test.ts index afdadf138d..8a0da53fdc 100644 --- a/packages/open-scd/test/integration/editors/cleanup/datasets-container.test.ts +++ b/packages/open-scd/test/integration/editors/cleanup/datasets-container.test.ts @@ -2,14 +2,13 @@ import { html, fixture, expect } from '@open-wc/testing'; import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; +import '../../../../src/editors/cleanup/datasets-container.js'; import { CleanupDatasets } from '../../../../src/editors/cleanup/datasets-container.js'; import { cleanSCLItems } from '../../../../src/editors/cleanup/foundation.js'; -import { MockOpenSCD } from '../../../mock-open-scd.js'; - describe('cleanup-editor integration: dataset removal', () => { - customElements.define('cleanup-plugin-datasets', CleanupDatasets); let element: CleanupDatasets; let parent: MockOpenSCD; @@ -18,7 +17,7 @@ describe('cleanup-editor integration: dataset removal', () => { const doc = null; parent = await fixture( html`` ); element = parent.getActivePlugin(); @@ -38,7 +37,7 @@ describe('cleanup-editor integration: dataset removal', () => { .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = await fixture( html`` ); element = parent.getActivePlugin(); diff --git a/packages/open-scd/test/integration/editors/cleanup/datatypes-container.test.ts b/packages/open-scd/test/integration/editors/cleanup/datatypes-container.test.ts index 9a7ef225c0..337df5a177 100644 --- a/packages/open-scd/test/integration/editors/cleanup/datatypes-container.test.ts +++ b/packages/open-scd/test/integration/editors/cleanup/datatypes-container.test.ts @@ -2,13 +2,13 @@ import { html, fixture, expect } from '@open-wc/testing'; import '../../../mock-open-scd.js'; +import { MockOpenSCD } from '../../../mock-open-scd.js'; +import '../../../../src/editors/cleanup/datatypes-container.js'; import { CleanupDataTypes } from '../../../../src/editors/cleanup/datatypes-container.js'; import { cleanSCLItems } from '../../../../src/editors/cleanup/foundation.js'; -import { MockOpenSCD } from '../../../mock-open-scd.js'; describe('cleanup-editor integration: unreferenced control blocks', () => { - customElements.define('cleanup-plugin-data-types', CleanupDataTypes); let element: CleanupDataTypes; let parent: MockOpenSCD; @@ -16,7 +16,7 @@ describe('cleanup-editor integration: unreferenced control blocks', () => { beforeEach(async () => { parent = await fixture( html`` ); element = parent.getActivePlugin(); @@ -36,7 +36,7 @@ describe('cleanup-editor integration: unreferenced control blocks', () => { .then(str => new DOMParser().parseFromString(str, 'application/xml')); parent = await fixture( html`` ); element = parent.getActivePlugin(); diff --git a/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js b/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js index 8ed25a5bf2..718cd347a4 100644 --- a/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js +++ b/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js @@ -42,10 +42,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) { exports.__esModule = true; var testing_1 = require("@open-wc/testing"); require("../../../mock-open-scd.js"); -var datasets_container_js_1 = require("../../../../src/editors/cleanup/datasets-container.js"); +require("../../../../src/editors/cleanup/datasets-container.js"); var foundation_js_1 = require("../../../../src/editors/cleanup/foundation.js"); describe('cleanup-editor integration: dataset removal', function () { - customElements.define('cleanup-plugin-datasets', datasets_container_js_1.CleanupDatasets); var element; var parent; describe('without a doc loaded', function () { @@ -55,7 +54,7 @@ describe('cleanup-editor integration: dataset removal', function () { switch (_a.label) { case 0: doc = null; - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; case 1: parent = _a.sent(); element = parent.getActivePlugin(); @@ -87,7 +86,7 @@ describe('cleanup-editor integration: dataset removal', function () { .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; case 1: doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; case 2: parent = _a.sent(); element = parent.getActivePlugin(); diff --git a/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js b/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js index b4eca26da2..04a713d8ef 100644 --- a/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js +++ b/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js @@ -42,17 +42,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) { exports.__esModule = true; var testing_1 = require("@open-wc/testing"); require("../../../mock-open-scd.js"); -var datatypes_container_js_1 = require("../../../../src/editors/cleanup/datatypes-container.js"); +require("../../../../src/editors/cleanup/datatypes-container.js"); var foundation_js_1 = require("../../../../src/editors/cleanup/foundation.js"); describe('cleanup-editor integration: unreferenced control blocks', function () { - customElements.define('cleanup-plugin-data-types', datatypes_container_js_1.CleanupDataTypes); var element; var parent; describe('without a doc loaded', function () { beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), null))]; + case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), null))]; case 1: parent = _a.sent(); element = parent.getActivePlugin(); @@ -84,7 +83,7 @@ describe('cleanup-editor integration: unreferenced control blocks', function () .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; case 1: doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; + return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; case 2: parent = _a.sent(); element = parent.getActivePlugin(); diff --git a/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js b/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js index 88c7917b07..b9c1a43161 100644 --- a/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js +++ b/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js @@ -199,7 +199,7 @@ describe('LNodeType wizards', function () { return [4 /*yield*/, parent.updateComplete]; case 1: _c.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 200); })]; case 2: _c.sent(); // await animation selector = parent.wizardUI.dialog.querySelector('mwc-select[label="lnClass"]'); diff --git a/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts b/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts index c057372f4a..42dacbce5b 100644 --- a/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts +++ b/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts @@ -144,7 +144,7 @@ describe('LNodeType wizards', () => { ); button.click(); await parent.updateComplete; - await new Promise(resolve => setTimeout(resolve, 100)); // await animation + await new Promise(resolve => setTimeout(resolve, 200)); // await animation selector = parent.wizardUI.dialog!.querySelector"], [""])), function (event) { + _this.onLoadFiles(event); + event.target.value = ''; + }); + }; + ImportingIedPlugin.prototype.buildIedSelection = function (importDoc, fileName) { + var _this = this; + var _a; + this.iedSelection.push(lit_element_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n \n ", "\n \n \n
    \n
    \n
    "], ["\n \n ", + "\n \n \n
    \n \n "])), fileName, Array.from((_a = importDoc === null || importDoc === void 0 ? void 0 : importDoc.querySelectorAll(':root > IED')) !== null && _a !== void 0 ? _a : []).map(function (ied) { + return lit_element_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject(["", ""], ["", ""])), foundation_js_1.identity(ied), ied.getAttribute('name')); + }), lit_translate_1.translate('close'), function () { return _this.importIEDs(importDoc, fileName); })); + }; + ImportingIedPlugin.prototype.render = function () { + return lit_element_1.html(templateObject_4 || (templateObject_4 = __makeTemplateObject(["", "", ""], ["", "", ""])), this.iedSelection, this.renderInput()); + }; + ImportingIedPlugin.styles = lit_element_1.css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n input {\n width: 0;\n height: 0;\n opacity: 0;\n }\n "], ["\n input {\n width: 0;\n height: 0;\n opacity: 0;\n }\n "]))); + __decorate([ + lit_element_1.property({ attribute: false }) + ], ImportingIedPlugin.prototype, "doc"); + __decorate([ + lit_element_1.property({ type: Number }) + ], ImportingIedPlugin.prototype, "editCount"); + __decorate([ + lit_element_1.state() + ], ImportingIedPlugin.prototype, "iedSelection"); + __decorate([ + lit_element_1.query('#importied-plugin-input') + ], ImportingIedPlugin.prototype, "pluginFileUI"); + __decorate([ + lit_element_1.query('mwc-dialog') + ], ImportingIedPlugin.prototype, "dialog"); + return ImportingIedPlugin; +}(lit_element_1.LitElement)); +exports["default"] = ImportingIedPlugin; +var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5; diff --git a/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js b/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js index b9c1a43161..c2b6b325a3 100644 --- a/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js +++ b/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js @@ -199,7 +199,7 @@ describe('LNodeType wizards', function () { return [4 /*yield*/, parent.updateComplete]; case 1: _c.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 200); })]; + return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 400); })]; case 2: _c.sent(); // await animation selector = parent.wizardUI.dialog.querySelector('mwc-select[label="lnClass"]'); diff --git a/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts b/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts index 42dacbce5b..4b869bd74b 100644 --- a/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts +++ b/packages/open-scd/test/integration/editors/templates/lnodetype-wizard.test.ts @@ -144,7 +144,7 @@ describe('LNodeType wizards', () => { ); button.click(); await parent.updateComplete; - await new Promise(resolve => setTimeout(resolve, 200)); // await animation + await new Promise(resolve => setTimeout(resolve, 400)); // await animation selector = parent.wizardUI.dialog!.querySelector"], [""])), function (event) { - _this.onLoadFiles(event); - event.target.value = ''; - }); - }; - ImportingIedPlugin.prototype.buildIedSelection = function (importDoc, fileName) { - var _this = this; - var _a; - this.iedSelection.push(lit_element_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n \n ", "\n \n \n \n \n "], ["\n \n ", - "\n \n \n \n \n "])), fileName, Array.from((_a = importDoc === null || importDoc === void 0 ? void 0 : importDoc.querySelectorAll(':root > IED')) !== null && _a !== void 0 ? _a : []).map(function (ied) { - return lit_element_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject(["", ""], ["", ""])), foundation_js_1.identity(ied), ied.getAttribute('name')); - }), lit_translate_1.translate('close'), function () { return _this.importIEDs(importDoc, fileName); })); - }; - ImportingIedPlugin.prototype.render = function () { - return lit_element_1.html(templateObject_4 || (templateObject_4 = __makeTemplateObject(["", "", ""], ["", "", ""])), this.iedSelection, this.renderInput()); - }; - ImportingIedPlugin.styles = lit_element_1.css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n input {\n width: 0;\n height: 0;\n opacity: 0;\n }\n "], ["\n input {\n width: 0;\n height: 0;\n opacity: 0;\n }\n "]))); - __decorate([ - lit_element_1.property({ attribute: false }) - ], ImportingIedPlugin.prototype, "doc"); - __decorate([ - lit_element_1.property({ type: Number }) - ], ImportingIedPlugin.prototype, "editCount"); - __decorate([ - lit_element_1.state() - ], ImportingIedPlugin.prototype, "iedSelection"); - __decorate([ - lit_element_1.query('#importied-plugin-input') - ], ImportingIedPlugin.prototype, "pluginFileUI"); - __decorate([ - lit_element_1.query('mwc-dialog') - ], ImportingIedPlugin.prototype, "dialog"); - return ImportingIedPlugin; -}(lit_element_1.LitElement)); -exports["default"] = ImportingIedPlugin; -var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5; diff --git a/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js b/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js deleted file mode 100644 index 718cd347a4..0000000000 --- a/packages/open-scd/test/integration/editors/cleanup/dist/datasets-container.test.js +++ /dev/null @@ -1,157 +0,0 @@ -'use strict'; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -require("../../../../src/editors/cleanup/datasets-container.js"); -var foundation_js_1 = require("../../../../src/editors/cleanup/foundation.js"); -describe('cleanup-editor integration: dataset removal', function () { - var element; - var parent; - describe('without a doc loaded', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var doc; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - doc = null; - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('With a test file loaded', function () { - var doc; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates two delete actions', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox, cleanItems, deleteActions; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - checkbox = element - .shadowRoot.querySelector('.dataSetList') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 1: - _b.sent(); - (_a = element.dataSetList) === null || _a === void 0 ? void 0 : _a.layout(); - cleanItems = Array.from(element.dataSetList.index.values()).map(function (index) { return element.unreferencedDataSets[index]; }); - deleteActions = foundation_js_1.cleanSCLItems(cleanItems); - testing_1.expect(deleteActions.length).to.equal(2); - return [2 /*return*/]; - } - }); - }); }); - it('correctly removes the datasets from the SCL file', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox, remainingDataSetCountCheck, datasetsCorrectlyRemoved; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - checkbox = element - .shadowRoot.querySelector('.dataSetList') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 1: - _b.sent(); - (_a = element.dataSetList) === null || _a === void 0 ? void 0 : _a.layout(); - return [4 /*yield*/, element.cleanupButton.click()]; - case 2: - _b.sent(); - remainingDataSetCountCheck = element.doc.querySelectorAll(':root > IED > AccessPoint > Server > LDevice > LN0 > DataSet, :root > IED > AccessPoint > Server > LDevice > LN > DataSet').length === 6; - datasetsCorrectlyRemoved = element.doc.querySelectorAll('DataSet[name="GooseDataSet2"], DataSet[name="PhsMeas2"]').length === 0; - testing_1.expect(remainingDataSetCountCheck && datasetsCorrectlyRemoved).to.equal(true); - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js b/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js deleted file mode 100644 index 04a713d8ef..0000000000 --- a/packages/open-scd/test/integration/editors/cleanup/dist/datatypes-container.test.js +++ /dev/null @@ -1,443 +0,0 @@ -'use strict'; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -require("../../../../src/editors/cleanup/datatypes-container.js"); -var foundation_js_1 = require("../../../../src/editors/cleanup/foundation.js"); -describe('cleanup-editor integration: unreferenced control blocks', function () { - var element; - var parent; - describe('without a doc loaded', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), null))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with a test file loaded', function () { - var doc; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('correctly removes a LNodeType entry from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; - case 1: - _b.sent(); - return [4 /*yield*/, element.cleanupDATypeFilter.click()]; - case 2: - _b.sent(); - return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; - case 3: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 4: - _b.sent(); - return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 5: - _b.sent(); - return [4 /*yield*/, element.cleanButton.click()]; - case 6: - _b.sent(); - // the correct number of LNodeTypes should remain - testing_1.expect(element.doc.querySelectorAll('LNodeType')).to.have.length(12); - testing_1.expect(element.doc.querySelectorAll('LNodeType[id="NotUsedTVTR"]')).to.have.length(0); - return [2 /*return*/]; - } - }); - }); }); - it('correctly removes DOTypes and SDOs from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; - case 1: - _b.sent(); - return [4 /*yield*/, element.cleanupDATypeFilter.click()]; - case 2: - _b.sent(); - return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; - case 3: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 4: - _b.sent(); - return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 5: - _b.sent(); - return [4 /*yield*/, element.cleanButton.click()]; - case 6: - _b.sent(); - // the correct number of DOTypes should remain - testing_1.expect(element.doc.querySelectorAll('DOType')).to.have.lengthOf(32); - testing_1.expect(element.doc.querySelectorAll('DOType[id="NotUsedDummy.SPS"], DOType[name="WYE_2_3"], DOType[id="CMV_1"]')).to.have.lengthOf(0); - return [2 /*return*/]; - } - }); - }); }); - it('correctly removes DATypes and those referenced via BDAs from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; - case 1: - _b.sent(); - return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; - case 2: - _b.sent(); - return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; - case 3: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 4: - _b.sent(); - return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 5: - _b.sent(); - return [4 /*yield*/, element.cleanButton.click()]; - case 6: - _b.sent(); - testing_1.expect(element.doc.querySelectorAll('DAType')).to.have.lengthOf(15); - testing_1.expect(element.doc.querySelectorAll('DAType[id="NotUsedDummy.LPHD1.Sim.Cancel"], DAType[id="OnlySubUsedVector_0"], DAType[id="AnalogValue_0"]')).to.have.lengthOf(0); - return [2 /*return*/]; - } - }); - }); }); - it('correctly removes EnumTypes', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; - case 1: - _b.sent(); - return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; - case 2: - _b.sent(); - return [4 /*yield*/, element.cleanupDATypeFilter.click()]; - case 3: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 4: - _b.sent(); - return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 5: - _b.sent(); - return [4 /*yield*/, element.cleanButton.click()]; - case 6: - _b.sent(); - testing_1.expect(element.doc.querySelectorAll('EnumType')).to.have.lengthOf(11); - testing_1.expect(element.doc.querySelectorAll('EnumType[id="NotUsedDir"]')).to.have.lengthOf(0); - return [2 /*return*/]; - } - }); - }); }); - describe('if the Remove subtypes checkbox is unchecked', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - element.cleanSubTypesCheckbox.checked = false; - return [4 /*yield*/, element.cleanSubTypesCheckbox.requestUpdate()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('correctly removes two DOTypes and not those referenced via an SDO from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; - case 1: - _b.sent(); - return [4 /*yield*/, element.cleanupDATypeFilter.click()]; - case 2: - _b.sent(); - return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; - case 3: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 4: - _b.sent(); - return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 5: - _b.sent(); - return [4 /*yield*/, element.cleanButton.click()]; - case 6: - _b.sent(); - // the correct number of DOTypes should remain - testing_1.expect(element.doc.querySelectorAll('DOType')).to.have.lengthOf(33); - testing_1.expect(element.doc.querySelectorAll('DOType[id="NotUsedDummy.SPS"], DOType[id="WYE_2_3"], DOType[id="Dummy.LLN0.Health.Unused]')).to.have.lengthOf(0); - testing_1.expect(element.doc.querySelectorAll('DOType[id="CMV_1"]')).to.have.lengthOf(1); - return [2 /*return*/]; - } - }); - }); }); - it('correctly removes DATypes and _not_ those referenced via a BDA from the SCL', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; - case 1: - _b.sent(); - return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; - case 2: - _b.sent(); - return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; - case 3: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 4: - _b.sent(); - return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 5: - _b.sent(); - return [4 /*yield*/, element.cleanButton.click()]; - case 6: - _b.sent(); - // the correct number of DATypes should remain - testing_1.expect(element.doc.querySelectorAll('DAType')).to.have.lengthOf(16); - testing_1.expect(element.doc.querySelectorAll('DAType[id="NotUsedDummy.LPHD1.Sim.Cancel"], DAType[id="OnlySubUsedVector_0"]')).to.have.lengthOf(0); - testing_1.expect(element.doc.querySelectorAll('DAType[id="AnalogValue_0"]')).to.have.lengthOf(1); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('if the LN filter is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupLNodeTypeFilter.click()]; - case 1: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 2: - _b.sent(); - return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 3: - _b.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates the correct number of Delete actions', function () { - var deleteActions = foundation_js_1.cleanSCLItems(element.getCleanItems()); - testing_1.expect(deleteActions.length).to.equal(14); - }); - return [2 /*return*/]; - }); - }); }); - describe('if the DO filter is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupDOTypeFilter.click()]; - case 1: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 2: - _b.sent(); - (_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout(); - return [2 /*return*/]; - } - }); - }); }); - it('creates the correct number of Delete actions (LNx1, DAx3, ENx1)', function () { - var deleteActions = foundation_js_1.cleanSCLItems(element.getCleanItems()); - testing_1.expect(deleteActions.length).to.equal(26); - }); - return [2 /*return*/]; - }); - }); }); - describe('if the DA filter is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupDATypeFilter.click()]; - case 1: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 2: - _b.sent(); - (_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout(); - return [2 /*return*/]; - } - }); - }); }); - it('creates the correct number of Delete Actions', function () { return __awaiter(void 0, void 0, void 0, function () { - var deleteActions; - return __generator(this, function (_a) { - deleteActions = foundation_js_1.cleanSCLItems(element.getCleanItems()); - testing_1.expect(deleteActions.length).to.equal(29); - return [2 /*return*/]; - }); - }); }); - return [2 /*return*/]; - }); - }); }); - describe('if the EN filter is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, element.cleanupEnumTypeFilter.click()]; - case 1: - _b.sent(); - checkbox = element - .shadowRoot.querySelector('.cleanup-list') - .shadowRoot.querySelector('mwc-formfield') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 2: - _b.sent(); - (_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout(); - return [2 /*return*/]; - } - }); - }); }); - it('creates the correct number of Delete Actions', function () { return __awaiter(void 0, void 0, void 0, function () { - var deleteActions; - return __generator(this, function (_a) { - deleteActions = foundation_js_1.cleanSCLItems(element.getCleanItems()); - testing_1.expect(deleteActions.length).to.equal(33); - return [2 /*return*/]; - }); - }); }); - return [2 /*return*/]; - }); - }); }); - }); -}); -var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/integration/editors/communication/dist/Communication.test.js b/packages/open-scd/test/integration/editors/communication/dist/Communication.test.js deleted file mode 100644 index 3cc8560cf1..0000000000 --- a/packages/open-scd/test/integration/editors/communication/dist/Communication.test.js +++ /dev/null @@ -1,176 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -var Communication_js_1 = require("../../../../src/editors/Communication.js"); -describe('Communication Plugin', function () { - customElements.define('communication-plugin', Communication_js_1["default"]); - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; - case 1: - element = _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - describe('without a doc loaded', function () { - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with a doc loaded including communication section', function () { - var doc; - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B4.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; - case 2: - element = _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('constains a subnetwork-editor rendering the communication section', function () { - var _a; - testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('subnetwork-editor')).to.exist; - }); - }); - describe('with a doc loaded missing a communication section', function () { - var doc; - var parent; - var fab; - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/missingCommunication.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _c.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _c.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _c.sent(); - fab = ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('communication-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-fab')); - return [2 /*return*/]; - } - }); - }); }); - it('has a mwc-fab', function () { - var _a; - testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-fab')).to.exist; - }); - it('that opens a add subnetwork wizard on mwc-fab click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(parent.wizardUI.dialogs.length).to.equal(0); - fab.click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - testing_1.expect(parent.wizardUI.dialogs.length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }); - it('Should create a Communication Element', function () { return __awaiter(void 0, void 0, void 0, function () { - var dialog, nameInput, saveButton; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(parent.wizardUI.dialogs.length).to.equal(0); - testing_1.expect(element.doc.querySelector('Communication')).is["null"]; - return [4 /*yield*/, fab.click()]; - case 1: - _a.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _a.sent(); // await animation - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - dialog = parent.wizardUI.dialog; - testing_1.expect(dialog).to.not.be.undefined; - nameInput = dialog.querySelector('wizard-textfield[label="name"]'); - nameInput.value = 'Test'; - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _a.sent(); // await animation - saveButton = dialog.querySelector('mwc-button[slot="primaryAction"]'); - return [4 /*yield*/, saveButton.click()]; - case 5: - _a.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 6: - _a.sent(); // await animation - testing_1.expect(element.doc.querySelector('Communication')).not.is["null"]; - testing_1.expect(element.doc.querySelector('Communication > SubNetwork[name="Test"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/editors/dist/Substation.test.js b/packages/open-scd/test/integration/editors/dist/Substation.test.js deleted file mode 100644 index deebbf8234..0000000000 --- a/packages/open-scd/test/integration/editors/dist/Substation.test.js +++ /dev/null @@ -1,141 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../mock-open-scd.js"); -var Substation_js_1 = require("../../../src/editors/Substation.js"); -describe('Substation Plugin', function () { - customElements.define('substation-plugin', Substation_js_1["default"]); - var element; - var parent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [2 /*return*/]; - } - }); - }); }); - describe('without a doc loaded', function () { - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with a doc loaded including substation section', function () { - var doc; - var element; - var parent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B4.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [2 /*return*/]; - } - }); - }); }); - it('constains a zeroline-pane rendering the substation sections', function () { - var _a; - testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('zeroline-pane')).to.exist; - }); - }); - describe('with a doc loaded missing a substation section', function () { - var doc; - var parent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/missingSubstation.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, element.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('has a mwc-fab', function () { - var _a; - testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-fab')).to.exist; - }); - it('that opens an add substation wizard on click', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect(parent.wizardUI.dialogs.length).to.equal(0); - ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('substation-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-fab')).click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect(parent.wizardUI.dialogs.length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/editors/templates/dist/Templates.test.js b/packages/open-scd/test/integration/editors/templates/dist/Templates.test.js deleted file mode 100644 index 431ce9557b..0000000000 --- a/packages/open-scd/test/integration/editors/templates/dist/Templates.test.js +++ /dev/null @@ -1,365 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -var Templates_js_1 = require("../../../../src/editors/Templates.js"); -var foundation_js_1 = require("../../../../src/foundation.js"); -describe('Templates Plugin', function () { - customElements.define('templates-plugin', Templates_js_1["default"]); - var element; - var parent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [2 /*return*/]; - } - }); - }); }); - describe('without a doc loaded', function () { - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with a doc loaded', function () { - var doc; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - element.doc = doc; - return [4 /*yield*/, element.requestUpdate()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - describe('having a LNodeType element list that', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - parent.workflow.length = 0; - ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[0].querySelector('mwc-list-item')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _b.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('opens a LNodeType edit wizard on list element click', function () { - var _a; - return testing_1.expect((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="lnClass"]')).to.exist; - }); - it('allows to reopen the LNodeType edit wizard for the same element', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - parent.dispatchEvent(foundation_js_1.newWizardEvent()); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _c.sent(); - ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list:nth-of-type(1) > mwc-list-item')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _c.sent(); - testing_1.expect((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="lnClass"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('having a DOType element list that', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - parent.workflow.length = 0; - ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[1].querySelector('mwc-list-item')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _b.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('opens a DOType edit wizard on list element click', function () { - var _a; - return testing_1.expect((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="CDC"]')).to.exist; - }); - it('allows to reopen the DOType edit wizard for the same element', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - parent.dispatchEvent(foundation_js_1.newWizardEvent()); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _c.sent(); - ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[1].querySelector('mwc-list-item')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _c.sent(); - testing_1.expect((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="CDC"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('having a DAType element list that', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - parent.workflow.length = 0; - ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[2].querySelector('mwc-list-item')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _b.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('opens a DAType edit wizard on list element click', function () { - return testing_1.expect(parent.wizardUI.dialog).to.exist; - }); - it('allows to reopen the DAType edit wizard for the same element', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - parent.dispatchEvent(foundation_js_1.newWizardEvent()); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _b.sent(); - ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[3].querySelector('mwc-list-item')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _b.sent(); - testing_1.expect(parent.wizardUI.dialog).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('having a EnumType element list that', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - parent.workflow.length = 0; - ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[3].querySelector('mwc-list-item')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _b.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('opens a EnumType edit wizard on list element click', function () { - return testing_1.expect(parent.wizardUI.dialog).to.exist; - }); - it('allows to reopen the EnumType edit wizard for the same element', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - parent.dispatchEvent(foundation_js_1.newWizardEvent()); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _b.sent(); - ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('filtered-list')[3].querySelector('mwc-list-item')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _b.sent(); - testing_1.expect(parent.wizardUI.dialog).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); - }); - describe('with a doc loaded missing a datatypetemplates section', function () { - var doc; - var parent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/missingdatatypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, element.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('has a mwc-fab', function () { - var _a; - testing_1.expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-fab')).to.exist; - }); - it('adds a DataTypeTemplates on floating action button click', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect(doc.querySelector('DataTypeTemplates')).to.not.exist; - ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('templates-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-fab')).click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect(parent - .querySelector('templates-plugin') - .doc.querySelector('DataTypeTemplates')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with a doc loaded having a datatypetemplates section', function () { - var doc; - var parent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, element.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('opens an add enumtype wizard', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect(parent.wizardUI.dialogs.length).to.equal(0); - ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('templates-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[2]).click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _c.sent(); // await animation - testing_1.expect(parent.wizardUI.dialogs.length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }); - it('adding an EnumType with the enumtype wizard', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - testing_1.expect(doc.querySelectorAll('EnumType').length).to.equal(4); - ((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.querySelector('templates-plugin')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('section:last-child mwc-icon-button[icon="playlist_add"]')).click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _d.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _d.sent(); // await animation - parent.wizardUI.inputs[1].value = 'myID'; - return [4 /*yield*/, parent.updateComplete]; - case 3: - _d.sent(); - ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-button[slot="primaryAction"]')).click(); - return [4 /*yield*/, parent.updateComplete]; - case 4: - _d.sent(); - testing_1.expect(doc.querySelectorAll('EnumType').length).to.equal(5); - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/editors/templates/dist/datype-wizarding.test.js b/packages/open-scd/test/integration/editors/templates/dist/datype-wizarding.test.js deleted file mode 100644 index a41452e66e..0000000000 --- a/packages/open-scd/test/integration/editors/templates/dist/datype-wizarding.test.js +++ /dev/null @@ -1,333 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd"); -var Templates_js_1 = require("../../../../src/editors/Templates.js"); -var foundation_js_1 = require("../../../../src/foundation.js"); -describe('DAType wizards', function () { - if (customElements.get('templates-editor') === undefined) - customElements.define('templates-editor', Templates_js_1["default"]); - var doc; - var parent; - var templates; - var dATypeList; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; - case 1: - parent = _b.sent(); - templates = parent.getActivePlugin(); - return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 2: - doc = _b.sent(); - templates.doc = doc; - return [4 /*yield*/, templates.updateComplete]; - case 3: - _b.sent(); - dATypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="datypelist"]')); - return [2 /*return*/]; - } - }); - }); }); - describe('defines a createDATypeWizard', function () { - var selector; - var idField; - var primayAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var button; - var _a, _b, _c, _d; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - button = ((_a = templates === null || templates === void 0 ? void 0 : templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[2]); - button.click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _e.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _e.sent(); // await animation - selector = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-select[label="values"]')); - idField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="id"]')); - primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - //work around, because the escapes get removed in snapshot - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - var pattern; - return __generator(this, function (_a) { - pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(2); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(pattern); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); - return [2 /*return*/]; - }); - }); }); - it('allows to add empty DATypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DAType[id="myGeneralDAType"]')).to.not.exist; - idField.maybeValue = 'myGeneralDAType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="myGeneralDAType"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('respects the sequence defined in the standard', function () { return __awaiter(void 0, void 0, void 0, function () { - var element; - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - idField.maybeValue = 'myGeneralDAType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _c.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _c.sent(); - element = doc.querySelector('DAType[id="myGeneralDAType"]'); - testing_1.expect((_a = element === null || element === void 0 ? void 0 : element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.tagName).to.equal('DAType'); - testing_1.expect((_b = element === null || element === void 0 ? void 0 : element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.tagName).to.equal('DOType'); - return [2 /*return*/]; - } - }); - }); }); - it('recursively add missing! subsequent EnumType elements', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DAType[id="myOriginator"]')).to.not.exist; - selector.value = 'OpenSCD_Originator'; - idField.maybeValue = 'myOriginator'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="myOriginator"]')).to.exist; - testing_1.expect(doc.querySelector('EnumType[id="OriginatorCategoryKind"]')).to - .exist; - testing_1.expect(doc.querySelectorAll('EnumType[id="OriginatorCategoryKind"]').length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }); - it('recursively add missing! subsequent DAType elements', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_AnalogueValue_FLOAT32"]')).to - .not.exist; - selector.value = 'OpenSCD_RangeConfig'; - idField.maybeValue = 'myOriginator'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_AnalogueValue_FLOAT32"]')).to - .exist; - testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_AnalogueValue_FLOAT32"]') - .length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('defines a dATypeWizard', function () { - var idField; - var primayAction; - var deleteButton; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - (dATypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod.SBOw"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _d.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _d.sent(); // await animation - idField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="id"]')); - primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-menu > mwc-list-item')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - //work around, because the escapes get removed in snapshot - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - var pattern; - return __generator(this, function (_a) { - pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(2); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(pattern); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); - return [2 /*return*/]; - }); - }); }); - it('edits DAType attributes id', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).to.exist; - idField.value = 'changedDAType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).to.not - .exist; - testing_1.expect(doc.querySelector('DAType[id="changedDAType"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('deletes the DAType attribute on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).to.exist; - testing_1.expect(doc.querySelectorAll('DAType').length).to.equal(5); - deleteButton.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).to.not - .exist; - testing_1.expect(doc.querySelectorAll('DAType').length).to.equal(4); - return [2 /*return*/]; - } - }); - }); }); - it('does not edit DAType element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { - var originData; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - originData = (doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]')).cloneNode(true); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(originData.isEqualNode(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"]'))).to.be["true"]; - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js b/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js deleted file mode 100644 index 178ca881d1..0000000000 --- a/packages/open-scd/test/integration/editors/templates/dist/dotype-wizarding.test.js +++ /dev/null @@ -1,612 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -var Templates_js_1 = require("../../../../src/editors/Templates.js"); -var limits_js_1 = require("../../../../src/wizards/foundation/limits.js"); -describe('DOType wizards', function () { - if (customElements.get('templates-editor') === undefined) - customElements.define('templates-editor', Templates_js_1["default"]); - var doc; - var parent; - var templates; - var dOTypeList; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _b.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _b.sent(); - templates = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _b.sent(); - dOTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="dotypelist"]')); - return [2 /*return*/]; - } - }); - }); }); - describe('defines a createDOTypeWizard', function () { - var selector; - var idField; - var cdcField; - var primayAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var button; - var _a, _b, _c, _d, _e; - return __generator(this, function (_f) { - switch (_f.label) { - case 0: - button = ((_a = templates === null || templates === void 0 ? void 0 : templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[1]); - button.click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _f.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _f.sent(); // await animation - selector = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-select[label="values"]')); - idField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="id"]')); - cdcField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="cdc"]')); - primayAction = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-button[slot="primaryAction"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - // prettier does not support escaping in regexes of the /v flag - return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - // prettier does not support escaping in regexes of the /v flag - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - // work around, because the escapes get removed in snapshot by prettier - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(3); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.nmToken); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[2] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.cdc); - return [2 /*return*/]; - }); - }); }); - it('allows to add empty DOTypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="myGeneralDOType"]')).to.not.exist; - idField.maybeValue = 'myGeneralDOType'; - cdcField.maybeValue = 'SPS'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="myGeneralDOType"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('allows to define CDC only for empty DOType creation', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, cdcField.updateComplete]; - case 1: - _a.sent(); - testing_1.expect(cdcField.disabled).to.not.be["true"]; - selector.value = 'OpenSCD_ENS_Health'; - return [4 /*yield*/, cdcField.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(cdcField.disabled).to.be["true"]; - return [2 /*return*/]; - } - }); - }); }); - it('requires CDC definition for empty DOTypes', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="myGeneralDOType"]')).to.not.exist; - idField.maybeValue = 'myGeneralDOType'; - cdcField.maybeValue = null; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="myGeneralDOType"]')).to.not.exist; - return [2 /*return*/]; - } - }); - }); }); - it('respects the sequence defined in the standard', function () { return __awaiter(void 0, void 0, void 0, function () { - var element; - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - idField.maybeValue = 'myGeneralDOType'; - cdcField.maybeValue = 'SPS'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _c.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _c.sent(); - element = doc.querySelector('DOType[id="myGeneralDOType"]'); - testing_1.expect((_a = element === null || element === void 0 ? void 0 : element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.tagName).to.equal('DOType'); - testing_1.expect((_b = element === null || element === void 0 ? void 0 : element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.tagName).to.equal('LNodeType'); - return [2 /*return*/]; - } - }); - }); }); - it('recursively add missing! subsequent EnumType elements', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="myENSHealth"]')).to.not.exist; - testing_1.expect(doc.querySelector('EnumType[id="HealthKind"]')).to.not.exist; - selector.value = 'OpenSCD_ENS_Health'; - idField.maybeValue = 'myENSHealth'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="myENSHealth"]')).to.exist; - testing_1.expect(doc.querySelector('EnumType[id="HealthKind"]')).to.exist; - testing_1.expect(doc.querySelectorAll('EnumType[id="HealthKind"]').length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }); - it('recursively add missing! subsequent DAType elements', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_AnalogueValue_INT32"]')).to - .not.exist; - selector.value = 'OpenSCD_MV_int'; - idField.maybeValue = 'myMV'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_AnalogueValue_INT32"]')).to - .exist; - testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_AnalogueValue_INT32"]').length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('defines a dOTypeWizard', function () { - var idField; - var primayAction; - var deleteButton; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - (dOTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _c.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _c.sent(); //recursive call takes time - idField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="id"]')); - primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes("Remove"); })); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - // prettier does not support escaping in regexes of the /v flag - return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - // prettier does not support escaping in regexes of the /v flag - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - // work around, because the escapes get removed in snapshot by prettier - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(3); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.nmToken); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[2] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); - return [2 /*return*/]; - }); - }); }); - it('edits DOType attributes id', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.exist; - idField.value = 'changedDOType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.not.exist; - testing_1.expect(doc.querySelector('DOType[id="changedDOType"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('deletes the DOType attribute on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.exist; - testing_1.expect(doc.querySelectorAll('DOType').length).to.equal(15); - console.log('del button'); - deleteButton.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod"]')).to.not.exist; - testing_1.expect(doc.querySelectorAll('DOType').length).to.equal(14); - return [2 /*return*/]; - } - }); - }); }); - it('does not edit DOType element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { - var originData; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - originData = (doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).cloneNode(true); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(originData.isEqualNode(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]'))).to.be["true"]; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('defines a sDOWizard to edit an existing SDO', function () { - var nameField; - var primayAction; - var deleteButton; - var typeSelect; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f; - return __generator(this, function (_g) { - switch (_g.label) { - case 0: - (dOTypeList.querySelector('mwc-list-item[value="#Dummy.WYE"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _g.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _g.sent(); // await animation - ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy.WYE>phsA"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _g.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _g.sent(); // await animation - nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); - primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-menu > mwc-list-item')); - typeSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('mwc-select[label="type"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - // prettier does not support escaping in regexes of the /v flag - return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - // prettier does not support escaping in regexes of the /v flag - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - // work around, because the escapes get removed in snapshot by prettier - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(2); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.tRestrName1stL); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); - return [2 /*return*/]; - }); - }); }); - it('edits SDO attributes name', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).to - .exist; - nameField.value = 'newPhsA'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).to - .not.exist; - testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="newPhsA"]')) - .to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('deletes the SDO element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).to - .exist; - testing_1.expect(doc.querySelectorAll('DOType[id="Dummy.WYE"] > SDO').length).to.equal(3); - deleteButton.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).to - .not.exist; - testing_1.expect(doc.querySelectorAll('DOType[id="Dummy.WYE"] > SDO').length).to.equal(2); - return [2 /*return*/]; - } - }); - }); }); - it('does not edit SDO element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { - var originData; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - originData = (doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]')).cloneNode(true); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(originData.isEqualNode(doc.querySelector('DOType[id="Dummy.WYE"] > SDO[name="phsA"]'))).to.be["true"]; - return [2 /*return*/]; - } - }); - }); }); - it('filters the type selector to DOTypes', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - testing_1.expect(typeSelect.querySelectorAll('mwc-list-item').length).to.equal(doc.querySelectorAll('DOType').length); - return [2 /*return*/]; - }); - }); }); - }); - describe('defines a sDOWizard to create a new SDO element', function () { - var nameField; - var descField; - var typeSelect; - var primaryAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e; - return __generator(this, function (_f) { - switch (_f.label) { - case 0: - (dOTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _f.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _f.sent(); // await animation - (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes("Data object"); })).click(); - return [4 /*yield*/, ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.requestUpdate())]; - case 3: - _f.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _f.sent(); // await animation - nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); - descField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="desc"]')); - typeSelect = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-select[label="type"]')); - primaryAction = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-button[slot="primaryAction"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - // prettier does not support escaping in regexes of the /v flag - return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - // prettier does not support escaping in regexes of the /v flag - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - // work around, because the escapes get removed in snapshot by prettier - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(2); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.tRestrName1stL); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(limits_js_1.patterns.normalizedString); - return [2 /*return*/]; - }); - }); }); - it('creates a new SDO element', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > SDO[name="newSDOElement"]')).to.not.exist; - nameField.value = 'newSDOElement'; - typeSelect.value = 'Dummy.CMV'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primaryAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > SDO[name="newSDOElement"]:not([desc])[type="Dummy.CMV"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('creates yet another new SDO element', function () { return __awaiter(void 0, void 0, void 0, function () { - var name, desc; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - name = 'newSDOElement2'; - desc = 'newSDOdesc'; - testing_1.expect(doc.querySelector('DOType[id="#Dummy.LLN0.Mod"] > SDO[name="newSDOElement2"]')).to.not.exist; - nameField.value = name; - descField.nullable = false; - descField.value = desc; - typeSelect.value = 'Dummy.CMV'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primaryAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector("DOType[id=\"Dummy.LLN0.Mod\"] >" + - ("SDO[name=\"" + name + "\"][desc=\"" + desc + "\"][type=\"Dummy.CMV\"]"))).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/integration/editors/templates/dist/enumtype-wizarding.test.js b/packages/open-scd/test/integration/editors/templates/dist/enumtype-wizarding.test.js deleted file mode 100644 index b0bb64e910..0000000000 --- a/packages/open-scd/test/integration/editors/templates/dist/enumtype-wizarding.test.js +++ /dev/null @@ -1,510 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -var Templates_js_1 = require("../../../../src/editors/Templates.js"); -var foundation_js_1 = require("../../../../src/foundation.js"); -describe('EnumType wizards', function () { - if (customElements.get('templates-editor') === undefined) - customElements.define('templates-editor', Templates_js_1["default"]); - var doc; - var parent; - var templates; - var eNumTypeList; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; - case 1: - parent = _b.sent(); - templates = parent.getActivePlugin(); - return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 2: - doc = _b.sent(); - templates.doc = doc; - return [4 /*yield*/, templates.updateComplete]; - case 3: - _b.sent(); - eNumTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="enumtypelist"]')); - return [2 /*return*/]; - } - }); - }); }); - describe('defines a createEnumTypeWizard', function () { - var selector; - var idField; - var primayAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var button; - var _a, _b, _c, _d; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - button = ((_a = templates === null || templates === void 0 ? void 0 : templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[3]); - button.click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _e.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _e.sent(); // await animation - selector = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-select[label="values"]')); - idField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="id"]')); - primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - //work around, because the escapes get removed in snapshot - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - var pattern; - return __generator(this, function (_a) { - pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(2); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(pattern); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); - return [2 /*return*/]; - }); - }); }); - it('allows to add empty EnumType to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('EnumType[id="myGeneralEnumType"]')).to.not - .exist; - idField.maybeValue = 'myGeneralEnumType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('EnumType[id="myGeneralEnumType"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('respects the sequence defined in the standard', function () { return __awaiter(void 0, void 0, void 0, function () { - var element; - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - idField.maybeValue = 'myGeneralEnumType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _c.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _c.sent(); - element = doc.querySelector('EnumType[id="myGeneralEnumType"]'); - testing_1.expect((_a = element === null || element === void 0 ? void 0 : element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.tagName).to.equal('EnumType'); - testing_1.expect((_b = element === null || element === void 0 ? void 0 : element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.tagName).to.equal('DAType'); - return [2 /*return*/]; - } - }); - }); }); - it('allows to add a predefined EnumType', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('EnumType[id="myGeneralEnumType"]')).to.not - .exist; - selector.value = 'AdjustmentKind'; - idField.maybeValue = 'myGeneralEnumType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('EnumType[id="myGeneralEnumType"]')).to.exist; - testing_1.expect(doc.querySelectorAll('EnumType[id="myGeneralEnumType"] > EnumVal') - .length).to.equal(4); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('defines an eNumTypeEditWizard', function () { - var idField; - var primayAction; - var deleteButton; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - (eNumTypeList.querySelector('mwc-list-item[value="#Dummy_ctlModel"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _d.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _d.sent(); // await animation - idField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="id"]')); - primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelectorAll('mwc-menu > mwc-list-item')[0]); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - //work around, because the escapes get removed in snapshot - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - var pattern; - return __generator(this, function (_a) { - pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(2); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(pattern); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); - return [2 /*return*/]; - }); - }); }); - it('edits EnumType attributes id', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"]')).to.exist; - idField.value = 'changedEnumType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"]')).to.not.exist; - testing_1.expect(doc.querySelector('EnumType[id="changedEnumType"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('deletes the EnumVal element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"]')).to.exist; - testing_1.expect(doc.querySelectorAll('EnumType').length).to.equal(4); - deleteButton.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"]')).to.not.exist; - testing_1.expect(doc.querySelectorAll('EnumType').length).to.equal(3); - return [2 /*return*/]; - } - }); - }); }); - it('does not edit EnumType element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { - var originData; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - originData = (doc.querySelector('EnumType[id="Dummy_ctlModel"]')).cloneNode(true); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(originData.isEqualNode(doc.querySelector('EnumType[id="Dummy_ctlModel"]'))).to.be["true"]; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('defines a eNumValWizard to edit an existing EnumVal', function () { - var ordField; - var valueField; - var descField; - var primayAction; - var deleteButton; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g; - return __generator(this, function (_h) { - switch (_h.label) { - case 0: - (eNumTypeList.querySelector('mwc-list-item[value="#Dummy_ctlModel"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _h.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _h.sent(); // await animation - ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy_ctlModel>1"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _h.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _h.sent(); // await animation - ordField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="ord"]')); - valueField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="value"]')); - descField = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('wizard-textfield[label="desc"]')); - primayAction = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelectorAll('mwc-menu > mwc-list-item')[0]); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('edits EnumVal attributes ord', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')).to.exist; - ordField.value = '10'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')).to.not.exist; - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="10"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('edits EnumVal attributes value', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect((_a = doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('direct-with-normal-security'); - valueField.value = 'direct-with-normal-security-test'; - descField.nullable = false; - descField.maybeValue = 'myDesc'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _c.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _c.sent(); - testing_1.expect((_b = doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"][desc="myDesc"]')) === null || _b === void 0 ? void 0 : _b.textContent).to.equal('direct-with-normal-security-test'); - return [2 /*return*/]; - } - }); - }); }); - it('deletes the EnumVal element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')).to.exist; - testing_1.expect(doc.querySelectorAll('EnumType[id="Dummy_ctlModel"] > EnumVal').length).to.equal(5); - deleteButton.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[name="1"]')).to.not.exist; - testing_1.expect(doc.querySelectorAll('EnumType[id="Dummy_ctlModel"] > EnumVal').length).to.equal(4); - return [2 /*return*/]; - } - }); - }); }); - it('does not edit EnumVal element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { - var originData; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - originData = (doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]')).cloneNode(true); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(originData.isEqualNode(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="1"]'))).to.be["true"]; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('defines a eNumValWizard to create a new EnumVal element', function () { - var ordField; - var valueField; - var descField; - var primayAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e; - return __generator(this, function (_f) { - switch (_f.label) { - case 0: - (eNumTypeList.querySelector('mwc-list-item[value="#Dummy_ctlModel"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _f.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _f.sent(); // await animation - ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-menu > mwc-list-item')[1]).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _f.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _f.sent(); // await animation - ordField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="ord"]')); - descField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="desc"]')); - valueField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="value"]')); - primayAction = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-button[slot="primaryAction"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates a new EnumVal element', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="9"]')).to.not.exist; - ordField.value = '9'; - valueField.value = 'newValue'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _b.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _b.sent(); - testing_1.expect((_a = doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="9"]:not([desc])')) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('newValue'); - return [2 /*return*/]; - } - }); - }); }); - it('creates yet another new EnumVal element', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - testing_1.expect(doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="9"]')).to.not.exist; - ordField.value = '9'; - valueField.value = 'newValue'; - descField.nullable = false; - descField.maybeValue = 'myDesc'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _b.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _b.sent(); - testing_1.expect((_a = doc.querySelector('EnumType[id="Dummy_ctlModel"] > EnumVal[ord="9"][desc="myDesc"]')) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('newValue'); - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js b/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js deleted file mode 100644 index 3ece5e1973..0000000000 --- a/packages/open-scd/test/integration/editors/templates/dist/lnodetype-wizard.test.js +++ /dev/null @@ -1,726 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -var Templates_js_1 = require("../../../../src/editors/Templates.js"); -var foundation_js_1 = require("../../../../src/foundation.js"); -describe('LNodeType wizards', function () { - if (customElements.get('templates-editor') === undefined) - customElements.define('templates-editor', Templates_js_1["default"]); - var doc; - var parent; - var templates; - var lNodeTypeList; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _b.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _b.sent(); - templates = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _b.sent(); - lNodeTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="lnodetypelist"]')); - return [2 /*return*/]; - } - }); - }); }); - describe('defines a lNodeTypeHelperWizard', function () { - var idField; - var primayAction; - var deleteButton; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - (lNodeTypeList.querySelector('mwc-list-item[value="#Dummy.CSWI"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _d.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _d.sent(); //recursive call takes time - idField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="id"]')); - primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-menu > mwc-list-item')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - //work around, because the escapes get removed in snapshot - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - var pattern; - return __generator(this, function (_a) { - pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(3); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(pattern); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[2] - .getAttribute('pattern')).to.equal(foundation_js_1.patterns.lnClass); - return [2 /*return*/]; - }); - }); }); - it('edits LNodeType attributes id', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.CSWI"]')).to.exist; - idField.value = 'changedLNodeType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.CSWI"]')).to.not.exist; - testing_1.expect(doc.querySelector('LNodeType[id="changedLNodeType"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('deletes the LNodeType attribute on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.CSWI"]')).to.exist; - testing_1.expect(doc.querySelectorAll('LNodeType').length).to.equal(8); - deleteButton.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.CSWI"]')).to.not.exist; - testing_1.expect(doc.querySelectorAll('LNodeType').length).to.equal(7); - return [2 /*return*/]; - } - }); - }); }); - it('does not edit LNodeType element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { - var originData; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - originData = (doc.querySelector('LNodeType[id="Dummy.CSWI"]')).cloneNode(true); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(originData.isEqualNode(doc.querySelector('LNodeType[id="Dummy.CSWI"]'))).to.be["true"]; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('defines a createLNodeTypeWizard', function () { - var selector; - var idField; - var primayAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var button; - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - button = ((_a = templates === null || templates === void 0 ? void 0 : templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-icon-button[icon="playlist_add"]')[0]); - button.click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 400); })]; - case 2: - _c.sent(); // await animation - selector = parent.wizardUI.dialog.querySelector('mwc-select[label="lnClass"]'); - idField = parent.wizardUI.dialog.querySelector('wizard-textfield[label="id"]'); - primayAction = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot({ - ignoreAttributes: [ - { - tags: ['wizard-textfield'], - attributes: ['pattern'] - }, - ] - })]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - //work around, because the escapes get removed in snapshot - it('should have correct pattern', function () { return __awaiter(void 0, void 0, void 0, function () { - var pattern; - return __generator(this, function (_a) { - pattern = '([:_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]|[.0-9\\-]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])+'; - testing_1.expect(parent.wizardUI.dialog.querySelectorAll('wizard-textfield[pattern]') - .length).to.equal(2); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[0] - .getAttribute('pattern')).to.equal(pattern); - testing_1.expect(parent.wizardUI - .dialog.querySelectorAll('wizard-textfield[pattern]')[1] - .getAttribute('pattern')).to.equal(foundation_js_1.patterns.normalizedString); - return [2 /*return*/]; - }); - }); }); - it('uses -7-4 and -7-420 namespace for lnClass suggestion', function () { - return testing_1.expect(selector.items.filter(function (item) { return !item.noninteractive && !item.twoline; })).to.have.lengthOf(215); - }); - it('recursively add missing! subsequent DOType elements', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.not.exist; - testing_1.expect(doc.querySelector('DOType[id="OpenSCD_ENC_Mod"]')).to.not.exist; - testing_1.expect(doc.querySelector('DOType[id="OpenSCD_ENS_Beh"]')).to.not.exist; - testing_1.expect(doc.querySelector('DOType[id="OpenSCD_ENS_Health"]')).to.not.exist; - testing_1.expect(doc.querySelector('DOType[id="OpenSCD_LPL_noLD"]')).to.not.exist; - testing_1.expect(doc.querySelector('DOType[id="OpenSCD_SPS_simple"]')).to.not.exist; - testing_1.expect(doc.querySelector('DOType[id="OpenSCD_DPC"]')).to.not.exist; - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 1: - _a.sent(); //recursive call takes time - selector.value = '#OpenSCD_CSWI_noPB'; - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); // selector updates autoimport - idField.maybeValue = 'myCSWI'; - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 4: - _a.sent(); - testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.exist; - testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_ENC_Mod"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_ENS_Beh"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_ENS_Health"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_LPL_noLD"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_SPS_simple"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DOType[id="OpenSCD_DPC"]').length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }).timeout(5000); - it('recursively add missing! subsequent DAType elements', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.not.exist; - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_Originator"]')).to.not.exist; - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_OperSBOw_Dbpos"]')).to.not - .exist; - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_Cancel_Dbpos"]')).to.not - .exist; - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_OperSBOw_BehaviourModeKind"]')).to.not.exist; - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_Cancel_BehaviourModeKind"]')) - .to.not.exist; - testing_1.expect(doc.querySelector('DAType[id="OpenSCD_PulseConfig"]')).to.not - .exist; - selector.value = '#OpenSCD_CSWI_noPB'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); // selector updates autoimport - idField.maybeValue = 'myCSWI'; - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.exist; - testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_Originator"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_OperSBOw_Dbpos"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_Cancel_Dbpos"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_OperSBOw_BehaviourModeKind"]') - .length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_Cancel_BehaviourModeKind"]') - .length).to.equal(1); - testing_1.expect(doc.querySelectorAll('DAType[id="OpenSCD_PulseConfig"]').length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }).timeout(5000); - it('recursively add missing! subsequent EnumType elements', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.not.exist; - testing_1.expect(doc.querySelector('EnumType[id="OriginatorCategoryKind"]')).to.not - .exist; - testing_1.expect(doc.querySelector('EnumType[id="BehaviourModeKind"]')).to.not - .exist; - testing_1.expect(doc.querySelector('EnumType[id="CtlModelKind"]')).to.not.exist; - testing_1.expect(doc.querySelector('EnumType[id="HealthKind"]')).to.not.exist; - testing_1.expect(doc.querySelector('EnumType[id="OutputSignalKind"]')).to.not.exist; - selector.value = '#OpenSCD_CSWI_noPB'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); // selector updates autoimport - idField.maybeValue = 'myCSWI'; - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - testing_1.expect(doc.querySelector('LNodeType[id="myCSWI"]')).to.exist; - testing_1.expect(doc.querySelectorAll('EnumType[id="OriginatorCategoryKind"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('EnumType[id="BehaviourModeKind"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('EnumType[id="CtlModelKind"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('EnumType[id="HealthKind"]').length).to.equal(1); - testing_1.expect(doc.querySelectorAll('EnumType[id="OutputSignalKind"]').length).to.equal(1); - return [2 /*return*/]; - } - }); - }); }).timeout(5000); - it('respects the sequence defined in the standard', function () { return __awaiter(void 0, void 0, void 0, function () { - var element; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - selector.value = '#OpenSCD_CSWI_noPB'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _b.sent(); // selector updates autoimport - idField.maybeValue = 'myGeneralLNodeType'; - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _b.sent(); - primayAction.click(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _b.sent(); - element = doc.querySelector('LNodeType[id="myGeneralLNodeType"]'); - testing_1.expect((_a = element === null || element === void 0 ? void 0 : element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.tagName).to.equal('LNodeType'); - testing_1.expect(element === null || element === void 0 ? void 0 : element.previousElementSibling).to.be["null"]; - return [2 /*return*/]; - } - }); - }); }).timeout(5000); - describe('opens a createLNodeTypeHelperWizard', function () { - var saveButton; - var beh; - var enaOpn; - var enaCls; - var ens; - var sps; - var ensId; - var spsId; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - selector.value = 'CILO'; - idField.maybeValue = 'myGeneralLNodeType'; - return [4 /*yield*/, parent.updateComplete]; - case 1: - _d.sent(); - ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-button[slot="primaryAction"]')).click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _d.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 400); })]; - case 3: - _d.sent(); // await animation - saveButton = parent.wizardUI.shadowRoot.querySelector('mwc-button[slot="primaryAction"]'); - beh = parent.wizardUI.shadowRoot.querySelector('wizard-select:nth-child(2)'); - enaOpn = parent.wizardUI.shadowRoot.querySelector('wizard-select:nth-child(21)'); - enaCls = parent.wizardUI.shadowRoot.querySelector('wizard-select:nth-child(22)'); - ens = doc.querySelector('DOType[cdc="ENS"]'); - sps = doc.querySelector('DOType[cdc="SPS"]'); - ensId = (_b = ens === null || ens === void 0 ? void 0 : ens.getAttribute('id')) !== null && _b !== void 0 ? _b : ''; - spsId = (_c = sps === null || sps === void 0 ? void 0 : sps.getAttribute('id')) !== null && _c !== void 0 ? _c : ''; - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('filters the type selection for each DO to fit the cdc', function () { - testing_1.expect(beh.querySelectorAll('mwc-list-item').length).to.equal(doc.querySelectorAll('DOType[cdc="ENS"]').length); - }); - it('requires all mandatory DOs to be defined', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - beh.value = ensId; - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - saveButton.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 3: - _a.sent(); // await animation - testing_1.expect(parent.wizardUI.dialog).to.exist; - testing_1.expect(doc.querySelector('LNodeType[id="myGeneralLNodeType"][lnClass="CILO"]')).to.not.exist; - return [2 /*return*/]; - } - }); - }); }); - it('adds new LNodeType with correct id and lnClass', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - beh.value = ensId; - enaOpn.value = spsId; - enaCls.value = spsId; - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - saveButton.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 3: - _a.sent(); // await animation - testing_1.expect(parent.wizardUI.dialog).to.not.exist; - testing_1.expect(doc.querySelector('LNodeType[id="myGeneralLNodeType"][lnClass="CILO"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('adds selected DOs to new LNodeType', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - beh.value = ensId; - enaOpn.value = spsId; - enaCls.value = spsId; - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - saveButton.click(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 3: - _a.sent(); // await animation - testing_1.expect(doc.querySelector("LNodeType[id=\"myGeneralLNodeType\"][lnClass=\"CILO\"] > DO[name=\"Beh\"]:not([bType])[type=\"" + ensId + "\"]")).to.exist; - testing_1.expect(doc.querySelector("LNodeType[id=\"myGeneralLNodeType\"][lnClass=\"CILO\"] > DO[name=\"EnaOpn\"]:not([bType])[type=\"" + spsId + "\"]")).to.exist; - testing_1.expect(doc.querySelector("LNodeType[id=\"myGeneralLNodeType\"][lnClass=\"CILO\"] > DO[name=\"EnaCls\"]:not([bType])[type=\"" + spsId + "\"]")).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); - }); - describe('defines a dOWizard to edit an existing DO', function () { - var nameField; - var descField; - var typeSelect; - var accessControlField; - var transientSelect; - var primaryAction; - var deleteButton; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g, _h, _j; - return __generator(this, function (_k) { - switch (_k.label) { - case 0: - (lNodeTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _k.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _k.sent(); // await animation - ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy.LLN0>Mod"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _k.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _k.sent(); // await animation - nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); - descField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="desc"]')); - accessControlField = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('wizard-textfield[label="accessControl"]')); - typeSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('mwc-select[label="type"]')); - transientSelect = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelector('wizard-checkbox[label="transient"]')); - primaryAction = ((_h = parent.wizardUI.dialog) === null || _h === void 0 ? void 0 : _h.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = ((_j = parent.wizardUI.dialog) === null || _j === void 0 ? void 0 : _j.querySelector('mwc-menu > mwc-list-item')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { - testing_1.expect(parent.wizardUI.dialog).to; - }); - it('edits DO attributes name', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')) - .to.exist; - nameField.value = 'NewMod'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primaryAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')) - .to.not.exist; - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('edits yet another attribute of the DO element', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]')).to.not.exist; - nameField.value = 'NewMod'; - descField.nullable = false; - descField.value = 'myDesc'; - typeSelect.value = 'Dummy.CMV'; - accessControlField.nullable = false; - accessControlField.maybeValue = 'myAccessControl'; - transientSelect.maybeValue = 'true'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primaryAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector("LNodeType[id=\"Dummy.LLN0\"] >" + - "DO[name=\"NewMod\"][desc=\"myDesc\"][type=\"Dummy.CMV\"][accessControl=\"myAccessControl\"][transient=\"true\"]")).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('deletes the DO element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')) - .to.exist; - testing_1.expect(doc.querySelectorAll('LNodeType[id="Dummy.LLN0"] > DO').length).to.equal(4); - deleteButton.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')) - .to.not.exist; - testing_1.expect(doc.querySelectorAll('LNodeType[id="Dummy.LLN0"] > DO').length).to.equal(3); - return [2 /*return*/]; - } - }); - }); }); - it('does not edit DO element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { - var originData; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - originData = (doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]')).cloneNode(true); - primaryAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(originData.isEqualNode(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Mod"]'))).to.be["true"]; - return [2 /*return*/]; - } - }); - }); }); - it('filters the type selector to DOTypes', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - testing_1.expect(typeSelect.querySelectorAll('mwc-list-item').length).to.equal(doc.querySelectorAll('DOType').length); - return [2 /*return*/]; - }); - }); }); - }); - describe('defines a dOWizard to create a new DO element', function () { - var nameField; - var descField; - var typeSelect; - var accessControlField; - var transientSelect; - var primaryAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g; - return __generator(this, function (_h) { - switch (_h.label) { - case 0: - (lNodeTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _h.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _h.sent(); // await animation - ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-menu > mwc-list-item')[1]).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _h.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _h.sent(); // await animation - nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); - descField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="desc"]')); - accessControlField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="accessControl"]')); - typeSelect = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('mwc-select[label="type"]')); - transientSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('wizard-checkbox[label="transient"]')); - primaryAction = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelector('mwc-button[slot="primaryAction"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates a new DO element', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]')).to.not.exist; - nameField.value = 'NewMod'; - typeSelect.value = 'Dummy.CMV'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primaryAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]:not([desc])[type="Dummy.CMV"]:not([accessControl]):not([transient])')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('creates yet another new DO element', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="NewMod"]')).to.not.exist; - nameField.value = 'NewMod'; - descField.nullable = false; - descField.value = 'myDesc'; - typeSelect.value = 'Dummy.CMV'; - accessControlField.nullable = false; - accessControlField.maybeValue = 'myAccessControl'; - transientSelect.maybeValue = 'true'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primaryAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector("LNodeType[id=\"Dummy.LLN0\"] >" + - "DO[name=\"NewMod\"][desc=\"myDesc\"][type=\"Dummy.CMV\"][accessControl=\"myAccessControl\"][transient=\"true\"]")).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js b/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js deleted file mode 100644 index b8e24f9844..0000000000 --- a/packages/open-scd/test/integration/editors/triggered/dist/ImportIedsPlugin.test.js +++ /dev/null @@ -1,538 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -var ImportIEDs_js_1 = require("../../../../src/menu/ImportIEDs.js"); -describe('ImportIedsPlugin', function () { - customElements.define('import-ied-plugin', ImportIEDs_js_1["default"]); - describe('imports valid ied elements to empty projects', function () { - var doc; - var importDoc; - var parent; - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/emptyproject.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, fetch('/test/testfiles/importieds/valid.iid') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 2: - importDoc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; - case 3: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 4: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('loads ied element to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelector(':root > IED[name="TestImportIED"]')).to - .not.exist; - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelector(':root > IED[name="TestImportIED"]')).to - .exist; - return [2 /*return*/]; - } - }); - }); }); - it('adds the connectedap of the imported ied', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"] > ConnectedAP[iedName="TestImportIED"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('creates new subnetwork if not present in the doc', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')).to - .not.exist; - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')).to - .exist; - return [2 /*return*/]; - } - }); - }); }); - it('renames TEMPLATE IED element if manufacturer/type has illegal characters', function () { return __awaiter(void 0, void 0, void 0, function () { - var ied; - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - importDoc = _d.sent(); - ied = importDoc.querySelector('IED'); - ied.setAttribute('manufacturer', 'Fancy-Vendy'); - ied.setAttribute('type', 'Z#Mega$Y'); - return [4 /*yield*/, element.updateComplete]; - case 2: - _d.sent(); - element.prepareImport(importDoc, 'template.icd'); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _d.sent(); - console.log((_b = (_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelector(':root > IED')) === null || _b === void 0 ? void 0 : _b.getAttribute('name')); - testing_1.expect((_c = element.doc) === null || _c === void 0 ? void 0 : _c.querySelector(':root > IED[name="FancyVendy_ZMegaY_001"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('allows multiple import of TEMPLATE IEDs', function () { return __awaiter(void 0, void 0, void 0, function () { - var templateIED1, templateIED2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - templateIED1 = _a.sent(); - element.prepareImport(templateIED1, 'template.icd'); - return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 2: - templateIED2 = _a.sent(); - return [4 /*yield*/, element.updateComplete]; - case 3: - _a.sent(); - element.prepareImport(templateIED2, 'template.icd'); - return [4 /*yield*/, parent.updateComplete]; - case 4: - _a.sent(); - testing_1.expect(element.doc.querySelector('IED[name="FancyVendy_ZMegaY_001"]')).to - .exist; - testing_1.expect(element.doc.querySelector('IED[name="FancyVendy_ZMegaY_002"]')).to - .exist; - return [2 /*return*/]; - } - }); - }); }); - it('imports the ConnectedAPs for a TEMPLATE IED', function () { return __awaiter(void 0, void 0, void 0, function () { - var templateIED1; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - templateIED1 = _b.sent(); - element.prepareImport(templateIED1, 'template.icd'); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _b.sent(); - testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > Communication > SubNetwork > ConnectedAP[iedName="FancyVendy_ZMegaY_001"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('loads unique lnodetypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > LNodeType').length).to.equal(0); - element.prepareImport(importDoc, 'template.icd'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > LNodeType').length).to.equal(5); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('imports valid ied elements', function () { - var doc; - var importDoc; - var parent; - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B4.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [4 /*yield*/, fetch('/test/testfiles/importieds/valid.iid') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 4: - importDoc = _a.sent(); - return [4 /*yield*/, element.updateComplete]; - case 5: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('loads ied element to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelector(':root > IED[name="TestImportIED"]')).to - .not.exist; - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelector(':root > IED[name="TestImportIED"]')).to - .exist; - return [2 /*return*/]; - } - }); - }); }); - it('loads unique lnodetypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > LNodeType').length).to.equal(11); - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > LNodeType').length).to.equal(16); - return [2 /*return*/]; - } - }); - }); }); - it('loads unique dotypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > DOType').length).to.equal(16); - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > DOType').length).to.equal(26); - return [2 /*return*/]; - } - }); - }); }); - it('loads unique datypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > DAType').length).to.equal(7); - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > DAType').length).to.equal(11); - return [2 /*return*/]; - } - }); - }); }); - it('loads unique enumtypes to the project', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect((_a = element.doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(':root > DataTypeTemplates > EnumType').length).to.equal(4); - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect((_b = element.doc) === null || _b === void 0 ? void 0 : _b.querySelectorAll(':root > DataTypeTemplates > EnumType').length).to.equal(10); - return [2 /*return*/]; - } - }); - }); }); - it('adds the connectedap of the imported ied', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - testing_1.expect(element.doc.querySelector('ConnectedAP[iedName="TestImportIED"]')) - .to.not.exist; - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _b.sent(); - testing_1.expect(element.doc.querySelector('ConnectedAP[iedName="TestImportIED"]')) - .to.exist; - testing_1.expect((_a = element.doc.querySelector('ConnectedAP[iedName="TestImportIED"]')) === null || _a === void 0 ? void 0 : _a.parentElement).to.equal(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')); - return [2 /*return*/]; - } - }); - }); }); - it('creates new subnetwork if not present in the doc', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')).to - .not.exist; - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - testing_1.expect(element.doc.querySelector('SubNetwork[name="NewSubNetwork"]')).to - .exist; - return [2 /*return*/]; - } - }); - }); }); - it('correctly transfers document element namespaces', function () { return __awaiter(void 0, void 0, void 0, function () { - var output, lineFeedAndSpacesReplace; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - element.prepareImport(importDoc, 'valid.iid'); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - testing_1.expect(element.doc.querySelector('SCL').getAttribute('xmlns:eTest1')).to.equal('http://www.eTest1.com/2022/Better61850'); - testing_1.expect(element.doc.querySelector('SCL').getAttribute('xmlns:eTest2')).to.equal('http://www.eTest2.com/2032/Better61850ForReal'); - output = new XMLSerializer().serializeToString(element.doc); - testing_1.expect(output).to.contain('xmlns:eTest1="http://www.eTest1.com/2022/Better61850"'); - testing_1.expect(output).to.contain('xmlns:eTest2="http://www.eTest2.com/2032/Better61850ForReal"'); - lineFeedAndSpacesReplace = /[\s\n\r]+/g; - testing_1.expect(output.replace(lineFeedAndSpacesReplace, '')).to.include("\n\n

    \n".replace(lineFeedAndSpacesReplace, '')); - return [2 /*return*/]; - } - }); - }); }); - it('allows multiple import of TEMPLATE IEDs', function () { return __awaiter(void 0, void 0, void 0, function () { - var templateIED1, templateIED2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(element.doc.querySelectorAll('IED').length).to.equal(3); - return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - templateIED1 = _a.sent(); - element.prepareImport(templateIED1, 'template.icd'); - return [4 /*yield*/, fetch('/test/testfiles/importieds/template.icd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 2: - templateIED2 = _a.sent(); - element.prepareImport(templateIED2, 'template.icd'); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - testing_1.expect(element.doc.querySelector('IED[name="FancyVendy_ZMegaY_001"]')).to - .exist; - testing_1.expect(element.doc.querySelector('IED[name="FancyVendy_ZMegaY_002"]')).to - .exist; - return [2 /*return*/]; - } - }); - }); }); - it('renders wizard for files containing more than one IED', function () { return __awaiter(void 0, void 0, void 0, function () { - var multipleIedDoc; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/multipleied.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - multipleIedDoc = _b.sent(); - element.prepareImport(multipleIedDoc, 'multipleied.scd'); - return [4 /*yield*/, element.updateComplete]; - case 2: - _b.sent(); - testing_1.expect(element.dialog).to.exist; - testing_1.expect(element.dialog.open).to.be["true"]; - testing_1.expect((_a = element.dialog) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-check-list-item').length).to.equal(3); - return [2 /*return*/]; - } - }); - }); }); - it('imports selected IEDs from Import IED wizard', function () { return __awaiter(void 0, void 0, void 0, function () { - var multipleIedDoc; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/multipleied.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - multipleIedDoc = _b.sent(); - element.prepareImport(multipleIedDoc, 'multipleied.scd'); - return [4 /*yield*/, element.updateComplete]; - case 2: - _b.sent(); - (element.dialog.querySelectorAll('mwc-check-list-item')[1]).setAttribute('selected', 'true'); - (element.dialog.querySelectorAll('mwc-check-list-item')[2]).setAttribute('selected', 'true'); - return [4 /*yield*/, element.dialog.updateComplete]; - case 3: - _b.sent(); - ((_a = element.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-button[slot="primaryAction"]')).click(); - return [4 /*yield*/, parent.updateComplete]; - case 4: - _b.sent(); - return [4 /*yield*/, element.requestUpdate()]; - case 5: - _b.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 6: - _b.sent(); // await complex action - testing_1.expect(element.doc.querySelectorAll('IED[name="IED3"]').length).to.equal(1); - testing_1.expect(element.doc.querySelector('IED[name="IED4"]')).to.exist; - testing_1.expect(element.doc.querySelector('IED[name="IED5"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('importing invalid ieds', function () { - var doc; - var importDoc; - var parent; - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B4.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('throws missing ied elements error', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/invalid.iid') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - importDoc = _a.sent(); - element.prepareImport(importDoc, 'invalid.iid'); - testing_1.expect(parent.log[0].kind).to.equal('error'); - testing_1.expect(parent.log[0].title).to.equal('No IED element in the file'); - return [2 /*return*/]; - } - }); - }); }); - it('throws duplicate ied name error', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/duplicate.iid') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - importDoc = _a.sent(); - element.prepareImport(importDoc, 'duplicate.iid'); - testing_1.expect(parent.log[0].kind).to.equal('error'); - testing_1.expect(parent.log[0].title).to.equal('IED element IED2 already in the file'); - return [2 /*return*/]; - } - }); - }); }); - it('throws parser error', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/importieds/parsererror.iid') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - importDoc = _a.sent(); - return [4 /*yield*/, element.updateComplete]; - case 2: - _a.sent(); - element.prepareImport(importDoc, 'parsererror.iid'); - testing_1.expect(parent.log[0].kind).to.equal('error'); - testing_1.expect(parent.log[0].title).to.equal('Parser error'); - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/menu/dist/NewProject.test.js b/packages/open-scd/test/integration/menu/dist/NewProject.test.js deleted file mode 100644 index ed1efe6294..0000000000 --- a/packages/open-scd/test/integration/menu/dist/NewProject.test.js +++ /dev/null @@ -1,139 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../mock-open-scd.js"); -var NewProject_js_1 = require("../../../src/menu/NewProject.js"); -describe('NewProject loader', function () { - customElements.define('new-project-plugin', NewProject_js_1["default"]); - var parent; - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [2 /*return*/]; - } - }); - }); }); - it('creates an empty Edition 2.1 project on wizard primary button click', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - return __generator(this, function (_m) { - switch (_m.label) { - case 0: - element.run(); - return [4 /*yield*/, element.updateComplete]; - case 1: - _m.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _m.sent(); // await animation - (parent.wizardUI.shadowRoot.querySelector('mwc-button[slot="primaryAction"]')).click(); - testing_1.expect((_a = parent.doc) === null || _a === void 0 ? void 0 : _a.querySelector('Header')).to.exist; - testing_1.expect((_c = (_b = parent.doc) === null || _b === void 0 ? void 0 : _b.querySelector('Header')) === null || _c === void 0 ? void 0 : _c.getAttribute('id')).to.equal(parent.docName.slice(0, -4)); - testing_1.expect((_e = (_d = parent.doc) === null || _d === void 0 ? void 0 : _d.querySelector('SCL')) === null || _e === void 0 ? void 0 : _e.getAttribute('xmlns')).to.equal('http://www.iec.ch/61850/2003/SCL'); - testing_1.expect((_g = (_f = parent.doc) === null || _f === void 0 ? void 0 : _f.querySelector('SCL')) === null || _g === void 0 ? void 0 : _g.getAttribute('version')).to.equal('2007'); - testing_1.expect((_j = (_h = parent.doc) === null || _h === void 0 ? void 0 : _h.querySelector('SCL')) === null || _j === void 0 ? void 0 : _j.getAttribute('revision')).to.equal('B'); - testing_1.expect((_l = (_k = parent.doc) === null || _k === void 0 ? void 0 : _k.querySelector('SCL')) === null || _l === void 0 ? void 0 : _l.getAttribute('release')).to.equal('4'); - return [2 /*return*/]; - } - }); - }); }); - it('creates an empty Edition 2 project on wizard primary button click', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - return __generator(this, function (_m) { - switch (_m.label) { - case 0: - element.run(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _m.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _m.sent(); // await animation - (parent.wizardUI.dialog.querySelector('mwc-radio-list-item:nth-child(2)')).click(); - return [4 /*yield*/, element.updateComplete]; - case 3: - _m.sent(); - (parent.wizardUI.shadowRoot.querySelector('mwc-button[slot="primaryAction"]')).click(); - testing_1.expect((_a = parent.doc) === null || _a === void 0 ? void 0 : _a.querySelector('Header')).to.exist; - testing_1.expect((_c = (_b = parent.doc) === null || _b === void 0 ? void 0 : _b.querySelector('Header')) === null || _c === void 0 ? void 0 : _c.getAttribute('id')).to.equal(parent.docName.slice(0, -4)); - testing_1.expect((_e = (_d = parent.doc) === null || _d === void 0 ? void 0 : _d.querySelector('SCL')) === null || _e === void 0 ? void 0 : _e.getAttribute('xmlns')).to.equal('http://www.iec.ch/61850/2003/SCL'); - testing_1.expect((_g = (_f = parent.doc) === null || _f === void 0 ? void 0 : _f.querySelector('SCL')) === null || _g === void 0 ? void 0 : _g.getAttribute('version')).to.equal('2007'); - testing_1.expect((_j = (_h = parent.doc) === null || _h === void 0 ? void 0 : _h.querySelector('SCL')) === null || _j === void 0 ? void 0 : _j.getAttribute('revision')).to.equal('B'); - testing_1.expect((_l = (_k = parent.doc) === null || _k === void 0 ? void 0 : _k.querySelector('SCL')) === null || _l === void 0 ? void 0 : _l.getAttribute('release')).to.be["null"]; - return [2 /*return*/]; - } - }); - }); }); - it('creates an empty Edition 1 project on wizard primary button click', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - return __generator(this, function (_m) { - switch (_m.label) { - case 0: - element.run(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _m.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _m.sent(); // await animation - (parent.wizardUI.dialog.querySelector('mwc-radio-list-item:nth-child(1)')).click(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _m.sent(); - (parent.wizardUI.shadowRoot.querySelector('mwc-button[slot="primaryAction"]')).click(); - testing_1.expect((_a = parent.doc) === null || _a === void 0 ? void 0 : _a.querySelector('Header')).to.exist; - testing_1.expect((_c = (_b = parent.doc) === null || _b === void 0 ? void 0 : _b.querySelector('Header')) === null || _c === void 0 ? void 0 : _c.getAttribute('id')).to.equal(parent.docName.slice(0, -4)); - testing_1.expect((_e = (_d = parent.doc) === null || _d === void 0 ? void 0 : _d.querySelector('SCL')) === null || _e === void 0 ? void 0 : _e.getAttribute('xmlns')).to.equal('http://www.iec.ch/61850/2003/SCL'); - testing_1.expect((_g = (_f = parent.doc) === null || _f === void 0 ? void 0 : _f.querySelector('SCL')) === null || _g === void 0 ? void 0 : _g.getAttribute('version')).to.be["null"]; - testing_1.expect((_j = (_h = parent.doc) === null || _h === void 0 ? void 0 : _h.querySelector('SCL')) === null || _j === void 0 ? void 0 : _j.getAttribute('revision')).to.be["null"]; - testing_1.expect((_l = (_k = parent.doc) === null || _k === void 0 ? void 0 : _k.querySelector('SCL')) === null || _l === void 0 ? void 0 : _l.getAttribute('release')).to.be["null"]; - return [2 /*return*/]; - } - }); - }); }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/integration/menu/dist/UpdateDescritionABB.test.js b/packages/open-scd/test/integration/menu/dist/UpdateDescritionABB.test.js deleted file mode 100644 index 02f687838c..0000000000 --- a/packages/open-scd/test/integration/menu/dist/UpdateDescritionABB.test.js +++ /dev/null @@ -1,104 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../mock-open-scd.js"); -var UpdateDescriptionABB_js_1 = require("../../../src/menu/UpdateDescriptionABB.js"); -describe('Update method for desc attributes in ABB IEDs', function () { - if (customElements.get('update-description-abb') === undefined) - customElements.define('update-description-abb', UpdateDescriptionABB_js_1["default"]); - var parent; - var element; - var doc; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/updatedesc/updatedescABB.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - element.doc = doc; - element.run(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates desc attributes for ExtRef elements with existing intAddr attribute', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect(doc.querySelector('IED[name="IED1"] LN[lnClass="CSWI"][inst="1"] ExtRef:not([desc])')).to.exist; - (_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]').click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect(doc.querySelector('IED[name="IED1"] LN[lnClass="CSWI"][inst="1"] ExtRef[desc="GOOSERCV_BIN.3.I1"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('does not create desc attributes for ExtRef elements with missing intAddr attribute', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - testing_1.expect(doc.querySelector('IED[name="IED1"] LN[lnClass="CSWI"][inst="2"] ExtRef:not([desc])')).to.exist; - (_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-button[slot="primaryAction"]').click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _c.sent(); - testing_1.expect(doc.querySelector('IED[name="IED1"] LN[lnClass="CSWI"][inst="2"] ExtRef:not([desc])')).to.exist; - return [2 /*return*/]; - } - }); - }); }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js b/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js deleted file mode 100644 index ba825c796c..0000000000 --- a/packages/open-scd/test/integration/validators/dist/ValidateSchema.test.js +++ /dev/null @@ -1,185 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../mock-open-scd.js"); -var ValidateSchema_js_1 = require("../../../src/validators/ValidateSchema.js"); -describe('ValidateSchema plugin', function () { - if (customElements.get('') === undefined) - customElements.define('validate-schema', ValidateSchema_js_1["default"]); - var parent; - var element; - var valid2007B4; - var invalid2007B; - before(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - element.pluginId = '/src/validators/ValidateSchema.js'; - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - describe('for valid SCL files', function () { - before(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - valid2007B4 = _a.sent(); - element.doc = valid2007B4; - element.docName = 'valid2007B'; - return [2 /*return*/]; - } - }); - }); }); - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - parent.diagnoses.clear(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - return [4 /*yield*/, element.validate()]; - case 2: - _a.sent(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('zeroissues indication looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); }); }); - it('indicates successful schema validation in the diagnoses pane', function () { return __awaiter(void 0, void 0, void 0, function () { - var lastEntry; - return __generator(this, function (_a) { - lastEntry = (parent.diagnoses.get('/src/validators/ValidateSchema.js')); - testing_1.expect(lastEntry.length).to.equal(1); - testing_1.expect(lastEntry[0].title).to.contain('valid2007B XML schema validation successful'); - return [2 /*return*/]; - }); - }); }); - it('indicates successful schema validation in the log', function () { return __awaiter(void 0, void 0, void 0, function () { - var lastEntry; - return __generator(this, function (_a) { - lastEntry = parent.log.pop(); - testing_1.expect(lastEntry.kind).to.equal('info'); - testing_1.expect(lastEntry.title).to.contain('valid2007B XML schema validation successful'); - return [2 /*return*/]; - }); - }); }); - }); - describe('for invalid SCL files', function () { - before(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/invalid2007B.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - invalid2007B = _a.sent(); - element.doc = invalid2007B; - element.docName = 'invalid2007B'; - return [4 /*yield*/, element.requestUpdate()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - parent.diagnoses.clear(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _a.sent(); - return [4 /*yield*/, element.validate()]; - case 2: - _a.sent(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('pushes issues to the diagnostics pane that look like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); }); }); - it('create issues in diagnose', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, testing_1.expect(parent.diagnoses.get('/src/validators/ValidateSchema.js')).to.not - .be.undefined]; - }); - }); }); - it('generates error messages in the log', function () { return __awaiter(void 0, void 0, void 0, function () { - var lastLogEntry; - return __generator(this, function (_a) { - lastLogEntry = parent.log.pop(); - testing_1.expect(lastLogEntry.kind).to.equal('warning'); - testing_1.expect(lastLogEntry.title).to.contain('invalid2007B XML schema validation failed'); - return [2 /*return*/]; - }); - }); }); - }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/integration/validators/dist/ValidateTemplates.test.js b/packages/open-scd/test/integration/validators/dist/ValidateTemplates.test.js deleted file mode 100644 index cf105af454..0000000000 --- a/packages/open-scd/test/integration/validators/dist/ValidateTemplates.test.js +++ /dev/null @@ -1,184 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../mock-open-scd.js"); -var ValidateTemplates_js_1 = require("../../../src/validators/ValidateTemplates.js"); -describe('ValidateTemplates OpenSCD integration test ', function () { - if (customElements.get('validate-templates') === undefined) - customElements.define('validate-templates', ValidateTemplates_js_1["default"]); - var parent; - var element; - var doc; - describe('with a valid DataTypeTemplates section', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/zeroissues.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n\n \n \n \n "], ["\n \n\n \n \n \n "])), doc, doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - element.pluginId = '/src/validators/ValidateTemplates.js'; - return [4 /*yield*/, element.validate()]; - case 3: - _a.sent(); - return [4 /*yield*/, parent.updateComplete]; - case 4: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('shows a "No errors" message in the diagnostics pane', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(parent.diagnosticUI).to.contain.text('No errors'); - return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with issues in the DataTypeTemplates section', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/datatypetemplateerrors.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n \n\n \n \n \n "], ["\n \n\n \n \n \n "])), doc, doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - element.pluginId = '/src/validators/ValidateTemplates.js'; - return [4 /*yield*/, element.validate()]; - case 3: - _a.sent(); - return [4 /*yield*/, parent.updateComplete]; - case 4: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('generates issues in the diagnistics pane', function () { return __awaiter(void 0, void 0, void 0, function () { - var issues; - return __generator(this, function (_a) { - issues = parent.diagnoses.get('/src/validators/ValidateTemplates.js'); - testing_1.expect(issues === null || issues === void 0 ? void 0 : issues.length).to.equal(28); - return [2 /*return*/]; - }); - }); }).timeout(1000); - it('pushes issues to the diagnostics pane that look like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with schema version smaller "2007B3"', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/valid2007B.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n \n\n \n \n \n "], ["\n \n\n \n \n \n "])), doc, doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - element.pluginId = '/src/validators/ValidateTemplates.js'; - return [4 /*yield*/, element.validate()]; - case 3: - _a.sent(); - return [4 /*yield*/, parent.updateComplete]; - case 4: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('shows only one message in the diagnostics pane', function () { return __awaiter(void 0, void 0, void 0, function () { - var issues; - return __generator(this, function (_a) { - issues = parent.diagnoses.get('/src/validators/ValidateTemplates.js'); - testing_1.expect(issues === null || issues === void 0 ? void 0 : issues.length).to.equal(1); - return [2 /*return*/]; - }); - }); }).timeout(1000); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - return [4 /*yield*/, testing_1.expect(parent.diagnosticUI).to.equalSnapshot()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js b/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js deleted file mode 100644 index d6c6610ec1..0000000000 --- a/packages/open-scd/test/integration/wizards/dist/bda-wizarding-editing.test.js +++ /dev/null @@ -1,255 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../mock-open-scd.js"); -var Templates_js_1 = require("../../../src/editors/Templates.js"); -describe('BDA wizarding editing integration', function () { - if (customElements.get('templates-editor') === undefined) - customElements.define('templates-editor', Templates_js_1["default"]); - var doc; - var parent; - var templates; - var dATypeList; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; - case 1: - parent = _b.sent(); - templates = parent.getActivePlugin(); - return [4 /*yield*/, fetch('/test/testfiles/templates/datypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 2: - doc = _b.sent(); - templates.doc = doc; - return [4 /*yield*/, templates.updateComplete]; - case 3: - _b.sent(); - dATypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="datypelist"]')); - return [2 /*return*/]; - } - }); - }); }); - describe('defines a editBDaWizard to edit an existing BDA', function () { - var nameField; - var primayAction; - var deleteButton; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - (dATypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod.SBOw"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _e.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _e.sent(); // await animation - ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod.SBOw>ctlVal"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _e.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _e.sent(); // await animation - nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); - primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('Remove'); })); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('edits BDA element', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="ctlVal"]')).to.exist; - nameField.value = 'newCtlVal'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="ctlVal"]')).to.not.exist; - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="newCtlVal"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('deletes the BDA element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="ctlVal"]')).to.exist; - testing_1.expect(doc.querySelectorAll('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA').length).to.equal(6); - deleteButton.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="ctlVal"]')).to.not.exist; - testing_1.expect(doc.querySelectorAll('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA').length).to.equal(5); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('defines a createBDaWizard to create a new BDA element', function () { - var nameField; - var descField; - var sAddrField; - var bTypeSelect; - var valKindSelect; - var valImportSelect; - var primayAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g, _h; - return __generator(this, function (_j) { - switch (_j.label) { - case 0: - (dATypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod.SBOw"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _j.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _j.sent(); // await animation - ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-menu > mwc-list-item')[1]).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _j.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _j.sent(); // await animation - nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); - descField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="desc"]')); - sAddrField = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-textfield[label="sAddr"]')); - bTypeSelect = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('wizard-select[label="bType"]')); - valKindSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('wizard-select[label="valKind"]')); - valImportSelect = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelector('wizard-checkbox[label="valImport"]')); - primayAction = ((_h = parent.wizardUI.dialog) === null || _h === void 0 ? void 0 : _h.querySelector('mwc-button[slot="primaryAction"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates a new BDA element', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="newBDAElement"]')).to.not.exist; - nameField.value = 'newBDAElement'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - bTypeSelect.value = 'BOOLEAN'; - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _a.sent(); - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="newBDAElement"]:not([desc]):not([sAddr])[bType="BOOLEAN"]:not([valKind]):not([valImport])')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('creates yet another new BDA element', function () { return __awaiter(void 0, void 0, void 0, function () { - var name, desc, sAddr; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - name = 'newBDAElement2'; - desc = 'newBDAdesc'; - sAddr = 'myNewAddr'; - testing_1.expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="newBDAElement2"]')).to.not.exist; - nameField.value = name; - descField.nullable = false; - descField.value = desc; - sAddrField.nullable = false; - sAddrField.value = sAddr; - bTypeSelect.value = 'BOOLEAN'; - valKindSelect.nullable = false; - valKindSelect.value = 'RO'; - valImportSelect.nullable = false; - valImportSelect.maybeValue = 'true'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector("DAType[id=\"Dummy.LLN0.Mod.SBOw\"] >" + - ("BDA[name=\"" + name + "\"][desc=\"" + desc + "\"][sAddr=\"" + sAddr + "\"][bType=\"BOOLEAN\"]:not([type])[valKind=\"RO\"][valImport=\"true\"]"))).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js b/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js deleted file mode 100644 index d369f9a937..0000000000 --- a/packages/open-scd/test/integration/wizards/dist/da-wizarding-editing.test.js +++ /dev/null @@ -1,273 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../mock-open-scd.js"); -var Templates_js_1 = require("../../../src/editors/Templates.js"); -describe('DA wizarding editing integration', function () { - if (customElements.get('templates-editor') === undefined) - customElements.define('templates-editor', Templates_js_1["default"]); - var doc; - var parent; - var templates; - var dOTypeList; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/templates/dotypes.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _b.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _b.sent(); - templates = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _b.sent(); - dOTypeList = ((_a = templates.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list[id="dotypelist"]')); - return [2 /*return*/]; - } - }); - }); }); - describe('defines a editDaWizard to edit an existing DA', function () { - var nameField; - var primayAction; - var deleteButton; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - (dOTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _e.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _e.sent(); // await animation - ((_b = (_a = parent.wizardUI) === null || _a === void 0 ? void 0 : _a.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod>stVal"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _e.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _e.sent(); // await animation - nameField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="name"]')); - primayAction = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('mwc-button[slot="primaryAction"]')); - deleteButton = (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('Remove'); })); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('edits DA attributes name', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).to.exist; - nameField.value = 'newCtlVal'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).to.not.exist; - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="newCtlVal"]')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('deletes the DA element on delete button click', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).to.exist; - testing_1.expect(doc.querySelectorAll('DOType[id="Dummy.LLN0.Mod"] > DA').length).to.equal(14); - deleteButton.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).to.not.exist; - testing_1.expect(doc.querySelectorAll('DOType[id="Dummy.LLN0.Mod"] > DA').length).to.equal(13); - return [2 /*return*/]; - } - }); - }); }); - it('does not edit DA element without changes', function () { return __awaiter(void 0, void 0, void 0, function () { - var originData; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - originData = (doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]')).cloneNode(true); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - testing_1.expect(originData.isEqualNode(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="stVal"]'))).to.be["true"]; - return [2 /*return*/]; - } - }); - }); }); - }); - describe('defines a createDaWizard to create a new DA element', function () { - var nameField; - var descField; - var sAddrField; - var bTypeSelect; - var valKindSelect; - var valImportSelect; - var fcSelect; - var primayAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g, _h; - return __generator(this, function (_j) { - switch (_j.label) { - case 0: - (dOTypeList.querySelector('mwc-list-item[value="#Dummy.LLN0.Mod"]')).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _j.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 2: - _j.sent(); // await animation - (Array.from(parent.wizardUI.dialog.querySelectorAll('mwc-menu > mwc-list-item')).find(function (item) { return item.innerHTML.includes('Data attribute'); })).click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _j.sent(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })]; - case 4: - _j.sent(); // await animation - nameField = ((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('wizard-textfield[label="name"]')); - descField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="desc"]')); - sAddrField = ((_c = parent.wizardUI.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('wizard-textfield[label="sAddr"]')); - bTypeSelect = ((_d = parent.wizardUI.dialog) === null || _d === void 0 ? void 0 : _d.querySelector('wizard-select[label="bType"]')); - valKindSelect = ((_e = parent.wizardUI.dialog) === null || _e === void 0 ? void 0 : _e.querySelector('wizard-select[label="valKind"]')); - valImportSelect = ((_f = parent.wizardUI.dialog) === null || _f === void 0 ? void 0 : _f.querySelector('wizard-checkbox[label="valImport"]')); - fcSelect = ((_g = parent.wizardUI.dialog) === null || _g === void 0 ? void 0 : _g.querySelector('wizard-select[label="fc"]')); - primayAction = ((_h = parent.wizardUI.dialog) === null || _h === void 0 ? void 0 : _h.querySelector('mwc-button[slot="primaryAction"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates a new DA element', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="newDAElement"]')).to.not.exist; - nameField.value = 'newDAElement'; - fcSelect.value = 'ST'; - bTypeSelect.value = 'Struct'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"] > ' + - 'DA[name="newDAElement"]:not([desc]):not([sAddr])[bType="Struct"]' + - '[type="Dummy_origin"]:not([valKind]):not([valImport])')).to.exist; - return [2 /*return*/]; - } - }); - }); }); - it('creates yet another new DA element', function () { return __awaiter(void 0, void 0, void 0, function () { - var name, desc, sAddr; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - name = 'newDAElement2'; - desc = 'newDAdesc'; - sAddr = 'myNewAddr'; - testing_1.expect(doc.querySelector('DAType[id="#Dummy.LLN0.Mod"] > DA[name="newDAElement2"]')).to.not.exist; - nameField.value = name; - descField.nullable = false; - descField.value = desc; - sAddrField.nullable = false; - sAddrField.value = sAddr; - bTypeSelect.value = 'BOOLEAN'; - valKindSelect.nullable = false; - valKindSelect.value = 'RO'; - valImportSelect.nullable = false; - valImportSelect.maybeValue = 'true'; - fcSelect.value = 'ST'; - return [4 /*yield*/, parent.requestUpdate()]; - case 1: - _a.sent(); - primayAction.click(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - testing_1.expect(doc.querySelector("DOType[id=\"Dummy.LLN0.Mod\"] >" + - ("DA[name=\"" + name + "\"][desc=\"" + desc + "\"][sAddr=\"" + sAddr + "\"][bType=\"BOOLEAN\"]") + - ":not([type])[valKind=\"RO\"][valImport=\"true\"]")).to.exist; - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js b/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js deleted file mode 100644 index 3cf8ef12a1..0000000000 --- a/packages/open-scd/test/unit/editors/cleanup/dist/control-blocks-container.test.js +++ /dev/null @@ -1,182 +0,0 @@ -'use strict'; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../../src/editors/cleanup/control-blocks-container.js"); -describe('Cleanup: Control Blocks Container', function () { - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; - case 1: - element = _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - describe('without a doc loaded', function () { - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('With a test file loaded', function () { - var doc; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; - case 2: - element = _a.sent(); - return [4 /*yield*/, element.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates correct number of checkboxes for the expected unreferenced control blocks', function () { - testing_1.expect(Array.from(element.unreferencedControls).length).to.equal(5); - }); - it('has the remove button disabled by default', function () { - testing_1.expect(element.cleanButton).to.have.property('disabled', true); - }); - it('has the remove button enabled after selecting an item', function () { return __awaiter(void 0, void 0, void 0, function () { - var firstCheckListItem; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - firstCheckListItem = element.cleanupListItems[0]; - return [4 /*yield*/, firstCheckListItem.click()]; - case 1: - _a.sent(); - return [4 /*yield*/, element.cleanupList.layout()]; - case 2: - _a.sent(); - testing_1.expect(element.cleanButton).to.have.property('disabled', false); - return [2 /*return*/]; - } - }); - }); }); - it('after selecting and deselecting an item the remove button is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { - var firstCheckListItem; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - firstCheckListItem = element.cleanupListItems[0]; - return [4 /*yield*/, firstCheckListItem.click()]; - case 1: - _a.sent(); - return [4 /*yield*/, element.cleanupList.layout()]; - case 2: - _a.sent(); - return [4 /*yield*/, firstCheckListItem.click()]; - case 3: - _a.sent(); - return [4 /*yield*/, element.cleanupList.layout()]; - case 4: - _a.sent(); - testing_1.expect(element.cleanButton).to.have.property('disabled', true); - return [2 /*return*/]; - } - }); - }); }); - it('after clicking select all the button is not disabled', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - checkbox = element - .shadowRoot.querySelector('.cleanupList') - .shadowRoot.querySelector('.checkall') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 1: - _b.sent(); - return [4 /*yield*/, ((_a = element.cleanupList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 2: - _b.sent(); - testing_1.expect(element.cleanButton).to.have.property('disabled', false); - return [2 /*return*/]; - } - }); - }); }); - /* This test is currently failing and has been commented out - TODO: Investigate further. It appears that a filtered list will not - unselect all if there are hidden items. */ - // it('after clicking select all twice the button is disabled', async () => { - // const checkbox = element - // .shadowRoot!.querySelector('.cleanupList')! - // .shadowRoot!.querySelector('.checkall')! - // .querySelector('mwc-checkbox')!; - // await checkbox.click(); - // await element.cleanupList?.layout(); - // await checkbox.click(); - // await element.cleanupList?.layout(); - // expect(element.cleanButton).to.have.property('disabled', true); - // }); - }); -}); -var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js b/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js deleted file mode 100644 index 6cac5d73ff..0000000000 --- a/packages/open-scd/test/unit/editors/cleanup/dist/datasets-container.test.js +++ /dev/null @@ -1,190 +0,0 @@ -'use strict'; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -require("../../../../src/editors/cleanup/datasets-container.js"); -describe('Cleanup: Datasets Container', function () { - var element; - var parent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - describe('without a doc loaded', function () { - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with a test file loaded', function () { - var doc; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates correct number of checkboxes for the expected unreferenced datasets', function () { - testing_1.expect(Array.from(element.dataSetItems).length).to.equal(2); - }); - it('has the remove button disabled by default', function () { - testing_1.expect(element.cleanupButton).to.have.property('disabled', true); - }); - it('has the remove button enabled after selecting an item', function () { return __awaiter(void 0, void 0, void 0, function () { - var firstCheckListItem; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - firstCheckListItem = element.dataSetItems[0]; - return [4 /*yield*/, firstCheckListItem.click()]; - case 1: - _a.sent(); - testing_1.expect(element.cleanupButton).to.have.property('disabled', false); - return [2 /*return*/]; - } - }); - }); }); - it('after selecting and deselecting an item the remove button is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { - var firstCheckListItem; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - firstCheckListItem = element.dataSetItems[0]; - return [4 /*yield*/, firstCheckListItem.click()]; - case 1: - _a.sent(); - return [4 /*yield*/, firstCheckListItem.click()]; - case 2: - _a.sent(); - testing_1.expect(element.cleanupButton).to.have.property('disabled', true); - return [2 /*return*/]; - } - }); - }); }); - it('after clicking select all the button is not disabled', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - checkbox = element - .shadowRoot.querySelector('.dataSetList') - .shadowRoot.querySelector('.checkall') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 1: - _b.sent(); - return [4 /*yield*/, ((_a = element.dataSetList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 2: - _b.sent(); - testing_1.expect(element.cleanupButton).to.have.property('disabled', false); - return [2 /*return*/]; - } - }); - }); }); - it('after clicking select all twice the button is disabled', function () { return __awaiter(void 0, void 0, void 0, function () { - var checkbox; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - checkbox = element - .shadowRoot.querySelector('.dataSetList') - .shadowRoot.querySelector('.checkall') - .querySelector('mwc-checkbox'); - return [4 /*yield*/, checkbox.click()]; - case 1: - _b.sent(); - return [4 /*yield*/, checkbox.click()]; - case 2: - _b.sent(); - return [4 /*yield*/, ((_a = element.dataSetList) === null || _a === void 0 ? void 0 : _a.layout())]; - case 3: - _b.sent(); - testing_1.expect(element.cleanupButton).to.have.property('disabled', true); - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js b/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js deleted file mode 100644 index d7a0e298ad..0000000000 --- a/packages/open-scd/test/unit/editors/cleanup/dist/datatypes-container.test.js +++ /dev/null @@ -1,131 +0,0 @@ -'use strict'; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -require("../../../../src/editors/cleanup/datatypes-container.js"); -describe('Cleanup: DataTypes Container', function () { - var element; - var parent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - describe('without a doc loaded', function () { - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('With a test file loaded', function () { - var doc; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/cleanup.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, element.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates correct number of checkboxes for the expected unreferenced datatypes', function () { - testing_1.expect(Array.from(element.unreferencedDataTypes).length).to.equal(9); - }); - it('has the remove button disabled by default', function () { - testing_1.expect(element.cleanButton).to.have.property('disabled', true); - }); - it('has the remove button enabled after selecting an item', function () { return __awaiter(void 0, void 0, void 0, function () { - var firstCheckListItem; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - firstCheckListItem = element.cleanupListItems[0]; - return [4 /*yield*/, firstCheckListItem.click()]; - case 1: - _a.sent(); - return [4 /*yield*/, element.cleanupList.layout()]; - case 2: - _a.sent(); - testing_1.expect(element.cleanButton).to.have.property('disabled', false); - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2; diff --git a/packages/open-scd/test/unit/editors/subscription/dist/fcda-binding-list.test.js b/packages/open-scd/test/unit/editors/subscription/dist/fcda-binding-list.test.js deleted file mode 100644 index d5a08f90e3..0000000000 --- a/packages/open-scd/test/unit/editors/subscription/dist/fcda-binding-list.test.js +++ /dev/null @@ -1,434 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -require("../../../mock-open-scd.js"); -require("../../../../src/editors/subscription/fcda-binding-list.js"); -var sinon_1 = require("sinon"); -describe('fcda-binding-list', function () { - var parent; - var element; - var doc; - var selectEvent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - localStorage.clear(); - selectEvent = sinon_1.spy(); - window.addEventListener('fcda-select', selectEvent); - return [2 /*return*/]; - }); - }); }); - describe('without a doc loaded', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('no event is fired, because no property are changed', function () { - testing_1.expect(selectEvent).to.not.have.been.called; - }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""]))))]; - case 1: - element = _a.sent(); - return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with a SampledValueControl doc loaded', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - localStorage.clear(); - return [4 /*yield*/, fetch('/test/testfiles/editors/LaterBindingSMV2007B4.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n \n "], ["\n \n "])), doc, true))]; - case 2: - parent = _a.sent(); - element = parent.getPlugin('fcda-binding-list'); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('the SVC editor is opened', function () { return __awaiter(void 0, void 0, void 0, function () { - var nameField; - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - // Select the first list item that has an edit button, this should be an SVC Element. - return [4 /*yield*/, ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-list-item > mwc-icon-button[icon="edit"]')).click()]; - case 1: - // Select the first list item that has an edit button, this should be an SVC Element. - _c.sent(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _c.sent(); - nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); - testing_1.expect(nameField.value).to.be.equal('fullSmv'); - return [2 /*return*/]; - } - }); - }); }); - it('event is fired, but properties are undefined', function () { - testing_1.expect(selectEvent).to.have.been.calledOnce; - testing_1.expect(selectEvent.args[0][0].detail.selectedSvcElement).to.be.undefined; - testing_1.expect(selectEvent.args[0][0].detail.selectedFcdaElement).to.be.undefined; - }); - it('event is fired with selected elements', function () { return __awaiter(void 0, void 0, void 0, function () { - var listItem; - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - selectEvent.resetHistory(); - listItem = Array.from((_b = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('mwc-list-item.subitem')) !== null && _b !== void 0 ? _b : []).filter(function (listItem) { - var _a; - var value = (_a = listItem.getAttribute('value')) !== null && _a !== void 0 ? _a : ''; - return (value.includes('currentOnly') && value.includes('AmpSv instMag.i')); - })[0]; - listItem.click(); - return [4 /*yield*/, element.updateComplete]; - case 1: - _c.sent(); - testing_1.expect(selectEvent).to.have.been.called; - testing_1.expect(selectEvent.args[0][0].detail.control).to.equal(doc.querySelector('IED[name="SMV_Publisher"] LN0 > SampledValueControl[name="currentOnly"]')); - testing_1.expect(selectEvent.args[0][0].detail.fcda).to.equal(doc.querySelector('IED[name="SMV_Publisher"] LN0 > DataSet[name="currentOnlysDataSet"] > ' + - 'FCDA[ldInst="CurrentTransformer"][prefix="L1"][lnClass="TCTR"][lnInst="1"][doName="AmpSv"][daName="instMag.i"][fc="MX"]')); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('is initially unfiltered', function () { return __awaiter(void 0, void 0, void 0, function () { - var displayedElements; - return __generator(this, function (_a) { - displayedElements = Array.from(element.shadowRoot.querySelectorAll('mwc-list-item')).filter(function (item) { - var displayStyle = getComputedStyle(item).display; - return displayStyle !== 'none' || displayStyle === undefined; - }); - testing_1.expect(displayedElements.length).to.equal(27); - return [2 /*return*/]; - }); - }); }); - it('allows filtering of only not subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { - var fcdaList, displayedElements; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - element.actionsMenuIcon.click(); - return [4 /*yield*/, element.updateComplete]; - case 1: - _b.sent(); - (element.actionsMenu.querySelector('.filter-subscribed')).click(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 200); })]; - case 2: - _b.sent(); // await animation - return [4 /*yield*/, element.updateComplete]; - case 3: - _b.sent(); - fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); - displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { - var displayStyle = getComputedStyle(item).display; - return displayStyle !== 'none' || displayStyle === undefined; - }); - testing_1.expect(displayedElements.length).to.equal(24); - return [2 /*return*/]; - } - }); - }); }); - it('allows filtering of only subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { - var fcdaList, displayedElements; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - element.actionsMenuIcon.click(); - return [4 /*yield*/, element.updateComplete]; - case 1: - _b.sent(); - (element.actionsMenu.querySelector('.filter-not-subscribed')).click(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 200); })]; - case 2: - _b.sent(); // await animation - return [4 /*yield*/, element.updateComplete]; - case 3: - _b.sent(); - fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); - displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { - var displayStyle = getComputedStyle(item).display; - return displayStyle !== 'none' || displayStyle === undefined; - }); - testing_1.expect(displayedElements.length).to.equal(5); - return [2 /*return*/]; - } - }); - }); }); - it('allows filtering out of all subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { - var fcdaList, displayedElements; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - element.actionsMenuIcon.click(); - return [4 /*yield*/, element.updateComplete]; - case 1: - _b.sent(); - (element.actionsMenu.querySelector('.filter-subscribed')).click(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; - case 2: - _b.sent(); // await animation - return [4 /*yield*/, element.updateComplete]; - case 3: - _b.sent(); - element.actionsMenuIcon.click(); - return [4 /*yield*/, element.updateComplete]; - case 4: - _b.sent(); - (element.actionsMenu.querySelector('.filter-not-subscribed')).click(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; - case 5: - _b.sent(); // await animation - return [4 /*yield*/, element.updateComplete]; - case 6: - _b.sent(); - fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); - displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { - var displayStyle = getComputedStyle(item).display; - return displayStyle !== 'none' || displayStyle === undefined; - }); - testing_1.expect(displayedElements.length).to.equal(0); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('with a GSEControl doc loaded', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - localStorage.clear(); - return [4 /*yield*/, fetch('/test/testfiles/editors/LaterBindingGOOSE2007B4.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n \n "], ["\n \n "])), doc, true))]; - case 2: - parent = _a.sent(); - element = parent.getPlugin('fcda-binding-list'); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('the GOOSE editor is opened', function () { return __awaiter(void 0, void 0, void 0, function () { - var nameField; - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - // Select the first list item that has an edit button, this should be an GOOSE Element. - return [4 /*yield*/, ((_a = element === null || element === void 0 ? void 0 : element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-list-item > mwc-icon-button[icon="edit"]')).click()]; - case 1: - // Select the first list item that has an edit button, this should be an GOOSE Element. - _c.sent(); - return [4 /*yield*/, parent.updateComplete]; - case 2: - _c.sent(); - nameField = ((_b = parent.wizardUI.dialog) === null || _b === void 0 ? void 0 : _b.querySelector('wizard-textfield[label="name"]')); - testing_1.expect(nameField.value).to.be.equal('GOOSE2'); - return [2 /*return*/]; - } - }); - }); }); - it('looks like the latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(element).shadowDom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('is initially unfiltered', function () { return __awaiter(void 0, void 0, void 0, function () { - var displayedElements; - return __generator(this, function (_a) { - displayedElements = Array.from(element.shadowRoot.querySelectorAll('mwc-list-item')).filter(function (item) { - var displayStyle = getComputedStyle(item).display; - return displayStyle !== 'none' || displayStyle === undefined; - }); - testing_1.expect(displayedElements.length).to.equal(9); - return [2 /*return*/]; - }); - }); }); - it('allows filtering of only not subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { - var fcdaList, displayedElements; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - element.actionsMenuIcon.click(); - return [4 /*yield*/, element.updateComplete]; - case 1: - _b.sent(); - (element.actionsMenu.querySelector('.filter-subscribed')).click(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; - case 2: - _b.sent(); // await animation - return [4 /*yield*/, element.updateComplete]; - case 3: - _b.sent(); - fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); - displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { - var displayStyle = getComputedStyle(item).display; - return displayStyle !== 'none' || displayStyle === undefined; - }); - testing_1.expect(displayedElements.length).to.equal(3); - return [2 /*return*/]; - } - }); - }); }); - it('allows filtering of only subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { - var fcdaList, displayedElements; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - element.actionsMenuIcon.click(); - return [4 /*yield*/, element.updateComplete]; - case 1: - _b.sent(); - (element.actionsMenu.querySelector('.filter-not-subscribed')).click(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; - case 2: - _b.sent(); // await animation - return [4 /*yield*/, element.updateComplete]; - case 3: - _b.sent(); - fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); - displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { - var displayStyle = getComputedStyle(item).display; - return displayStyle !== 'none' || displayStyle === undefined; - }); - testing_1.expect(displayedElements.length).to.equal(6); - return [2 /*return*/]; - } - }); - }); }); - it('allows filtering out of all subscribed control blocks', function () { return __awaiter(void 0, void 0, void 0, function () { - var fcdaList, displayedElements; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - element.actionsMenuIcon.click(); - return [4 /*yield*/, element.updateComplete]; - case 1: - _b.sent(); - (element.actionsMenu.querySelector('.filter-subscribed')).click(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; - case 2: - _b.sent(); // await animation - return [4 /*yield*/, element.updateComplete]; - case 3: - _b.sent(); - element.actionsMenuIcon.click(); - return [4 /*yield*/, element.updateComplete]; - case 4: - _b.sent(); - (element.actionsMenu.querySelector('.filter-not-subscribed')).click(); - return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 300); })]; - case 5: - _b.sent(); // await animation - return [4 /*yield*/, element.updateComplete]; - case 6: - _b.sent(); - fcdaList = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('filtered-list'); - displayedElements = Array.from(fcdaList.querySelectorAll('mwc-list-item')).filter(function (item) { - var displayStyle = getComputedStyle(item).display; - return displayStyle !== 'none' || displayStyle === undefined; - }); - testing_1.expect(displayedElements.length).to.equal(0); - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2, templateObject_3, templateObject_4; diff --git a/packages/open-scd/test/unit/menu/dist/SclHistory.test.js b/packages/open-scd/test/unit/menu/dist/SclHistory.test.js deleted file mode 100644 index 71cbb53ff7..0000000000 --- a/packages/open-scd/test/unit/menu/dist/SclHistory.test.js +++ /dev/null @@ -1,158 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -var SclHistory_js_1 = require("../../../src/menu/SclHistory.js"); -describe('testing sclHistory dialog', function () { - if (customElements.get('scl-history') === undefined) - customElements.define('scl-history', SclHistory_js_1["default"]); - var plugin; - var doc; - describe('with a document loaded containing SCL history items', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/history.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject([" "], [" "])), doc))]; - case 2: - plugin = _a.sent(); - plugin.run(); - return [4 /*yield*/, plugin.requestUpdate()]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like its latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(plugin.historyLog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('has 7 items in the history list', function () { - testing_1.expect(plugin.sclHistory.length).to.be.equal(7); - }); - describe('testing createMessage function', function () { - it('creates a message with two valid strings', function () { - testing_1.expect(plugin['createMessage']('string who', 'string why')).to.be.equal('string who : string why'); - }); - it('creates a message with one valid string or returns undefined', function () { - testing_1.expect(plugin['createMessage']('string who', null)).to.be.equal('string who'); - testing_1.expect(plugin['createMessage'](null, 'string why')).to.be.equal('string why'); - testing_1.expect(plugin['createMessage'](null, null)).to.be.undefined; - }); - }); - }); - describe('with no document', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject([" "], [" "]))))]; - case 1: - plugin = _a.sent(); - plugin.run(); - return [4 /*yield*/, plugin.requestUpdate()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like its latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(plugin.historyLog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('has no items in the history list', function () { - testing_1.expect(plugin.sclHistory).to.be.empty; - }); - }); - describe('with a document without SCL history items', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/no-history.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject([" "], [" "])), doc))]; - case 2: - plugin = _a.sent(); - plugin.run(); - return [4 /*yield*/, plugin.requestUpdate()]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('looks like its latest snapshot', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(plugin.historyLog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('has no items in the history list', function () { - testing_1.expect(plugin.sclHistory).to.be.empty; - }); - }); -}); -var templateObject_1, templateObject_2, templateObject_3; diff --git a/packages/open-scd/test/unit/menu/dist/UpdateDescriptionSEL.test.js b/packages/open-scd/test/unit/menu/dist/UpdateDescriptionSEL.test.js deleted file mode 100644 index ceea54498a..0000000000 --- a/packages/open-scd/test/unit/menu/dist/UpdateDescriptionSEL.test.js +++ /dev/null @@ -1,236 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -var sinon_1 = require("sinon"); -require("../../mock-open-scd.js"); -var foundation_js_1 = require("../../../src/foundation.js"); -var UpdateDescriptionSEL_js_1 = require("../../../src/menu/UpdateDescriptionSEL.js"); -describe('Update method for desc attributes in SEL IEDs', function () { - if (customElements.get('update-description-sel') === undefined) - customElements.define('update-description-sel', UpdateDescriptionSEL_js_1["default"]); - var parent; - var element; - var wizardAction; - var editorAction; - var signalList; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; - case 1: - parent = _a.sent(); - element = (parent.querySelector('update-description-sel')); - return [4 /*yield*/, element.requestUpdate()]; - case 2: - _a.sent(); - editorAction = sinon_1.spy(); - window.addEventListener('editor-action', editorAction); - wizardAction = sinon_1.spy(); - window.addEventListener('wizard', wizardAction); - return [2 /*return*/]; - } - }); - }); }); - it('allows to select signal list only as csv file', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - testing_1.expect(element.pluginFileUI).to.have.property('accept', '.csv'); - testing_1.expect(element.pluginFileUI).to.have.property('type', 'file'); - return [2 /*return*/]; - }); - }); }); - it('allows to select signal list as csv file', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, element.run()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - describe('working on SCL files without manufacturer SEL', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var doc; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('test/testfiles/validators/zeroissues.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - element.doc = doc; - return [4 /*yield*/, fetch('test/testfiles/updatedesc/testSignalListSemicolon.csv').then(function (response) { return response.text(); })]; - case 2: - signalList = _a.sent(); - element.processSignalList(signalList); - return [4 /*yield*/, parent.requestUpdate()]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('cannot find any desc fields to update', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - testing_1.expect(wizardAction).to.have.been.calledOnce; - testing_1.expect((_a = parent.wizardUI.dialog) === null || _a === void 0 ? void 0 : _a.querySelector('mwc-checked-list-item')).to - .be["null"]; - return [2 /*return*/]; - }); - }); }); - }); - describe('working on SCL files containing manufacturer SEL', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var doc; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('test/testfiles/updatedesc/updatedescSEL.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - element.doc = doc; - return [2 /*return*/]; - } - }); - }); }); - describe('using a semicolon separated file', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('test/testfiles/updatedesc/testSignalListSemicolon.csv').then(function (response) { return response.text(); })]; - case 1: - signalList = _a.sent(); - element.processSignalList(signalList); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates filtered list with all proposed desc attribute updates', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('allows to update selected desc attributes updates', function () { return __awaiter(void 0, void 0, void 0, function () { - var complexAction, _i, _a, action; - var _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - (_c = (_b = parent.wizardUI) === null || _b === void 0 ? void 0 : _b.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-button[slot="primaryAction"]').click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _d.sent(); - testing_1.expect(editorAction).to.have.been.calledOnce; - testing_1.expect(editorAction.args[0][0].detail.action).to.not.satisfy(foundation_js_1.isSimple); - complexAction = (editorAction.args[0][0].detail.action); - testing_1.expect(complexAction.actions.length).to.equal(7); - for (_i = 0, _a = complexAction.actions; _i < _a.length; _i++) { - action = _a[_i]; - testing_1.expect(action).to.satisfy(foundation_js_1.isReplace); - } - return [2 /*return*/]; - } - }); - }); }); - }); - describe('using a comma separated (CSV) file', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('test/testfiles/updatedesc/testSignalListComma.csv').then(function (response) { return response.text(); })]; - case 1: - signalList = _a.sent(); - element.processSignalList(signalList); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates filtered list with all proposed desc attribute updates', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).dom.to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('allows to update selected desc attributes updates', function () { return __awaiter(void 0, void 0, void 0, function () { - var complexAction, _i, _a, action; - var _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - (_c = (_b = parent.wizardUI) === null || _b === void 0 ? void 0 : _b.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-button[slot="primaryAction"]').click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _d.sent(); - testing_1.expect(editorAction).to.have.been.calledOnce; - testing_1.expect(editorAction.args[0][0].detail.action).to.not.satisfy(foundation_js_1.isSimple); - complexAction = (editorAction.args[0][0].detail.action); - testing_1.expect(complexAction.actions.length).to.equal(7); - for (_i = 0, _a = complexAction.actions; _i < _a.length; _i++) { - action = _a[_i]; - testing_1.expect(action).to.satisfy(foundation_js_1.isReplace); - } - return [2 /*return*/]; - } - }); - }); }); - }); - }); -}); -var templateObject_1; diff --git a/packages/open-scd/test/unit/menu/dist/UpdateDescritionABB.test.js b/packages/open-scd/test/unit/menu/dist/UpdateDescritionABB.test.js deleted file mode 100644 index 62a8a5e2d4..0000000000 --- a/packages/open-scd/test/unit/menu/dist/UpdateDescritionABB.test.js +++ /dev/null @@ -1,150 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -var sinon_1 = require("sinon"); -require("../../mock-open-scd.js"); -var foundation_js_1 = require("../../../src/foundation.js"); -var UpdateDescriptionABB_js_1 = require("../../../src/menu/UpdateDescriptionABB.js"); -describe('Update method for desc attributes in ABB IEDs', function () { - if (customElements.get('update-description-abb') === undefined) - customElements.define('update-description-abb', UpdateDescriptionABB_js_1["default"]); - var parent; - var element; - var editorAction; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "]))))]; - case 1: - parent = _a.sent(); - element = parent.getActivePlugin(); - editorAction = sinon_1["default"].spy(); - window.addEventListener('editor-action', editorAction); - return [2 /*return*/]; - } - }); - }); }); - describe('working on SCL files without manufacturer ABB', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var doc; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/zeroissues.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - element.doc = doc; - element.run(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates an empty wizard indicating not found desc updates', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - }); - describe('working on SCL files containing manufacturer ABB', function () { - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var doc; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/updatedesc/updatedescABB.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - element.doc = doc; - element.run(); - return [4 /*yield*/, parent.requestUpdate()]; - case 2: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates a wizard with all valid desc update possibilities', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, testing_1.expect(parent.wizardUI.dialog).to.equalSnapshot()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('creates wizard that on save triggers a complex action containing selected desc updates', function () { return __awaiter(void 0, void 0, void 0, function () { - var complexAction, _i, _a, action; - var _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - (_c = (_b = parent.wizardUI) === null || _b === void 0 ? void 0 : _b.dialog) === null || _c === void 0 ? void 0 : _c.querySelector('mwc-button[slot="primaryAction"]').click(); - return [4 /*yield*/, parent.updateComplete]; - case 1: - _d.sent(); - testing_1.expect(editorAction).to.have.been.calledOnce; - testing_1.expect(editorAction.args[0][0].detail.action).to.not.satisfy(foundation_js_1.isSimple); - complexAction = (editorAction.args[0][0].detail.action); - testing_1.expect(complexAction.actions.length).to.equal(2); - for (_i = 0, _a = complexAction.actions; _i < _a.length; _i++) { - action = _a[_i]; - testing_1.expect(action).to.satisfy(foundation_js_1.isReplace); - } - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1; From 7cf43b8fabcb129416a8ac04f0e4b4693e7b6457 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Thu, 15 Feb 2024 23:05:47 +0100 Subject: [PATCH 22/27] Removed dist folder --- .../validators/dist/ValidateTemplates.test.js | 218 ------------------ 1 file changed, 218 deletions(-) delete mode 100644 packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js diff --git a/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js b/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js deleted file mode 100644 index 1574112c7a..0000000000 --- a/packages/open-scd/test/unit/validators/dist/ValidateTemplates.test.js +++ /dev/null @@ -1,218 +0,0 @@ -"use strict"; -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -exports.__esModule = true; -var testing_1 = require("@open-wc/testing"); -var sinon_1 = require("sinon"); -require("../../mock-open-scd.js"); -var ValidateTemplates_js_1 = require("../../../src/validators/ValidateTemplates.js"); -describe('ValidateTemplates', function () { - if (customElements.get('validate-templates') === undefined) - customElements.define('validate-templates', ValidateTemplates_js_1["default"]); - var logEvent; - var issueEvent; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - logEvent = sinon_1.spy(); - issueEvent = sinon_1.spy(); - window.addEventListener('log', logEvent); - window.addEventListener('issue', issueEvent); - return [2 /*return*/]; - }); - }); }); - describe('dispatch', function () { - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var doc, parent; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/zeroissues.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n \n "], ["\n \n "])), doc, '/src/validators/ValidateTemplates.js'))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('triggers as newIssuesEvent for detail not containing kind', function () { - var detail = { - title: 'title', - message: 'message' - }; - element.dispatch(detail); - testing_1.expect(issueEvent).to.have.been.called; - testing_1.expect(logEvent).to.not.have.been.called; - testing_1.expect(issueEvent.args[0][0].type).to.equal('issue'); - testing_1.expect(issueEvent.args[0][0].detail.validatorId).to.equal('/src/validators/ValidateTemplates.js'); - testing_1.expect(issueEvent.args[0][0].detail.message).to.equal('message'); - testing_1.expect(issueEvent.args[0][0].detail.title).to.equal('title'); - }); - it('triggers as newLogEvent for detail containing kind info', function () { - var detail = { - kind: 'info', - title: 'title', - message: 'message' - }; - element.dispatch(detail); - testing_1.expect(logEvent).to.have.been.called; - testing_1.expect(issueEvent).to.not.have.been.called; - testing_1.expect(logEvent.args[0][0].type).to.equal('log'); - testing_1.expect(logEvent.args[0][0].detail.kind).to.equal('info'); - testing_1.expect(logEvent.args[0][0].detail.message).to.equal('message'); - testing_1.expect(logEvent.args[0][0].detail.title).to.equal('title'); - }); - it('triggers as newLogEvent for detail containing kind warning', function () { - var detail = { - kind: 'warning', - title: 'title', - message: 'message' - }; - element.dispatch(detail); - testing_1.expect(logEvent).to.have.been.called; - testing_1.expect(issueEvent).to.not.have.been.called; - testing_1.expect(logEvent.args[0][0].type).to.equal('log'); - testing_1.expect(logEvent.args[0][0].detail.kind).to.equal('warning'); - }); - it('triggers as newLogEvent for detail containing kind error', function () { - var detail = { - kind: 'error', - title: 'title', - message: 'message' - }; - element.dispatch(detail); - testing_1.expect(logEvent).to.have.been.called; - testing_1.expect(issueEvent).to.not.have.been.called; - testing_1.expect(logEvent.args[0][0].type).to.equal('log'); - testing_1.expect(logEvent.args[0][0].detail.kind).to.equal('error'); - }); - }); - describe('validate', function () { - var element; - beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { - var doc, parent; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, fetch('/test/testfiles/validators/zeroissues.scd') - .then(function (response) { return response.text(); }) - .then(function (str) { return new DOMParser().parseFromString(str, 'application/xml'); })]; - case 1: - doc = _a.sent(); - return [4 /*yield*/, testing_1.fixture(testing_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n \n "], ["\n \n "])), doc))]; - case 2: - parent = _a.sent(); - element = parent.getActivePlugin(); - return [4 /*yield*/, parent.updateComplete]; - case 3: - _a.sent(); - return [2 /*return*/]; - } - }); - }); }); - it('pushes only diag.zeroissues issue to diagnostics when no issues found', function () { return __awaiter(void 0, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, element.validate()]; - case 1: - _a.sent(); - testing_1.expect(issueEvent).to.have.been.calledOnce; - testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('No errors found in the project'); - return [2 /*return*/]; - } - }); - }); }); - it('pushes only diag.missingnsd issue to diagnostics pane for SCL version < 2007B3', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - (_a = element.doc.querySelector('SCL')) === null || _a === void 0 ? void 0 : _a.setAttribute('version', '2003'); - return [4 /*yield*/, element.validate()]; - case 1: - _b.sent(); - testing_1.expect(issueEvent).to.have.been.calledOnce; - testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('Cannot validate DataTypeTemplates. The version of the project must be higher than or equal to 2007B3'); - return [2 /*return*/]; - } - }); - }); }); - it('pushes only diag.missingnsd issue to diagnostics pane for SCL not having version information', function () { return __awaiter(void 0, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - (_a = element.doc.querySelector('SCL')) === null || _a === void 0 ? void 0 : _a.removeAttribute('version'); - (_b = element.doc.querySelector('SCL')) === null || _b === void 0 ? void 0 : _b.removeAttribute('revision'); - return [4 /*yield*/, element.validate()]; - case 1: - _c.sent(); - testing_1.expect(issueEvent).to.have.been.calledOnce; - testing_1.expect(issueEvent.args[0][0].detail.title).to.contain('Cannot validate DataTypeTemplates. The version of the project must be higher than or equal to 2007B3'); - return [2 /*return*/]; - } - }); - }); }); - it('does not trigger anything for SCL missing DataTypeTemplates', function () { return __awaiter(void 0, void 0, void 0, function () { - var data; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - data = element.doc.querySelector('DataTypeTemplates'); - (_a = element.doc.querySelector('SCL')) === null || _a === void 0 ? void 0 : _a.removeChild(data); - return [4 /*yield*/, element.validate()]; - case 1: - _b.sent(); - testing_1.expect(issueEvent).to.not.have.been.calledOnce; - return [2 /*return*/]; - } - }); - }); }); - }); -}); -var templateObject_1, templateObject_2; From 21a04344166a19e72e9c731867d9367dd75198cf Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Mon, 26 Feb 2024 15:20:48 +0100 Subject: [PATCH 23/27] Updated test --- packages/open-scd/src/addons/Waiter.ts | 14 - .../__snapshots__/Setting.test.snap.js | 176 --------- .../unit/__snapshots__/Setting.test.snap.js | 369 ++++++++++++++++++ 3 files changed, 369 insertions(+), 190 deletions(-) create mode 100644 packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js diff --git a/packages/open-scd/src/addons/Waiter.ts b/packages/open-scd/src/addons/Waiter.ts index 04a8300092..83bce55e0d 100644 --- a/packages/open-scd/src/addons/Waiter.ts +++ b/packages/open-scd/src/addons/Waiter.ts @@ -17,10 +17,7 @@ export class OscdWaiter extends LitElement { waiting = false; private work: Set> = new Set(); -<<<<<<< HEAD -======= ->>>>>>> main /** A promise which resolves once all currently pending work is done. */ workDone = Promise.allSettled(this.work); @@ -35,16 +32,6 @@ export class OscdWaiter extends LitElement { constructor() { super(); -<<<<<<< HEAD - this.addEventListener('pending-state', this.onPendingState); - } - - render(): TemplateResult { - return html` - - `; -======= - this.onPendingState = this.onPendingState.bind(this); } @@ -64,6 +51,5 @@ export class OscdWaiter extends LitElement { .closed=${!this.waiting} indeterminate >`; ->>>>>>> main } } diff --git a/packages/open-scd/test/integration/__snapshots__/Setting.test.snap.js b/packages/open-scd/test/integration/__snapshots__/Setting.test.snap.js index 0ab088d9f5..2e9c41bb9b 100644 --- a/packages/open-scd/test/integration/__snapshots__/Setting.test.snap.js +++ b/packages/open-scd/test/integration/__snapshots__/Setting.test.snap.js @@ -186,179 +186,3 @@ snapshots["Oscd-Settings upload .nsdoc file using event and looks like latest sn `; /* end snapshot Oscd-Settings upload .nsdoc file using event and looks like latest snapshot */ -snapshots["Oscd-Settings upload .nsdoc file using event and looks like latest snapshot"] = -` -

    - - - English - - - German (Deutsch) - - - - - - - - - - - - - - -
    - - -
    -

    - Uploaded NSDoc files -

    - - - -
    - - - - IEC 61850-7-2 - - - close - - - - - IEC 61850-7-3 - - - close - - - - - IEC 61850-7-4 - - - close - - - - - IEC 61850-8-1 - - - close - - - - - Cancel - - - Reset - - - Save - - -`; -/* end snapshot Oscd-Settings upload .nsdoc file using event and looks like latest snapshot */ - diff --git a/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js b/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js new file mode 100644 index 0000000000..9491f83fb1 --- /dev/null +++ b/packages/open-scd/test/unit/__snapshots__/Setting.test.snap.js @@ -0,0 +1,369 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["OSCD-Settings saves chosen .nsdoc file and looks like latest snapshot"] = +` +
    + + + English + + + German (Deutsch) + + + + + + + + + + + + + + +
    + + +
    +

    + Uploaded NSDoc files +

    + + + +
    + + + + IEC 61850-7-2 + + + 2007B3 + + + done + + + delete + + + + + IEC 61850-7-3 + + + close + + + + + IEC 61850-7-4 + + + close + + + + + IEC 61850-8-1 + + + close + + + + + Cancel + + + Reset + + + Save + +
    + + +`; +/* end snapshot OSCD-Settings saves chosen .nsdoc file and looks like latest snapshot */ + +snapshots["OSCD-Settings deletes a chosen .nsdoc file and looks like latest snapshot"] = +` +
    + + + English + + + German (Deutsch) + + + + + + + + + + + + + + +
    + + +
    +

    + Uploaded NSDoc files +

    + + + +
    + + + + IEC 61850-7-2 + + + close + + + + + IEC 61850-7-3 + + + close + + + + + IEC 61850-7-4 + + + close + + + + + IEC 61850-8-1 + + + close + + + + + Cancel + + + Reset + + + Save + +
    + + +`; +/* end snapshot OSCD-Settings deletes a chosen .nsdoc file and looks like latest snapshot */ + From 57573c75dccc332708bc20f37771a90d32233c9c Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Mon, 26 Feb 2024 16:11:55 +0100 Subject: [PATCH 24/27] Update control-blocks-container.test.ts removed console.logs --- .../editors/cleanup/control-blocks-container.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/open-scd/test/integration/editors/cleanup/control-blocks-container.test.ts b/packages/open-scd/test/integration/editors/cleanup/control-blocks-container.test.ts index 95aa73eec6..dc39caef17 100644 --- a/packages/open-scd/test/integration/editors/cleanup/control-blocks-container.test.ts +++ b/packages/open-scd/test/integration/editors/cleanup/control-blocks-container.test.ts @@ -41,11 +41,9 @@ describe('cleanup-editor integration: unreferenced control blocks', () => { ); element = parent.getActivePlugin(); await parent.updateComplete; - console.log('foo'); }); it('correctly removes all LogControl entries from the SCL', async () => { - console.log('error here'); await element.cleanupGSEControlFilter.click(); await element.cleanupSampledValueControlFilter.click(); // select all items and update list From 13cdb129784c81be091c71e1e539878ec460817b Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Mon, 26 Feb 2024 16:20:38 +0100 Subject: [PATCH 25/27] Delete packages/open-scd/src/editors/subscription/dist/fcda-binding-list.js --- .../subscription/dist/fcda-binding-list.js | 273 ------------------ 1 file changed, 273 deletions(-) delete mode 100644 packages/open-scd/src/editors/subscription/dist/fcda-binding-list.js diff --git a/packages/open-scd/src/editors/subscription/dist/fcda-binding-list.js b/packages/open-scd/src/editors/subscription/dist/fcda-binding-list.js deleted file mode 100644 index 9ce27fb982..0000000000 --- a/packages/open-scd/src/editors/subscription/dist/fcda-binding-list.js +++ /dev/null @@ -1,273 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -exports.__esModule = true; -exports.FcdaBindingList = void 0; -var lit_element_1 = require("lit-element"); -var lit_html_1 = require("lit-html"); -var class_map_js_1 = require("lit-html/directives/class-map.js"); -var lit_translate_1 = require("lit-translate"); -require("@material/mwc-icon"); -require("@material/mwc-list"); -require("@material/mwc-list/mwc-list-item"); -require("@material/mwc-list/mwc-check-list-item"); -require("@material/mwc-menu"); -require("@material/mwc-icon-button"); -var foundation_js_1 = require("../../foundation.js"); -var icons_js_1 = require("../../icons/icons.js"); -var wizard_library_js_1 = require("../../wizards/wizard-library.js"); -var foundation_js_2 = require("./foundation.js"); -var foundation_js_3 = require("./later-binding/foundation.js"); -/** - * A sub element for showing all Goose/Sampled Value Controls. - * A control can be edited using the standard wizard. - * And when selecting a FCDA Element a custom event is fired, so other list can be updated. - */ -var FcdaBindingList = /** @class */ (function (_super) { - __extends(FcdaBindingList, _super); - function FcdaBindingList() { - var _this = _super.call(this) || this; - _this.editCount = -1; - _this.extRefCounters = new Map(); - _this.iconControlLookup = { - SampledValueControl: icons_js_1.smvIcon, - GSEControl: icons_js_1.gooseIcon - }; - _this.resetSelection = _this.resetSelection.bind(_this); - parent.addEventListener('open-doc', _this.resetSelection); - var parentDiv = _this.closest('.container'); - if (parentDiv) { - _this.resetExtRefCount = _this.resetExtRefCount.bind(_this); - parentDiv.addEventListener('subscription-changed', _this.resetExtRefCount); - } - return _this; - } - Object.defineProperty(FcdaBindingList.prototype, "hideSubscribed", { - get: function () { - var _a; - return ((_a = localStorage.getItem("fcda-binding-list-" + (this.includeLaterBinding ? 'later-binding' : 'data-binding') + "-" + this.controlTag + "$hideSubscribed") === 'true') !== null && _a !== void 0 ? _a : false); - }, - set: function (value) { - var oldValue = this.hideSubscribed; - localStorage.setItem("fcda-binding-list-" + (this.includeLaterBinding ? 'later-binding' : 'data-binding') + "-" + this.controlTag + "$hideSubscribed", "" + value); - this.requestUpdate('hideSubscribed', oldValue); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(FcdaBindingList.prototype, "hideNotSubscribed", { - get: function () { - var _a; - return ((_a = localStorage.getItem("fcda-binding-list-" + (this.includeLaterBinding ? 'later-binding' : 'data-binding') + "-" + this.controlTag + "$hideNotSubscribed") === 'true') !== null && _a !== void 0 ? _a : false); - }, - set: function (value) { - var oldValue = this.hideNotSubscribed; - localStorage.setItem("fcda-binding-list-" + (this.includeLaterBinding ? 'later-binding' : 'data-binding') + "-" + this.controlTag + "$hideNotSubscribed", "" + value); - this.requestUpdate('hideNotSubscribed', oldValue); - }, - enumerable: false, - configurable: true - }); - FcdaBindingList.prototype.getControlElements = function () { - if (this.doc) { - return Array.from(this.doc.querySelectorAll("LN0 > " + this.controlTag)); - } - return []; - }; - FcdaBindingList.prototype.getFcdaElements = function (controlElement) { - var lnElement = controlElement.parentElement; - if (lnElement) { - return Array.from(lnElement.querySelectorAll(":scope > DataSet[name=" + controlElement.getAttribute('datSet') + "] > FCDA")); - } - return []; - }; - FcdaBindingList.prototype.resetExtRefCount = function (event) { - if (event.detail.control && event.detail.fcda) { - var controlBlockFcdaId = foundation_js_1.identity(event.detail.control) + " " + foundation_js_1.identity(event.detail.fcda); - this.extRefCounters["delete"](controlBlockFcdaId); - } - }; - FcdaBindingList.prototype.getExtRefCount = function (fcdaElement, controlElement) { - var controlBlockFcdaId = foundation_js_1.identity(controlElement) + " " + foundation_js_1.identity(fcdaElement); - if (!this.extRefCounters.has(controlBlockFcdaId)) { - var extRefCount = foundation_js_3.getSubscribedExtRefElements(this.doc.getRootNode(), this.controlTag, fcdaElement, controlElement, this.includeLaterBinding).length; - this.extRefCounters.set(controlBlockFcdaId, extRefCount); - } - return this.extRefCounters.get(controlBlockFcdaId); - }; - FcdaBindingList.prototype.openEditWizard = function (controlElement) { - var wizard = wizard_library_js_1.wizards[this.controlTag].edit(controlElement); - if (wizard) - this.dispatchEvent(foundation_js_1.newWizardEvent(wizard)); - }; - FcdaBindingList.prototype.resetSelection = function () { - this.selectedControlElement = undefined; - this.selectedFcdaElement = undefined; - }; - FcdaBindingList.prototype.onFcdaSelect = function (controlElement, fcdaElement) { - this.resetSelection(); - this.selectedControlElement = controlElement; - this.selectedFcdaElement = fcdaElement; - }; - FcdaBindingList.prototype.updated = function (_changedProperties) { - _super.prototype.updated.call(this, _changedProperties); - // When a new document is loaded or the selection is changed - // we will fire the FCDA Select Event. - if (_changedProperties.has('doc') || - _changedProperties.has('selectedControlElement') || - _changedProperties.has('selectedFcdaElement')) { - this.dispatchEvent(foundation_js_2.newFcdaSelectEvent(this.selectedControlElement, this.selectedFcdaElement)); - } - // When a new document is loaded we will reset the Map to clear old entries. - if (_changedProperties.has('doc')) { - this.extRefCounters = new Map(); - } - }; - FcdaBindingList.prototype.renderFCDA = function (controlElement, fcdaElement) { - var _this = this; - var fcdaCount = this.getExtRefCount(fcdaElement, controlElement); - var filterClasses = { - subitem: true, - 'show-subscribed': fcdaCount !== 0, - 'show-not-subscribed': fcdaCount === 0 - }; - return lit_element_1.html(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n ", "\n subdirectory_arrow_right\n ", "\n
    "], ["\n ", "\n ", "\n subdirectory_arrow_right\n ", "\n "])), fcdaCount !== 0, class_map_js_1.classMap(filterClasses), function () { return _this.onFcdaSelect(controlElement, fcdaElement); }, foundation_js_1.identity(controlElement), foundation_js_1.identity(fcdaElement), foundation_js_2.getFcdaTitleValue(fcdaElement), foundation_js_2.getFcdaSubtitleValue(fcdaElement), fcdaCount !== 0 ? lit_element_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), fcdaCount) : lit_html_1.nothing); - }; - FcdaBindingList.prototype.updateBaseFilterState = function () { - !this.hideSubscribed - ? this.controlBlockList.classList.add('show-subscribed') - : this.controlBlockList.classList.remove('show-subscribed'); - !this.hideNotSubscribed - ? this.controlBlockList.classList.add('show-not-subscribed') - : this.controlBlockList.classList.remove('show-not-subscribed'); - }; - FcdaBindingList.prototype.firstUpdated = function () { - var _this = this; - this.actionsMenu.anchor = this.actionsMenuIcon; - this.actionsMenu.addEventListener('closed', function () { - _this.hideSubscribed = !_this.actionsMenu.index.has(0); - _this.hideNotSubscribed = !_this.actionsMenu.index.has(1); - _this.updateBaseFilterState(); - }); - this.updateBaseFilterState(); - }; - FcdaBindingList.prototype.renderTitle = function () { - var _this = this; - var menuClasses = { - 'filter-off': this.hideSubscribed || this.hideNotSubscribed - }; - return lit_element_1.html(templateObject_3 || (templateObject_3 = __makeTemplateObject(["

    \n ", "\n \n \n \n ", "\n \n \n ", "\n \n \n

    "], ["

    \n ", "\n \n \n \n ", "\n \n \n ", "\n \n \n

    "])), lit_translate_1.translate("subscription." + this.controlTag + ".controlBlockList.title"), class_map_js_1.classMap(menuClasses), function () { - if (!_this.actionsMenu.open) - _this.actionsMenu.show(); - else - _this.actionsMenu.close(); - }, !this.hideSubscribed, lit_translate_1.translate('subscription.subscriber.subscribed'), !this.hideNotSubscribed, lit_translate_1.translate('subscription.subscriber.notSubscribed')); - }; - FcdaBindingList.prototype.renderControls = function (controlElements) { - var _this = this; - return lit_element_1.html(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", "\n "], ["\n ", - "\n "])), controlElements - .filter(function (controlElement) { return _this.getFcdaElements(controlElement).length; }) - .map(function (controlElement) { - var fcdaElements = _this.getFcdaElements(controlElement); - var showSubscribed = fcdaElements.some(function (fcda) { return _this.getExtRefCount(fcda, controlElement) !== 0; }); - var showNotSubscribed = fcdaElements.some(function (fcda) { return _this.getExtRefCount(fcda, controlElement) === 0; }); - var filterClasses = { - control: true, - 'show-subscribed': showSubscribed, - 'show-not-subscribed': showNotSubscribed - }; - return lit_element_1.html(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n \n \n ", "\n ", "\n ", "\n ", "\n \n
  • \n ", "\n "], ["\n \n \n ", "\n ", - "\n ", "\n ", "\n \n
  • \n ", - "\n "])), class_map_js_1.classMap(filterClasses), foundation_js_1.identity(controlElement), fcdaElements - .map(function (fcdaElement) { return "\n " + foundation_js_2.getFcdaTitleValue(fcdaElement) + "\n " + foundation_js_2.getFcdaSubtitleValue(fcdaElement) + "\n " + foundation_js_1.identity(fcdaElement); }) - .join(''), function () { return _this.openEditWizard(controlElement); }, foundation_js_1.getNameAttribute(controlElement), foundation_js_1.getDescriptionAttribute(controlElement) - ? lit_element_1.html(templateObject_4 || (templateObject_4 = __makeTemplateObject(["", ""], ["", ""])), foundation_js_1.getDescriptionAttribute(controlElement)) : lit_html_1.nothing, foundation_js_1.identity(controlElement), _this.iconControlLookup[_this.controlTag], fcdaElements.map(function (fcdaElement) { - return _this.renderFCDA(controlElement, fcdaElement); - })); - })); - }; - FcdaBindingList.prototype.render = function () { - var controlElements = this.getControlElements(); - return lit_element_1.html(templateObject_8 || (templateObject_8 = __makeTemplateObject(["
    \n ", "\n ", "\n
    "], ["
    \n ", "\n ", - "\n
    "])), this.renderTitle(), controlElements - ? this.renderControls(controlElements) - : lit_element_1.html(templateObject_7 || (templateObject_7 = __makeTemplateObject(["

    ", "

    "], ["

    ", "

    "])), lit_translate_1.translate('subscription.subscriber.notSubscribed'))); - }; - FcdaBindingList.styles = lit_element_1.css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n ", "\n\n mwc-list-item.hidden[noninteractive] + li[divider] {\n display: none;\n }\n\n mwc-list-item {\n --mdc-list-item-meta-size: 48px;\n }\n\n section {\n position: relative;\n }\n\n .actions-menu-icon {\n float: right;\n }\n\n .actions-menu-icon.filter-off {\n color: var(--secondary);\n background-color: var(--mdc-theme-background);\n }\n\n /* Filtering rules for control blocks end up implementing logic to allow\n very fast CSS response. The following rules appear to be minimal but can be\n hard to understand intuitively for the multiple conditions. If modifying,\n it is suggested to create a truth-table to check for side-effects */\n\n /* remove all control blocks if no filters */\n filtered-list.control-block-list:not(.show-subscribed, .show-not-subscribed)\n mwc-list-item {\n display: none;\n }\n\n /* remove control blocks taking care to respect multiple conditions */\n filtered-list.control-block-list.show-not-subscribed:not(.show-subscribed)\n mwc-list-item.control.show-subscribed:not(.show-not-subscribed) {\n display: none;\n }\n\n filtered-list.control-block-list.show-subscribed:not(.show-not-subscribed)\n mwc-list-item.control.show-not-subscribed:not(.show-subscribed) {\n display: none;\n }\n\n /* remove fcdas if not part of filter */\n filtered-list.control-block-list:not(.show-not-subscribed)\n mwc-list-item.subitem.show-not-subscribed {\n display: none;\n }\n\n filtered-list.control-block-list:not(.show-subscribed)\n mwc-list-item.subitem.show-subscribed {\n display: none;\n }\n\n .interactive {\n pointer-events: all;\n }\n\n .subitem {\n padding-left: var(--mdc-list-side-padding, 16px);\n }\n "], ["\n ", "\n\n mwc-list-item.hidden[noninteractive] + li[divider] {\n display: none;\n }\n\n mwc-list-item {\n --mdc-list-item-meta-size: 48px;\n }\n\n section {\n position: relative;\n }\n\n .actions-menu-icon {\n float: right;\n }\n\n .actions-menu-icon.filter-off {\n color: var(--secondary);\n background-color: var(--mdc-theme-background);\n }\n\n /* Filtering rules for control blocks end up implementing logic to allow\n very fast CSS response. The following rules appear to be minimal but can be\n hard to understand intuitively for the multiple conditions. If modifying,\n it is suggested to create a truth-table to check for side-effects */\n\n /* remove all control blocks if no filters */\n filtered-list.control-block-list:not(.show-subscribed, .show-not-subscribed)\n mwc-list-item {\n display: none;\n }\n\n /* remove control blocks taking care to respect multiple conditions */\n filtered-list.control-block-list.show-not-subscribed:not(.show-subscribed)\n mwc-list-item.control.show-subscribed:not(.show-not-subscribed) {\n display: none;\n }\n\n filtered-list.control-block-list.show-subscribed:not(.show-not-subscribed)\n mwc-list-item.control.show-not-subscribed:not(.show-subscribed) {\n display: none;\n }\n\n /* remove fcdas if not part of filter */\n filtered-list.control-block-list:not(.show-not-subscribed)\n mwc-list-item.subitem.show-not-subscribed {\n display: none;\n }\n\n filtered-list.control-block-list:not(.show-subscribed)\n mwc-list-item.subitem.show-subscribed {\n display: none;\n }\n\n .interactive {\n pointer-events: all;\n }\n\n .subitem {\n padding-left: var(--mdc-list-side-padding, 16px);\n }\n "])), foundation_js_2.styles); - __decorate([ - lit_element_1.property({ attribute: false }) - ], FcdaBindingList.prototype, "doc"); - __decorate([ - lit_element_1.property({ type: Number }) - ], FcdaBindingList.prototype, "editCount"); - __decorate([ - lit_element_1.property() - ], FcdaBindingList.prototype, "controlTag"); - __decorate([ - lit_element_1.property() - ], FcdaBindingList.prototype, "includeLaterBinding"); - __decorate([ - lit_element_1.state() - ], FcdaBindingList.prototype, "selectedControlElement"); - __decorate([ - lit_element_1.state() - ], FcdaBindingList.prototype, "selectedFcdaElement"); - __decorate([ - lit_element_1.state() - ], FcdaBindingList.prototype, "extRefCounters"); - __decorate([ - lit_element_1.property({ - type: Boolean, - hasChanged: function () { - return false; - } - }) - ], FcdaBindingList.prototype, "hideSubscribed"); - __decorate([ - lit_element_1.property({ - type: Boolean, - hasChanged: function () { - return false; - } - }) - ], FcdaBindingList.prototype, "hideNotSubscribed"); - __decorate([ - lit_element_1.query('.actions-menu') - ], FcdaBindingList.prototype, "actionsMenu"); - __decorate([ - lit_element_1.query('.actions-menu-icon') - ], FcdaBindingList.prototype, "actionsMenuIcon"); - __decorate([ - lit_element_1.query('.control-block-list') - ], FcdaBindingList.prototype, "controlBlockList"); - FcdaBindingList = __decorate([ - lit_element_1.customElement('fcda-binding-list') - ], FcdaBindingList); - return FcdaBindingList; -}(lit_element_1.LitElement)); -exports.FcdaBindingList = FcdaBindingList; -var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9; From 24a80dc63178279e18a50f0c1188fed045eae8b0 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Tue, 27 Feb 2024 14:13:24 +0100 Subject: [PATCH 26/27] Update dotype-wizarding.test.ts --- .../test/integration/editors/templates/dotype-wizarding.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts b/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts index d8c68b6010..c341ad3b3f 100644 --- a/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts +++ b/packages/open-scd/test/integration/editors/templates/dotype-wizarding.test.ts @@ -257,7 +257,6 @@ describe('DOType wizards', () => { it('deletes the DOType attribute on delete button click', async () => { expect(doc.querySelector('DOType[id="Dummy.LLN0.Mod"]')).to.exist; expect(doc.querySelectorAll('DOType').length).to.equal(15); - console.log('del button'); deleteButton.click(); await parent.requestUpdate(); expect(doc.querySelector('DAType[id="Dummy.LLN0.Mod"]')).to.not.exist; From 15ba2511d236a5463587cba8d9d4a207feba9360 Mon Sep 17 00:00:00 2001 From: Pascal Wilbrink Date: Wed, 28 Feb 2024 12:53:57 +0100 Subject: [PATCH 27/27] Update Templates.test.ts --- .../test/integration/editors/templates/Templates.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/open-scd/test/integration/editors/templates/Templates.test.ts b/packages/open-scd/test/integration/editors/templates/Templates.test.ts index 755b26d9a6..3b184bf8d8 100644 --- a/packages/open-scd/test/integration/editors/templates/Templates.test.ts +++ b/packages/open-scd/test/integration/editors/templates/Templates.test.ts @@ -4,7 +4,6 @@ import '../../../mock-open-scd.js'; import { MockOpenSCD } from '../../../mock-open-scd.js'; import TemplatesPlugin from '../../../../src/editors/Templates.js'; -import { EditingElement } from '../../../../src/Editing.js'; import { newWizardEvent } from '../../../../src/foundation.js'; describe('Templates Plugin', () => { @@ -211,7 +210,7 @@ describe('Templates Plugin', () => { await parent.updateComplete; expect( parent! - .querySelector('templates-plugin')! + .querySelector('templates-plugin')! .doc!.querySelector('DataTypeTemplates') ).to.exist; });