-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(saving): last change is always saved now (#1170)
* fix(saving): focus on current element blurred when saving / exporting * docs(contrib): corrected bug report template * refactor(saving): improved conciseness * fix(save): add contentUpdate and blurActiveElement actions * test(save-action): add save-action tests Co-authored-by: JPSchellenberg <jps@Lumi.education>
- Loading branch information
1 parent
879042f
commit 9c2eb34
Showing
10 changed files
with
1,009 additions
and
861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
client/src/state/H5PEditor/__tests__/H5PEditorActions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
import * as actions from '../H5PEditorActions'; | ||
|
||
import { | ||
H5PEDITOR_BLURACTIVEELEMENT, | ||
H5PEDITOR_UPDATE_CONTENT_SERVER | ||
} from '../H5PEditorTypes'; | ||
|
||
const middlewares = [thunk]; | ||
const mockStore = configureMockStore(middlewares); | ||
|
||
// declare var window: any; | ||
|
||
describe('blurActiveElement', () => { | ||
it('calls the window.document.activeElement?.blur() function', (done) => { | ||
const store = mockStore(); | ||
// window = {}; | ||
// window.document = {}; | ||
// window.document.activeElement = {}; | ||
|
||
// const mockBlur = jest.fn(); | ||
// window.document.activeElement.blur = mockBlur; | ||
|
||
store.dispatch(actions.blurActiveElement()); | ||
|
||
expect(store.getActions()).toEqual([ | ||
{ | ||
type: H5PEDITOR_BLURACTIVEELEMENT | ||
} | ||
]); | ||
|
||
// expect(mockBlur.mock.calls.length).toBe(1); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
describe('updateConentOnServer', () => { | ||
it('blurs the active element first', (done) => { | ||
const store = mockStore(); | ||
|
||
store.dispatch(actions.updateContentOnServer()); | ||
|
||
expect(store.getActions()[0]).toEqual({ | ||
type: H5PEDITOR_BLURACTIVEELEMENT | ||
}); | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('save', () => { | ||
const store = mockStore(); | ||
|
||
store.dispatch(actions.save() as any); | ||
|
||
it('blurs the active element first', (done) => { | ||
expect(store.getActions()[0]).toEqual({ | ||
type: H5PEDITOR_BLURACTIVEELEMENT | ||
}); | ||
done(); | ||
}); | ||
|
||
it('updates the content on the server', (done) => { | ||
expect(store.getActions()[1]).toEqual({ | ||
type: H5PEDITOR_UPDATE_CONTENT_SERVER | ||
}); | ||
done(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters