Skip to content

Commit c31a117

Browse files
committed
Change tests accordingly to new metadata keyword values input.
1 parent dd965df commit c31a117

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

test/Figure.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const xrefListItemSelector = '.sc-edit-xref-tool .se-option .sc-preview'
2424
const figurePanelPreviousSelector = '.sc-figure .se-control.sm-previous'
2525
const figurePanelNextSelector = '.sc-figure .se-control.sm-next'
2626
const currentPanelSelector = '.sc-figure .se-current-panel .sc-figure-panel'
27-
const figureCustomMetadataFieldInputSelector = '.sc-custom-metadata-field .sc-string'
27+
const figureCustomMetadataFieldNameSelector = '.sc-custom-metadata-field .sc-string'
28+
const figureCustomMetadataFieldValuesSelector = '.sc-custom-metadata-field .sc-keyword-input'
2829

2930
const FIGURE_WITH_TWO_PANELS = `
3031
<fig-group id="fig1">
@@ -462,9 +463,12 @@ test('Figure: replicate first panel structure', t => {
462463
t.ok(insertFigurePanelTool.el.click(), 'clicking on the insert figure panel button should not throw error')
463464
insertFigurePanelTool.onFileSelect(new PseudoFileEvent())
464465
_gotoNext()
465-
const fields = editor.findAll(figureCustomMetadataFieldInputSelector)
466-
t.equal(fields[0].getTextContent(), 'Field I', 'shoud be replicated keyword label inside custom field name')
467-
t.equal(fields[1].getTextContent(), '', 'shoud be empty value')
466+
const fieldNames = editor.findAll(figureCustomMetadataFieldNameSelector)
467+
const fieldValues = editor.findAll(figureCustomMetadataFieldValuesSelector)
468+
t.equal(fieldNames.length, 1, 'there should be one input for a field name')
469+
t.equal(fieldNames.length, fieldValues.length, 'there should be the same number of custom metadata field name and values')
470+
t.equal(fieldNames[0].getTextContent(), 'Field I', 'shoud be replicated keyword label inside custom field name')
471+
t.equal(fieldValues[0].getTextContent(), 'Click to add keywords', 'shoud be empty value')
468472
t.end()
469473
})
470474

test/FigureMetadata.test.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const moveUpCustomMetadataFieldToolSelector = '.sm-move-up-metadata-field'
1111
const removeCustomMetadataFieldToolSelector = '.sm-remove-metadata-field'
1212

1313
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'
1616

1717
const 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

Comments
 (0)