Skip to content

Commit

Permalink
Merge pull request #300 from com-pas/298-restore-edit-scl-name-in-com…
Browse files Browse the repository at this point in the history
…pas-versions

fix: restored rename SCL button behavior
  • Loading branch information
Stef3st authored Dec 11, 2023
2 parents 3e1b4a3 + 7623eba commit f43a3d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/compas-open-scd/src/compas-editors/CompasVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -121,6 +122,7 @@ describe('compas-versions-plugin', () => {
});

describe('items-in-list', () => {
let wizardEvent: SinonSpy;
beforeEach(async () => {
element = fixtureSync(html` <compas-versions-plugin
.doc="${doc}"
Expand All @@ -137,7 +139,8 @@ describe('compas-versions-plugin', () => {
element.historyItem = result;
}
);

wizardEvent = spy();
window.addEventListener('wizard', wizardEvent);
await element.updateComplete;
await waitUntil(() => element.historyItem !== undefined);
});
Expand All @@ -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')
Expand Down

0 comments on commit f43a3d9

Please sign in to comment.