@@ -13,6 +13,7 @@ context('metis-ui', () => {
13
13
const selMenuContentDepublish = '.dropdown-content.depublish' ;
14
14
const selMenuOpenAdd = '.dropdown-options.add > a' ;
15
15
const selMenuOpenDepublish = '.dropdown-options.depublish > a' ;
16
+ const selModalTitle = '.modal .head' ;
16
17
const selItemDRecords = `${ selMenuContentDepublish } :first-child a` ;
17
18
const selItemDDataset = `${ selMenuContentDepublish } :last-child a` ;
18
19
@@ -22,19 +23,30 @@ context('metis-ui', () => {
22
23
const selItemInput = `${ selMenuContentAdd } :last-child a` ;
23
24
const selLoadMore = '.tab-content .load-more-btn' ;
24
25
25
- const submitEntries = ( entries : string ) : void => {
26
+ const selSelectReason = '[name=depublicationReason]' ;
27
+ const testTexts = [ 'Test1' , 'Test2' ] ;
28
+
29
+ const submitEntriesOpen = ( fileInput = false ) : void => {
26
30
cy . get ( selMenuOpenAdd ) . click ( force ) ;
27
- cy . get ( selItemInput )
31
+ const selInput = fileInput ? selItemFile : selItemInput ;
32
+ cy . get ( selInput )
28
33
. scrollIntoView ( )
29
34
. click ( force ) ;
35
+ } ;
36
+
37
+ const submitEntries = ( entries : string , submit = true ) : void => {
38
+ submitEntriesOpen ( ) ;
30
39
cy . get ( '[name=recordIds]' ) . type ( entries ) ;
31
- cy . get ( '.modal [type="button"]' ) . click ( ) ;
40
+ if ( submit ) {
41
+ cy . get ( '.modal [type="submit"]' ) . click ( ) ;
42
+ }
32
43
cy . wait ( 100 ) ;
33
44
} ;
34
45
35
46
const deleteVisibleEntries = ( ) : void => {
47
+ const selDeleteBtn = `${ selCtrls } .btn-delete` ;
36
48
cy . get ( selCheckboxes ) . click ( { force : true , multiple : true } ) ;
37
- cy . get ( '.depublication-ctrls .btn-delete' ) . click ( force ) ;
49
+ cy . get ( selDeleteBtn ) . click ( force ) ;
38
50
cy . wait ( 100 ) ;
39
51
} ;
40
52
@@ -53,7 +65,18 @@ context('metis-ui', () => {
53
65
describe ( 'grid' , ( ) => {
54
66
it ( 'should show the grid and menus' , ( ) => {
55
67
cy . get ( selGrid ) . should ( 'have.length' , 1 ) ;
56
- cy . get ( '.depublication-ctrls' ) . should ( 'have.length' , 1 ) ;
68
+ cy . get ( selCtrls ) . should ( 'have.length' , 1 ) ;
69
+ } ) ;
70
+
71
+ it ( 'should show the grid headers' , ( ) => {
72
+ const selGridHeader = '.state-arrow' ;
73
+ [ 'Record Id' , 'Record Status' , 'Depublication Reason' , 'Unpublished Date' ] . forEach (
74
+ ( headerText : string ) => {
75
+ cy . get ( selGridHeader )
76
+ . contains ( headerText )
77
+ . should ( 'have.length' , 1 ) ;
78
+ }
79
+ ) ;
57
80
} ) ;
58
81
} ) ;
59
82
@@ -79,36 +102,42 @@ context('metis-ui', () => {
79
102
80
103
describe ( 'forms' , ( ) => {
81
104
describe ( 'successful operations' , ( ) => {
105
+ const modalTitle = 'Add record ids to depublish' ;
106
+
82
107
it ( 'should open and close the file dialog form' , ( ) => {
83
108
cy . get ( selDialogFile ) . should ( 'not.exist' ) ;
84
- cy . get ( selMenuOpenAdd ) . click ( force ) ;
85
- cy . get ( selItemFile )
86
- . scrollIntoView ( )
87
- . click ( force ) ;
109
+ cy . get ( selModalTitle ) . should ( 'not.exist' ) ;
110
+ submitEntriesOpen ( true ) ;
88
111
112
+ cy . get ( selModalTitle )
113
+ . contains ( modalTitle )
114
+ . should ( 'exist' ) ;
89
115
cy . get ( selDialogFile ) . should ( 'be.visible' ) ;
90
116
cy . get ( selDialogClose ) . click ( ) ;
91
117
cy . get ( selDialogFile ) . should ( 'not.exist' ) ;
118
+ cy . get ( selModalTitle ) . should ( 'not.exist' ) ;
92
119
} ) ;
93
120
94
121
it ( 'should open and close the input dialog form' , ( ) => {
95
122
cy . get ( selDialogInput ) . should ( 'not.exist' ) ;
96
- cy . get ( selMenuOpenAdd ) . click ( force ) ;
97
- cy . get ( selItemInput )
98
- . scrollIntoView ( )
99
- . click ( force ) ;
123
+ cy . get ( selModalTitle ) . should ( 'not.exist' ) ;
124
+ submitEntriesOpen ( ) ;
100
125
126
+ cy . get ( selModalTitle )
127
+ . contains ( modalTitle )
128
+ . should ( 'exist' ) ;
101
129
cy . get ( selDialogInput ) . should ( 'be.visible' ) ;
102
130
cy . get ( selDialogClose ) . click ( ) ;
131
+
103
132
cy . get ( selDialogInput ) . should ( 'not.exist' ) ;
133
+ cy . get ( selModalTitle ) . should ( 'not.exist' ) ;
104
134
} ) ;
105
135
106
136
it ( 'should submit new entries' , ( ) => {
107
- const testTexts = [ 'Test1' , 'Test2' ] ;
108
137
submitEntries ( testTexts . join ( '\n' ) ) ;
109
138
110
139
testTexts . forEach ( ( txt ) => {
111
- cy . get ( '. record-url ' )
140
+ cy . get ( '[data-e2e= record-id] ' )
112
141
. contains ( txt )
113
142
. should ( 'have.length' , 1 ) ;
114
143
} ) ;
@@ -154,7 +183,7 @@ context('metis-ui', () => {
154
183
cy . screenshot ( ) ;
155
184
156
185
testMore . slice ( 2 ) . forEach ( ( txt ) => {
157
- cy . get ( '. record-url ' )
186
+ cy . get ( '[data-e2e= record-id] ' )
158
187
. contains ( txt )
159
188
. should ( 'have.length' , 1 ) ;
160
189
} ) ;
@@ -184,29 +213,49 @@ context('metis-ui', () => {
184
213
} ) ;
185
214
186
215
describe ( 'confirmations' , ( ) => {
216
+ const modalTitle = 'Depublish' ;
187
217
const selDialogConfirm = '.modal-wrapper' ;
188
- const selDialogConfirmClose = selDialogConfirm + ' .btn-close' ;
218
+ const selDialogConfirmClose = ` ${ selDialogConfirm } .btn-close` ;
189
219
190
220
it ( 'should ask confirmation for dataset depublication' , ( ) => {
191
221
cy . get ( selDialogConfirm ) . should ( 'not.exist' ) ;
192
222
cy . wait ( 1000 ) ;
193
223
openDepublishMenu ( ) ;
224
+ cy . get ( selModalTitle ) . should ( 'not.exist' ) ;
225
+ cy . get ( selMenuContentDepublish ) . should ( 'exist' ) ;
226
+
194
227
cy . get ( selItemDDataset ) . click ( force ) ;
228
+ cy . get ( selModalTitle )
229
+ . contains ( modalTitle )
230
+ . should ( 'exist' ) ;
195
231
cy . get ( selDialogConfirm ) . should ( 'be.visible' ) ;
232
+ cy . get ( selSelectReason ) . should ( 'exist' ) ;
233
+ cy . get ( selSelectReason ) . should ( 'be.visible' ) ;
234
+
196
235
cy . get ( selDialogConfirmClose ) . click ( ) ;
197
236
cy . get ( selDialogConfirm ) . should ( 'not.exist' ) ;
237
+ cy . get ( selMenuContentDepublish ) . should ( 'not.exist' ) ;
238
+ cy . get ( selModalTitle ) . should ( 'not.exist' ) ;
198
239
} ) ;
199
240
200
241
it ( 'should ask confirmation for record id depublication' , ( ) => {
242
+ submitEntries ( testTexts . join ( '\n' ) ) ;
201
243
submitEntries ( 'Test1\nTest2' ) ;
202
244
cy . get ( selDialogConfirm ) . should ( 'not.exist' ) ;
245
+ cy . get ( selModalTitle ) . should ( 'not.exist' ) ;
203
246
cy . wait ( 1000 ) ;
204
247
cy . get ( selCheckbox ) . click ( { force : true , multiple : true } ) ;
205
248
openDepublishMenu ( ) ;
249
+ cy . get ( selMenuContentDepublish ) . should ( 'exist' ) ;
206
250
cy . get ( selItemDRecords ) . click ( force ) ;
207
251
cy . get ( selDialogConfirm ) . should ( 'be.visible' ) ;
252
+ cy . get ( selModalTitle )
253
+ . contains ( modalTitle )
254
+ . should ( 'exist' ) ;
208
255
cy . get ( selDialogConfirmClose ) . click ( ) ;
209
256
cy . get ( selDialogConfirm ) . should ( 'not.exist' ) ;
257
+ cy . get ( selMenuContentDepublish ) . should ( 'not.exist' ) ;
258
+ cy . get ( selModalTitle ) . should ( 'not.exist' ) ;
210
259
deleteVisibleEntries ( ) ;
211
260
} ) ;
212
261
} ) ;
0 commit comments