@@ -11,8 +11,8 @@ const moveUpCustomMetadataFieldToolSelector = '.sm-move-up-metadata-field'
11
11
const removeCustomMetadataFieldToolSelector = '.sm-remove-metadata-field'
12
12
13
13
const 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'
16
16
17
17
const FIXTURE = `
18
18
<fig-group id="fig1">
@@ -35,10 +35,12 @@ test('Figure Metadata: open figure with custom fields in manuscript and metadata
35
35
let editor = openManuscriptEditor ( app )
36
36
loadBodyFixture ( editor , FIXTURE )
37
37
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' )
42
44
editor = openMetadataEditor ( app )
43
45
t . notNil ( editor . find ( figureMetadataSelector ) , 'there should be a figure with metadata in manuscript' )
44
46
t . end ( )
@@ -54,8 +56,9 @@ test('Figure Metadata: add a new custom field', t => {
54
56
t . ok ( addCustomMetadataFieldTool . click ( ) , 'clicking on add custom field tool should not throw error' )
55
57
t . equal ( editor . findAll ( figureMetadataSelector ) . length , 2 , 'there should be two custom fields now' )
56
58
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' )
59
62
t . end ( )
60
63
} )
61
64
@@ -70,8 +73,9 @@ test('Figure Metadata: add a new custom field when figure is selected', t => {
70
73
t . ok ( addCustomMetadataFieldTool . click ( ) , 'clicking on add custom field tool should not throw error' )
71
74
t . equal ( editor . findAll ( figureMetadataSelector ) . length , 2 , 'there should be two custom fields now' )
72
75
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' )
75
79
t . end ( )
76
80
} )
77
81
0 commit comments