@@ -11,8 +11,8 @@ const moveUpCustomMetadataFieldToolSelector = '.sm-move-up-metadata-field'
1111const removeCustomMetadataFieldToolSelector = '.sm-remove-metadata-field'
1212
1313const figureMetadataSelector = '.sc-custom-metadata-field'
14- const figureCustomMetadataFieldInputSelector = '.sc-custom-metadata-field .sc-string'
15- const figureCustomMetadataFieldNameSelector = '.sc-custom-metadata-field .se-field-name .se -input'
14+ const figureCustomMetadataFieldNameSelector = '.sc-custom-metadata-field .sc-string'
15+ const figureCustomMetadataFieldValuesSelector = '.sc-custom-metadata-field .sc-keyword -input'
1616
1717const FIXTURE = `
1818 <fig-group id="fig1">
@@ -35,10 +35,12 @@ test('Figure Metadata: open figure with custom fields in manuscript and metadata
3535 let editor = openManuscriptEditor ( app )
3636 loadBodyFixture ( editor , FIXTURE )
3737 t . notNil ( editor . find ( figureMetadataSelector ) , 'there should be a figure with metadata in manuscript' )
38- const fields = editor . findAll ( figureCustomMetadataFieldInputSelector )
39- t . equal ( fields . length , 2 , 'there should be two inputs' )
40- t . equal ( fields [ 0 ] . getTextContent ( ) , 'Field I' , 'shoud be keyword label inside first' )
41- t . equal ( fields [ 1 ] . getTextContent ( ) , 'Value A, Value B' , 'shoud be values joined with comma inside second' )
38+ const fieldNames = editor . findAll ( figureCustomMetadataFieldNameSelector )
39+ const fieldValues = editor . findAll ( figureCustomMetadataFieldValuesSelector )
40+ t . equal ( fieldNames . length , 1 , 'there should be one input for a field name' )
41+ t . equal ( fieldNames . length , fieldValues . length , 'there should be the same number of custom metadata field name and values' )
42+ t . equal ( fieldNames [ 0 ] . getTextContent ( ) , 'Field I' , 'shoud be keyword label inside first' )
43+ t . equal ( fieldValues [ 0 ] . getTextContent ( ) , 'Value A, Value B' , 'shoud be values joined with comma inside second' )
4244 editor = openMetadataEditor ( app )
4345 t . notNil ( editor . find ( figureMetadataSelector ) , 'there should be a figure with metadata in manuscript' )
4446 t . end ( )
@@ -54,8 +56,9 @@ test('Figure Metadata: add a new custom field', t => {
5456 t . ok ( addCustomMetadataFieldTool . click ( ) , 'clicking on add custom field tool should not throw error' )
5557 t . equal ( editor . findAll ( figureMetadataSelector ) . length , 2 , 'there should be two custom fields now' )
5658 const selectedNodePath = getSelection ( editor ) . path
57- const secondCustomFieldInputPath = editor . findAll ( figureCustomMetadataFieldNameSelector ) [ 1 ] . getPath ( )
58- t . deepEqual ( selectedNodePath , secondCustomFieldInputPath , 'selection path and second custom field path should match' )
59+ const secondCustomFieldInput = editor . findAll ( figureCustomMetadataFieldNameSelector ) [ 1 ]
60+ const secondCustomFieldInputModel = secondCustomFieldInput . props . model
61+ t . deepEqual ( selectedNodePath , secondCustomFieldInputModel . getPath ( ) , 'selection path and second custom field path should match' )
5962 t . end ( )
6063} )
6164
@@ -70,8 +73,9 @@ test('Figure Metadata: add a new custom field when figure is selected', t => {
7073 t . ok ( addCustomMetadataFieldTool . click ( ) , 'clicking on add custom field tool should not throw error' )
7174 t . equal ( editor . findAll ( figureMetadataSelector ) . length , 2 , 'there should be two custom fields now' )
7275 const selectedNodePath = getSelection ( editor ) . path
73- const secondCustomFieldInputPath = editor . findAll ( figureCustomMetadataFieldNameSelector ) [ 1 ] . getPath ( )
74- t . deepEqual ( selectedNodePath , secondCustomFieldInputPath , 'selection path and second custom field path should match' )
76+ const secondCustomFieldInput = editor . findAll ( figureCustomMetadataFieldNameSelector ) [ 1 ]
77+ const secondCustomFieldInputModel = secondCustomFieldInput . props . model
78+ t . deepEqual ( selectedNodePath , secondCustomFieldInputModel . getPath ( ) , 'selection path and second custom field path should match' )
7579 t . end ( )
7680} )
7781
0 commit comments