Skip to content

Commit

Permalink
disable grading period set toggling while editing periods
Browse files Browse the repository at this point in the history
fixes CNVS-30094

test plan:
 1. Visit the Grading Standards page
 2. Expand a Grading Period Set
 3. Click any 'edit grading period' button
 4. Verify that the Grading Period Set cannot be collapsed
 5. Save or Cancel the form (test both)
 6. Verify that the Grading Period Set can now be collapsed

Change-Id: I52238b3e30a062c47ba5333174e450bf55b350d5
Reviewed-on: https://gerrit.instructure.com/83165
Tested-by: Jenkins
Reviewed-by: Derek Bender <[email protected]>
Reviewed-by: Keith T. Garner <[email protected]>
QA-Review: Amber Taniuchi <[email protected]>
Product-Review: Keith T. Garner <[email protected]>
  • Loading branch information
jneander committed Jun 22, 2016
1 parent 62a4c18 commit ebfc588
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/jsx/grading/GradingPeriodSet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ define([
},

toggleSetBody() {
this.setState({ expanded: !this.state.expanded });
if (!this.state.editPeriod.id) {
this.setState({ expanded: !this.state.expanded });
}
},

promptDeleteSet(event) {
Expand Down
28 changes: 28 additions & 0 deletions spec/javascripts/jsx/grading/GradingPeriodSetSpec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ define([
ok(set.refs["show-grading-period-3"].props.actionsDisabled);
});

test("disables set toggling while open", function() {
let set = this.renderComponent();
Simulate.click(set.refs["show-grading-period-1"].refs.editButton);
ok(set.refs.setBody);
Simulate.click(set.refs.toggleSetBody);
ok(set.refs.setBody);
});

test("'onCancel' removes the 'edit grading period' form", function() {
let set = this.renderComponent();
Simulate.click(set.refs["show-grading-period-1"].refs.editButton);
Expand All @@ -226,6 +234,14 @@ define([
notOk(set.refs["show-grading-period-3"].props.actionsDisabled);
});

test("'onCancel' re-enables set toggling", function() {
let set = this.renderComponent();
Simulate.click(set.refs["show-grading-period-1"].refs.editButton);
set.refs.editPeriodForm.props.onCancel();
Simulate.click(set.refs.toggleSetBody);
notOk(!!set.refs.setBody);
});

module("GradingPeriodSet 'Edit Grading Period - onSave'", {
renderComponent(opts = {}) {
let attrs = _.extend({}, props, opts);
Expand Down Expand Up @@ -330,6 +346,18 @@ define([
});
});

asyncTest("re-enables set toggling upon completion", function() {
let success = new Promise(resolve => resolve(examplePeriods));
this.stub(gradingPeriodsApi, "batchUpdate").returns(success);
let set = this.renderComponent();
this.callOnSave(set);
requestAnimationFrame(() => {
Simulate.click(set.refs.toggleSetBody);
notOk(!!set.refs.setBody);
start();
});
});

module("GradingPeriodSet 'Edit Grading Period - validations'", {
stubUpdate() {
let failure = new Promise(_, reject => { throw("FAIL") });
Expand Down

0 comments on commit ebfc588

Please sign in to comment.