-
Notifications
You must be signed in to change notification settings - Fork 26
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 (fixes #158) #159
Merged
Merged
Changes from 31 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
b84e4cf
Initial migration scripts for v1 & 2
joe-replin e683d55
all migration scripts for adapt-contrib-accordion
joe-replin 4900d7e
Remove v3.js
joe-replin 5640369
Added template comments
joe-replin c15d411
v2 & v4 too early for v2.4.0 of FW
joe-replin e4c246f
Globals Attribute
joe-replin c847a36
Updates to accordion migrations
joe-replin 535198f
Chris' review
joe-replin b292981
Update v7.js
joe-replin df25a2e
Remove Comment
joe-replin 02e9d33
Update migrations/v2.js
joe-replin 8a7df4e
Update migrations/v2.js
joe-replin 7cadc9a
Update migrations/v2.js
joe-replin cbbc778
Update migrations/v2.js
joe-replin f366db3
Update migrations/v2.js
joe-replin 5a89b21
Update migrations/v2.js
joe-replin 8c65953
Update migrations/v4.js
joe-replin f55a611
Update migrations/v7.js
joe-replin f1e082a
Update migrations/v7.js
joe-replin 25f11d7
Update migrations/v7.js
joe-replin d2923be
Update migrations/v7.js
joe-replin e71a29a
Update migrations/v7.js
joe-replin 3c3cdc1
Apply suggestions from code review
joe-replin 6ebd41a
Accordion length and global lodash fix
joe-replin 6eee52a
Update v2.js
joe-replin 7e6e4c0
Remove migration from v1 to v2
joe-replin 1748d4e
whereContent return adjustments
joe-replin 56321cb
Removing comments.
joe-replin 6be48d7
Migration Script Test
joe-replin 1f4b734
adding helpers
joe-replin 98ac887
auomated testing added to migrations
joe-allen-89 b1a3217
amends to automated tests
joe-allen-89 5e78c35
review amends completed
joe-allen-89 aa18166
correct/incorrect _supportedLayout added to test
joe-allen-89 d33bf6c
review amends completed
joe-allen-89 a8863ca
Updating conditional logic.
joe-replin a47a73e
Update v7.js
joe-replin 7f90202
Amending for early return
joe-replin c48b29e
optional chaining added for accordion._items?.forEach
joe-allen-89 2548e0b
component with no items added to each test
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 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,143 @@ | ||
import { describe, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin, getComponents, testStopWhere, testSuccessWhere } from 'adapt-migrations'; | ||
import _ from 'lodash'; | ||
|
||
describe('adapt-contrib-accordion - v2.0.3 > v2.0.4', async () => { | ||
let accordions; | ||
|
||
whereFromPlugin('adapt-contrib-accordion - from v2.0.3', { name: 'adapt-contrib-accordion', version: '>=2.0.0 <2.0.4' }); | ||
|
||
whereContent('adapt-contrib-accordion - where accordion', async content => { | ||
accordions = getComponents('accordion'); | ||
return accordions.length; | ||
}); | ||
|
||
mutateContent('adapt-contrib-accordion - add accordion._items._classes attribute', async () => { | ||
accordions.forEach(accordion => { | ||
accordion._items.forEach(item => { | ||
joe-allen-89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
item._classes = ''; | ||
}); | ||
}); | ||
return true; | ||
}); | ||
|
||
checkContent('adapt-contrib-accordion - check accordion._items._classes attribute', async () => { | ||
const isValid = accordions.every(accordion => | ||
accordion._items.every(item => | ||
item && item._classes !== undefined | ||
joe-allen-89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
); | ||
if (!isValid) throw new Error('adapt-contrib-accordion - _classes not added to every instance of accordion._items'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('adapt-contrib-accordion - update to v2.0.4', { name: 'adapt-contrib-accordion', version: '2.0.4', framework: '>=2.0.0' }); | ||
|
||
testSuccessWhere('correct version with accordion components', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.0.3' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _id: 'c-105', _component: 'accordion', _items: [{ title: 'item 1' }] } | ||
] | ||
}); | ||
|
||
testStopWhere('no accordion components', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.0.3' }], | ||
content: [{ _component: 'other' }] | ||
}); | ||
|
||
testStopWhere('incorrect version', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.0.4' }] | ||
}); | ||
}); | ||
|
||
describe('adapt-contrib-accordion - v2.0.4 > v2.0.5', async () => { | ||
let accordions; | ||
|
||
whereFromPlugin('adapt-contrib-accordion - from v2.0.4', { name: 'adapt-contrib-accordion', version: '<2.0.5' }); | ||
|
||
whereContent('adapt-contrib-accordion - where accordion', async content => { | ||
accordions = getComponents('accordion'); | ||
return accordions.length; | ||
}); | ||
|
||
mutateContent('adapt-contrib-accordion - add accordion._shouldCollapseItems attribute', async () => { | ||
accordions.forEach(accordion => { | ||
accordion._shouldCollapseItems = true; | ||
}); | ||
return true; | ||
}); | ||
|
||
checkContent('adapt-contrib-accordion - check accordion._shouldCollapseItems attribute', async () => { | ||
const isValid = accordions.every(({ _shouldCollapseItems }) => _shouldCollapseItems === true); | ||
if (!isValid) throw new Error('adapt-contrib-accordion - _shouldCollapseItems not added to every instance of accordion and set to true.'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('adapt-contrib-accordion - update to v2.0.5', { name: 'adapt-contrib-accordion', version: '2.0.5', framework: '>=2.0.0' }); | ||
|
||
testSuccessWhere('correct version with accordion components', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.0.4' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _id: 'c-105', _component: 'accordion' } | ||
] | ||
}); | ||
|
||
testStopWhere('no accordion components', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.0.4' }], | ||
content: [{ _component: 'other' }] | ||
}); | ||
|
||
testStopWhere('incorrect version', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.0.5' }] | ||
}); | ||
}); | ||
|
||
describe('adapt-contrib-accordion - v2.0.5 > v2.1.0', async () => { | ||
let accordions; | ||
|
||
whereFromPlugin('adapt-contrib-accordion - from v2.0.5', { name: 'adapt-contrib-accordion', version: '<2.1.0' }); | ||
|
||
whereContent('adapt-contrib-accordion - where accordion', async content => { | ||
accordions = getComponents('accordion'); | ||
return accordions.length; | ||
}); | ||
|
||
mutateContent('adapt-contrib-accordion - add accordion._items._graphic.attribution', async () => { | ||
accordions.forEach(accordion => { | ||
accordion._items.forEach(item => { | ||
_.set(item, '_graphic.attribution', ''); | ||
}); | ||
}); | ||
return true; | ||
}); | ||
|
||
checkContent('adapt-contrib-accordion - check accordion._items._graphic.attribution atrribute', async () => { | ||
const isValid = accordions.every(accordion => | ||
accordion._items.every(item => | ||
item._graphic && item._graphic.attribution !== undefined | ||
joe-allen-89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
); | ||
if (!isValid) throw new Error('adapt-contrib-accordion - _graphic.attribution not added to every instance of accordion._items'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('adapt-contrib-accordion - update to v2.1.0', { name: 'adapt-contrib-accordion', version: '2.1.0', framework: '>=2.0.0' }); | ||
|
||
testSuccessWhere('correct version with accordion components with/without _graphic', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.0.5' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1', _graphic: {} }] }, | ||
{ _id: 'c-105', _component: 'accordion', _items: [{ title: 'item 1' }] } | ||
] | ||
}); | ||
|
||
testStopWhere('no accordion components', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.0.5' }], | ||
content: [{ _component: 'other' }] | ||
}); | ||
|
||
testStopWhere('incorrect version', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.1.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,82 @@ | ||
import { describe, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin, getCourse, getComponents, testStopWhere, testSuccessWhere } from 'adapt-migrations'; | ||
import _ from 'lodash'; | ||
|
||
describe('adapt-contrib-accordion - v2.1.0 > v4.0.0', async () => { | ||
|
||
let course, courseAccordionGlobals, accordions; | ||
const oldAriaRegion = 'This component requires you to answer the question by selecting the relevant value. After selecting a value select the submit button below.'; | ||
|
||
whereFromPlugin('adapt-contrib-accordion - from v2.1.0', { name: 'adapt-contrib-accordion', version: '<4.0.0' }); | ||
|
||
whereContent('adapt-contrib-accordion - where accordion', async content => { | ||
accordions = getComponents('accordion'); | ||
return accordions.length; | ||
}); | ||
|
||
mutateContent('adapt-contrib-accordion - modify globals ariaRegion attribute', async (content) => { | ||
course = getCourse(); | ||
if (!_.has(course, '_globals._components._accordion')) _.set(course, '_globals._components._accordion', { ariaRegion: oldAriaRegion }); | ||
courseAccordionGlobals = course._globals._components._accordion; | ||
if (courseAccordionGlobals.ariaRegion === oldAriaRegion) { | ||
courseAccordionGlobals.ariaRegion = 'Accordion. Select each button to expand the content.'; | ||
} | ||
return true; | ||
}); | ||
|
||
mutateContent('adapt-contrib-accordion - add accordion._setCompletionOn and set attribute', async () => { | ||
accordions.forEach(accordion => { | ||
accordion._setCompletionOn = 'allItems'; | ||
}); | ||
return true; | ||
}); | ||
|
||
checkContent('adapt-contrib-accordion - modify globals ariaRegion attribute', async (content) => { | ||
const isValid = courseAccordionGlobals.ariaRegion !== oldAriaRegion; | ||
if (!isValid) throw new Error('Accordion globals ariaRegion attribute not modified.'); | ||
return true; | ||
}); | ||
|
||
checkContent('adapt-contrib-accordion - check accordion._setCompletionOn attribute', async () => { | ||
const isValid = accordions.every(({ _setCompletionOn }) => _setCompletionOn === 'allItems'); | ||
if (!isValid) throw new Error('adapt-contrib-accordion - _setCompletionOn not added to every instance of accordion and set to "allItems"'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('adapt-contrib-accordion - update to v4.0.0', { name: 'adapt-contrib-accordion', version: '4.0.0', framework: '>=3.3.0' }); | ||
|
||
testSuccessWhere('correct version with accordion components and empty course', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.1.0' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _id: 'c-105', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _type: 'course' } | ||
] | ||
}); | ||
|
||
testSuccessWhere('correct version with accordion components and course globals', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.1.0' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _id: 'c-105', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _type: 'course', _globals: { _components: { _accordion: {} } } } | ||
] | ||
}); | ||
|
||
testSuccessWhere('correct version with accordion components and custom course globals', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.1.0' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _id: 'c-105', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _type: 'course', _globals: { _components: { _accordion: { ariaRegion: 'custom aria region' } } } } | ||
] | ||
}); | ||
|
||
testStopWhere('no accordion components', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.1.0' }], | ||
content: [{ _component: 'other' }] | ||
}); | ||
|
||
testStopWhere('incorrect version', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '4.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,128 @@ | ||
import { describe, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin, getCourse, getComponents, testStopWhere, testSuccessWhere } from 'adapt-migrations'; | ||
import _ from 'lodash'; | ||
|
||
describe('adapt-contrib-accordion - v4.0.0 > v5.0.0', async () => { | ||
let course, courseAccordionGlobals, accordions; | ||
const originalAriaRegion = 'Accordion. Select each button to expand the content.'; | ||
const newAriaRegion = 'List of expandable sections. Select each button to expand the content.'; | ||
joe-allen-89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
whereFromPlugin('adapt-contrib-accordion - from v4.0.0', { name: 'adapt-contrib-accordion', version: '<5.0.0' }); | ||
|
||
whereContent('adapt-contrib-accordion - where accordion', async content => { | ||
accordions = getComponents('accordion'); | ||
return accordions.length; | ||
}); | ||
|
||
mutateContent('adapt-contrib-accordion - modify globals ariaRegion attribute', async (content) => { | ||
course = getCourse(); | ||
if (!_.has(course, '_globals._components._accordion.ariaRegion')) _.set(course, '_globals._components._accordion', { ariaRegion: originalAriaRegion }); | ||
joe-allen-89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
courseAccordionGlobals = course._globals._components._accordion; | ||
if (courseAccordionGlobals.ariaRegion === originalAriaRegion) { | ||
courseAccordionGlobals.ariaRegion = newAriaRegion; | ||
} | ||
return true; | ||
}); | ||
|
||
mutateContent('adapt-contrib-accordion - update accordion._supportedLayout attribute to full-width if current isn\'t a supported value.', async () => { | ||
accordions.forEach(accordion => { | ||
if (accordion._supportedLayout !== 'full-width' || accordion._supportedLayout !== 'half-width' || accordion._supportedLayout !== 'both') { | ||
accordion._supportedLayout = 'full-width'; | ||
} | ||
joe-allen-89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
return true; | ||
}); | ||
|
||
checkContent('adapt-contrib-accordion - modify globals ariaRegion attribute', async (content) => { | ||
const isValid = courseAccordionGlobals.ariaRegion !== originalAriaRegion; | ||
if (!isValid) throw new Error('adapt-contrib-accordion - globals ariaRegion attribute not modified.'); | ||
return true; | ||
}); | ||
|
||
checkContent('adapt-contrib-accordion - check accordion._supportedLayout attribute is now full-width', async () => { | ||
const isValid = accordions.every(({ _supportedLayout }) => _supportedLayout === 'full-width' || _supportedLayout === 'half-width' || _supportedLayout === 'both'); | ||
oliverfoster marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!isValid) throw new Error('adapt-contrib-accordion - _supportedLayout attribute has not been modified to a supported value.'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('adapt-contrib-accordion - update to v5.0.0', { name: 'adapt-contrib-accordion', version: '5.0.0', framework: '>=5.0.0' }); | ||
|
||
testSuccessWhere('correct version with accordion components and empty course', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.1.0' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _id: 'c-105', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _type: 'course' } | ||
] | ||
}); | ||
|
||
testSuccessWhere('correct version with accordion components and course globals', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.1.0' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _id: 'c-105', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _type: 'course', _globals: { _components: { _accordion: {} } } } | ||
] | ||
}); | ||
|
||
testSuccessWhere('correct version with accordion components and custom course globals', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.1.0' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _id: 'c-105', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _type: 'course', _globals: { _components: { _accordion: { ariaRegion: 'custom aria region' } } } } | ||
] | ||
}); | ||
|
||
testStopWhere('no accordion components', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '2.1.0' }], | ||
content: [{ _component: 'other' }] | ||
}); | ||
|
||
testStopWhere('incorrect version', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '4.0.0' }] | ||
}); | ||
}); | ||
|
||
describe('adapt-contrib-accordion - v5.0.0 > v5.3.0', async () => { | ||
let accordions; | ||
|
||
whereFromPlugin('adapt-contrib-accordion - from v5.0.0', { name: 'adapt-contrib-accordion', version: '<5.3.0' }); | ||
|
||
whereContent('adapt-contrib-accordion - where accordion', async content => { | ||
accordions = getComponents('accordion'); | ||
return accordions.length; | ||
}); | ||
|
||
mutateContent('adapt-contrib-accordion - add accordion._shouldExpandFirstItem', async () => { | ||
accordions.forEach(accordion => { | ||
accordion._shouldExpandFirstItem = false; | ||
}); | ||
return true; | ||
}); | ||
|
||
checkContent('adapt-contrib-accordion - check accordion._shouldExpandFirstItem atrribute', async () => { | ||
const isValid = accordions.every(({ _shouldExpandFirstItem }) => _shouldExpandFirstItem === false); | ||
if (!isValid) throw new Error('adapt-contrib-accordion - _shouldExpandFirstItem not added to every instance of accordion'); | ||
return true; | ||
}); | ||
|
||
updatePlugin('adapt-contrib-accordion - update to v5.3.0', { name: 'adapt-contrib-accordion', version: '5.3.0', framework: '>=5.8.0' }); | ||
|
||
testSuccessWhere('correct version with accordion components and empty course', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '5.0.0' }], | ||
content: [ | ||
{ _id: 'c-100', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _id: 'c-105', _component: 'accordion', _items: [{ title: 'item 1' }] }, | ||
{ _type: 'course' } | ||
] | ||
}); | ||
|
||
testStopWhere('no accordion components', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '5.0.0' }], | ||
content: [{ _component: 'other' }] | ||
}); | ||
|
||
testStopWhere('incorrect version', { | ||
fromPlugins: [{ name: 'adapt-contrib-accordion', version: '5.3.0' }] | ||
}); | ||
}); |
Oops, something went wrong.
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.
A test with missing
_items
will error here.Is this ok?