download bulk management history if showBulkManagement (#210)
* download bulk management history if showBulkManagement * separate fetchBulkUpgrade call from fetchTracks * 1.4.47
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@edx/frontend-app-gradebook",
|
||||
"version": "1.4.46",
|
||||
"version": "1.4.47",
|
||||
"description": "edx editable gradebook-ui to manipulate grade overrides on subsections",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import { StrictDict } from 'utils';
|
||||
import actions from 'data/actions';
|
||||
import lms from 'data/services/lms';
|
||||
|
||||
const { fetching, gotGradesFrozen } = actions.assignmentTypes;
|
||||
const { gotBulkManagementConfig } = actions.config;
|
||||
import lms from 'data/services/lms';
|
||||
import actions from 'data/actions';
|
||||
|
||||
import { fetchBulkUpgradeHistory } from './grades';
|
||||
|
||||
const {
|
||||
assignmentTypes: { fetching, gotGradesFrozen },
|
||||
config: { gotBulkManagementConfig },
|
||||
} = actions;
|
||||
|
||||
export const fetchAssignmentTypes = () => (
|
||||
(dispatch) => {
|
||||
@@ -15,6 +20,9 @@ export const fetchAssignmentTypes = () => (
|
||||
dispatch(fetching.received(Object.keys(data.assignment_types)));
|
||||
dispatch(gotGradesFrozen(data.grades_frozen));
|
||||
dispatch(gotBulkManagementConfig(data.can_see_bulk_management));
|
||||
if (data.can_see_bulk_management) {
|
||||
dispatch(fetchBulkUpgradeHistory());
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch(fetching.error());
|
||||
|
||||
@@ -3,6 +3,7 @@ import lms from '../services/lms';
|
||||
import actions from '../actions';
|
||||
import * as thunkActions from './assignmentTypes';
|
||||
import { createTestFetcher } from './testUtils';
|
||||
import { fetchBulkUpgradeHistory } from './grades';
|
||||
|
||||
jest.mock('data/services/lms', () => ({
|
||||
api: {
|
||||
@@ -11,6 +12,9 @@ jest.mock('data/services/lms', () => ({
|
||||
},
|
||||
},
|
||||
}));
|
||||
jest.mock('data/thunkActions/grades', () => ({
|
||||
fetchBulkUpgradeHistory: () => ({ type: 'fetchBulkUpgradeHistory' }),
|
||||
}));
|
||||
|
||||
const responseData = {
|
||||
assignment_types: {
|
||||
@@ -18,7 +22,7 @@ const responseData = {
|
||||
other: 'TYpeS',
|
||||
},
|
||||
grades_frozen: 'bOOl',
|
||||
can_see_bulk_management: 'BooL',
|
||||
can_see_bulk_management: true,
|
||||
};
|
||||
|
||||
describe('assignmentType thunkActions', () => {
|
||||
@@ -36,15 +40,29 @@ describe('assignmentType thunkActions', () => {
|
||||
'gotGradesFrozen with data.grades_frozen',
|
||||
'config.gotBulkManagement with data.can_see_bulk_management',
|
||||
];
|
||||
test(actionNames.join(', '), () => testFetch(
|
||||
(resolve) => resolve({ data: responseData }),
|
||||
[
|
||||
actions.assignmentTypes.fetching.started(),
|
||||
actions.assignmentTypes.fetching.received(Object.keys(responseData.assignment_types)),
|
||||
actions.assignmentTypes.gotGradesFrozen(responseData.grades_frozen),
|
||||
actions.config.gotBulkManagementConfig(responseData.can_see_bulk_management),
|
||||
],
|
||||
));
|
||||
describe('if data.can_see_bulk_management', () => {
|
||||
test([...actionNames, 'fetchBulkUpgradeHistory'].join(', '), () => testFetch(
|
||||
(resolve) => resolve({ data: responseData }),
|
||||
[
|
||||
actions.assignmentTypes.fetching.started(),
|
||||
actions.assignmentTypes.fetching.received(Object.keys(responseData.assignment_types)),
|
||||
actions.assignmentTypes.gotGradesFrozen(responseData.grades_frozen),
|
||||
actions.config.gotBulkManagementConfig(responseData.can_see_bulk_management),
|
||||
fetchBulkUpgradeHistory(),
|
||||
],
|
||||
));
|
||||
});
|
||||
describe('if not data.can_see_bulk_management', () => {
|
||||
test(actionNames.join(', '), () => testFetch(
|
||||
(resolve) => resolve({ data: { ...responseData, can_see_bulk_management: false } }),
|
||||
[
|
||||
actions.assignmentTypes.fetching.started(),
|
||||
actions.assignmentTypes.fetching.received(Object.keys(responseData.assignment_types)),
|
||||
actions.assignmentTypes.gotGradesFrozen(responseData.grades_frozen),
|
||||
actions.config.gotBulkManagementConfig(false),
|
||||
],
|
||||
));
|
||||
});
|
||||
});
|
||||
describe('actions dispatched on api error', () => {
|
||||
test('fetching.started, fetching.error', () => testFetch(
|
||||
|
||||
@@ -15,6 +15,7 @@ jest.mock('data/selectors', () => ({
|
||||
filters: {
|
||||
allFilters: jest.fn(),
|
||||
},
|
||||
root: {},
|
||||
app: {},
|
||||
},
|
||||
}));
|
||||
@@ -31,6 +32,7 @@ jest.mock('./cohorts', () => ({
|
||||
}));
|
||||
jest.mock('./grades', () => ({
|
||||
fetchGrades: jest.fn((...args) => ({ type: 'fetchGrades', args })),
|
||||
fetchBulkUpgradeHistory: jest.fn((...args) => ({ type: 'fetchBulkUpgradeHistory', args })),
|
||||
}));
|
||||
jest.mock('./tracks', () => ({
|
||||
fetchTracks: jest.fn((...args) => ({ type: 'fetchTracks', args })),
|
||||
|
||||
@@ -3,9 +3,6 @@ import { StrictDict } from 'utils';
|
||||
|
||||
import lms from 'data/services/lms';
|
||||
import actions from 'data/actions';
|
||||
import selectors from 'data/selectors';
|
||||
|
||||
import { fetchBulkUpgradeHistory } from './grades';
|
||||
|
||||
export const fetchTracks = () => (
|
||||
(dispatch) => {
|
||||
@@ -14,9 +11,6 @@ export const fetchTracks = () => (
|
||||
.then(response => response.data)
|
||||
.then((data) => {
|
||||
dispatch(actions.tracks.fetching.received(data.course_modes));
|
||||
if (selectors.tracks.hasMastersTrack(data.course_modes)) {
|
||||
dispatch(fetchBulkUpgradeHistory());
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch(actions.tracks.fetching.error());
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import lms from 'data/services/lms';
|
||||
import actions from 'data/actions';
|
||||
import selectors from 'data/selectors';
|
||||
|
||||
import { createTestFetcher } from './testUtils';
|
||||
|
||||
import { fetchBulkUpgradeHistory } from './grades';
|
||||
import { fetchTracks } from './tracks';
|
||||
|
||||
jest.mock('data/services/lms', () => ({
|
||||
@@ -15,7 +13,7 @@ jest.mock('data/services/lms', () => ({
|
||||
jest.mock('data/selectors', () => ({
|
||||
__esModule: true,
|
||||
default: {
|
||||
tracks: { hasMastersTrack: jest.fn(() => false) },
|
||||
root: { showBulkManagement: jest.fn(() => false) },
|
||||
},
|
||||
}));
|
||||
jest.mock('./grades', () => ({
|
||||
@@ -35,43 +33,18 @@ describe('tracks thunkActions', () => {
|
||||
() => expect(lms.api.fetch.tracks).toHaveBeenCalledWith(),
|
||||
);
|
||||
describe('valid response', () => {
|
||||
describe('if not hasMastersTrack(data.course_modes)', () => {
|
||||
describe('dispatched actions', () => {
|
||||
beforeEach(() => {
|
||||
selectors.tracks.hasMastersTrack.mockReturnValue(false);
|
||||
});
|
||||
const expectedActions = [
|
||||
'tracks.fetching.started',
|
||||
'tracks.fetching.received with course_modes',
|
||||
];
|
||||
it(`dispatches [${expectedActions.join(', ')}]`, () => testFetch(
|
||||
(resolve) => resolve({ data: responseData }),
|
||||
[
|
||||
actions.tracks.fetching.started(),
|
||||
actions.tracks.fetching.received(responseData.course_modes),
|
||||
],
|
||||
));
|
||||
});
|
||||
});
|
||||
describe('if hasMastersTrack(data.course_modes)', () => {
|
||||
describe('dispatched actions', () => {
|
||||
beforeEach(() => {
|
||||
selectors.tracks.hasMastersTrack.mockReturnValue(true);
|
||||
});
|
||||
const expectedActions = [
|
||||
'fetching.started',
|
||||
'fetching.received with course_modes',
|
||||
'fetchBulkUpgradeHistory thunkAction',
|
||||
];
|
||||
test(`[${expectedActions.join(', ')}]`, () => testFetch(
|
||||
(resolve) => resolve({ data: responseData }),
|
||||
[
|
||||
actions.tracks.fetching.started(),
|
||||
actions.tracks.fetching.received(responseData.course_modes),
|
||||
fetchBulkUpgradeHistory(),
|
||||
],
|
||||
));
|
||||
});
|
||||
describe('dispatched actions', () => {
|
||||
const expectedActions = [
|
||||
'tracks.fetching.started',
|
||||
'tracks.fetching.received with course_modes',
|
||||
];
|
||||
it(`dispatches [${expectedActions.join(', ')}]`, () => testFetch(
|
||||
(resolve) => resolve({ data: responseData }),
|
||||
[
|
||||
actions.tracks.fetching.started(),
|
||||
actions.tracks.fetching.received(responseData.course_modes),
|
||||
],
|
||||
));
|
||||
});
|
||||
});
|
||||
describe('actions dispatched on api error', () => {
|
||||
|
||||
Reference in New Issue
Block a user