Skip to content

Commit de87245

Browse files
author
Dennis Labordus
committed
Fixed test.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent ed61e72 commit de87245

File tree

4 files changed

+59
-26
lines changed

4 files changed

+59
-26
lines changed

src/compas-editors/CompasVersions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ export default class CompasVersionsPlugin extends LitElement {
4444
docName!: string;
4545

4646
@property()
47-
itemHistory!: Element[];
47+
historyItem!: Element[];
4848

4949
firstUpdated(): void {
5050
if (!this.docId) {
51-
this.itemHistory = [];
51+
this.historyItem = [];
5252
} else {
5353
this.fetchData()
5454
}
@@ -58,10 +58,10 @@ export default class CompasVersionsPlugin extends LitElement {
5858
const type = getTypeFromDocName(this.docName);
5959
CompasSclDataService().listVersions(type, this.docId)
6060
.then(xmlResponse => {
61-
this.itemHistory = Array.from(xmlResponse.querySelectorAll('HistoryItem') ?? []);
61+
this.historyItem = Array.from(xmlResponse.querySelectorAll('HistoryItem') ?? []);
6262
})
6363
.catch(() => {
64-
this.itemHistory = [];
64+
this.historyItem = [];
6565
});
6666
}
6767

@@ -169,13 +169,13 @@ export default class CompasVersionsPlugin extends LitElement {
169169
}
170170

171171
render(): TemplateResult {
172-
if (!this.itemHistory) {
172+
if (!this.historyItem) {
173173
return html `
174174
<compas-loading></compas-loading>
175175
`
176176
}
177177

178-
if (this.itemHistory.length <= 0) {
178+
if (this.historyItem.length <= 0) {
179179
return html `
180180
<mwc-list>
181181
<mwc-list-item>
@@ -221,7 +221,7 @@ export default class CompasVersionsPlugin extends LitElement {
221221
@selected=${(evt: MultiSelectedEvent) => {
222222
selectedVersionsOnCompasVersionsEditor = evt.detail.index;
223223
}}>
224-
${this.itemHistory.map( (item, index, items) => {
224+
${this.historyItem.map( (item, index, items) => {
225225
const version = getElementByName(item, SDS_NAMESPACE, "Version")!.textContent ?? '';
226226
if (items.length - 1 === index) {
227227
return html`<mwc-check-list-item value="${version}"

test/integration/compas-editors/CompasVersions.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('compas-versions-plugin', () => {
4141
});
4242

4343
await element;
44-
await waitUntil(() => element.itemHistory !== undefined);
44+
await waitUntil(() => element.historyItem !== undefined);
4545
});
4646

4747
afterEach(() => {
@@ -85,11 +85,11 @@ describe('compas-versions-plugin', () => {
8585

8686
stub = stubFetchResponseFunction(element, FETCH_FUNCTION, undefined, VERSION_ENTRY_ELEMENT_NAME,
8787
(result: Element[]) => {
88-
element.itemHistory = result;
88+
element.historyItem = result;
8989
});
9090

9191
await element;
92-
await waitUntil(() => element.itemHistory !== undefined);
92+
await waitUntil(() => element.historyItem !== undefined);
9393
});
9494

9595
afterEach(() => {
@@ -110,11 +110,11 @@ describe('compas-versions-plugin', () => {
110110

111111
stub = stubFetchResponseFunction(element, FETCH_FUNCTION, BASIC_VERSIONS_LIST_RESPONSE, VERSION_ENTRY_ELEMENT_NAME,
112112
(result: Element[]) => {
113-
element.itemHistory = result;
113+
element.historyItem = result;
114114
});
115115

116116
await element;
117-
await waitUntil(() => element.itemHistory !== undefined);
117+
await waitUntil(() => element.historyItem !== undefined);
118118
});
119119

120120
afterEach(() => {

test/integration/compas-editors/__snapshots__/CompasVersions.test.snap.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @web/test-runner snapshot v1 */
22
export const snapshots = {};
33

4-
snapshots["compas-versions-plugin no-compas-document looks like the latest snapshot"] =
4+
snapshots["compas-versions-plugin no-compas-document looks like the latest snapshot"] =
55
`<mwc-list>
66
<mwc-list-item
77
aria-disabled="false"
@@ -18,15 +18,15 @@ snapshots["compas-versions-plugin no-compas-document looks like the latest snaps
1818
`;
1919
/* end snapshot compas-versions-plugin no-compas-document looks like the latest snapshot */
2020

21-
snapshots["compas-versions-plugin show-loading looks like the latest snapshot"] =
21+
snapshots["compas-versions-plugin show-loading looks like the latest snapshot"] =
2222
`<compas-loading>
2323
</compas-loading>
2424
<wizard-dialog>
2525
</wizard-dialog>
2626
`;
2727
/* end snapshot compas-versions-plugin show-loading looks like the latest snapshot */
2828

29-
snapshots["compas-versions-plugin no-items-in-list looks like the latest snapshot"] =
29+
snapshots["compas-versions-plugin no-items-in-list looks like the latest snapshot"] =
3030
`<mwc-list>
3131
<mwc-list-item
3232
aria-disabled="false"
@@ -43,7 +43,7 @@ snapshots["compas-versions-plugin no-items-in-list looks like the latest snapsho
4343
`;
4444
/* end snapshot compas-versions-plugin no-items-in-list looks like the latest snapshot */
4545

46-
snapshots["compas-versions-plugin items-in-list looks like the latest snapshot"] =
46+
snapshots["compas-versions-plugin items-in-list looks like the latest snapshot"] =
4747
`<h1>
4848
[compas.versions.sclInfo]
4949
<nav>
@@ -76,9 +76,17 @@ snapshots["compas-versions-plugin items-in-list looks like the latest snapshot"]
7676
graphic="icon"
7777
mwc-list-item=""
7878
tabindex="0"
79+
twoline=""
7980
value="1.0.0"
8081
>
81-
demo_station1 (1.0.0)
82+
<span>
83+
demo_station1 (Version: 1.0.0)
84+
</span>
85+
<span slot="secondary">
86+
Who: "Mr Editor",
87+
When: "2021-11-22T03:47:00+01:00",
88+
What: "SCL created, test configuration for station 0001"
89+
</span>
8290
<span slot="graphic">
8391
<mwc-icon>
8492
restore
@@ -93,9 +101,17 @@ snapshots["compas-versions-plugin items-in-list looks like the latest snapshot"]
93101
graphic="icon"
94102
mwc-list-item=""
95103
tabindex="-1"
104+
twoline=""
96105
value="2.0.0"
97106
>
98-
demo_station1 (2.0.0)
107+
<span>
108+
demo_station1 (Version: 2.0.0)
109+
</span>
110+
<span slot="secondary">
111+
Who: "Mr Editor",
112+
When: "2021-11-22T03:47:16+01:00",
113+
What: "SCL updated, Updated the Station with breakers"
114+
</span>
99115
<span slot="graphic">
100116
<mwc-icon>
101117
restore
@@ -110,9 +126,17 @@ snapshots["compas-versions-plugin items-in-list looks like the latest snapshot"]
110126
graphic="icon"
111127
mwc-list-item=""
112128
tabindex="-1"
129+
twoline=""
113130
value="2.1.0"
114131
>
115-
3b572a56-51cc-479b-97fd-e404ebf9ae67 (2.1.0)
132+
<span>
133+
3b572a56-51cc-479b-97fd-e404ebf9ae67 (Version: 2.1.0)
134+
</span>
135+
<span slot="secondary">
136+
Who: "Mr Editor",
137+
When: "2021-11-22T03:47:18+01:00",
138+
What: "SCL updated, Updated the Station with breakers"
139+
</span>
116140
<span slot="graphic">
117141
<mwc-icon>
118142
restore

test/unit/compas/CompasSclDataServiceResponses.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,32 @@ export const BASIC_ITEM_LIST_RESPONSE = `
2929
</Item>
3030
</ListResponse>`;
3131

32-
export const VERSION_ENTRY_ELEMENT_NAME = 'Item';
32+
export const VERSION_ENTRY_ELEMENT_NAME = 'HistoryItem';
3333
export const BASIC_VERSIONS_LIST_RESPONSE = `
3434
<ListResponse xmlns="${SDS_NAMESPACE}">
35-
<Item>
35+
<HistoryItem>
3636
<Id>3b572a56-51cc-479b-97fd-e404ebf9ae67</Id>
3737
<Name>demo_station1</Name>
3838
<Version>1.0.0</Version>
39-
</Item>
40-
<Item>
39+
<Who>Mr Editor</Who>
40+
<When>2021-11-22T03:47:00+01:00</When>
41+
<What>SCL created, test configuration for station 0001</What>
42+
</HistoryItem>
43+
<HistoryItem>
4144
<Id>3b572a56-51cc-479b-97fd-e404ebf9ae67</Id>
4245
<Name>demo_station1</Name>
4346
<Version>2.0.0</Version>
44-
</Item>
45-
<Item>
47+
<Who>Mr Editor</Who>
48+
<When>2021-11-22T03:47:16+01:00</When>
49+
<What>SCL updated, Updated the Station with breakers</What>
50+
</HistoryItem>
51+
<HistoryItem>
4652
<Id>3b572a56-51cc-479b-97fd-e404ebf9ae67</Id>
4753
<Version>2.1.0</Version>
48-
</Item>
54+
<Who>Mr Editor</Who>
55+
<When>2021-11-22T03:47:18+01:00</When>
56+
<What>SCL updated, Updated the Station with breakers</What>
57+
</HistoryItem>
4958
</ListResponse>`;
5059

5160
export function stubFetchResponseFunction(element: any,

0 commit comments

Comments
 (0)