Skip to content

Commit

Permalink
chore: add requested changes from @juancho0202
Browse files Browse the repository at this point in the history
Signed-off-by: Stef3st <[email protected]>
  • Loading branch information
Stef3st committed Jan 11, 2024
1 parent 7215e8b commit 327d095
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* @web/test-runner snapshot v1 */
export const snapshots = {};

snapshots["Wizards for SCL element LDevice Allowing ldName editing looks like the latest snapshot"] =
snapshots["Wizards for SCL element LDevice Allowing/Disallowing ldName editing looks like the latest snapshot"] =
`<mwc-dialog
defaultaction="next"
heading="[ldevice.wizard.title.edit]"
Expand Down Expand Up @@ -48,5 +48,5 @@ snapshots["Wizards for SCL element LDevice Allowing ldName editing looks like th
</mwc-button>
</mwc-dialog>
`;
/* end snapshot Wizards for SCL element LDevice Allowing ldName editing looks like the latest snapshot */
/* end snapshot Wizards for SCL element LDevice Allowing/Disallowing ldName editing looks like the latest snapshot */

44 changes: 39 additions & 5 deletions packages/open-scd/test/unit/wizards/ldevice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import '../../mock-wizard.js';
import { MockWizard } from '../../mock-wizard.js';

import { WizardTextField } from '../../../src/wizard-textfield.js';
import { WizardInputElement } from '../../../src/foundation.js';
import {
WizardInputElement,
createUpdateAction,
getValue,
} from '../../../src/foundation.js';
import { editLDeviceWizard } from '../../../src/wizards/ldevice.js';

import { fetchDoc, setWizardTextFieldValue } from './test-support.js';
import {
fetchDoc,
setWizardTextFieldValue,
expectUpdateAction,
} from './test-support.js';

describe('Wizards for SCL element LDevice', () => {
let doc: XMLDocument;
Expand Down Expand Up @@ -48,7 +55,7 @@ describe('Wizards for SCL element LDevice', () => {
).to.be.equal('');
});

describe('Allowing ldName editing', () => {
describe('Allowing/Disallowing ldName editing', () => {
it('ConfLdName should not be present and therefore ldName should be readonly', async function () {
expect(services.querySelector('ConfLdName')).to.not.exist;
expect(<WizardTextField>inputs[0]).to.have.attribute('readonly');
Expand All @@ -58,7 +65,7 @@ describe('Wizards for SCL element LDevice', () => {
await expect(element.wizardUI.dialog).dom.to.equalSnapshot();
});

it('ConfLdName should be present in IED1 and therefore ldName should be readonly', async function () {
it('ConfLdName should be present in IED1 and therefore ldName should not be readonly', async function () {
ied = doc.querySelector('IED[name="IED1"]')!;
services = ied.querySelector('Services')!;
ldevice = ied.querySelectorAll('AccessPoint > Server > LDevice')[0];
Expand All @@ -70,6 +77,33 @@ describe('Wizards for SCL element LDevice', () => {

expect(services.querySelector('ConfLdName')).to.exist;
expect(<WizardTextField>inputs[0]).to.not.have.attribute('readonly');

describe('Modify ldName', () => {
it('should be registered as an update action', async () => {
const newValue = 'LDevice1';
const ldeviceTextField = (<WizardTextField[]>inputs).find(
textField => textField.label == 'ldName'
)!;

expect(ldeviceTextField?.value).to.be.equal('');
await setWizardTextFieldValue(ldeviceTextField, newValue);

const ldNameVal = getValue(inputs.find(i => i.label === 'ldName')!)!;
expect(ldNameVal).to.not.be.equal(ldevice.getAttribute('ldName'));

const simpleAction = createUpdateAction(ldevice, {
ldName: ldNameVal,
});

expectUpdateAction(
simpleAction,
ldevice.tagName,
ldeviceTextField.label,
null,
newValue
);
});
});
});
});
});

0 comments on commit 327d095

Please sign in to comment.