Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

Commit

Permalink
gh-52 Fix for buttons in submit form
Browse files Browse the repository at this point in the history
  They are now enabled properly after selecting a file
  • Loading branch information
holandes22 committed Mar 31, 2017
1 parent 803fc91 commit 39374dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/components/file-selector/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<div class="sub header">note that README.md, test files and nested folders are skipped from this list</div>
</h5>
{{#if problem.files}}
<div class="ui large form">
<div class="ui form">
<div class="grouped inline fields">
{{#each problem.files as |file|}}
<div class="field" data-test-files>
{{ui-radio name="selectedFile" value=file label=file current=selectedFile}}
{{ui-radio name="selectedFile" value=file label=file current=selectedFile onChange=(action (mut selectedFile))}}
</div>
{{/each}}
</div>
Expand All @@ -27,6 +27,7 @@
Submit
</button>
<button
data-test-open-btn
class="ui secondary basic button {{if (not selectedFile) 'disabled'}}"
{{action "open"}}>
Open
Expand Down
13 changes: 12 additions & 1 deletion tests/integration/components/file-selector/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@ test('it shows message when no files available', function(assert) {
assert.equal(this.$(testSelector('no-files-msg')).text().trim(), 'None');
});

test('it disables submit button if no selection', function(assert) {
test('it disables submit and open buttons if no selection', function(assert) {
let problem = { files: ['f1'] };
this.set('problem', problem);

this.render(hbs`{{file-selector problem=problem}}`);
assert.equal(this.$(testSelector('files')).length, 1);
assert.ok(this.$(testSelector('submit-btn')).hasClass('disabled'));
assert.ok(this.$(testSelector('open-btn')).hasClass('disabled'));
});

test('it enables submit and open buttons if selection', function(assert) {
let problem = { files: ['f1'] };
this.set('problem', problem);
this.set('selectedFile', 'f1');

this.render(hbs`{{file-selector problem=problem selectedFile=selectedFile}}`);
assert.notOk(this.$(testSelector('submit-btn')).hasClass('disabled'));
assert.notOk(this.$(testSelector('open-btn')).hasClass('disabled'));
});

test('it shows error message if file no longer exists', function(assert) {
Expand Down

0 comments on commit 39374dd

Please sign in to comment.