Skip to content

Commit

Permalink
fix: advanced editor not saving (openedx#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored Apr 21, 2023
1 parent 492ee27 commit c37e695
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const getContent = ({
lmsEndpointUrl,
}) => {
const problem = problemState;
const hasNoAnswers = checkForNoAnswers({
const hasNoAnswers = isAdvancedProblemType ? false : checkForNoAnswers({
problem,
openNoAnswerModal,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,16 @@ describe('EditProblemView hooks parseState', () => {
});
});
describe('getContent', () => {
const problemState = { problemType: ProblemTypeKeys.NUMERIC, answers: [{ id: 'A', title: 'problem', correct: true }] };
const isAdvancedProblem = false;
const assets = {};
const lmsEndpointUrl = 'someUrl';
const editorRef = refMock;
const openNoAnswerModal = jest.fn();

test('default save and returns parseState data', () => {
test('default visual save and returns parseState data', () => {
const problemState = { problemType: ProblemTypeKeys.NUMERIC, answers: [{ id: 'A', title: 'problem', correct: true }] };
const content = hooks.getContent({
isAdvancedProblemType: false,
problemState,
isAdvancedProblem,
editorRef,
assets,
lmsEndpointUrl,
Expand All @@ -211,11 +210,26 @@ describe('EditProblemView hooks parseState', () => {
settings: undefined,
});
});
test('default advanced save and returns parseState data', () => {
const problemState = { problemType: ProblemTypeKeys.ADVANCED };
const content = hooks.getContent({
isAdvancedProblemType: true,
problemState,
editorRef,
assets,
lmsEndpointUrl,
openNoAnswerModal,
});
expect(content).toEqual({
olx: 'rawOLX',
settings: undefined,
});
});
test('returns null', () => {
const problem = { ...problemState, answers: [{ id: 'A', title: '', correct: true }] };
const problemState = { problemType: ProblemTypeKeys.NUMERIC, answers: [{ id: 'A', title: '', correct: true }] };
const content = hooks.getContent({
problemState: problem,
isAdvancedProblem,
isAdvancedProblemType: false,
problemState,
editorRef,
assets,
lmsEndpointUrl,
Expand Down

0 comments on commit c37e695

Please sign in to comment.