From 7e49670a95af76d6ff99ae467bc039eb9be4d781 Mon Sep 17 00:00:00 2001 From: leangseu-edx <83240113+leangseu-edx@users.noreply.github.com> Date: Fri, 10 Dec 2021 14:57:24 -0500 Subject: [PATCH] feat: update lock/unlock logistic (#38) * feat: update lock/unlock logistic * chore: disable submit grade on lock pending * chore: update mock for contested lock * chore: update set lock success response * chore: add failure reducer/action for set lock --- .../components/StartGradingButton.jsx | 8 +- .../components/StartGradingButton.test.jsx | 24 ++++-- .../StartGradingButton.test.jsx.snap | 34 +++++++- .../ReviewModal/ReviewErrors/LockErrors.jsx | 65 +++++++++++++++ .../ReviewErrors/LockErrors.test.jsx | 62 +++++++++++++++ .../ReviewModal/ReviewErrors/ReviewError.jsx | 5 +- .../__snapshots__/LockErrors.test.jsx.snap | 39 +++++++++ .../__snapshots__/index.test.jsx.snap | 1 + .../ReviewModal/ReviewErrors/index.jsx | 2 + .../ReviewModal/ReviewErrors/index.test.jsx | 1 + .../ReviewModal/ReviewErrors/messages.js | 21 ++++- .../Rubric/__snapshots__/index.test.jsx.snap | 79 +++++++++++++++++++ src/containers/Rubric/index.jsx | 14 ++-- src/containers/Rubric/index.test.jsx | 20 ++++- src/data/redux/grading/reducer.js | 4 + src/data/redux/thunkActions/grading.js | 10 +++ src/data/services/lms/fakeData/testUtils.js | 15 ++++ 17 files changed, 382 insertions(+), 22 deletions(-) create mode 100644 src/containers/ReviewModal/ReviewErrors/LockErrors.jsx create mode 100644 src/containers/ReviewModal/ReviewErrors/LockErrors.test.jsx create mode 100644 src/containers/ReviewModal/ReviewErrors/__snapshots__/LockErrors.test.jsx.snap diff --git a/src/containers/ReviewActions/components/StartGradingButton.jsx b/src/containers/ReviewActions/components/StartGradingButton.jsx index ce40ea4..db80cbe 100644 --- a/src/containers/ReviewActions/components/StartGradingButton.jsx +++ b/src/containers/ReviewActions/components/StartGradingButton.jsx @@ -94,7 +94,7 @@ export class StartGradingButton extends React.Component { variant="primary" iconAfter={args.iconAfter} onClick={this.handleClick} - disabled={this.props.isPending} + disabled={this.props.gradeIsPending || this.props.lockIsPending} > @@ -119,11 +119,13 @@ StartGradingButton.propTypes = { gradingStatus: PropTypes.string.isRequired, startGrading: PropTypes.func.isRequired, stopGrading: PropTypes.func.isRequired, - isPending: PropTypes.bool.isRequired, + gradeIsPending: PropTypes.bool.isRequired, + lockIsPending: PropTypes.bool.isRequired, }; export const mapStateToProps = (state) => ({ - isPending: selectors.requests.isPending(state, { requestKey: RequestKeys.submitGrade }), + gradeIsPending: selectors.requests.isPending(state, { requestKey: RequestKeys.submitGrade }), + lockIsPending: selectors.requests.isPending(state, { requestKey: RequestKeys.setLock }), gradeStatus: selectors.grading.selected.gradeStatus(state), gradingStatus: selectors.grading.selected.gradingStatus(state), }); diff --git a/src/containers/ReviewActions/components/StartGradingButton.test.jsx b/src/containers/ReviewActions/components/StartGradingButton.test.jsx index 6afef81..2a29d42 100644 --- a/src/containers/ReviewActions/components/StartGradingButton.test.jsx +++ b/src/containers/ReviewActions/components/StartGradingButton.test.jsx @@ -36,7 +36,8 @@ let el; describe('StartGradingButton component', () => { describe('component', () => { const props = { - isPending: false, + gradeIsPending: false, + lockIsPending: false, }; beforeEach(() => { props.startGrading = jest.fn().mockName('this.props.startGrading'); @@ -69,9 +70,14 @@ describe('StartGradingButton component', () => { test('snapshot: ungraded (startGrading callback)', () => { expect(mockedEl(statuses.ungraded).instance().render()).toMatchSnapshot(); }); - test('snapshot: pending (disabled)', () => { + test('snapshot: grade pending (disabled)', () => { el = mockedEl(statuses.ungraded); - el.setProps({ isPending: true }); + el.setProps({ gradeIsPending: true }); + expect(el.instance().render()).toMatchSnapshot(); + }); + test('snapshot: lock pending (disabled)', () => { + el = mockedEl(statuses.ungraded); + el.setProps({ lockIsPending: true }); expect(el.instance().render()).toMatchSnapshot(); }); test('snapshot: graded, confirmOverride (startGrading callback)', () => { @@ -92,14 +98,22 @@ describe('StartGradingButton component', () => { beforeEach(() => { mapped = mapStateToProps(testState); }); - test('isPending loads from requests.isPending(submitGrade)', () => { - expect(mapped.isPending).toEqual( + test('gradeIsPending loads from requests.gradeIsPending(submitGrade)', () => { + expect(mapped.gradeIsPending).toEqual( selectors.requests.isPending( testState, { requestKey: RequestKeys.submitGrade }, ), ); }); + test('lockIsPending loads from requests.lockIsPending(setLock)', () => { + expect(mapped.lockIsPending).toEqual( + selectors.requests.isPending( + testState, + { requestKey: RequestKeys.setLock }, + ), + ); + }); test('gradeStatus loads from grading.selected.gradeStatus', () => { expect(mapped.gradeStatus).toEqual(selectors.grading.selected.gradeStatus(testState)); }); diff --git a/src/containers/ReviewActions/components/__snapshots__/StartGradingButton.test.jsx.snap b/src/containers/ReviewActions/components/__snapshots__/StartGradingButton.test.jsx.snap index be5f631..bff99fc 100644 --- a/src/containers/ReviewActions/components/__snapshots__/StartGradingButton.test.jsx.snap +++ b/src/containers/ReviewActions/components/__snapshots__/StartGradingButton.test.jsx.snap @@ -1,5 +1,33 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`StartGradingButton component component snapshotes snapshot: grade pending (disabled) 1`] = ` + + + + + +`; + exports[`StartGradingButton component component snapshotes snapshot: graded, confirmOverride (startGrading callback) 1`] = `