-
Notifications
You must be signed in to change notification settings - Fork 30
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
New: migration scripts added to repo (fixes #208) #209
Open
chris-steele
wants to merge
7
commits into
master
Choose a base branch
from
issue/208
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4eddad4
Added migration scripts
chris-steele fa3b643
Migration corrections
chris-steele 915d063
Migration corrections
chris-steele 61cafe9
Review amendments
chris-steele 1cb30e6
Migration scripts review amendments
chris-steele 7632560
Migration scripts review amendments
chris-steele 9a9f10d
Migration scripts review amendments
chris-steele 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 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,32 @@ | ||
import { describe, getCourse, whereFromPlugin, mutateContent, checkContent, updatePlugin } from 'adapt-migrations'; | ||
import _ from 'lodash'; | ||
|
||
describe('Box menu - v2.0.2 to v2.0.3', async () => { | ||
|
||
// https://github.com/adaptlearning/adapt-contrib-boxMenu/compare/v2.0.2..v2.0.3 | ||
|
||
let course, courseBoxMenuGlobals; | ||
const durationLabel = 'Duration:'; | ||
|
||
whereFromPlugin('Box menu - from v2.0.2', { name: 'adapt-contrib-boxMenu', version: '>=2.0.0 <2.0.3' }); | ||
|
||
mutateContent('Box menu - add globals if missing', async (content) => { | ||
course = getCourse(); | ||
if (!_.has(course, '_globals._menu._boxMenu')) _.set(course, '_globals._menu._boxMenu', {}); | ||
courseBoxMenuGlobals = course._globals._menu._boxMenu; | ||
return true; | ||
}); | ||
|
||
mutateContent('Box menu - add new globals', async (content) => { | ||
courseBoxMenuGlobals.durationLabel = durationLabel; | ||
return true; | ||
}); | ||
|
||
checkContent('Box menu - check new globals', async (content) => { | ||
const isValid = courseBoxMenuGlobals.durationLabel === durationLabel; | ||
if (!isValid) throw new Error('Box menu - global attribute durationLabel'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('Box menu - update to v2.0.3', { name: 'adapt-contrib-boxMenu', version: '2.0.3', framework: '">=2.0.0' }); | ||
}); |
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,53 @@ | ||
import { describe, getCourse, whereFromPlugin, mutateContent, checkContent, updatePlugin } from 'adapt-migrations'; | ||
import _ from 'lodash'; | ||
|
||
describe('Box menu - v3.0.0 to v4.0.0', async () => { | ||
|
||
// https://github.com/adaptlearning/adapt-contrib-boxMenu/compare/v3.0.0..v4.0.0 | ||
|
||
let course, courseBoxMenuGlobals; | ||
|
||
whereFromPlugin('Box menu - from v3.0.0', { name: 'adapt-contrib-boxMenu', version: '<4.0.0' }); | ||
|
||
mutateContent('Box menu - add globals if missing', async (content) => { | ||
course = getCourse(); | ||
if (!_.has(course, '_globals._menu._boxMenu')) _.set(course, '_globals._menu._boxMenu', {}); | ||
courseBoxMenuGlobals = course._globals._menu._boxMenu; | ||
return true; | ||
}); | ||
|
||
mutateContent('Box menu - remove global attribute ariaRegion', async (content) => { | ||
delete courseBoxMenuGlobals.ariaRegion; | ||
return true; | ||
}); | ||
|
||
mutateContent('Box menu - remove globas attribute menuItem', async (content) => { | ||
delete courseBoxMenuGlobals.menuItem; | ||
return true; | ||
}); | ||
|
||
mutateContent('Box menu - remove globas attribute menuEnd', async (content) => { | ||
delete courseBoxMenuGlobals.menuEnd; | ||
return true; | ||
}); | ||
|
||
checkContent('Box menu - check global attribute ariaRegion', async (content) => { | ||
const isValid = !_.has(courseBoxMenuGlobals, 'ariaRegion'); | ||
if (!isValid) throw new Error('Box menu - global attribute ariaRegion'); | ||
return true; | ||
}); | ||
|
||
checkContent('Box menu - check global attribute menuItem', async (content) => { | ||
const isValid = !_.has(courseBoxMenuGlobals, 'menuItem'); | ||
if (!isValid) throw new Error('Box menu - global attribute menuItem'); | ||
return true; | ||
}); | ||
|
||
checkContent('Box menu - check global attribute menuEnd', async (content) => { | ||
const isValid = !_.has(courseBoxMenuGlobals, 'menuEnd'); | ||
if (!isValid) throw new Error('Box menu - global attribute menuEnd'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('Box menu - update to v4.0.0', { name: 'adapt-contrib-boxMenu', version: '4.0.0', framework: '">=4' }); | ||
}); |
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,146 @@ | ||
import { describe, getCourse, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin } from 'adapt-migrations'; | ||
import _ from 'lodash'; | ||
|
||
describe('Box menu - v6.0.2 to v6.1.0', async () => { | ||
|
||
// https://github.com/adaptlearning/adapt-contrib-boxMenu/compare/v6.0.2..v6.1.0 | ||
|
||
let course; | ||
const defaultTextAlignment = { | ||
_title: '', | ||
_body: '', | ||
_instruction: '' | ||
}; | ||
|
||
whereFromPlugin('Box menu - from v6.0.2', { name: 'adapt-contrib-boxMenu', version: '<6.1.0' }); | ||
|
||
whereContent('Box menu - where course has _menuHeader', async (content) => { | ||
course = getCourse(); | ||
return course?._boxMenu?._menuHeader; | ||
}); | ||
|
||
mutateContent('Box menu - add _textAlignment attribute', async (content) => { | ||
course._boxMenu._menuHeader._textAlignment = defaultTextAlignment; | ||
return true; | ||
}); | ||
|
||
checkContent('Box menu - check _textAlignment attribute', async (content) => { | ||
const isValid = _.isEqual(course._boxMenu._menuHeader._textAlignment, defaultTextAlignment); | ||
if (!isValid) throw new Error('Box menu - course attribute _textAlignment'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('Box menu - update to v6.1.0', { name: 'adapt-contrib-boxMenu', version: '6.1.0', framework: '">=5.22.6' }); | ||
}); | ||
|
||
describe('Box menu - v6.2.0 to v6.2.1', async () => { | ||
|
||
// https://github.com/adaptlearning/adapt-contrib-boxMenu/compare/v6.2.0..v6.2.1 | ||
|
||
let course; | ||
const defaultGraphic = { | ||
_src: '', | ||
alt: '' | ||
}; | ||
|
||
whereFromPlugin('Box menu - from v6.2.0', { name: 'adapt-contrib-boxMenu', version: '<6.2.1' }); | ||
|
||
whereContent('Box menu - where course has _boxMenu', async (content) => { | ||
course = getCourse(); | ||
return course?._boxMenu; | ||
}); | ||
|
||
mutateContent('Box menu - add _graphic attribute', async (content) => { | ||
course._boxMenu._graphic = defaultGraphic; | ||
return true; | ||
}); | ||
|
||
checkContent('Box menu - check _graphic attribute', async (content) => { | ||
const isValid = _.isEqual(course._boxMenu._graphic, defaultGraphic); | ||
if (!isValid) throw new Error('Box menu - course attribute _graphic'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('Box menu - update to v6.2.1', { name: 'adapt-contrib-boxMenu', version: '6.2.1', framework: '">=5.24.2' }); | ||
}); | ||
|
||
describe('Box menu - v6.3.8 to v6.3.9', async () => { | ||
|
||
// https://github.com/adaptlearning/adapt-contrib-boxMenu/compare/v6.3.8..v6.3.9 | ||
|
||
let course; | ||
|
||
whereFromPlugin('Box menu - from v6.3.8', { name: 'adapt-contrib-boxMenu', version: '<6.3.9' }); | ||
|
||
whereContent('Box menu - where course has _backgroundImage', async (content) => { | ||
course = getCourse(); | ||
return ( | ||
course?._boxMenu?._backgroundImage || | ||
course?._boxMenu?._menuHeader?._backgroundImage | ||
); | ||
}); | ||
|
||
mutateContent('Box menu - add _xlarge attribute', async (content) => { | ||
if (course._boxMenu._backgroundImage) { | ||
course._boxMenu._backgroundImage._xlarge = ''; | ||
} | ||
return true; | ||
}); | ||
|
||
mutateContent('Box menu - add _xlarge attribute to _menuHeader', async (content) => { | ||
if (course._boxMenu._menuHeader._backgroundImage) { | ||
course._boxMenu._menuHeader._backgroundImage._xlarge = ''; | ||
} | ||
return true; | ||
}); | ||
|
||
checkContent('Box menu - check _xlarge attribute', async (content) => { | ||
const isValid = ( | ||
!course._boxMenu._backgroundImage || | ||
course._boxMenu._backgroundImage._xlarge === '' | ||
); | ||
if (!isValid) throw new Error('Box menu - course attribute _xlarge'); | ||
return true; | ||
}); | ||
|
||
checkContent('Box menu - check _xlarge attribute for _menuHeader', async (content) => { | ||
const isValid = ( | ||
!course._boxMenu._menuHeader?._backgroundImage || | ||
course._boxMenu._menuHeader._backgroundImage._xlarge === '' | ||
); | ||
if (!isValid) throw new Error('Box menu - course attribute _xlarge'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('Box menu - update to v6.3.9', { name: 'adapt-contrib-boxMenu', version: '6.3.9', framework: '">=5.24.2' }); | ||
}); | ||
|
||
describe('Box menu - v6.3.9 to v6.3.10', async () => { | ||
|
||
// https://github.com/adaptlearning/adapt-contrib-boxMenu/compare/v6.3.9..v6.3.10 | ||
|
||
let course, courseBoxMenuGlobals; | ||
const itemCount = 'Item {{_nthChild}} of {{_totalChild}}'; | ||
|
||
whereFromPlugin('Box menu - from v6.3.9', { name: 'adapt-contrib-boxMenu', version: '<6.3.10' }); | ||
|
||
mutateContent('Box menu - add globals if missing', async (content) => { | ||
course = getCourse(); | ||
if (!_.has(course, '_globals._menu._boxMenu')) _.set(course, '_globals._menu._boxMenu', {}); | ||
courseBoxMenuGlobals = course._globals._menu._boxMenu; | ||
return true; | ||
}); | ||
|
||
mutateContent('Box menu - add new globals', async (content) => { | ||
courseBoxMenuGlobals.itemCount = itemCount; | ||
return true; | ||
}); | ||
|
||
checkContent('Box menu - check new globals', async (content) => { | ||
const isValid = courseBoxMenuGlobals.itemCount === itemCount; | ||
if (!isValid) throw new Error('Box menu - global attribute itemCount'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('Box menu - update to v6.3.10', { name: 'adapt-contrib-boxMenu', version: '6.3.10', framework: '">=5.24.2' }); | ||
}); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chris-steele Thoughts on splitting these into two mutates as there's two attributes in the object? Or as it's setting a single attribute leave it as one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could argue that you are adding a single attribute; it just happens to be of type object. I'd say let's leave as is otherwise we might fall on the sword of consistency elsewhere where there are tons of new properties which will make for a very verbose script.