@@ -267,4 +267,95 @@ describe('From a fixed app', () => {
267267 . should ( 'not.have.class' , 'q-field--error' )
268268 cy . checkThatAppValidityIs ( true )
269269 } )
270+
271+ it ( 'should validate screen Extra CFF Fields' , ( ) => {
272+ cy . visit ( '/extra-cff-fields' )
273+ // no errors initially
274+ cy . checkThatAppValidityIs ( true )
275+
276+ // YAML errors
277+ cy . dataCy ( 'input-extra-cff-fields' )
278+ . type ( 'a: -' )
279+ cy . checkThatAppValidityIs ( false )
280+ cy . dataCy ( 'list-raw-errors' )
281+ . children ( )
282+ . should ( 'have.length' , 1 )
283+ cy . dataCy ( 'item-raw-error-keyword-0' )
284+ . should ( 'contain.text' , 'keyword: "Extra CFF Fields error"' )
285+ cy . dataCy ( 'item-raw-error-message-0' )
286+ . should ( 'contain.text' , 'YAML Error: end of the stream' )
287+
288+ // wrong field
289+ cy . dataCy ( 'input-extra-cff-fields' )
290+ . clear ( )
291+ . type ( 'bad: field' )
292+ cy . checkThatAppValidityIs ( false )
293+ cy . dataCy ( 'list-raw-errors' )
294+ . children ( )
295+ . should ( 'have.length' , 1 )
296+ cy . dataCy ( 'item-raw-error-keyword-0' )
297+ . should ( 'contain.text' , 'additionalProperties' )
298+ cy . dataCy ( 'item-raw-error-message-0' )
299+ . should ( 'contain.text' , 'must NOT have additional properties' )
300+
301+ // preferred-citation
302+ cy . dataCy ( 'input-extra-cff-fields' )
303+ . clear ( )
304+ . type ( 'preferred-citation:' )
305+ cy . checkThatAppValidityIs ( false )
306+ cy . dataCy ( 'list-raw-errors' )
307+ . children ( )
308+ . should ( 'have.length' , 1 )
309+ cy . dataCy ( 'item-raw-error-instancePath-0' )
310+ . should ( 'contain.text' , '/preferred-citation' )
311+ cy . dataCy ( 'item-raw-error-message-0' )
312+ . should ( 'contain.text' , 'must be object' )
313+
314+ cy . dataCy ( 'input-extra-cff-fields' )
315+ . type ( '\n title: The Paper' )
316+ cy . dataCy ( 'list-raw-errors' )
317+ . children ( )
318+ . should ( 'have.length' , 2 )
319+ cy . dataCy ( 'item-raw-error-instancePath-0' )
320+ . should ( 'contain.text' , '/preferred-citation' )
321+ cy . dataCy ( 'item-raw-error-instancePath-1' )
322+ . should ( 'contain.text' , '/preferred-citation' )
323+ cy . dataCy ( 'item-raw-error-message-0' )
324+ . should ( 'contain.text' , "must have required property 'authors'" )
325+ cy . dataCy ( 'item-raw-error-message-1' )
326+ . should ( 'contain.text' , "must have required property 'type'" )
327+
328+ cy . dataCy ( 'input-extra-cff-fields' )
329+ . type ( '\n type: article\n authors:' )
330+ cy . dataCy ( 'list-raw-errors' )
331+ . children ( )
332+ . should ( 'have.length' , 1 )
333+ cy . dataCy ( 'item-raw-error-instancePath-0' )
334+ . should ( 'contain.text' , '/preferred-citation/authors' )
335+ cy . dataCy ( 'item-raw-error-message-0' )
336+ . should ( 'contain.text' , 'must be array' )
337+
338+ cy . dataCy ( 'input-extra-cff-fields' )
339+ . type ( ' [{}]' )
340+ cy . checkThatAppValidityIs ( true )
341+
342+ // Duplicate fields
343+ cy . dataCy ( 'input-extra-cff-fields' )
344+ . clear ( )
345+ . type ( 'title: Another title\n' )
346+ cy . dataCy ( 'list-raw-errors' )
347+ . children ( )
348+ . should ( 'have.length' , 1 )
349+ cy . dataCy ( 'item-raw-error-keyword-0' )
350+ . should ( 'contain.text' , 'keyword: "Extra CFF Fields error"' )
351+ cy . dataCy ( 'item-raw-error-message-0' )
352+ . should ( 'contain.text' , "Duplicate keys: 'title'" )
353+ cy . dataCy ( 'input-extra-cff-fields' )
354+ . type ( 'message: Another message' )
355+ cy . dataCy ( 'list-raw-errors' )
356+ . children ( )
357+ . should ( 'have.length' , 1 )
358+ cy . dataCy ( 'item-raw-error-message-0' )
359+ . should ( 'contain.text' , "Duplicate keys: 'title', 'message'" )
360+ } )
270361} )
0 commit comments