Skip to content

Commit 7455481

Browse files
Merge pull request #2112 from ucfopen/dev/33-serpierite
This has been running properly in a production environment for quite a while. Finalizing to start a new dev branch.
2 parents e8050b0 + 435edea commit 7455481

File tree

60 files changed

+1115
-529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1115
-529
lines changed

docker/obojobo-pm2-server-src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obojobo-pm2-server-app",
3-
"version": "17.0.0",
3+
"version": "17.1.0",
44
"description": "Reference project for deploying and customizing an Obojobo Next server",
55
"main": "./index.js",
66
"private": true,

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"packages": [
33
"packages/**/*"
44
],
5-
"version": "17.0.0",
5+
"version": "17.1.0",
66
"command": {
77
"command": {
88
"run": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "obojobo-next",
4-
"version": "17.0.0",
4+
"version": "17.1.0",
55
"repository": "https://github.com/ucfopen/Obojobo.git",
66
"homepage": "https://ucfopen.github.io/Obojobo-Docs/",
77
"license": "AGPL-3.0-only",

packages/app/obojobo-document-engine/__tests__/Viewer/stores/assessment-state-helpers.test.js

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,44 @@ describe('AssessmentStateHelpers', () => {
8282
spy.mockRestore()
8383
})
8484

85+
test('saveAttemptState returns true when good response returns', async () => {
86+
AssessmentAPI.saveAttempt.mockResolvedValue({ status: 'ok' })
87+
88+
const mockState = { mockProp: 'mockVal' }
89+
90+
const result = await AssessmentStateHelpers.saveAttemptState(
91+
'mockAssessmentId',
92+
'mockAttemptId',
93+
mockState
94+
)
95+
96+
expect(AssessmentAPI.saveAttempt).toHaveBeenCalledWith({
97+
assessmentId: 'mockAssessmentId',
98+
attemptId: 'mockAttemptId',
99+
draftId: 'mockDraftId',
100+
draftContentId: 'mockDraftId',
101+
state: mockState,
102+
visitId: 'mockVisitId'
103+
})
104+
expect(result).toBe(true)
105+
})
106+
107+
test('saveAttemptState throws an error when bad response returns', async () => {
108+
AssessmentAPI.saveAttempt.mockResolvedValue({
109+
status: 'error',
110+
value: { message: 'mockErrorMessage' }
111+
})
112+
113+
try {
114+
await AssessmentStateHelpers.saveAttemptState('mockAssessmentId', 'mockAttemptId'),
115+
{
116+
mockProp: 'mockVal'
117+
}
118+
} catch (e) {
119+
expect(e).toEqual(Error('mockErrorMessage'))
120+
}
121+
})
122+
85123
test('resumeAttempt calls AssessmentStateHelpers.onAttemptStarted when good response returned', async () => {
86124
AssessmentAPI.resumeAttempt.mockResolvedValue({ status: 'ok', value: { questions: [] } })
87125
const spy = jest.spyOn(AssessmentStateHelpers, 'onAttemptStarted').mockReturnValue(true)
@@ -318,7 +356,7 @@ describe('AssessmentStateHelpers', () => {
318356
expect.assertions(1)
319357
})
320358

321-
test('onAttemptStarted creates OboModels, updates nav context, rebuilds the nav menu, navigates to the assessment, runs the onStartAttempt trigger and fires the assessment:attemptStarted event', () => {
359+
test('onAttemptStarted creates OboModels, updates nav context, rebuilds the nav menu, navigates to the assessment, runs the onStartAttempt trigger and fires the assessment:attemptStarted event (no question responses)', () => {
322360
const res = {
323361
value: {
324362
assessmentId: 'mockAssessmentId',
@@ -340,11 +378,59 @@ describe('AssessmentStateHelpers', () => {
340378
expect(navUtilSetContextSpy).toHaveBeenCalledWith('assessment:mockAssessmentId:mockAttemptId')
341379
expect(navUtilRebuildMenuSpy).toHaveBeenCalled()
342380
expect(navUtilGoToSpy).toHaveBeenCalledWith('mockAssessmentId')
381+
expect(QuestionStore.getOrCreateContextState).not.toHaveBeenCalled()
382+
expect(QuestionStore.updateStateByContext).not.toHaveBeenCalled()
383+
384+
navUtilSetContextSpy.mockRestore()
385+
navUtilRebuildMenuSpy.mockRestore()
386+
navUtilGoToSpy.mockRestore()
387+
dispatcherTriggerSpy.mockRestore()
388+
})
389+
390+
test('onAttemptStarted creates OboModels, updates nav context, rebuilds the nav menu, navigates to the assessment, runs the onStartAttempt trigger and fires the assessment:attemptStarted event (with question responses)', () => {
391+
const res = {
392+
value: {
393+
assessmentId: 'mockAssessmentId',
394+
attemptId: 'mockAttemptId',
395+
questions: [{ id: 'question1' }, { id: 'question2' }],
396+
questionResponses: [
397+
{ questionId: 'question1', response: true },
398+
{ questionId: 'question2', response: { ids: ['mockNodeId1'] } }
399+
]
400+
}
401+
}
402+
403+
const navUtilSetContextSpy = jest.spyOn(NavUtil, 'setContext')
404+
const navUtilRebuildMenuSpy = jest.spyOn(NavUtil, 'rebuildMenu')
405+
const navUtilGoToSpy = jest.spyOn(NavUtil, 'goto')
406+
const dispatcherTriggerSpy = jest.spyOn(Dispatcher, 'trigger')
407+
const questionStoreContextStateSpy = jest
408+
.spyOn(QuestionStore, 'getOrCreateContextState')
409+
.mockReturnValue({
410+
responseMetadata: {},
411+
responses: {},
412+
viewedQuestions: {}
413+
})
414+
415+
AssessmentStateHelpers.onAttemptStarted(res)
416+
417+
const assessmentModel = OboModel.models.mockAssessmentId
418+
expect(assessmentModel.children.at(1).children.reset).toHaveBeenCalled()
419+
expect(assessmentModel.children.at(1).children.add).toHaveBeenCalledTimes(2)
420+
expect(navUtilSetContextSpy).toHaveBeenCalledWith('assessment:mockAssessmentId:mockAttemptId')
421+
expect(navUtilRebuildMenuSpy).toHaveBeenCalled()
422+
expect(navUtilGoToSpy).toHaveBeenCalledWith('mockAssessmentId')
423+
expect(QuestionStore.getOrCreateContextState).toHaveBeenCalledWith(
424+
'assessment:mockAssessmentId:mockAttemptId'
425+
)
426+
// TODO: check the object specifically to make sure everything was carried over correctly?
427+
expect(QuestionStore.updateStateByContext).toHaveBeenCalledTimes(1)
343428

344429
navUtilSetContextSpy.mockRestore()
345430
navUtilRebuildMenuSpy.mockRestore()
346431
navUtilGoToSpy.mockRestore()
347432
dispatcherTriggerSpy.mockRestore()
433+
questionStoreContextStateSpy.mockRestore()
348434
})
349435

350436
test('getUpdatedAssessmentData returns the expected object', () => {

0 commit comments

Comments
 (0)