diff --git a/packages/open-scd/src/Logging.ts b/packages/open-scd/src/Historing.ts similarity index 73% rename from packages/open-scd/src/Logging.ts rename to packages/open-scd/src/Historing.ts index b2f5b2ebb8..5b0ef07f2b 100644 --- a/packages/open-scd/src/Logging.ts +++ b/packages/open-scd/src/Historing.ts @@ -21,8 +21,11 @@ import { Snackbar } from '@material/mwc-snackbar'; import './filtered-list.js'; import { + CommitDetail, CommitEntry, ifImplemented, + InfoDetail, + InfoEntry, invert, IssueDetail, IssueEvent, @@ -40,7 +43,6 @@ const icons = { info: 'info', warning: 'warning', error: 'report', - action: 'history', }; function getPluginName(src: string): string { @@ -66,13 +68,18 @@ function getPluginName(src: string): string { * Renders the `history` to `logUI` and the latest `'error'` [[`LogEntry`]] to * `messageUI`. */ -export type LoggingElement = Mixin; +export type HistoringElement = Mixin; -export function Logging(Base: TBase) { - class LoggingElement extends Base { +export function Historing(Base: TBase) { + class HistoringElement extends Base { /** All [[`LogEntry`]]s received so far through [[`LogEvent`]]s. */ @property({ type: Array }) - history: LogEntry[] = []; + log: InfoEntry[] = []; + + /** All [[`CommitEntry`]]s received so far through [[`LogEvent`]]s */ + @property({ type: Array }) + history: CommitEntry[] = []; + /** Index of the last [[`EditorAction`]] applied. */ @property({ type: Number }) editCount = -1; @@ -82,6 +89,7 @@ export function Logging(Base: TBase) { latestIssue!: IssueDetail; @query('#log') logUI!: Dialog; + @query('#history') historyUI!: Dialog; @query('#diagnostic') diagnosticUI!: Dialog; @query('#error') errorUI!: Snackbar; @query('#warning') warningUI!: Snackbar; @@ -140,16 +148,10 @@ export function Logging(Base: TBase) { return true; } - private onLog(le: LogEvent): void { - if (le.detail.kind === 'reset') { - this.history = []; - this.editCount = -1; - return; - } - - const entry: LogEntry = { + private onHistory(detail: CommitDetail) { + const entry: CommitEntry = { time: new Date(), - ...le.detail, + ...detail, }; if (entry.kind === 'action') { @@ -160,22 +162,51 @@ export function Logging(Base: TBase) { } this.history.push(entry); + this.requestUpdate('history', []); + } + + private onReset() { + this.log = []; + this.history = []; + this.editCount = -1; + } + + private onInfo(detail: InfoDetail) { + const entry: InfoEntry = { + time: new Date(), + ...detail, + }; + + this.log.push(entry); if (!this.logUI.open) { const ui = { error: this.errorUI, warning: this.warningUI, info: this.infoUI, - action: this.infoUI, - }[le.detail.kind]; + }[detail.kind]; ui.close(); ui.show(); } - if (le.detail.kind == 'error') { + if (detail.kind == 'error') { this.errorUI.close(); // hack to reset timeout this.errorUI.show(); } - this.requestUpdate('history', []); + this.requestUpdate('log', []); + } + + private onLog(le: LogEvent): void { + switch (le.detail.kind) { + case 'reset': + this.onReset(); + break; + case 'action': + this.onHistory(le.detail); + break; + default: + this.onInfo(le.detail); + break; + } } async performUpdate() { @@ -197,7 +228,36 @@ export function Logging(Base: TBase) { } renderLogEntry( - entry: LogEntry, + entry: InfoEntry, + index: number, + log: LogEntry[] + ): TemplateResult { + return html` + + + + ${entry.time?.toLocaleString()} + ${entry.title} + ${entry.message} + ${icons[entry.kind]} + `; + } + + renderHistoryEntry( + entry: CommitEntry, index: number, history: LogEntry[] ): TemplateResult { @@ -219,18 +279,31 @@ export function Logging(Base: TBase) { style="--mdc-theme-text-icon-on-background:var(${ifDefined( iconColors[entry.kind] )})" - >${icons[entry.kind]}history `; } + private renderLog(): TemplateResult[] | TemplateResult { + if (this.log.length > 0) + return this.log.slice().reverse().map(this.renderLogEntry, this); + else + return html` + ${translate('log.placeholder')} + info + `; + } + private renderHistory(): TemplateResult[] | TemplateResult { if (this.history.length > 0) - return this.history.slice().reverse().map(this.renderLogEntry, this); + return this.history + .slice() + .reverse() + .map(this.renderHistoryEntry, this); else return html` - ${translate('log.placeholder')} + ${translate('history.placeholder')} info `; } @@ -281,6 +354,42 @@ export function Logging(Base: TBase) { ); } + private renderLogDialog(): TemplateResult { + return html` + ${this.renderFilterButtons()} + ${this.renderLog()} + ${translate('close')} + `; + } + + private renderHistoryDialog(): TemplateResult { + return html` + ${this.renderHistory()} + + + ${translate('close')} + `; + } + render(): TemplateResult { return html`${ifImplemented(super.render())} - - ${this.renderFilterButtons()} - ${this.renderHistory()} - - - ${translate('close')} - - + ${this.renderLogDialog()} ${this.renderHistoryDialog()} ${this.renderIssues()}(Base: TBase) { le.kind === 'info' || le.kind === 'action')?.title ?? + .find(le => le.kind === 'info')?.title ?? get('log.snackbar.placeholder')}" > @@ -391,7 +473,7 @@ export function Logging(Base: TBase) { le.kind === 'warning')?.title ?? @@ -408,7 +490,7 @@ export function Logging(Base: TBase) { le.kind === 'error')?.title ?? @@ -439,5 +521,5 @@ export function Logging(Base: TBase) { } } - return LoggingElement; + return HistoringElement; } diff --git a/packages/open-scd/src/Hosting.ts b/packages/open-scd/src/Hosting.ts index bdfa7ced91..33701eee00 100644 --- a/packages/open-scd/src/Hosting.ts +++ b/packages/open-scd/src/Hosting.ts @@ -16,7 +16,7 @@ import { ActionDetail, List } from '@material/mwc-list'; import { ListItem } from '@material/mwc-list/mwc-list-item'; import { Mixin, newPendingStateEvent } from './foundation.js'; -import { LoggingElement } from './Logging.js'; +import { HistoringElement } from './Historing.js'; import { Plugin, PluggingElement, pluginIcons } from './Plugging.js'; import { SettingElement } from './Setting.js'; @@ -39,12 +39,12 @@ interface MenuPlugin { run: () => Promise; } -/** Mixin that hosts the UI for Plugins, Settings and Logging */ +/** Mixin that hosts the UI for Plugins, Settings and Historing */ export type HostingElement = Mixin; export function Hosting< TBase extends new (...args: any[]) => PluggingElement & - LoggingElement & + HistoringElement & SettingElement >(Base: TBase) { class HostingElement extends Base { @@ -176,12 +176,19 @@ export function Hosting< }, ...validators, { - icon: 'history', + 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', diff --git a/packages/open-scd/src/Plugging.ts b/packages/open-scd/src/Plugging.ts index 1b0f86d5b4..781da6cac2 100644 --- a/packages/open-scd/src/Plugging.ts +++ b/packages/open-scd/src/Plugging.ts @@ -25,7 +25,7 @@ import { ifImplemented, Mixin } from './foundation.js'; import { EditingElement } from './Editing.js'; import { officialPlugins } from '../public/js/plugins.js'; import { Nsdoc } from './foundation/nsdoc.js'; -import { LoggingElement } from './Logging.js'; +import { HistoringElement } from './Historing.js'; const pluginTags = new Map(); /** * Hashes `uri` using cyrb64 analogous to @@ -177,7 +177,7 @@ const loadedPlugins = new Set(); export type PluggingElement = Mixin; export function Plugging< - TBase extends new (...args: any[]) => EditingElement & LoggingElement + TBase extends new (...args: any[]) => EditingElement & HistoringElement >(Base: TBase) { class PluggingElement extends Base { // DIRTY HACK: will refactored with open-scd-core diff --git a/packages/open-scd/src/open-scd.ts b/packages/open-scd/src/open-scd.ts index 3afa2c8616..aa463098c7 100644 --- a/packages/open-scd/src/open-scd.ts +++ b/packages/open-scd/src/open-scd.ts @@ -14,7 +14,7 @@ import { getTheme } from './themes.js'; import { Editing } from './Editing.js'; import { Hosting } from './Hosting.js'; -import { Logging } from './Logging.js'; +import { Historing } from './Historing.js'; import { Plugging } from './Plugging.js'; import { Setting } from './Setting.js'; import { Waiting } from './Waiting.js'; @@ -24,7 +24,7 @@ import { Wizarding } from './Wizarding.js'; * Open Substation Configuration Designer. */ @customElement('open-scd') export class OpenSCD extends Waiting( - Hosting(Setting(Wizarding(Plugging(Editing(Logging(LitElement)))))) + Hosting(Setting(Wizarding(Plugging(Editing(Historing(LitElement)))))) ) { private currentSrc = ''; /** The current file's URL. `blob:` URLs are *revoked after parsing*! */ diff --git a/packages/open-scd/src/translations/de.ts b/packages/open-scd/src/translations/de.ts index 0b47737633..e77ef35c0c 100644 --- a/packages/open-scd/src/translations/de.ts +++ b/packages/open-scd/src/translations/de.ts @@ -170,6 +170,7 @@ export const de: Translations = { }, history: { name: 'SCL History', + placeholder: 'Keine History', noEntries: 'Keine Einträge in der SCL History', }, diag: { diff --git a/packages/open-scd/src/translations/en.ts b/packages/open-scd/src/translations/en.ts index fe8463f38c..6affea53b0 100644 --- a/packages/open-scd/src/translations/en.ts +++ b/packages/open-scd/src/translations/en.ts @@ -139,7 +139,7 @@ export const en = { }, log: { name: 'Log', - placeholder: 'Edits, errors, and other notifications will show up here.', + placeholder: 'Errors, warnings and other notifications will show up here.', snackbar: { show: 'Show', placeholder: 'No errors', @@ -147,6 +147,7 @@ export const en = { }, history: { name: 'SCL History', + placeholder: 'Edits will show up here', noEntries: 'No SCL history entries', }, diag: { diff --git a/packages/open-scd/test/integration/Setting.test.ts b/packages/open-scd/test/integration/Setting.test.ts index 3ecea09328..e0c40ccb45 100644 --- a/packages/open-scd/test/integration/Setting.test.ts +++ b/packages/open-scd/test/integration/Setting.test.ts @@ -47,8 +47,8 @@ describe('Setting', () => { await element.requestUpdate(); await element.updateComplete; - expect(element.history.length).to.be.equal(1); - expect(element.history[0].title).to.be.equal( + expect(element.log.length).to.be.equal(1); + expect(element.log[0].title).to.be.equal( "Invalid NSDoc (invalid.nsdoc); no 'id' attribute found in file" ); }); @@ -66,8 +66,8 @@ describe('Setting', () => { await element.requestUpdate(); await element.updateComplete; - expect(element.history.length).to.be.equal(1); - expect(element.history[0].title).to.be.equal( + expect(element.log.length).to.be.equal(1); + expect(element.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__/open-scd.test.snap.js b/packages/open-scd/test/integration/__snapshots__/open-scd.test.snap.js index 94b10ad8a0..ea1848c844 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 @@ -313,11 +313,17 @@ snapshots["open-scd looks like its snapshot"] = > + + - - + + + Errors, warnings and other notifications will show up here. + + + info + + + + + Close + + + - Edits, errors, and other notifications will show up here. + Edits will show up here info diff --git a/packages/open-scd/test/integration/editors/GooseSubscriberDataBinding.test.ts b/packages/open-scd/test/integration/editors/GooseSubscriberDataBinding.test.ts index eae5c221da..33825d49e3 100644 --- a/packages/open-scd/test/integration/editors/GooseSubscriberDataBinding.test.ts +++ b/packages/open-scd/test/integration/editors/GooseSubscriberDataBinding.test.ts @@ -1,7 +1,7 @@ import { expect, fixture, html } from '@open-wc/testing'; import { Wizarding } from '../../../src/Wizarding.js'; import { Editing } from '../../../src/Editing.js'; -import { Logging } from '../../../src/Logging.js'; +import { Historing } from '../../../src/Historing.js'; import { initializeNsdoc } from '../../../src/foundation/nsdoc.js'; import GooseSubscriberDataBinding from '../../../src/editors/GooseSubscriberDataBinding.js'; @@ -16,7 +16,7 @@ import { describe('GOOSE Subscribe Data Binding Plugin', async () => { customElements.define( 'goose-subscriber-data-binding-plugin', - Wizarding(Editing(Logging(GooseSubscriberDataBinding))) + Wizarding(Editing(Historing(GooseSubscriberDataBinding))) ); let element: GooseSubscriberDataBinding; diff --git a/packages/open-scd/test/integration/editors/GooseSubscriberLaterBinding.test.ts b/packages/open-scd/test/integration/editors/GooseSubscriberLaterBinding.test.ts index ac3961d19a..9528cb4e06 100644 --- a/packages/open-scd/test/integration/editors/GooseSubscriberLaterBinding.test.ts +++ b/packages/open-scd/test/integration/editors/GooseSubscriberLaterBinding.test.ts @@ -1,7 +1,7 @@ import { expect, fixture, html } from '@open-wc/testing'; import { Wizarding } from '../../../src/Wizarding.js'; import { Editing } from '../../../src/Editing.js'; -import { Logging } from '../../../src/Logging.js'; +import { Historing } from '../../../src/Historing.js'; import GooseSubscriberLaterBinding from '../../../src/editors/GooseSubscriberLaterBinding.js'; import { @@ -15,7 +15,7 @@ import { ExtRefLaterBindingList } from '../../../src/editors/subscription/later- describe('GOOSE Subscribe Later Binding Plugin', () => { customElements.define( 'goose-subscriber-later-binding-plugin', - Wizarding(Editing(Logging(GooseSubscriberLaterBinding))) + Wizarding(Editing(Historing(GooseSubscriberLaterBinding))) ); let element: GooseSubscriberLaterBinding; diff --git a/packages/open-scd/test/integration/editors/GooseSubscriberMessageBinding.test.ts b/packages/open-scd/test/integration/editors/GooseSubscriberMessageBinding.test.ts index c3c7e15ae9..f047e3335d 100644 --- a/packages/open-scd/test/integration/editors/GooseSubscriberMessageBinding.test.ts +++ b/packages/open-scd/test/integration/editors/GooseSubscriberMessageBinding.test.ts @@ -6,13 +6,13 @@ import { ListItem } from '@material/mwc-list/mwc-list-item.js'; import { Editing } from '../../../src/Editing.js'; import { Wizarding } from '../../../src/Wizarding.js'; -import { Logging } from '../../../src/Logging.js'; +import { Historing } from '../../../src/Historing.js'; import GooseSubscriberMessageBindingPlugin from '../../../src/editors/GooseSubscriberMessageBinding.js'; describe('GOOSE subscriber plugin', () => { customElements.define( 'subscription-plugin', - Wizarding(Editing(Logging(GooseSubscriberMessageBindingPlugin))) + Wizarding(Editing(Historing(GooseSubscriberMessageBindingPlugin))) ); let element: GooseSubscriberMessageBindingPlugin; let doc: XMLDocument; diff --git a/packages/open-scd/test/integration/editors/SMVSubscriberDataBinding.test.ts b/packages/open-scd/test/integration/editors/SMVSubscriberDataBinding.test.ts index 3e8d80d481..1410840532 100644 --- a/packages/open-scd/test/integration/editors/SMVSubscriberDataBinding.test.ts +++ b/packages/open-scd/test/integration/editors/SMVSubscriberDataBinding.test.ts @@ -11,11 +11,11 @@ import { getSelectedSubItemValue, selectFCDAItem, } from './test-support.js'; -import { Logging } from '../../../src/Logging.js'; +import { Historing } from '../../../src/Historing.js'; describe('SMV Subscribe Data Binding Plugin', async () => { customElements.define( 'smv-subscriber-data-binding-plugin', - Wizarding(Editing(Logging(SMVSubscriberDataBinding))) + Wizarding(Editing(Historing(SMVSubscriberDataBinding))) ); let element: SMVSubscriberDataBinding; diff --git a/packages/open-scd/test/integration/editors/SMVSubscriberLaterBinding.test.ts b/packages/open-scd/test/integration/editors/SMVSubscriberLaterBinding.test.ts index 2f69700d20..40e8b7e5dd 100644 --- a/packages/open-scd/test/integration/editors/SMVSubscriberLaterBinding.test.ts +++ b/packages/open-scd/test/integration/editors/SMVSubscriberLaterBinding.test.ts @@ -2,7 +2,7 @@ import { expect, fixture, html } from '@open-wc/testing'; import { Wizarding } from '../../../src/Wizarding.js'; import { Editing } from '../../../src/Editing.js'; -import { Logging } from '../../../src/Logging.js'; +import { Historing } from '../../../src/Historing.js'; import SMVSubscribeLaterBindingPlugin from '../../../src/editors/SMVSubscriberLaterBinding.js'; import { @@ -16,7 +16,7 @@ import { ExtRefLaterBindingList } from '../../../src/editors/subscription/later- describe('SMV Subscribe Later Binding plugin', () => { customElements.define( 'smv-subscribe-later-binding-plugin', - Wizarding(Editing(Logging(SMVSubscribeLaterBindingPlugin))) + Wizarding(Editing(Historing(SMVSubscribeLaterBindingPlugin))) ); let element: SMVSubscribeLaterBindingPlugin; let doc: XMLDocument; diff --git a/packages/open-scd/test/integration/editors/SMVSubscriberMessageBinding.test.ts b/packages/open-scd/test/integration/editors/SMVSubscriberMessageBinding.test.ts index 5d16b54654..e6f9f1d225 100644 --- a/packages/open-scd/test/integration/editors/SMVSubscriberMessageBinding.test.ts +++ b/packages/open-scd/test/integration/editors/SMVSubscriberMessageBinding.test.ts @@ -4,14 +4,14 @@ import '../../mock-wizard.js'; import SMVSubscriberMessageBindingPlugin from '../../../src/editors/SMVSubscriberMessageBinding.js'; import { Editing } from '../../../src/Editing.js'; -import { Logging } from '../../../src/Logging.js'; +import { Historing } from '../../../src/Historing.js'; import { Wizarding } from '../../../src/Wizarding.js'; import { ListItem } from '@material/mwc-list/mwc-list-item.js'; describe('Sampled Values Plugin', () => { customElements.define( 'smv-plugin', - Wizarding(Editing(Logging(SMVSubscriberMessageBindingPlugin))) + Wizarding(Editing(Historing(SMVSubscriberMessageBindingPlugin))) ); let element: SMVSubscriberMessageBindingPlugin; let doc: XMLDocument; diff --git a/packages/open-scd/test/integration/editors/__snapshots__/GooseSubscriberMessageBinding.test.snap.js b/packages/open-scd/test/integration/editors/__snapshots__/GooseSubscriberMessageBinding.test.snap.js index 2d3c512d97..5b60496600 100644 --- a/packages/open-scd/test/integration/editors/__snapshots__/GooseSubscriberMessageBinding.test.snap.js +++ b/packages/open-scd/test/integration/editors/__snapshots__/GooseSubscriberMessageBinding.test.snap.js @@ -46,11 +46,6 @@ snapshots["GOOSE subscriber plugin in Publisher view per default the plugin itse on="" > - - + + [close] + + + + + + + [history.placeholder] + + + info + + + - - + + [close] + + + + + + + [history.placeholder] + + + info + + + - - + + [close] + + + + + + + [history.placeholder] + + + info + + + - - + + [close] + + + + + + + [history.placeholder] + + + info + + + { .then(str => new DOMParser().parseFromString(str, 'application/xml')); element.prepareImport(importDoc, 'invalid.iid'); - expect(parent.history[0].kind).to.equal('error'); - expect(parent.history[0].title).to.equal('[import.log.missingied]'); + expect(parent.log[0].kind).to.equal('error'); + expect(parent.log[0].title).to.equal('[import.log.missingied]'); }); it('throws duplicate ied name error', async () => { @@ -423,8 +423,8 @@ describe('ImportIedsPlugin', () => { .then(str => new DOMParser().parseFromString(str, 'application/xml')); element.prepareImport(importDoc, 'duplicate.iid'); - expect(parent.history[0].kind).to.equal('error'); - expect(parent.history[0].title).to.equal('[import.log.nouniqueied]'); + expect(parent.log[0].kind).to.equal('error'); + expect(parent.log[0].title).to.equal('[import.log.nouniqueied]'); }); it('throws parser error', async () => { @@ -435,8 +435,8 @@ describe('ImportIedsPlugin', () => { element.prepareImport(importDoc, 'parsererror.iid'); - expect(parent.history[0].kind).to.equal('error'); - expect(parent.history[0].title).to.equal('[import.log.parsererror]'); + expect(parent.log[0].kind).to.equal('error'); + expect(parent.log[0].title).to.equal('[import.log.parsererror]'); }); }); }); diff --git a/packages/open-scd/test/integration/open-scd.test.ts b/packages/open-scd/test/integration/open-scd.test.ts index 02645d51b4..4354785629 100644 --- a/packages/open-scd/test/integration/open-scd.test.ts +++ b/packages/open-scd/test/integration/open-scd.test.ts @@ -42,11 +42,19 @@ describe('open-scd', () => { it('opens the log on log icon click', async () => { expect(element.logUI).to.have.property('open', false); await (( - element.shadowRoot!.querySelector('mwc-icon-button[icon="history"]')! + element.shadowRoot!.querySelector('mwc-icon-button[icon="list"]')! )).click(); expect(element.logUI).to.have.property('open', true); }); + it('opens the history on history icon click', async () => { + expect(element.historyUI).to.have.property('open', false); + await (( + element.shadowRoot!.querySelector('mwc-icon-button[icon="history"]')! + )).click(); + expect(element.historyUI).to.have.property('open', true); + }); + it('opens the log on snackbar button click', async () => { expect(element.logUI).to.have.property('open', false); await element.errorUI.querySelector('mwc-button')!.click(); diff --git a/packages/open-scd/test/integration/validators/ValidateSchema.test.ts b/packages/open-scd/test/integration/validators/ValidateSchema.test.ts index ba68861031..4b2b55d546 100644 --- a/packages/open-scd/test/integration/validators/ValidateSchema.test.ts +++ b/packages/open-scd/test/integration/validators/ValidateSchema.test.ts @@ -58,7 +58,7 @@ describe('ValidateSchema plugin', () => { }); it('indicates successful schema validation in the log', async () => { - const lastEntry = parent.history.pop(); + const lastEntry = parent.log.pop(); expect(lastEntry.kind).to.equal('info'); expect(lastEntry.title).to.contain('[validator.schema.valid]'); }); @@ -92,7 +92,7 @@ describe('ValidateSchema plugin', () => { .be.undefined); it('generates error messages in the log', async () => { - const lastLogEntry = parent.history.pop(); + const lastLogEntry = parent.log.pop(); expect(lastLogEntry.kind).to.equal('warning'); expect(lastLogEntry.title).to.contain('[validator.schema.invalid]'); }); diff --git a/packages/open-scd/test/mock-editor-logger.ts b/packages/open-scd/test/mock-editor-logger.ts index fe99e943ac..63f1e9aae1 100644 --- a/packages/open-scd/test/mock-editor-logger.ts +++ b/packages/open-scd/test/mock-editor-logger.ts @@ -1,7 +1,7 @@ import { LitElement, customElement } from 'lit-element'; import { Editing } from '../src/Editing.js'; -import { Logging } from '../src/Logging.js'; +import { Historing } from '../src/Historing.js'; @customElement('mock-editor-logger') -export class MockEditorLogger extends Editing(Logging(LitElement)) {} +export class MockEditorLogger extends Editing(Historing(LitElement)) {} diff --git a/packages/open-scd/test/mock-setter-logger.ts b/packages/open-scd/test/mock-setter-logger.ts index e371586e95..a7bfc22318 100644 --- a/packages/open-scd/test/mock-setter-logger.ts +++ b/packages/open-scd/test/mock-setter-logger.ts @@ -1,7 +1,7 @@ import { LitElement, customElement } from 'lit-element'; import { Setting } from '../src/Setting.js'; import { Editing } from '../src/Editing.js'; -import { Logging } from '../src/Logging.js'; +import { Historing } from '../src/Historing.js'; @customElement('mock-setter-logger') -export class MockSetterLogger extends Setting(Editing(Logging(LitElement))) {} +export class MockSetterLogger extends Setting(Editing(Historing(LitElement))) {} diff --git a/packages/open-scd/test/unit/Logging.test.ts b/packages/open-scd/test/unit/Historing.test.ts similarity index 90% rename from packages/open-scd/test/unit/Logging.test.ts rename to packages/open-scd/test/unit/Historing.test.ts index 5331aa193d..ea4a5155ac 100644 --- a/packages/open-scd/test/unit/Logging.test.ts +++ b/packages/open-scd/test/unit/Historing.test.ts @@ -10,21 +10,21 @@ import { newLogEvent, } from '../../src/foundation.js'; -describe('LoggingElement', () => { +describe('HistoringElement', () => { let element: MockLogger; beforeEach(async () => { element = await fixture(html``); }); - it('starts out with an empty history', () => - expect(element).property('history').to.be.empty); + it('starts out with an empty log', () => + expect(element).property('log').to.be.empty); it('cannot undo', () => expect(element).property('canUndo').to.be.false); it('cannot redo', () => expect(element).property('canRedo').to.be.false); it('cannot undo info messages', () => { element.dispatchEvent(newLogEvent({ kind: 'info', title: 'test info' })); - expect(element).property('history').to.have.lengthOf(1); + expect(element).property('log').to.have.lengthOf(1); expect(element).property('canUndo').to.be.false; }); @@ -32,13 +32,13 @@ describe('LoggingElement', () => { element.dispatchEvent( newLogEvent({ kind: 'warning', title: 'test warning' }) ); - expect(element).property('history').to.have.lengthOf(1); + expect(element).property('log').to.have.lengthOf(1); expect(element).property('canUndo').to.be.false; }); it('cannot undo error messages', () => { element.dispatchEvent(newLogEvent({ kind: 'error', title: 'test error' })); - expect(element).property('history').to.have.lengthOf(1); + expect(element).property('log').to.have.lengthOf(1); expect(element).property('canUndo').to.be.false; }); @@ -135,14 +135,15 @@ describe('LoggingElement', () => { expect(element).property('history').to.have.lengthOf(1); }); - it('can reset its history', () => { + it('can reset its log', () => { element.dispatchEvent(newLogEvent({ kind: 'reset' })); + expect(element).property('log').to.be.empty; expect(element).property('history').to.be.empty; expect(element).to.have.property('editCount', -1); }); - it('renders a log message for the action', () => - expect(element.logUI).to.contain.text('test')); + it('renders a history message for the action', () => + expect(element.historyUI).to.contain.text('test')); describe('with a second action logged', () => { beforeEach(() => { @@ -164,7 +165,7 @@ describe('LoggingElement', () => { it('has a previous action', () => expect(element).to.have.property('previousAction', 0)); it('has an edit count', () => - expect(element).to.have.property('editCount', 2)); + expect(element).to.have.property('editCount', 1)); it('has no next action', () => expect(element).to.have.property('nextAction', -1)); @@ -176,7 +177,7 @@ describe('LoggingElement', () => { it('has an edit count', () => expect(element).to.have.property('editCount', 0)); it('has a next action', () => - expect(element).to.have.property('nextAction', 2)); + expect(element).to.have.property('nextAction', 1)); it('can redo', () => expect(element).property('canRedo').to.be.true); @@ -188,8 +189,9 @@ describe('LoggingElement', () => { action: MockAction.mov, }) ); - expect(element).property('history').to.have.lengthOf(3); - expect(element).to.have.property('editCount', 2); + expect(element).property('log').to.have.lengthOf(1); + expect(element).property('history').to.have.lengthOf(2); + expect(element).to.have.property('editCount', 1); expect(element).to.have.property('nextAction', -1); }); @@ -206,7 +208,7 @@ describe('LoggingElement', () => { it('has a previous action', () => expect(element).to.have.property('previousAction', 0)); it('has an edit count', () => - expect(element).to.have.property('editCount', 2)); + expect(element).to.have.property('editCount', 1)); it('has no next action', () => expect(element).to.have.property('nextAction', -1)); diff --git a/packages/open-scd/test/unit/mock-logger.ts b/packages/open-scd/test/unit/mock-logger.ts index 29ea74d4bb..6fa6586823 100644 --- a/packages/open-scd/test/unit/mock-logger.ts +++ b/packages/open-scd/test/unit/mock-logger.ts @@ -1,5 +1,5 @@ import { LitElement, customElement } from 'lit-element'; -import { Logging } from '../../src/Logging.js'; +import { Historing } from '../../src/Historing.js'; @customElement('mock-logger') -export class MockLogger extends Logging(LitElement) {} +export class MockLogger extends Historing(LitElement) {} diff --git a/packages/open-scd/test/unit/mock-plugger.ts b/packages/open-scd/test/unit/mock-plugger.ts index 656d3d5b0b..72c3637771 100644 --- a/packages/open-scd/test/unit/mock-plugger.ts +++ b/packages/open-scd/test/unit/mock-plugger.ts @@ -1,7 +1,7 @@ import { LitElement, customElement } from 'lit-element'; import { Plugging } from '../../src/Plugging.js'; import { Editing } from '../../src/Editing.js'; -import { Logging } from '../../src/Logging.js'; +import { Historing } from '../../src/Historing.js'; @customElement('mock-plugger') -export class MockPlugger extends Plugging(Editing(Logging(LitElement))) {} +export class MockPlugger extends Plugging(Editing(Historing(LitElement))) {}