diff --git a/packages/compas-open-scd/src/compas-editors/CompasVersions.ts b/packages/compas-open-scd/src/compas-editors/CompasVersions.ts index 394144460..f0ed19f0b 100644 --- a/packages/compas-open-scd/src/compas-editors/CompasVersions.ts +++ b/packages/compas-open-scd/src/compas-editors/CompasVersions.ts @@ -42,7 +42,7 @@ import { } from '../compas/foundation.js'; import { addVersionToCompasWizard } from '../compas/CompasUploadVersion.js'; import { getElementByName, styles } from './foundation.js'; -import { wizards } from 'open-scd/src/wizards/wizard-library.js'; +import { editCompasSCLWizard } from "../compas-wizards/scl.js"; /** An editor [[`plugin`]] for selecting the `Substation` section. */ export default class CompasVersionsPlugin extends LitElement { @@ -373,7 +373,7 @@ export default class CompasVersionsPlugin extends LitElement { } private openEditWizard(): void { - const wizard = wizards['SCL'].edit(this.doc.documentElement); + const wizard = editCompasSCLWizard(this.doc.documentElement); if (wizard) this.dispatchEvent(newWizardEvent(wizard)); } diff --git a/packages/compas-open-scd/test/integration/compas-editors/CompasVersions.test.ts b/packages/compas-open-scd/test/integration/compas-editors/CompasVersions.test.ts index 1da40a067..bec039bb4 100644 --- a/packages/compas-open-scd/test/integration/compas-editors/CompasVersions.test.ts +++ b/packages/compas-open-scd/test/integration/compas-editors/CompasVersions.test.ts @@ -1,5 +1,5 @@ import { expect, fixtureSync, html, waitUntil } from '@open-wc/testing'; -import sinon, { SinonStub } from 'sinon'; +import sinon, { SinonSpy, spy, SinonStub } from 'sinon'; import { Editing } from 'open-scd/src/Editing.js'; import { Wizarding } from 'open-scd/src/Wizarding.js'; @@ -10,6 +10,7 @@ import { VERSION_ENTRY_ELEMENT_NAME, } from '../../unit/compas/CompasSclDataServiceResponses.js'; import CompasVersionsPlugin from '../../../src/compas-editors/CompasVersions.js'; +import { IconButton } from '@material/mwc-icon-button'; describe('compas-versions-plugin', () => { const FETCH_FUNCTION = 'fetchData'; @@ -121,6 +122,7 @@ describe('compas-versions-plugin', () => { }); describe('items-in-list', () => { + let wizardEvent: SinonSpy; beforeEach(async () => { element = fixtureSync(html` { element.historyItem = result; } ); - + wizardEvent = spy(); + window.addEventListener('wizard', wizardEvent); await element.updateComplete; await waitUntil(() => element.historyItem !== undefined); }); @@ -152,6 +155,14 @@ describe('compas-versions-plugin', () => { ).to.have.length(3); }); + it('dispatches a wizard event when edit button is clicked', () => { + (element.shadowRoot!.querySelector('mwc-icon-button[icon="edit"]')! as IconButton).click() + expect(wizardEvent).to.have.been.calledOnce; + expect(wizardEvent.args[0][0].detail.wizard()[0].title).to.contain( + 'compas.scl.wizardTitle' + ); + }); + it('first entry has correct buttons', () => { expect( element.shadowRoot!.querySelectorAll('mwc-list > mwc-check-list-item')