Skip to content

Commit 588a7ae

Browse files
authored
Merge pull request #746 from tadast/tt/fix-remember-and-test
Fix remembering last used advanced params, add tests
2 parents 45049ef + 37bb7c6 commit 588a7ae

5 files changed

Lines changed: 30 additions & 9 deletions

File tree

lib/sequenceserver/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def update_searchdata_from_job(searchdata)
300300
if job.advanced && job.advanced !=
301301
searchdata.dig(:options, method, :default, :attributes).to_a.join(' ')
302302
searchdata[:options] = searchdata[:options].deep_copy
303-
searchdata[:options][method]['last search'] = [job.advanced]
303+
searchdata[:options][method]['last search'] = { attributes: [job.advanced] }
304304
end
305305
end
306306

public/js/options.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export class Options extends Component {
2828
componentDidUpdate(prevProps) {
2929
if (prevProps.predefinedOptions !== this.props.predefinedOptions) {
3030
let defaultOptions = this.props.predefinedOptions.default || {attributes: []};
31-
let initialTextValue = (this.props.predefinedOptions['last search'] ||
32-
defaultOptions.attributes || []).join(' ').trim();
31+
let advancedOptions = this.props.predefinedOptions['last search'] || defaultOptions || {attributes: []};
32+
let initialTextValue = advancedOptions.attributes.join(' ').trim();
3333
let parsedOptions = this.parsedOptions(initialTextValue);
3434
this.setState({ textValue: initialTextValue, objectValue: parsedOptions});
3535
}

public/js/tests/mock_data/databases.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@
8282
}
8383
],
8484
"options": {
85-
"blastn": { "default": ["-task blastn", "-evalue 1e-5"] },
86-
"blastp": { "default": ["-evalue 1e-5"] },
87-
"blastx": { "default": ["-evalue 1e-5"] },
88-
"tblastx": { "default": ["-evalue 1e-5"] },
89-
"tblastn": { "default": ["-evalue 1e-5"] }
85+
"blastn": { "default": { "attributes": ["-task blastn", "-evalue 1e-5"] }},
86+
"blastp": { "default": { "attributes": ["-evalue 1e-5"] }},
87+
"blastx": { "default": { "attributes": ["-evalue 1e-5"] }},
88+
"tblastx": { "default": { "attributes": ["-evalue 1e-5"] }},
89+
"tblastn": { "default": { "attributes": ["-evalue 1e-5"] }}
9090
}
9191
}

public/sequenceserver-search.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/features/search_and_results_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ def nucleotide_query
105105
expect(page).to have_content('TBLASTN')
106106
end
107107

108+
it 'remembers advanced params for the same algorithm' do
109+
visit '/'
110+
111+
fill_in('sequence', with: protein_query)
112+
nucleotide_databases.each { |db| check db }
113+
fill_in('advanced', with: '-evalue 0.01 -num_alignments 1')
114+
click_button('method')
115+
expect(page).to have_content('Query')
116+
117+
visit '/'
118+
fill_in('sequence', with: protein_query)
119+
check(protein_databases.first)
120+
expect(page).to have_field('advanced', with: '-evalue 1e-5') # different algorithm, no memories
121+
uncheck(protein_databases.first)
122+
123+
check(nucleotide_databases.first)
124+
expect(page).to have_field('advanced', with: '-evalue 0.01 -num_alignments 1')
125+
expect(page).to have_checked_field('predefinedOption', with: '-evalue 0.01 -num_alignments 1')
126+
127+
end
128+
108129
### Test aspects of the generated report.
109130

110131
it 'can download FASTA of each hit' do

0 commit comments

Comments
 (0)