Skip to content

Commit

Permalink
Change tests accordingly to new metadata keyword values input.
Browse files Browse the repository at this point in the history
  • Loading branch information
Integral committed May 9, 2019
1 parent dd965df commit c31a117
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
12 changes: 8 additions & 4 deletions test/Figure.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
<fig-group id="fig1">
Expand Down Expand Up @@ -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()
})

Expand Down
24 changes: 14 additions & 10 deletions test/FigureMetadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
<fig-group id="fig1">
Expand All @@ -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()
Expand All @@ -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()
})

Expand All @@ -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()
})

Expand Down

0 comments on commit c31a117

Please sign in to comment.