-
Notifications
You must be signed in to change notification settings - Fork 17
New: Migration scripts added to repo (fix #109) #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7967cbd
Add v4, globals
swashbuck e416d51
Add 4.1.0 describe
swashbuck 58a9705
Start updating components
swashbuck be6f1b4
Amends
swashbuck cc1ad92
Add _tutor to components
swashbuck fefd34a
Component properties, remove whereContent from v4.js
swashbuck c341307
Remove whereContent import
swashbuck 1a6f5ce
Finish 4.0.0 scripts
swashbuck fc71d9c
4.1.0 course _tutor props
swashbuck 25744f7
4.1.0 component _isInherited
swashbuck 4c98b09
Check for specific values
swashbuck c7f3416
Shorten tests
swashbuck 8c38331
Update hideFeedback check
swashbuck 7cef108
Remove duplicated course assignment, move variable declarations into …
swashbuck 75c2ac2
Remove optional chaining
swashbuck f86988f
Prevent migrations before 2.0.0
swashbuck 220dffa
Fix mutateContent for 'add _tutor._isInherited to components'
swashbuck aafcf38
Fix from versions in describes
swashbuck 89aec8f
Merge branch 'master' into issue/109
swashbuck 76ca375
automated testing added, standardise spacing
joe-allen-89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,58 @@ | ||
| import { describe, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin } from 'adapt-migrations'; | ||
| import _ from 'lodash'; | ||
|
|
||
| describe('Tutor - v2.1.0 to v4.0.0', async () => { | ||
| let course, courseTutorGlobals, components; | ||
| whereFromPlugin('Tutor - from v2.1.0', { name: 'adapt-contrib-tutor', version: '<4.0.0' }); | ||
| whereContent('Tutor - where ?', async (content) => { | ||
| // Check if Tutor is installed?? Configuration won't exist at this point. | ||
| // return true; | ||
|
|
||
| // Check if any components exist and set components variable | ||
| components = content.filter(({ _component }) => _component); | ||
| return components.length; | ||
| }); | ||
swashbuck marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mutateContent('Tutor - add globals if missing', async (content) => { | ||
| course = content.find(({ _type }) => _type === 'course'); | ||
| if (!_.has(course, '_globals._extensions._tutor')) _.set(course, '_globals._extensions._tutor', {}); | ||
| courseTutorGlobals = course._globals._extensions._tutor; | ||
| return true; | ||
| }); | ||
| mutateContent('Tutor - add globals hideFeedback', async (content) => { | ||
| courseTutorGlobals.hideFeedback = 'Hide feedback'; | ||
| return true; | ||
| }); | ||
| checkContent('Tutor - check globals _tutor attribute', async content => { | ||
| if (courseTutorGlobals === undefined) throw new Error('Tutor - globals _tutor invalid'); | ||
| return true; | ||
| }); | ||
| checkContent('Tutor - check globals hideFeedback attribute', async content => { | ||
| if (courseTutorGlobals?.hideFeedback === undefined) throw new Error('Tutor - globals hideFeedback invalid'); | ||
| return true; | ||
| }); | ||
|
|
||
| // Update components | ||
| mutateContent('Tutor - add _tutor to components if missing', async (content) => { | ||
| components.forEach(component => { | ||
| if (!_.has(component, '_tutor')) _.set(component, '_tutor', {}); | ||
| }); | ||
| return true; | ||
| }); | ||
| checkContent('Tutor - check for _tutor component attribute', async content => { | ||
| const isValid = components.every(({ _tutor }) => _tutor !== undefined); | ||
| if (!isValid) throw new Error('Tutor (components) - component _tutor invalid'); | ||
| return true; | ||
| }); | ||
| updatePlugin('Tutor - update to v4.0.0', { name: 'adapt-contrib-tutor', version: '4.0.0', framework: '>=5.18.0' }); | ||
| }); | ||
|
|
||
| // describe('Tutor - v4.0.0 to v4.1.0', async () => { | ||
| // let tutors, course, courseTutorGlobals; | ||
| // whereFromPlugin('Tutor - from v4.1.0', { name: 'adapt-contrib-tutor', version: '<4.1.0' }); | ||
| // whereContent('Tutor - where tutor', async content => { | ||
| // tutors = content.filter(({ _extension }) => _extension === 'tutor'); | ||
| // if (tutors) return true; | ||
| // }); | ||
|
|
||
| // updatePlugin('Tutor - update to v4.1.0', { name: 'adapt-contrib-tutor', version: '4.1.0', framework: '>=5.18.0' }); | ||
| // }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.