-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from Duke-GCB/138-file-picker-handle-single-f…
…ile-array Simple support for workflows using FASTQReadPairType[]
- Loading branch information
Showing
9 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Ember from 'ember'; | ||
import FASTQFilePairList from './fastq-file-pair-list'; | ||
|
||
export default FASTQFilePairList.extend({ | ||
// Primary purpose of this subclass is to provide a different structure from the 'answer' | ||
// method that returns single files wrapped in an array. | ||
answer: Ember.computed('fieldName', 'fileItems.cwlObjectValue.[]', function() { | ||
const fieldName = this.get('fieldName'); | ||
// Convert NamedFASTQFilePairType to a FASTQReadPairType | ||
const fastqReadPairs = this.get('fileItems.cwlObjectValue').map(namedPair => { | ||
return Ember.Object.create({ | ||
name: namedPair.get('name'), | ||
read1_files: [namedPair.get('file1')], | ||
read2_files: [namedPair.get('file2')] | ||
}); | ||
}); | ||
|
||
const answer = Ember.Object.create(); | ||
answer.set(fieldName, fastqReadPairs); | ||
return answer; | ||
}), | ||
// Support Message | ||
featureSupportMessage: Ember.String.htmlSafe('<strong>Note:</strong> This workflow supports multiple file pairs per read. ' + | ||
'However, the web interface only supports choosing one file pair per read. If you wish to run this workflow with multiple files per ' + | ||
'read, please use <a href="https://github.com/Duke-GCB/bespin-cli">bespin-cli</a>.'), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/integration/components/questionnaire/fastq-read-pair-list-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import StoreStub from '../../../helpers/store-stub'; | ||
import Ember from 'ember'; | ||
|
||
moduleForComponent('questionnaire/fastq-read-pair-list', 'Integration | Component | questionnaire/fastq read pair list', { | ||
integration: true, | ||
beforeEach: function() { | ||
this.register('service:store', StoreStub); | ||
} | ||
}); | ||
|
||
test('it renders using the fastq-file-pair-list template', function(assert) { | ||
const fileItems = Ember.Object.create({ | ||
samples: [{},{}] | ||
} | ||
); | ||
this.set('fileItems', fileItems); | ||
this.set('externalAction', () => {}); | ||
this.render(hbs`{{questionnaire/fastq-read-pair-list "FieldName" (action externalAction) fileItems=fileItems}}`); | ||
assert.equal(this.$('.fastq-file-pair-row').length, 2); | ||
assert.equal(this.$('div.file-group-list-picker').length, 1); | ||
|
||
}); | ||
|
||
test('It shows the featureSupportMessage', function(assert) { | ||
const fileItems = Ember.Object.create({ | ||
samples: [{},{}] | ||
} | ||
); | ||
this.set('fileItems', fileItems); | ||
this.set('externalAction', () => {}); | ||
this.render(hbs`{{questionnaire/fastq-read-pair-list "FieldName" (action externalAction) fileItems=fileItems}}`); | ||
assert.equal(this.$('.feature-support-message').length, 1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/unit/components/questionnaire/fastq-read-pair-list-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import Ember from 'ember'; | ||
|
||
moduleForComponent('questionnaire/fastq-read-pair-list', 'Unit | Component | questionnaire/fastq read pair list', { | ||
// Specify the other units that are required for this test | ||
needs: ['service:dds-projects', 'service:dds-user-credentials'], | ||
unit: true | ||
}); | ||
|
||
test('it computes answer with field name and files', function (assert) { | ||
|
||
const expected = Ember.Object.create({read_pairs: [{name: 'abc', read1_files: [{class: 'File', path: 'abc_1'}], read2_files: [{class: 'File', path: 'abc_2'}]}]}); | ||
const fieldName = 'read_pairs'; | ||
const mockFileItems = Ember.Object.create({ | ||
cwlObjectValue: [ | ||
Ember.Object.create({name: 'abc', file1: {class: 'File', path: 'abc_1'}, file2: {class: 'File', path: 'abc_2'}}) | ||
] | ||
}); | ||
|
||
const fastqReadPairList = this.subject({ | ||
groupSize: 2, | ||
fileItems: mockFileItems, | ||
fieldName: fieldName, | ||
answerChanged: () => { | ||
} | ||
}); | ||
const answer = fastqReadPairList.get('answer'); | ||
assert.equal(JSON.stringify(answer), JSON.stringify(expected)); | ||
}); | ||
|
||
test('it provides feature support message with link to bespin-cli', function(assert) { | ||
const fastqReadPairList = this.subject({fieldName: "SomeField", answerChanged: ()=>{}}); | ||
const messageString = fastqReadPairList.get('featureSupportMessage.string'); | ||
assert.ok(messageString.indexOf('https://github.com/Duke-GCB/bespin-cli') > 0); | ||
}); |