File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed
test/integration/editors/communication Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -18,21 +18,28 @@ export default class CommunicationPlugin extends LitElement {
18
18
@property ( )
19
19
doc ! : XMLDocument ;
20
20
21
- private createCommunication ( ) : void {
21
+ /**
22
+ * Creates the Communication Element and returns the created Element
23
+ * @returns {Element } Communication `Element`
24
+ */
25
+ private createCommunication ( ) : Element {
26
+ const element : Element = createElement ( this . doc , 'Communication' , { } ) ;
22
27
this . dispatchEvent (
23
28
newActionEvent ( {
24
29
new : {
25
30
parent : this . doc . documentElement ,
26
- element : createElement ( this . doc , 'Communication' , { } ) ,
31
+ element : element ,
27
32
} ,
28
33
} )
29
34
) ;
35
+ return element ;
30
36
}
31
37
32
38
/** Opens a [[`WizardDialog`]] for creating a new `SubNetwork` element. */
33
39
private openCreateSubNetworkWizard ( ) : void {
34
- const parent = this . doc . querySelector ( ':root > Communication' ) ;
35
- if ( ! parent ) this . createCommunication ( ) ;
40
+ const parent =
41
+ this . doc . querySelector ( ':root > Communication' ) ||
42
+ this . createCommunication ( ) ;
36
43
37
44
this . dispatchEvent ( newWizardEvent ( createSubNetworkWizard ( parent ! ) ) ) ;
38
45
}
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import { MockWizard } from '../../../mock-wizard.js';
6
6
import Communication from '../../../../src/editors/Communication.js' ;
7
7
import { Editing } from '../../../../src/Editing.js' ;
8
8
import { Wizarding } from '../../../../src/Wizarding.js' ;
9
+ import { Dialog } from '@material/mwc-dialog' ;
10
+ import { WizardTextField } from '../../../../src/wizard-textfield.js' ;
9
11
10
12
describe ( 'Communication Plugin' , ( ) => {
11
13
customElements . define (
@@ -73,5 +75,28 @@ describe('Communication Plugin', () => {
73
75
await parent . updateComplete ;
74
76
expect ( parent . wizardUI . dialogs . length ) . to . equal ( 1 ) ;
75
77
} ) ;
78
+
79
+ it ( 'Should create a Communication Element' , async ( ) => {
80
+ expect ( parent . wizardUI . dialogs . length ) . to . equal ( 0 ) ;
81
+ fab . click ( ) ;
82
+ await parent . updateComplete ;
83
+ expect ( parent . wizardUI . dialogs . length ) . to . equal ( 1 ) ;
84
+
85
+ const dialog : Dialog = parent . wizardUI . dialogs . item ( 0 ) ;
86
+
87
+ const nameInput : WizardTextField = dialog . querySelector < WizardTextField > ( 'wizard-textfield[label="name"]' ) ! ;
88
+
89
+ nameInput . value = 'Test' ;
90
+
91
+ const saveButton : HTMLElement = dialog . querySelector ( 'mwc-button[slot="primaryAction"]' ) ! ;
92
+
93
+ await parent . updateComplete ;
94
+
95
+ saveButton . click ( ) ;
96
+
97
+ await parent . updateComplete ;
98
+
99
+ expect ( parent . wizardUI . dialogs . length ) . to . equal ( 0 ) ;
100
+ } ) ;
76
101
} ) ;
77
102
} ) ;
You can’t perform that action at this time.
0 commit comments