-
Notifications
You must be signed in to change notification settings - Fork 21
New: added migration scripts #160
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
7 commits
Select commit
Hold shift + click to select a range
5654b39
Update: added migration scripts (fixes #158).
danielghost a0ac7a2
Added `setObjectPathValue` and updated tasks accordingly.
danielghost 5bb107b
Fixed an issue with `ariaRegion` not always being updated to 7.2.6. U…
danielghost 83e0a74
Changes to use replace custom helper methods with lodash.
danielghost 48d4247
Changes for adapt-migrations v1.1.0.
danielghost 6d86a10
Updated to `describe` and `whereFromPlugin` descriptions to align wit…
danielghost 6045779
automated testing added to migrations
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,270 @@ | ||
| import { | ||
| describe, | ||
| whereFromPlugin, | ||
| whereContent, | ||
| mutateContent, | ||
| checkContent, | ||
| updatePlugin, | ||
| getCourse, | ||
| getComponents, | ||
| testSuccessWhere, | ||
| testStopWhere | ||
| } from 'adapt-migrations'; | ||
| import _ from 'lodash'; | ||
|
|
||
| describe('adapt-contrib-textInput - to v2.0.2', async () => { | ||
| let components; | ||
|
|
||
| whereFromPlugin('adapt-contrib-textInput - from <v2.0.2', { name: 'adapt-contrib-textInput', version: '<2.0.2' }); | ||
|
|
||
| whereContent('adapt-contrib-textInput - where missing _recordInteraction', async () => { | ||
| components = getComponents('textinput').filter(component => !_.has(component, '_recordInteraction')); | ||
| return components.length; | ||
| }); | ||
|
|
||
| mutateContent('adapt-contrib-textInput - add _recordInteraction', async () => { | ||
| components.forEach(component => { | ||
| component._recordInteraction = true; | ||
| }); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('adapt-contrib-textInput - check _recordInteraction added', async () => { | ||
| const isValid = components.every(component => _.has(component, '_recordInteraction')); | ||
| if (!isValid) throw new Error('_recordInteraction not added'); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('adapt-contrib-textInput - update to v2.0.2', { name: 'adapt-contrib-textInput', version: '2.0.2', framework: '>=2.0.0' }); | ||
|
|
||
| testSuccessWhere('textInput multiple components with/without _recordInteraction', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.1' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _id: 'c-105', _component: 'textinput', _recordInteraction: true }, | ||
| { _id: 'c-110', _component: 'textinput' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no textInput components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.1' }], | ||
| content: [{ _component: 'other' }] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.2' }] | ||
| }); | ||
| }); | ||
|
|
||
| describe('adapt-contrib-textInput - to v2.0.4', async () => { | ||
| let components; | ||
|
|
||
| whereFromPlugin('adapt-contrib-textInput - from <v2.0.4', { name: 'adapt-contrib-textInput', version: '<2.0.4' }); | ||
|
|
||
| whereContent('adapt-contrib-textInput - where missing _canShowModelAnswer', async () => { | ||
| components = getComponents('textinput').filter(component => !_.has(component, '_canShowModelAnswer')); | ||
| return components.length; | ||
| }); | ||
|
|
||
| mutateContent('adapt-contrib-textInput - add _canShowModelAnswer', async () => { | ||
| components.forEach(component => { | ||
| component._canShowModelAnswer = true; | ||
| }); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('adapt-contrib-textInput - check _canShowModelAnswer added', async () => { | ||
| const isValid = components.every(component => _.has(component, '_canShowModelAnswer')); | ||
| if (!isValid) throw new Error('_canShowModelAnswer not added'); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('adapt-contrib-textInput - update to v2.0.4', { name: 'adapt-contrib-textInput', version: '2.0.4', framework: '>=2.0.0' }); | ||
|
|
||
| testSuccessWhere('textInput multiple components with/without _canShowModelAnswer', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.3' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _id: 'c-105', _component: 'textinput', _canShowModelAnswer: true }, | ||
| { _id: 'c-110', _component: 'textinput' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no textInput components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.3' }], | ||
| content: [{ _component: 'other' }] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.4' }] | ||
| }); | ||
| }); | ||
|
|
||
| describe('adapt-contrib-textInput - to v2.0.5', async () => { | ||
| let components; | ||
|
|
||
| whereFromPlugin('adapt-contrib-textInput - from <v2.0.5', { name: 'adapt-contrib-textInput', version: '<2.0.5' }); | ||
|
|
||
| whereContent('adapt-contrib-textInput - where has textInput components', async () => { | ||
| components = getComponents('textinput'); | ||
| return components.length; | ||
| }); | ||
|
|
||
| mutateContent('adapt-contrib-textInput - add _canShowFeedback', async () => { | ||
| components.forEach(component => { | ||
| if (_.has(component, '_canShowFeedback')) return; | ||
| component._canShowFeedback = true; | ||
| }); | ||
| return true; | ||
| }); | ||
|
|
||
| mutateContent('adapt-contrib-textInput - add _canShowMarking', async () => { | ||
| components.forEach(component => { | ||
| if (_.has(component, '_canShowMarking')) return; | ||
| component._canShowMarking = true; | ||
| }); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('adapt-contrib-textInput - check _canShowFeedback added', async () => { | ||
| const isValid = components.every(component => _.has(component, '_canShowFeedback')); | ||
| if (!isValid) throw new Error('_canShowFeedback not added'); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('adapt-contrib-textInput - check _canShowMarking added', async () => { | ||
| const isValid = components.every(component => _.has(component, '_canShowMarking')); | ||
| if (!isValid) throw new Error('_canShowMarking not added'); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('adapt-contrib-textInput - update to v2.0.5', { name: 'adapt-contrib-textInput', version: '2.0.5', framework: '>=2.0.11' }); | ||
|
|
||
| testSuccessWhere('textInput multiple components with/without _canShowFeedback/_canShowMarking', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.4' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _id: 'c-105', _component: 'textinput', _canShowFeedback: true }, | ||
| { _id: 'c-110', _component: 'textinput', _canShowMarking: true }, | ||
| { _id: 'c-115', _component: 'textinput', _canShowFeedback: true, _canShowMarking: true } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no textInput components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.4' }], | ||
| content: [{ _component: 'other' }] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.5' }] | ||
| }); | ||
| }); | ||
|
|
||
| describe('adapt-contrib-textInput - to v2.1.0', async () => { | ||
| let course; | ||
| const ariaRegionPath = '_globals._components._textInput.ariaRegion'; | ||
| const newAriaRegion = 'This question requires you to input your answer in the textbox provided. When you have done so, select the submit button below.'; | ||
| const oldAriaRegion = 'This question component requires you to input your answer in the textbox provided. When you have answered the question select the submit button below.'; | ||
|
|
||
| whereFromPlugin('adapt-contrib-textInput - from <v2.1.0', { name: 'adapt-contrib-textInput', version: '<2.1.0' }); | ||
|
|
||
| whereContent('adapt-contrib-textInput - where using old _globals ariaRegion default', async () => { | ||
| course = getCourse(); | ||
| return !_.has(course, ariaRegionPath) || _.get(course, ariaRegionPath) === oldAriaRegion; | ||
| }); | ||
|
|
||
| mutateContent('adapt-contrib-textInput - update _globals ariaRegion default', async () => { | ||
| _.set(course, ariaRegionPath, newAriaRegion); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('adapt-contrib-textInput - check _globals ariaRegion default updated', async () => { | ||
| const isValid = _.get(course, ariaRegionPath) === newAriaRegion; | ||
| if (!isValid) throw new Error(`${ariaRegionPath} default not updated`); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('adapt-contrib-textInput - update to v2.1.0', { name: 'adapt-contrib-textInput', version: '2.1.0', framework: '>=2.0.11' }); | ||
|
|
||
| testSuccessWhere('textInput component with empty course', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.5' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testSuccessWhere('textInput multiple components with course._globals', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.5' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _type: 'course', _globals: { _components: { _textInput: { ariaRegion: oldAriaRegion } } } } | ||
| ] | ||
| }); | ||
|
|
||
| testSuccessWhere('textInput multiple components with incorrect course._globals', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.5' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _type: 'course', _globals: { _textInput: { ariaRegion: oldAriaRegion } } } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('textInput multiple components with custom course._globals', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.0.5' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _type: 'course', _globals: { _components: { _textInput: { ariaRegion: 'Custom ariaRegion' } } } } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.1.0' }] | ||
| }); | ||
| }); | ||
|
|
||
| describe('adapt-contrib-textInput - to v2.2.0', async () => { | ||
| let components; | ||
| const feedbackTitlePath = '_feedback.title'; | ||
|
|
||
| whereFromPlugin('adapt-contrib-textInput - from <v2.2.0', { name: 'adapt-contrib-textInput', version: '<2.2.0' }); | ||
|
|
||
| whereContent('adapt-contrib-textInput - where missing _feedback.title', async () => { | ||
| components = getComponents('textinput').filter(component => !_.has(component, feedbackTitlePath)); | ||
| return components.length; | ||
| }); | ||
|
|
||
| mutateContent('adapt-contrib-textInput - add _feedback.title', async () => { | ||
| components.forEach(component => { | ||
| _.set(component, feedbackTitlePath, ''); | ||
| }); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('adapt-contrib-textInput - check _feedback.title added', async () => { | ||
| const isValid = components.every(component => _.has(component, feedbackTitlePath)); | ||
| if (!isValid) throw new Error(`${feedbackTitlePath} not added`); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('adapt-contrib-textInput - update to v2.2.0', { name: 'adapt-contrib-textInput', version: '2.2.0', framework: '>=2.0.11' }); | ||
|
|
||
| testSuccessWhere('textInput multiple components with/without _feedback.title', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.1.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _id: 'c-105', _component: 'textinput', _feedback: { title: 'title' } }, | ||
| { _id: 'c-110', _component: 'textinput', _feedback: {} }, | ||
| { _id: 'c-115', _component: 'textinput' } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('no textInput components', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.1.0' }], | ||
| content: [{ _component: 'other' }] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', 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,70 @@ | ||
| import { | ||
| describe, | ||
| whereFromPlugin, | ||
| whereContent, | ||
| mutateContent, | ||
| checkContent, | ||
| updatePlugin, | ||
| getCourse, | ||
| testSuccessWhere, | ||
| testStopWhere | ||
| } from 'adapt-migrations'; | ||
| import _ from 'lodash'; | ||
|
|
||
| /** | ||
| * schema previously updated in v2.1.0 but task shouldn't use >=2.1.0 <3.0.0 range | ||
| */ | ||
| describe('adapt-contrib-textInput - to v3.0.0', async () => { | ||
| let course; | ||
| const ariaRegionPath = '_globals._components._textInput.ariaRegion'; | ||
| const newAriaRegion = 'Text input. Type your answer and then submit.'; | ||
| const oldAriaRegion = 'This question requires you to input your answer in the textbox provided. When you have done so, select the submit button below.'; | ||
|
|
||
| whereFromPlugin('adapt-contrib-textInput - from <v3.0.0', { name: 'adapt-contrib-textInput', version: '<3.0.0' }); | ||
|
|
||
| whereContent('adapt-contrib-textInput - where using old _globals ariaRegion default', async () => { | ||
| course = getCourse(); | ||
| return !_.has(course, ariaRegionPath) || _.get(course, ariaRegionPath) === oldAriaRegion; | ||
| }); | ||
|
|
||
| mutateContent('adapt-contrib-textInput - update _globals ariaRegion default', async () => { | ||
| _.set(course, ariaRegionPath, newAriaRegion); | ||
| return true; | ||
| }); | ||
|
|
||
| checkContent('adapt-contrib-textInput - check _globals ariaRegion default updated', async () => { | ||
| const isValid = _.get(course, ariaRegionPath) === newAriaRegion; | ||
| if (!isValid) throw new Error(`${ariaRegionPath} default not updated`); | ||
| return true; | ||
| }); | ||
|
|
||
| updatePlugin('adapt-contrib-textInput - update to v3.0.0', { name: 'adapt-contrib-textInput', version: '3.0.0', framework: '>=2.0.16' }); | ||
|
|
||
| testSuccessWhere('textInput component with empty course', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.2.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _type: 'course' } | ||
| ] | ||
| }); | ||
|
|
||
| testSuccessWhere('textInput multiple components with default course._globals', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.2.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _type: 'course', _globals: { _components: { _textInput: { ariaRegion: oldAriaRegion } } } } | ||
| ] | ||
| }); | ||
|
|
||
| testSuccessWhere('textInput multiple components with empty course._globals', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', version: '2.2.0' }], | ||
| content: [ | ||
| { _id: 'c-100', _component: 'textinput' }, | ||
| { _type: 'course', _globals: { _components: { _textInput: { } } } } | ||
| ] | ||
| }); | ||
|
|
||
| testStopWhere('incorrect version', { | ||
| fromPlugins: [{ name: 'adapt-contrib-textInput', 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.