@@ -192,6 +192,23 @@ describe('User templates', function() {
192192 { index : 'ContentControls.ByIndex.4' , type : 'checkbox' , alias : '' , checked : false } ,
193193 ]
194194
195+ // Intercept the initial templates request to ensure it does not get the fields yet
196+ cy . intercept (
197+ 'GET' ,
198+ '**/apps/files/api/v1/templates' ,
199+ ( req ) => req . continue ( ) ,
200+ ) . as ( 'templatesRequest' )
201+
202+ // Intercept the POST request to verify the correct fields are submitted
203+ cy . intercept ( 'POST' , '**/templates/create' , ( req ) => {
204+ const templateFields = Object . values ( req . body . templateFields )
205+
206+ expect ( templateFields [ 0 ] . content ) . to . equal ( fields [ 0 ] . content )
207+ expect ( templateFields [ 1 ] . content ) . to . equal ( fields [ 1 ] . content )
208+
209+ req . continue ( )
210+ } ) . as ( 'reqFillFields' )
211+
195212 cy . visit ( '/apps/files' )
196213
197214 // Create a new document
@@ -205,21 +222,19 @@ describe('User templates', function() {
205222 cy . get ( 'input[data-cy-files-new-node-dialog-input=""]' ) . type ( 'FileFromTemplateWithFields' )
206223 cy . get ( 'button[data-cy-files-new-node-dialog-submit=""]' ) . click ( )
207224
225+ // Ensure the template fields array is of length 0, meaning no fields were fetched
226+ cy . wait ( '@templatesRequest' ) . then ( ( { response } ) => {
227+ const templates = response . body . ocs . data
228+ const template = templates [ 1 ] . templates [ 0 ]
229+
230+ expect ( template . fields . length ) . to . equal ( 0 )
231+ } )
232+
208233 // Choose the document template
209234 cy . get ( 'form.templates-picker__form' ) . as ( 'templatePicker' )
210235 cy . get ( '@templatePicker' ) . contains ( 'document' ) . click ( )
211236 cy . get ( '@templatePicker' ) . find ( 'input[type="submit"]' ) . click ( )
212237
213- // Intercept the POST request to verify the correct fields are submitted
214- cy . intercept ( 'POST' , '**/templates/create' , ( req ) => {
215- const templateFields = Object . values ( req . body . templateFields )
216-
217- expect ( templateFields [ 0 ] . content ) . to . equal ( fields [ 0 ] . content )
218- expect ( templateFields [ 1 ] . content ) . to . equal ( fields [ 1 ] . content )
219-
220- req . continue ( )
221- } ) . as ( 'reqFillFields' )
222-
223238 cy . submitTemplateFields ( fields )
224239
225240 // Wait for the response and collect the file ID of the created file
0 commit comments