diff --git a/test/Figure.test.js b/test/Figure.test.js index c17a39c34..fb50c0348 100644 --- a/test/Figure.test.js +++ b/test/Figure.test.js @@ -24,7 +24,8 @@ const xrefListItemSelector = '.sc-edit-xref-tool .se-option .sc-preview' const figurePanelPreviousSelector = '.sc-figure .se-control.sm-previous' const figurePanelNextSelector = '.sc-figure .se-control.sm-next' const currentPanelSelector = '.sc-figure .se-current-panel .sc-figure-panel' -const figureCustomMetadataFieldInputSelector = '.sc-custom-metadata-field .sc-string' +const figureCustomMetadataFieldNameSelector = '.sc-custom-metadata-field .sc-string' +const figureCustomMetadataFieldValuesSelector = '.sc-custom-metadata-field .sc-keyword-input' const FIGURE_WITH_TWO_PANELS = ` @@ -462,9 +463,12 @@ test('Figure: replicate first panel structure', t => { t.ok(insertFigurePanelTool.el.click(), 'clicking on the insert figure panel button should not throw error') insertFigurePanelTool.onFileSelect(new PseudoFileEvent()) _gotoNext() - const fields = editor.findAll(figureCustomMetadataFieldInputSelector) - t.equal(fields[0].getTextContent(), 'Field I', 'shoud be replicated keyword label inside custom field name') - t.equal(fields[1].getTextContent(), '', 'shoud be empty value') + const fieldNames = editor.findAll(figureCustomMetadataFieldNameSelector) + const fieldValues = editor.findAll(figureCustomMetadataFieldValuesSelector) + t.equal(fieldNames.length, 1, 'there should be one input for a field name') + t.equal(fieldNames.length, fieldValues.length, 'there should be the same number of custom metadata field name and values') + t.equal(fieldNames[0].getTextContent(), 'Field I', 'shoud be replicated keyword label inside custom field name') + t.equal(fieldValues[0].getTextContent(), 'Click to add keywords', 'shoud be empty value') t.end() }) diff --git a/test/FigureMetadata.test.js b/test/FigureMetadata.test.js index cf37c0e39..38e82cad9 100644 --- a/test/FigureMetadata.test.js +++ b/test/FigureMetadata.test.js @@ -11,8 +11,8 @@ const moveUpCustomMetadataFieldToolSelector = '.sm-move-up-metadata-field' const removeCustomMetadataFieldToolSelector = '.sm-remove-metadata-field' const figureMetadataSelector = '.sc-custom-metadata-field' -const figureCustomMetadataFieldInputSelector = '.sc-custom-metadata-field .sc-string' -const figureCustomMetadataFieldNameSelector = '.sc-custom-metadata-field .se-field-name .se-input' +const figureCustomMetadataFieldNameSelector = '.sc-custom-metadata-field .sc-string' +const figureCustomMetadataFieldValuesSelector = '.sc-custom-metadata-field .sc-keyword-input' const FIXTURE = ` @@ -35,10 +35,12 @@ test('Figure Metadata: open figure with custom fields in manuscript and metadata let editor = openManuscriptEditor(app) loadBodyFixture(editor, FIXTURE) t.notNil(editor.find(figureMetadataSelector), 'there should be a figure with metadata in manuscript') - const fields = editor.findAll(figureCustomMetadataFieldInputSelector) - t.equal(fields.length, 2, 'there should be two inputs') - t.equal(fields[0].getTextContent(), 'Field I', 'shoud be keyword label inside first') - t.equal(fields[1].getTextContent(), 'Value A, Value B', 'shoud be values joined with comma inside second') + const fieldNames = editor.findAll(figureCustomMetadataFieldNameSelector) + const fieldValues = editor.findAll(figureCustomMetadataFieldValuesSelector) + t.equal(fieldNames.length, 1, 'there should be one input for a field name') + t.equal(fieldNames.length, fieldValues.length, 'there should be the same number of custom metadata field name and values') + t.equal(fieldNames[0].getTextContent(), 'Field I', 'shoud be keyword label inside first') + t.equal(fieldValues[0].getTextContent(), 'Value A, Value B', 'shoud be values joined with comma inside second') editor = openMetadataEditor(app) t.notNil(editor.find(figureMetadataSelector), 'there should be a figure with metadata in manuscript') t.end() @@ -54,8 +56,9 @@ test('Figure Metadata: add a new custom field', t => { t.ok(addCustomMetadataFieldTool.click(), 'clicking on add custom field tool should not throw error') t.equal(editor.findAll(figureMetadataSelector).length, 2, 'there should be two custom fields now') const selectedNodePath = getSelection(editor).path - const secondCustomFieldInputPath = editor.findAll(figureCustomMetadataFieldNameSelector)[1].getPath() - t.deepEqual(selectedNodePath, secondCustomFieldInputPath, 'selection path and second custom field path should match') + const secondCustomFieldInput = editor.findAll(figureCustomMetadataFieldNameSelector)[1] + const secondCustomFieldInputModel = secondCustomFieldInput.props.model + t.deepEqual(selectedNodePath, secondCustomFieldInputModel.getPath(), 'selection path and second custom field path should match') t.end() }) @@ -70,8 +73,9 @@ test('Figure Metadata: add a new custom field when figure is selected', t => { t.ok(addCustomMetadataFieldTool.click(), 'clicking on add custom field tool should not throw error') t.equal(editor.findAll(figureMetadataSelector).length, 2, 'there should be two custom fields now') const selectedNodePath = getSelection(editor).path - const secondCustomFieldInputPath = editor.findAll(figureCustomMetadataFieldNameSelector)[1].getPath() - t.deepEqual(selectedNodePath, secondCustomFieldInputPath, 'selection path and second custom field path should match') + const secondCustomFieldInput = editor.findAll(figureCustomMetadataFieldNameSelector)[1] + const secondCustomFieldInputModel = secondCustomFieldInput.props.model + t.deepEqual(selectedNodePath, secondCustomFieldInputModel.getPath(), 'selection path and second custom field path should match') t.end() })