-
Notifications
You must be signed in to change notification settings - Fork 28
New: Migration scripts added to repo (fixes #201) #202
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 all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
89e6502
Initial commit
swashbuck c7029d8
v2 scripts
swashbuck c3e88e3
v3 scripts
swashbuck 5ccad76
Remove lodash import
swashbuck f0147e2
Add 4.2 scripts
swashbuck e92d56c
6.2 scripts
swashbuck 434037e
v6, v7
swashbuck 5ca5fec
Fix feedback title
swashbuck 5e6a8e4
v6 score scripts
swashbuck be8d705
v2, v6 fixes
swashbuck ca45595
7.2.0 scripts
swashbuck 4f148a6
7.2.1 scripts
swashbuck 5f1396d
7.3.0 scripts
swashbuck 6f34b43
7.4.1 scripts
swashbuck 69ed9db
Finish v7 scripts
swashbuck 55a03dd
7.2.0 fix for instruction
swashbuck 7434d43
Add globals check to v3
swashbuck 4a8ec6b
Add globals check to v4
swashbuck 424ec33
Fix 4.2.0 describe comment
swashbuck bfce99b
Fix 6.0.0 describe comment
swashbuck 133d74c
v7 check for globals, fix describe comments
swashbuck 9dd06ad
Update 7.4.1 describe
swashbuck e697999
Remove unnecessary courseMatchingGlobals reassignment
swashbuck 3a4b5e9
Add new v2 describes
swashbuck b311b4c
Move var declarations inside describes
swashbuck dba4469
Add v2 scripts
swashbuck fb5703b
Fix from versions in describes
swashbuck 095a281
automated testing added, standardised 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,241 @@ | ||
| import { describe, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin, testStopWhere, testSuccessWhere, getComponents } from 'adapt-migrations'; | ||
| import _ from 'lodash'; | ||
|
|
||
| describe('Matching - v2.0.0 to v2.0.1', async () => { | ||
| let matchings; | ||
|
|
||
| whereFromPlugin('Matching - from v2.0.0', { name: 'adapt-contrib-matching', version: '>=2.0.0 <2.0.1' }); | ||
|
|
||
| whereContent('Matching - where matching', async content => { | ||
| matchings = getComponents('matching'); | ||
| return matchings.length; | ||
| }); | ||
|
|
||
| mutateContent('Matching - add _recordInteraction attribute', async content => { | ||
| matchings.forEach(matching => { matching._recordInteraction = true; }); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('Matching - check _recordInteraction attribute', async content => { | ||
| const isValid = matchings.every(({ _recordInteraction }) => _recordInteraction === true); | ||
| if (!isValid) throw new Error('Matching - _recordInteraction attribute invalid'); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('Matching - update to v2.0.1', { name: 'adapt-contrib-matching', version: '2.0.1', framework: '^2.0.0' }); | ||
|
|
||
| testSuccessWhere('matching component with empty course', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'matching' }, | ||
| { _id: 'c-105', _component: 'matching' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no matching components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.0' }], | ||
| content: [ | ||
| { _component: 'other' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.1' }] | ||
| }); | ||
| }); | ||
|
|
||
| describe('Matching - v2.0.2 to v2.0.3', async () => { | ||
| let matchings; | ||
|
|
||
| whereFromPlugin('Matching - from v2.0.2', { name: 'adapt-contrib-matching', version: '<2.0.3' }); | ||
|
|
||
| whereContent('Matching - where matching', async content => { | ||
| matchings = getComponents('matching'); | ||
| return matchings.length; | ||
| }); | ||
|
|
||
| mutateContent('Matching - add _canShowModelAnswer attribute', async content => { | ||
| matchings.forEach(matching => { matching._canShowModelAnswer = true; }); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('Matching - check _canShowModelAnswer attribute', async content => { | ||
| const isValid = matchings.every(({ _canShowModelAnswer }) => _canShowModelAnswer === true); | ||
| if (!isValid) throw new Error('Matching - _canShowModelAnswer attribute invalid'); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('Matching - update to v2.0.3', { name: 'adapt-contrib-matching', version: '2.0.3', framework: '^2.0.0' }); | ||
|
|
||
| testSuccessWhere('matching component with empty course', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.2' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'matching' }, | ||
| { _id: 'c-105', _component: 'matching' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no matching components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.2' }], | ||
| content: [ | ||
| { _component: 'other' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.3' }] | ||
| }); | ||
| }); | ||
|
|
||
| describe('Matching - v2.0.4 to v2.1.0', async () => { | ||
| let matchings; | ||
|
|
||
| whereFromPlugin('Matching - from v2.0.4', { name: 'adapt-contrib-matching', version: '<2.1.0' }); | ||
|
|
||
| whereContent('Matching - where matching', async content => { | ||
| matchings = getComponents('matching'); | ||
| return matchings.length; | ||
| }); | ||
|
|
||
| mutateContent('Matching - add _canShowMarking attribute', async content => { | ||
| matchings.forEach(matching => { matching._canShowMarking = true; }); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('Matching - check _canShowMarking attribute', async content => { | ||
| const isValid = matchings.every(({ _canShowMarking }) => _canShowMarking === true); | ||
| if (!isValid) throw new Error('Matching - _canShowMarking attribute invalid'); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('Matching - update to v2.1.0', { name: 'adapt-contrib-matching', version: '2.1.0', framework: '^2.0.15' }); | ||
|
|
||
| testSuccessWhere('matching component with empty course', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.2' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'matching' }, | ||
| { _id: 'c-105', _component: 'matching' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no matching components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.2' }], | ||
| content: [ | ||
| { _component: 'other' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.1.0' }] | ||
| }); | ||
| }); | ||
|
|
||
| describe('Matching - v2.1.1 to v2.1.2', async () => { | ||
| let matchings; | ||
|
|
||
| whereFromPlugin('Matching - from v2.1.1', { name: 'adapt-contrib-matching', version: '<2.1.2' }); | ||
|
|
||
| whereContent('Matching - where matching', async content => { | ||
| matchings = getComponents('matching'); | ||
| return matchings.length; | ||
| }); | ||
|
|
||
| mutateContent('Matching - add _canShowFeedback attribute', async content => { | ||
| matchings.forEach(matching => { matching._canShowFeedback = true; }); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('Matching - check _canShowFeedback attribute', async content => { | ||
| const isValid = matchings.every(({ _canShowFeedback }) => _canShowFeedback === true); | ||
| if (!isValid) throw new Error('Matching - _canShowFeedback attribute invalid'); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('Matching - update to v2.1.2', { name: 'adapt-contrib-matching', version: '2.1.2', framework: '^2.0.15' }); | ||
|
|
||
| testSuccessWhere('matching component with empty course', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.2' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'matching' }, | ||
| { _id: 'c-105', _component: 'matching' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no matching components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.0.2' }], | ||
| content: [ | ||
| { _component: 'other' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.1.0' }] | ||
| }); | ||
| }); | ||
|
|
||
| describe('Matching - v2.1.4 to v2.2.0', async () => { | ||
| let matchings; | ||
|
|
||
| whereFromPlugin('Matching - from v2.1.4', { name: 'adapt-contrib-matching', version: '<2.2.0' }); | ||
|
|
||
| whereContent('Matching - where matching', async content => { | ||
| matchings = getComponents('matching'); | ||
| return matchings.length; | ||
| }); | ||
|
|
||
| mutateContent('Matching - add _shouldResetAllAnswers attribute', async content => { | ||
| matchings.forEach(matching => { matching._shouldResetAllAnswers = false; }); | ||
| return true; | ||
| }); | ||
|
|
||
| mutateContent('Matching - add _feedback.title attribute', async content => { | ||
| matchings.forEach(matching => { | ||
| _.set(matching, '_feedback.title', ''); | ||
| console.log(matching); | ||
| }); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('Matching - check _shouldResetAllAnswers attribute', async content => { | ||
| const isValid = matchings.every(({ _shouldResetAllAnswers }) => _shouldResetAllAnswers === false); | ||
| if (!isValid) throw new Error('Matching - _shouldResetAllAnswers attribute invalid'); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('Matching - check _feedback.title attribute', async content => { | ||
| const isValid = matchings.every(({ _feedback }) => _feedback.title === ''); | ||
| if (!isValid) throw new Error('Matching - _feedback.title attribute invalid'); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('Matching - update to v2.2.0', { name: 'adapt-contrib-matching', version: '2.2.0', framework: '>=2.0.15' }); | ||
|
|
||
| testSuccessWhere('matching component with empty course', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.1.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'matching' }, | ||
| { _id: 'c-105', _component: 'matching' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no matching components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.1.0' }], | ||
| content: [ | ||
| { _component: 'other' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.2.0' }] | ||
| }); | ||
| }); | ||
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,91 @@ | ||
| import { describe, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin, getCourse, testStopWhere, testSuccessWhere, getComponents } from 'adapt-migrations'; | ||
| import _ from 'lodash'; | ||
|
|
||
| describe('Matching - v2.3.0 to v3.0.0', async () => { | ||
| let matchings, course, courseMatchingGlobals; | ||
| const originalAriaRegion = 'This question component requires you to select the matching answer from a drop down list below. When you have selected your answers select the submit button.'; | ||
| const newAriaRegion = 'Matching. Select from lists and then submit.'; | ||
|
|
||
| whereFromPlugin('Matching - from v2.3.0', { name: 'adapt-contrib-matching', version: '<3.0.0' }); | ||
|
|
||
| whereContent('Matching - where matching', async content => { | ||
| matchings = getComponents('matching'); | ||
| return matchings.length; | ||
| }); | ||
|
|
||
| mutateContent('Matching - add globals if missing', async (content) => { | ||
| course = getCourse(); | ||
| if (!_.has(course, '_globals._components._matching.ariaRegion')) _.set(course, '_globals._components._matching.ariaRegion', newAriaRegion); | ||
| courseMatchingGlobals = course._globals._components._matching; | ||
swashbuck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return true; | ||
| }); | ||
|
|
||
| mutateContent('Matching - add globals ariaRegion attribute', async content => { | ||
| if (courseMatchingGlobals.ariaRegion !== originalAriaRegion) return true; | ||
| courseMatchingGlobals.ariaRegion = newAriaRegion; | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('Matching - check globals object', async (content) => { | ||
| if (!courseMatchingGlobals) throw new Error('Matching - course globals object missing'); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('Matching - check globals ariaRegion attribute', async (content) => { | ||
| if (courseMatchingGlobals) { | ||
| const isValid = courseMatchingGlobals.ariaRegion !== originalAriaRegion; | ||
| if (!isValid) throw new Error('Matching - ariaRegion attribute missing'); | ||
| } | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('Matching - update to v3.0.0', { name: 'adapt-contrib-matching', version: '3.0.0', framework: '>=2.0.16' }); | ||
|
|
||
| testSuccessWhere('matching component with empty course', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.2.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'matching' }, | ||
| { _id: 'c-105', _component: 'matching' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testSuccessWhere('matching component with empty course._globals', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.2.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'matching' }, | ||
| { _id: 'c-105', _component: 'matching' }, | ||
| { _type: 'course', _globals: { _components: { _matching: {} } } } | ||
| ] | ||
| }); | ||
|
|
||
| testSuccessWhere('matching component with default course._globals', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.2.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'matching' }, | ||
| { _id: 'c-105', _component: 'matching' }, | ||
| { _type: 'course', _globals: { _components: { _matching: { ariaRegion: originalAriaRegion } } } } | ||
| ] | ||
| }); | ||
|
|
||
| testSuccessWhere('matching component with custom course._globals', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.2.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'matching' }, | ||
| { _id: 'c-105', _component: 'matching' }, | ||
| { _type: 'course', _globals: { _components: { _matching: { ariaRegion: 'custom ariaRegion' } } } } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no matching components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '2.2.0' }], | ||
| content: [ | ||
| { _component: 'other' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-matching', version: '3.0.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.
Uh oh!
There was an error while loading. Please reload this page.