From e240255f83814d36afa129f384f4ccc7a1989ef5 Mon Sep 17 00:00:00 2001 From: Juan Munoz Date: Mon, 4 Dec 2023 15:51:16 +0100 Subject: [PATCH] chore: restored rename SCL button behavior test: added missing integration test Signed-off-by: Juan Munoz --- .../src/compas-editors/CompasVersions.ts | 4 ++-- .../compas-editors/CompasVersions.test.ts | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) 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 5dcccc6d1..ad3993983 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 '../../../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'; @@ -103,6 +104,7 @@ describe('compas-versions-plugin', () => { }); describe('items-in-list', () => { + let wizardEvent: SinonSpy; beforeEach(async () => { element = fixtureSync(html` @@ -112,7 +114,8 @@ describe('compas-versions-plugin', () => { (result: Element[]) => { element.historyItem = result; }); - + wizardEvent = spy(); + window.addEventListener('wizard', wizardEvent); await element.updateComplete; await waitUntil(() => element.historyItem !== undefined); }); @@ -126,6 +129,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').length) .to.be.greaterThan(1);