Skip to content

Commit 1c168c3

Browse files
author
Dennis Labordus
committed
Fixed broken tests.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 4811359 commit 1c168c3

File tree

11 files changed

+241
-83
lines changed

11 files changed

+241
-83
lines changed

test/unit/compas-wizards/__snapshots__/scl.test.snap.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ snapshots["Wizards for SCL element (CoMPAS) edit scl looks like the latest snaps
1717
validationmessage="[textfield.required]"
1818
>
1919
</wizard-textfield>
20+
<h3 style="color: var(--mdc-theme-on-surface);">
21+
[compas.scl.labelsTitle]
22+
</h3>
23+
<compas-labels-field>
24+
</compas-labels-field>
2025
</div>
2126
<mwc-button
2227
dialogaction="close"

test/unit/compas-wizards/scl.test.ts

Lines changed: 76 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,45 @@ import '../../mock-wizard.js';
44
import { MockWizard } from '../../mock-wizard.js';
55

66
import { WizardTextField } from '../../../src/wizard-textfield.js';
7-
import { WizardInputElement } from '../../../src/foundation.js';
7+
import {
8+
Create,
9+
isCreate,
10+
isReplace,
11+
Replace,
12+
Wizard,
13+
WizardInputElement,
14+
} from '../../../src/foundation.js';
815

916
import {
10-
executeWizardCreateAction,
11-
executeWizardReplaceAction,
12-
expectWizardNoUpdateAction,
17+
executeWizardComplexAction,
1318
fetchDoc,
1419
setWizardTextFieldValue,
1520
} from '../wizards/test-support.js';
1621
import {
1722
editCompasSCLWizard,
18-
updateSCL
19-
} from "../../../src/compas-wizards/scl.js";
23+
updateSCL,
24+
} from '../../../src/compas-wizards/scl.js';
2025

2126
describe('Wizards for SCL element (CoMPAS)', () => {
2227
let doc: XMLDocument;
2328
let scl: Element;
2429
let element: MockWizard;
30+
let wizard: Wizard;
2531
let inputs: WizardInputElement[];
2632

2733
async function createWizard(scl: Element): Promise<void> {
28-
element = await fixture(html`
29-
<mock-wizard></mock-wizard>`);
30-
const wizard = editCompasSCLWizard(scl);
34+
element = await fixture(html` <mock-wizard></mock-wizard>`);
35+
wizard = editCompasSCLWizard(scl);
3136
element.workflow.push(() => wizard);
3237
await element.requestUpdate();
3338
inputs = Array.from(element.wizardUI.inputs);
3439
}
3540

3641
describe('edit scl', () => {
3742
beforeEach(async () => {
38-
doc = await fetchDoc('/test/testfiles/compas/compas-scl-private-update-existing.scd');
43+
doc = await fetchDoc(
44+
'/test/testfiles/compas/compas-scl-private-update-existing.scd'
45+
);
3946
scl = doc.querySelector('SCL')!;
4047

4148
await createWizard(scl);
@@ -48,7 +55,9 @@ describe('Wizards for SCL element (CoMPAS)', () => {
4855

4956
describe('edit scl with existing SCL Name Element', () => {
5057
beforeEach(async () => {
51-
doc = await fetchDoc('/test/testfiles/compas/compas-scl-private-update-existing.scd');
58+
doc = await fetchDoc(
59+
'/test/testfiles/compas/compas-scl-private-update-existing.scd'
60+
);
5261
scl = doc.querySelector('SCL')!;
5362

5463
await createWizard(scl);
@@ -57,21 +66,38 @@ describe('Wizards for SCL element (CoMPAS)', () => {
5766
it('update SCL Name should be updated in document', async function () {
5867
await setWizardTextFieldValue(<WizardTextField>inputs[0], 'updated');
5968

60-
const replaceAction = executeWizardReplaceAction(updateSCL(scl), inputs);
69+
const complexAction = executeWizardComplexAction(
70+
updateSCL(scl),
71+
element.wizardUI,
72+
inputs
73+
);
74+
75+
expect(complexAction.actions.length).to.be.equal(2);
76+
expect(complexAction.actions[0]).to.satisfy(isReplace);
77+
78+
const replaceAction = <Replace>complexAction.actions[0];
6179
expect(replaceAction.old.element.tagName).to.be.equal('compas:SclName');
62-
expect(replaceAction.old.element).to.have.text('existing');
63-
expect(replaceAction.new.element.tagName).to.be.equal('compas:SclName');
64-
expect(replaceAction.new.element).to.have.text('updated');
80+
expect(replaceAction.old.element.textContent).to.be.equal('existing');
81+
expect(replaceAction.new.element.textContent).to.be.equal('updated');
6582
});
6683

67-
it('when no fields changed there will be no update action', async function () {
68-
expectWizardNoUpdateAction(updateSCL(scl), inputs);
84+
it('when no fields changed there will only be a Labels change', async function () {
85+
const complexAction = executeWizardComplexAction(
86+
updateSCL(scl),
87+
element.wizardUI,
88+
inputs
89+
);
90+
91+
expect(complexAction.actions.length).to.be.equal(1);
92+
expect(complexAction.actions[0]).to.satisfy(isCreate);
6993
});
7094
});
7195

7296
describe('edit scl with missing SCL Name Element', () => {
7397
beforeEach(async () => {
74-
doc = await fetchDoc('/test/testfiles/compas/compas-scl-private-missing-scl-name.scd');
98+
doc = await fetchDoc(
99+
'/test/testfiles/compas/compas-scl-private-missing-scl-name.scd'
100+
);
75101
scl = doc.querySelector('SCL')!;
76102

77103
await createWizard(scl);
@@ -80,16 +106,29 @@ describe('Wizards for SCL element (CoMPAS)', () => {
80106
it('update SCL Name should be updated in document', async function () {
81107
await setWizardTextFieldValue(<WizardTextField>inputs[0], 'updated');
82108

83-
const createAction = executeWizardCreateAction(updateSCL(scl), inputs);
109+
const complexAction = executeWizardComplexAction(
110+
updateSCL(scl),
111+
element.wizardUI,
112+
inputs
113+
);
114+
115+
expect(complexAction.actions.length).to.be.equal(2);
116+
expect(complexAction.actions[0]).to.satisfy(isCreate);
117+
118+
const createAction = <Create>complexAction.actions[0];
84119
expect((<Element>createAction.new.parent).tagName).to.be.equal('Private');
85-
expect((<Element>createAction.new.element).tagName).to.be.equal('compas:SclName');
120+
expect((<Element>createAction.new.element).tagName).to.be.equal(
121+
'compas:SclName'
122+
);
86123
expect(createAction.new.element).to.have.text('updated');
87124
});
88125
});
89126

90127
describe('edit scl with missing Private Element', () => {
91128
beforeEach(async () => {
92-
doc = await fetchDoc('/test/testfiles/compas/compas-scl-private-missing-private.scd');
129+
doc = await fetchDoc(
130+
'/test/testfiles/compas/compas-scl-private-missing-private.scd'
131+
);
93132
scl = doc.querySelector('SCL')!;
94133

95134
await createWizard(scl);
@@ -98,14 +137,23 @@ describe('Wizards for SCL element (CoMPAS)', () => {
98137
it('update SCL Name should be updated in document', async function () {
99138
await setWizardTextFieldValue(<WizardTextField>inputs[0], 'updated');
100139

101-
const createAction = executeWizardCreateAction(updateSCL(scl), inputs);
102-
expect((<Element>createAction.new.parent).tagName).to.be.equal('SCL');
103-
expect((<Element>createAction.new.element).tagName).to.be.equal('Private');
140+
const complexAction = executeWizardComplexAction(
141+
updateSCL(scl),
142+
element.wizardUI,
143+
inputs
144+
);
145+
146+
expect(complexAction.actions.length).to.be.equal(2);
147+
expect(complexAction.actions[0]).to.satisfy(isCreate);
104148

105-
const newSclNameElement = (<Element>createAction.new.element).querySelector('SclName');
106-
expect(newSclNameElement).to.not.be.null;
107-
expect(newSclNameElement!.tagName).to.be.equal('compas:SclName');
108-
expect(newSclNameElement).to.have.text('updated');
149+
// Because the private is created for the Labels outside the Actions it will be the same
150+
// Create Action being returned, but the Private Element is added directly to the SCL Element.
151+
const createAction = <Create>complexAction.actions[0];
152+
expect((<Element>createAction.new.parent).tagName).to.be.equal('Private');
153+
expect((<Element>createAction.new.element).tagName).to.be.equal(
154+
'compas:SclName'
155+
);
156+
expect(createAction.new.element).to.have.text('updated');
109157
});
110158
});
111159
});

test/unit/editors/protocol104/wizards/address.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('Wizards for 104 Address Element', () => {
6060

6161
const updateAction = executeWizardReplaceAction(
6262
updateAddressValue(doi, dai, address),
63+
element.wizardUI,
6364
inputs
6465
);
6566
expect(updateAction.old.element).to.have.attribute('casdu', '1');
@@ -69,7 +70,11 @@ describe('Wizards for 104 Address Element', () => {
6970
});
7071

7172
it('when no fields changed there will be no update action', async function () {
72-
expectWizardNoUpdateAction(updateAddressValue(doi, dai, address), inputs);
73+
expectWizardNoUpdateAction(
74+
updateAddressValue(doi, dai, address),
75+
element.wizardUI,
76+
inputs
77+
);
7378
});
7479

7580
it('looks like the latest snapshot', async () => {
@@ -101,6 +106,7 @@ describe('Wizards for 104 Address Element', () => {
101106

102107
const updateAction = executeWizardReplaceAction(
103108
updateAddressValue(doi, dai, address),
109+
element.wizardUI,
104110
inputs
105111
);
106112
expect(updateAction.old.element).to.not.have.attribute('unitMultiplier');
@@ -125,6 +131,7 @@ describe('Wizards for 104 Address Element', () => {
125131

126132
const updateAction = executeWizardReplaceAction(
127133
updateAddressValue(doi, dai, address),
134+
element.wizardUI,
128135
inputs
129136
);
130137
expect(updateAction.old.element).to.not.have.attribute('scaleMultiplier');

test/unit/editors/singlelinediagram/wizards/bay.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('Wizards for SCL element Bay (X/Y)', () => {
3636

3737
const updateAction = executeWizardReplaceAction(
3838
updateNamingAndCoordinatesAction(bay),
39+
element.wizardUI,
3940
inputs
4041
);
4142
expect(updateAction.old.element).to.have.attribute('name', 'BusBar A');
@@ -50,6 +51,7 @@ describe('Wizards for SCL element Bay (X/Y)', () => {
5051

5152
const updateAction = executeWizardReplaceAction(
5253
updateNamingAndCoordinatesAction(bay),
54+
element.wizardUI,
5355
inputs
5456
);
5557
expect(updateAction.old.element).to.not.have.attribute('desc');
@@ -64,6 +66,7 @@ describe('Wizards for SCL element Bay (X/Y)', () => {
6466

6567
const updateAction = executeWizardReplaceAction(
6668
updateNamingAndCoordinatesAction(bay),
69+
element.wizardUI,
6770
inputs
6871
);
6972
expect(updateAction.old.element).to.have.attribute('sxy:x', '1');
@@ -75,6 +78,7 @@ describe('Wizards for SCL element Bay (X/Y)', () => {
7578

7679
const updateAction = executeWizardReplaceAction(
7780
updateNamingAndCoordinatesAction(bay),
81+
element.wizardUI,
7882
inputs
7983
);
8084
expect(updateAction.old.element).to.have.attribute('sxy:y', '1');
@@ -86,14 +90,19 @@ describe('Wizards for SCL element Bay (X/Y)', () => {
8690

8791
const updateAction = executeWizardReplaceAction(
8892
updateNamingAndCoordinatesAction(bay),
93+
element.wizardUI,
8994
inputs
9095
);
9196
expect(updateAction.old.element).to.have.attribute('sxy:y', '1');
9297
expect(updateAction.new.element).to.not.have.attribute('sxy:y');
9398
});
9499

95100
it('when no fields changed there will be no update action', async function () {
96-
expectWizardNoUpdateAction(updateNamingAndCoordinatesAction(bay), inputs);
101+
expectWizardNoUpdateAction(
102+
updateNamingAndCoordinatesAction(bay),
103+
element.wizardUI,
104+
inputs
105+
);
97106
});
98107

99108
it('looks like the latest snapshot', async () => {

test/unit/editors/singlelinediagram/wizards/conductingequipment.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('Wizards for SCL element Conducting Equipment (X/Y)', () => {
3636

3737
const updateAction = executeWizardReplaceAction(
3838
updateNamingAndCoordinatesAction(conductingEquipment),
39+
element.wizardUI,
3940
inputs
4041
);
4142
expect(updateAction.old.element).to.have.attribute('name', 'QB1');
@@ -50,6 +51,7 @@ describe('Wizards for SCL element Conducting Equipment (X/Y)', () => {
5051

5152
const updateAction = executeWizardReplaceAction(
5253
updateNamingAndCoordinatesAction(conductingEquipment),
54+
element.wizardUI,
5355
inputs
5456
);
5557
expect(updateAction.old.element).to.not.have.attribute('desc');
@@ -64,6 +66,7 @@ describe('Wizards for SCL element Conducting Equipment (X/Y)', () => {
6466

6567
const updateAction = executeWizardReplaceAction(
6668
updateNamingAndCoordinatesAction(conductingEquipment),
69+
element.wizardUI,
6770
inputs
6871
);
6972
expect(updateAction.old.element).to.have.attribute('sxy:x', '1');
@@ -75,6 +78,7 @@ describe('Wizards for SCL element Conducting Equipment (X/Y)', () => {
7578

7679
const updateAction = executeWizardReplaceAction(
7780
updateNamingAndCoordinatesAction(conductingEquipment),
81+
element.wizardUI,
7882
inputs
7983
);
8084
expect(updateAction.old.element).to.have.attribute('sxy:y', '1');
@@ -86,6 +90,7 @@ describe('Wizards for SCL element Conducting Equipment (X/Y)', () => {
8690

8791
const updateAction = executeWizardReplaceAction(
8892
updateNamingAndCoordinatesAction(conductingEquipment),
93+
element.wizardUI,
8994
inputs
9095
);
9196
expect(updateAction.old.element).to.have.attribute('sxy:y', '1');
@@ -95,6 +100,7 @@ describe('Wizards for SCL element Conducting Equipment (X/Y)', () => {
95100
it('when no fields changed there will be no update action', async function () {
96101
expectWizardNoUpdateAction(
97102
updateNamingAndCoordinatesAction(conductingEquipment),
103+
element.wizardUI,
98104
inputs
99105
);
100106
});

test/unit/editors/singlelinediagram/wizards/powertransformer.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('Wizards for SCL element Power Transformer (X/Y)', () => {
3636

3737
const updateAction = executeWizardReplaceAction(
3838
updateNamingAndCoordinatesAction(powerTransformer),
39+
element.wizardUI,
3940
inputs
4041
);
4142
expect(updateAction.old.element).to.have.attribute('name', 'TA1');
@@ -50,6 +51,7 @@ describe('Wizards for SCL element Power Transformer (X/Y)', () => {
5051

5152
const updateAction = executeWizardReplaceAction(
5253
updateNamingAndCoordinatesAction(powerTransformer),
54+
element.wizardUI,
5355
inputs
5456
);
5557
expect(updateAction.old.element).to.not.have.attribute('desc');
@@ -64,6 +66,7 @@ describe('Wizards for SCL element Power Transformer (X/Y)', () => {
6466

6567
const updateAction = executeWizardReplaceAction(
6668
updateNamingAndCoordinatesAction(powerTransformer),
69+
element.wizardUI,
6770
inputs
6871
);
6972
expect(updateAction.old.element).to.have.attribute('sxy:x', '1');
@@ -75,6 +78,7 @@ describe('Wizards for SCL element Power Transformer (X/Y)', () => {
7578

7679
const updateAction = executeWizardReplaceAction(
7780
updateNamingAndCoordinatesAction(powerTransformer),
81+
element.wizardUI,
7882
inputs
7983
);
8084
expect(updateAction.old.element).to.have.attribute('sxy:y', '9');
@@ -86,6 +90,7 @@ describe('Wizards for SCL element Power Transformer (X/Y)', () => {
8690

8791
const updateAction = executeWizardReplaceAction(
8892
updateNamingAndCoordinatesAction(powerTransformer),
93+
element.wizardUI,
8994
inputs
9095
);
9196
expect(updateAction.old.element).to.have.attribute('sxy:y', '9');
@@ -95,6 +100,7 @@ describe('Wizards for SCL element Power Transformer (X/Y)', () => {
95100
it('when no fields changed there will be no update action', async function () {
96101
expectWizardNoUpdateAction(
97102
updateNamingAndCoordinatesAction(powerTransformer),
103+
element.wizardUI,
98104
inputs
99105
);
100106
});

0 commit comments

Comments
 (0)