Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion migrations/v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Box menu - v2.0.2 to v2.0.3', async () => {
return true;
});

updatePlugin('Box menu - update to v2.0.3', { name: 'adapt-contrib-boxMenu', version: '2.0.3', framework: '">=2.0.0' });
updatePlugin('Box menu - update to v2.0.3', { name: 'adapt-contrib-boxMenu', version: '2.0.3', framework: '>=2.0.0' });

testSuccessWhere('boxMenu with empty course', {
fromPlugins: [{ name: 'adapt-contrib-boxMenu', version: '2.0.2' }],
Expand Down
2 changes: 1 addition & 1 deletion migrations/v4.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Box menu - v3.0.0 to v4.0.0', async () => {
return true;
});

updatePlugin('Box menu - update to v4.0.0', { name: 'adapt-contrib-boxMenu', version: '4.0.0', framework: '">=4' });
updatePlugin('Box menu - update to v4.0.0', { name: 'adapt-contrib-boxMenu', version: '4.0.0', framework: '>=4' });

testStopWhere('boxMenu with empty course', {
fromPlugins: [{ name: 'adapt-contrib-boxMenu', version: '3.0.0' }],
Expand Down
48 changes: 36 additions & 12 deletions migrations/v6.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Box menu - v6.0.2 to v6.1.0', async () => {
return true;
});

updatePlugin('Box menu - update to v6.1.0', { name: 'adapt-contrib-boxMenu', version: '6.1.0', framework: '">=5.22.6' });
updatePlugin('Box menu - update to v6.1.0', { name: 'adapt-contrib-boxMenu', version: '6.1.0', framework: '>=5.22.6' });

testSuccessWhere('boxMenu with course/menu _boxMenu._menuHeader', {
fromPlugins: [{ name: 'adapt-contrib-boxMenu', version: '6.0.2' }],
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('Box menu - v6.2.0 to v6.2.1', async () => {
return true;
});

updatePlugin('Box menu - update to v6.2.1', { name: 'adapt-contrib-boxMenu', version: '6.2.1', framework: '">=5.24.2' });
updatePlugin('Box menu - update to v6.2.1', { name: 'adapt-contrib-boxMenu', version: '6.2.1', framework: '>=5.24.2' });

testSuccessWhere('boxMenu with course _boxMenu', {
fromPlugins: [{ name: 'adapt-contrib-boxMenu', version: '6.2.0' }],
Expand Down Expand Up @@ -137,36 +137,46 @@ describe('Box menu - v6.3.8 to v6.3.9', async () => {
mutateContent('Box menu - add _xlarge attribute', async (content) => {
menusWithBgImage.forEach(({ _boxMenu }) => {
if (!_.has(_boxMenu, '_backgroundImage')) return true;
_boxMenu._backgroundImage._xlarge = '';
// carry _large over so existing backgrounds survive at the new xlarge breakpoint
_boxMenu._backgroundImage._xlarge = _boxMenu._backgroundImage._large ?? '';
});
return true;
});

mutateContent('Box menu - add _xlarge attribute to _menuHeader', async (content) => {
menusWithBgImage.forEach(({ _boxMenu }) => {
if (!_.has(_boxMenu, '_menuHeader._backgroundImage')) return true;
_boxMenu._menuHeader._backgroundImage._xlarge = '';
// carry _large over so existing backgrounds survive at the new xlarge breakpoint
_boxMenu._menuHeader._backgroundImage._xlarge = _boxMenu._menuHeader._backgroundImage._large ?? '';
});
return true;
});

checkContent('Box menu - check _xlarge attribute', async (content) => {
const isValid = menusWithBgImage.every(({ _boxMenu }) => (
!_boxMenu._backgroundImage || _boxMenu._backgroundImage._xlarge === ''
));
const isValid = menusWithBgImage.every(({ _boxMenu }) => {
const backgroundImage = _boxMenu._backgroundImage;
if (!backgroundImage) return true;
if (typeof backgroundImage._xlarge !== 'string') return false;
// a populated _large must have been carried over, not blanked
return !backgroundImage._large || backgroundImage._xlarge === backgroundImage._large;
});
if (!isValid) throw new Error('Box menu - course attribute _xlarge');
return true;
});

checkContent('Box menu - check _xlarge attribute for _menuHeader', async (content) => {
const isValid = menusWithBgImage.every(({ _boxMenu }) => (
!_boxMenu._menuHeader?._backgroundImage || _boxMenu._menuHeader._backgroundImage._xlarge === ''
));
const isValid = menusWithBgImage.every(({ _boxMenu }) => {
const backgroundImage = _boxMenu._menuHeader?._backgroundImage;
if (!backgroundImage) return true;
if (typeof backgroundImage._xlarge !== 'string') return false;
// a populated _large must have been carried over, not blanked
return !backgroundImage._large || backgroundImage._xlarge === backgroundImage._large;
});
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' });
updatePlugin('Box menu - update to v6.3.9', { name: 'adapt-contrib-boxMenu', version: '6.3.9', framework: '>=5.24.2' });

testSuccessWhere('boxMenu with course._boxMenu._backgroundImage', {
fromPlugins: [{ name: 'adapt-contrib-boxMenu', version: '6.3.8' }],
Expand All @@ -185,6 +195,20 @@ describe('Box menu - v6.3.8 to v6.3.9', async () => {
]
});

testSuccessWhere('boxMenu with populated _large carried over to _xlarge', {
fromPlugins: [{ name: 'adapt-contrib-boxMenu', version: '6.3.8' }],
content: [
{
_type: 'course',
_boxMenu: {
_backgroundImage: { _large: 'menu-lg.jpg', _medium: 'menu-md.jpg', _small: 'menu-sm.jpg' },
_menuHeader: { _backgroundImage: { _large: 'hdr-lg.jpg', _medium: 'hdr-md.jpg', _small: 'hdr-sm.jpg' } }
}
},
{ _type: 'menu', _boxMenu: { _backgroundImage: { _large: 'sub-lg.jpg', _medium: '', _small: '' } } }
]
});

testStopWhere('boxMenu with empty course', {
fromPlugins: [{ name: 'adapt-contrib-boxMenu', version: '6.3.8' }],
content: [
Expand Down Expand Up @@ -231,7 +255,7 @@ describe('Box menu - v6.3.9 to v6.3.10', async () => {
return true;
});

updatePlugin('Box menu - update to v6.3.10', { name: 'adapt-contrib-boxMenu', version: '6.3.10', framework: '">=5.24.2' });
updatePlugin('Box menu - update to v6.3.10', { name: 'adapt-contrib-boxMenu', version: '6.3.10', framework: '>=5.24.2' });

testSuccessWhere('boxMenu with empty course', {
fromPlugins: [{ name: 'adapt-contrib-boxMenu', version: '6.3.9' }],
Expand Down