From 7121a8da0c249c7929c9fe5f95f2e74f8121f501 Mon Sep 17 00:00:00 2001 From: Ben Warzeski Date: Thu, 7 Oct 2021 15:07:33 -0400 Subject: [PATCH 1/2] feat: override grades workflow and action row score --- .../__snapshots__/index.test.jsx.snap | 26 ++++++-- .../components/StartGradingButton.jsx | 3 + .../components/StartGradingButton.test.jsx | 61 +++++++++++++------ .../components/StopGradingConfirmModal.jsx | 12 +++- .../StopGradingConfirmModal.test.jsx | 4 ++ .../StartGradingButton.test.jsx.snap | 45 +++++++------- .../StopGradingConfirmModal.test.jsx.snap | 16 ++++- src/containers/ReviewActions/index.jsx | 13 +++- src/containers/ReviewActions/index.test.jsx | 11 +++- src/data/reducers/grading.js | 8 +++ src/data/selectors/grading.js | 17 +++++- 11 files changed, 159 insertions(+), 57 deletions(-) diff --git a/src/containers/ReviewActions/__snapshots__/index.test.jsx.snap b/src/containers/ReviewActions/__snapshots__/index.test.jsx.snap index 8e413b4..8152820 100644 --- a/src/containers/ReviewActions/__snapshots__/index.test.jsx.snap +++ b/src/containers/ReviewActions/__snapshots__/index.test.jsx.snap @@ -8,11 +8,20 @@ exports[`ReviewActions component component snapshot: do not show rubric 1`] = ` - test-username + + test-username + + + Score: 3/10 +
`; -exports[`ReviewActions component component snapshot: show rubric 1`] = ` +exports[`ReviewActions component component snapshot: show rubric, no score 1`] = `
- test-username + + test-username + +
); @@ -113,12 +114,14 @@ export class StartGradingButton extends React.Component { } StartGradingButton.propTypes = { + gradeStatus: PropTypes.string.isRequired, gradingStatus: PropTypes.string.isRequired, startGrading: PropTypes.func.isRequired, stopGrading: PropTypes.func.isRequired, }; export const mapStateToProps = (state) => ({ + 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 1161914..c379d6e 100644 --- a/src/containers/ReviewActions/components/StartGradingButton.test.jsx +++ b/src/containers/ReviewActions/components/StartGradingButton.test.jsx @@ -23,6 +23,7 @@ jest.mock('data/selectors', () => ({ default: { grading: { selected: { + gradeStatus: (state) => ({ gradeStatus: state }), gradingStatus: (state) => ({ gradingStatus: state }), }, }, @@ -38,26 +39,43 @@ describe('StartGradingButton component', () => { props.startGrading = jest.fn().mockName('this.props.startGrading'); props.stopGrading = jest.fn().mockName('this.props.stopGrading'); }); - const render = (gradingStatus) => shallow( - , - ); - test('snapshot: locked (null)', () => { - el = render(statuses.locked); - expect(el).toMatchSnapshot(); - expect(el).toEqual({}); - }); - test('snapshot: ungraded (startGrading callback)', () => { - expect(render(statuses.ungraded)).toMatchSnapshot(); - }); - test('snapshot: graded, confirmOverride (startGrading callback)', () => { - el = render(statuses.graded); - el.setState({ showConfirmOverrideGrade: true }); - expect(el.instance().render()).toMatchSnapshot(); - }); - test('snapshot: inProgress, confirmStop (stopGrading callback)', () => { - el = render(statuses.inProgress); - el.setState({ showConfirmStopGrading: true }); - expect(el.instance().render()).toMatchSnapshot(); + describe('snapshotes', () => { + const mockedEl = (gradingStatus, gradeStatus) => { + const renderedEl = shallow( + , + ); + const mockMethod = (methodName) => { + renderedEl.instance()[methodName] = jest.fn().mockName(`this.${methodName}`); + }; + mockMethod('handleClick'); + mockMethod('hideConfirmOverrideGrade'); + mockMethod('confirmOverrideGrade'); + mockMethod('hideConfirmStopGrading'); + mockMethod('confirmStopGrading'); + return renderedEl; + }; + test('snapshot: locked (null)', () => { + el = mockedEl(statuses.locked); + expect(el.instance().render()).toMatchSnapshot(); + expect(el.isEmptyRender()).toEqual(true); + }); + test('snapshot: ungraded (startGrading callback)', () => { + expect(mockedEl(statuses.ungraded).instance().render()).toMatchSnapshot(); + }); + test('snapshot: graded, confirmOverride (startGrading callback)', () => { + el = mockedEl(statuses.graded); + el.setState({ showConfirmOverrideGrade: true }); + expect(el.instance().render()).toMatchSnapshot(); + }); + test('snapshot: inProgress, isOverride, confirmStop (stopGrading callback)', () => { + el = mockedEl(statuses.inProgress, statuses.graded); + el.setState({ showConfirmStopGrading: true }); + expect(el.instance().render()).toMatchSnapshot(); + }); }); }); describe('mapStateToProps', () => { @@ -66,6 +84,9 @@ describe('StartGradingButton component', () => { beforeEach(() => { mapped = mapStateToProps(testState); }); + test('gradeStatus loads from grading.selected.gradeStatus', () => { + expect(mapped.gradeStatus).toEqual(selectors.grading.selected.gradeStatus(testState)); + }); test('gradingStatus loads from grading.selected.gradingStatus', () => { expect(mapped.gradingStatus).toEqual(selectors.grading.selected.gradingStatus(testState)); }); diff --git a/src/containers/ReviewActions/components/StopGradingConfirmModal.jsx b/src/containers/ReviewActions/components/StopGradingConfirmModal.jsx index 3598b92..6f7836c 100644 --- a/src/containers/ReviewActions/components/StopGradingConfirmModal.jsx +++ b/src/containers/ReviewActions/components/StopGradingConfirmModal.jsx @@ -5,14 +5,21 @@ import ConfirmModal from 'components/ConfirmModal'; export const StopGradingConfirmModal = ({ isOpen, + isOverride, onCancel, onConfirm, }) => ( 'ConfirmModal'); describe('StopGradingConfirmModal', () => { const props = { isOpen: false, + isOverride: false, onCancel: jest.fn().mockName('this.props.onCancel'), onConfirm: jest.fn().mockName('this.props.onConfirm'), }; @@ -16,4 +17,7 @@ describe('StopGradingConfirmModal', () => { test('snapshot: open', () => { expect(shallow()).toMatchSnapshot(); }); + test('snapshot: open, isOverride', () => { + expect(shallow()).toMatchSnapshot(); + }); }); diff --git a/src/containers/ReviewActions/components/__snapshots__/StartGradingButton.test.jsx.snap b/src/containers/ReviewActions/components/__snapshots__/StartGradingButton.test.jsx.snap index 28c3315..abc818f 100644 --- a/src/containers/ReviewActions/components/__snapshots__/StartGradingButton.test.jsx.snap +++ b/src/containers/ReviewActions/components/__snapshots__/StartGradingButton.test.jsx.snap @@ -1,69 +1,72 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`StartGradingButton component component snapshot: graded, confirmOverride (startGrading callback) 1`] = ` +exports[`StartGradingButton component component snapshotes snapshot: graded, confirmOverride (startGrading callback) 1`] = ` `; -exports[`StartGradingButton component component snapshot: inProgress, confirmStop (stopGrading callback) 1`] = ` +exports[`StartGradingButton component component snapshotes snapshot: inProgress, isOverride, confirmStop (stopGrading callback) 1`] = ` `; -exports[`StartGradingButton component component snapshot: locked (null) 1`] = `""`; +exports[`StartGradingButton component component snapshotes snapshot: locked (null) 1`] = `null`; -exports[`StartGradingButton component component snapshot: ungraded (startGrading callback) 1`] = ` - +exports[`StartGradingButton component component snapshotes snapshot: ungraded (startGrading callback) 1`] = ` + - + `; diff --git a/src/containers/ReviewActions/components/__snapshots__/StopGradingConfirmModal.test.jsx.snap b/src/containers/ReviewActions/components/__snapshots__/StopGradingConfirmModal.test.jsx.snap index 4cd3a8a..4ff94bf 100644 --- a/src/containers/ReviewActions/components/__snapshots__/StopGradingConfirmModal.test.jsx.snap +++ b/src/containers/ReviewActions/components/__snapshots__/StopGradingConfirmModal.test.jsx.snap @@ -3,7 +3,7 @@ exports[`StopGradingConfirmModal snapshot: closed 1`] = ` `; + +exports[`StopGradingConfirmModal snapshot: open, isOverride 1`] = ` + +`; diff --git a/src/containers/ReviewActions/index.jsx b/src/containers/ReviewActions/index.jsx index 66ed1b0..f547178 100644 --- a/src/containers/ReviewActions/index.jsx +++ b/src/containers/ReviewActions/index.jsx @@ -17,14 +17,18 @@ import SubmissionNavigation from './components/SubmissionNavigation'; export const ReviewActions = ({ gradingStatus, toggleShowRubric, + score: { pointsEarned, pointsPossible }, showRubric, username, }) => (
- {username} - + {username} + + + {pointsPossible && `Score: ${pointsEarned}/${pointsPossible}`} +