@@ -21,16 +21,51 @@ const doc = new DOMParser().parseFromString(dataSetDoc, 'application/xml');
2121
2222describe ( 'DataSet editor component' , ( ) => {
2323 let editEvent : SinonSpy ;
24+ let editor : DataSetEditor ;
2425
2526 beforeEach ( async ( ) => {
26- await fixture ( html `< data-set-editor .doc ="${ doc } "> </ data-set-editor > ` ) ;
27+ editor = await fixture (
28+ html `< data-set-editor .doc ="${ doc } "> </ data-set-editor > `
29+ ) ;
2730
2831 editEvent = spy ( ) ;
2932 window . addEventListener ( 'oscd-edit-v2' , editEvent ) ;
3033 } ) ;
3134
32- it ( 'allows to add a new empty DataSet element' , async ( ) => {
33- await sendMouse ( { type : 'click' , position : [ 760 , 100 ] } ) ;
35+ it ( 'allows to add a new empty DataSet element to a selected LDevice if multiple LDevices are available' , async ( ) => {
36+ // should open LDevice select dialog
37+ const addDataSetListItem = editor . shadowRoot
38+ ?. querySelector ( 'action-list' )
39+ ?. shadowRoot ?. querySelector ( 'md-list:nth-child(2)' )
40+ ?. querySelector ( 'md-list-item' ) as HTMLElement ;
41+ expect ( addDataSetListItem ) . to . exist ;
42+ addDataSetListItem . click ( ) ;
43+
44+ await editor . updateComplete ;
45+ await Promise . resolve ( ) ;
46+
47+ // get the dialog
48+ const dialog = editor . lDeviceSelectDialog ;
49+
50+ // get the second lDevice radio button
51+ const radio = dialog
52+ . querySelector ( 'md-list' )
53+ ?. querySelector ( 'md-list-item:nth-child(2)' ) !
54+ . querySelector ( 'md-radio' ) as HTMLElement ;
55+
56+ // select second lDevice as target
57+ radio . click ( ) ;
58+ await editor . updateComplete ;
59+ await Promise . resolve ( ) ;
60+
61+ // click the "Select" button
62+ const selectBtn = dialog . querySelector (
63+ 'md-text-button.do.picker.save'
64+ ) as HTMLElement ;
65+ selectBtn . click ( ) ;
66+
67+ await editor . updateComplete ;
68+ await Promise . resolve ( ) ;
3469
3570 expect ( editEvent ) . to . have . been . calledOnce ;
3671
@@ -61,6 +96,7 @@ describe('DataSet editor component', () => {
6196
6297 const actionList = ( el as DataSetEditor ) . selectionList ;
6398 expect ( actionList ) . to . exist ;
99+ actionList . items ;
64100 expect ( actionList . searchValue ) . to . equal ( 'IED1' ) ;
65101 } ) ;
66102} ) ;
0 commit comments