Skip to content

Commit

Permalink
Merge branch 'NEXT-7641/fix-replacement-for-url-placeholder' into 'ma…
Browse files Browse the repository at this point in the history
…ster'

NEXT-7641 - fix replacement for url placeholder

Closes NEXT-7641

See merge request shopware/6/product/platform!1833
  • Loading branch information
pantrtxp committed Apr 2, 2020
2 parents ef05a6a + 886e22c commit caeb7ff
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-6.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ To get the diff between two versions, go to https://github.com/shopware/platform

* Administration
* Fixed VAT Information in default order confirmation mail templates
* Changed sw-text-editor to ignore addProtocol when the domainPlaceholder is used as a link

* Core
* Fix updater language to use the admin user language
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import template from './sw-text-editor-toolbar.html.twig';
import './sw-text-editor-toolbar.scss';

const { Component } = Shopware;
const domainPlaceholderId = '124c71d524604ccbad6042edce3ac799';

/**
* @private
Expand Down Expand Up @@ -383,7 +384,11 @@ Component.register('sw-text-editor-toolbar', {

prepareLink(link) {
link = link.trim();
link = this.addProtocol(link);

if (!link.startsWith(domainPlaceholderId)) {
link = this.addProtocol(link);
}

return link;
},

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
import { shallowMount } from '@vue/test-utils';
import 'src/app/component/form/sw-text-editor/sw-text-editor-toolbar';

const testCases = [{
link: '124c71d524604ccbad6042edce3ac799',
result: false
}, {
link: '/detail/124c71d524604ccbad6042edce3ac799',
result: false
}, {
link: 'www.domain.de/test',
result: true
}, {
link: 'domain.de',
result: true
}, {
link: 'http://domain.de',
result: true
}];

let wrapper;

beforeEach(() => {
wrapper = shallowMount(Shopware.Component.build('sw-text-editor-toolbar'), {
stubs: {
'sw-text-editor-toolbar-button': true
},
propsData: {
buttonConfig: [
{
type: 'paragraph',
icon: 'default-text-editor-style',
children: [
{
type: 'formatBlock',
name: 'Paragraph',
value: 'p',
tag: 'p'
},
{
type: 'formatBlock',
name: 'Heading 1',
value: 'h1',
tag: 'h1'
},
{
type: 'formatBlock',
name: 'Heading 2',
value: 'h2',
tag: 'h2'
},
{
type: 'formatBlock',
name: 'Heading 3',
value: 'h3',
tag: 'h3'
},
{
type: 'formatBlock',
name: 'Heading 4',
value: 'h4',
tag: 'h4'
},
{
type: 'formatBlock',
name: 'Heading 5',
value: 'h5',
tag: 'h5'
},
{
type: 'formatBlock',
name: 'Heading 6',
value: 'h6',
tag: 'h6'
},
{
type: 'formatBlock',
name: 'Blockquote',
value: 'blockquote',
tag: 'blockquote'
}
]
},
{
type: 'foreColor',
value: '',
tag: 'font'
},
{
type: 'bold',
icon: 'default-text-editor-bold',
tag: 'b'
},
{
type: 'italic',
icon: 'default-text-editor-italic',
tag: 'i'
},
{
type: 'underline',
icon: 'default-text-editor-underline',
tag: 'u'
},
{
type: 'strikethrough',
icon: 'default-text-editor-strikethrough',
tag: 'strike'
},
{
type: 'superscript',
icon: 'default-text-editor-superscript',
tag: 'sup'
},
{
type: 'subscript',
icon: 'default-text-editor-subscript',
tag: 'sub'
},
{
type: 'justify',
icon: 'default-text-editor-align-left',
children: [
{
type: 'justifyLeft',
icon: 'default-text-align-left'
},
{
type: 'justifyCenter',
icon: 'default-text-align-center'
},
{
type: 'justifyRight',
icon: 'default-text-align-right'
},
{
type: 'justifyFull',
icon: 'default-text-align-justify'
}
]
},
{
type: 'insertUnorderedList',
icon: 'default-text-editor-list-unordered',
tag: 'ul'
},
{
type: 'insertOrderedList',
icon: 'default-text-editor-list-numberd',
tag: 'ol'
},
{
type: 'link',
icon: 'default-text-editor-link',
expanded: false,
newTab: false,
displayAsButton: false,
buttonVariant: '',
buttonVariantList: [
{
id: 'primary',
name: 'sw-text-editor-toolbar.link.buttonVariantPrimary'
},
{
id: 'secondary',
name: 'sw-text-editor-toolbar.link.buttonVariantSecondary'
},
{
id: 'primary-sm',
name: 'sw-text-editor-toolbar.link.buttonVariantPrimarySmall'
},
{
id: 'secondary-sm',
name: 'sw-text-editor-toolbar.link.buttonVariantSecondarySmall'
}
],
value: '',
tag: 'a'
},
{
type: 'undo',
icon: 'default-text-editor-undo',
position: 'middle'
},
{
type: 'redo',
icon: 'default-text-editor-redo',
position: 'middle'
}
]
}
});
});

describe('components/form/sw-text-editor/sw-text-editor-toolbar', () => {
it('should be a Vue.js component', () => {
expect(wrapper.isVueInstance()).toBeTruthy();
});
it('it should apply http correctly', () => {
testCases.forEach(({ link, result }) => {
expect(wrapper.vm.prepareLink(link).startsWith('http://')).toBe(result);
});
});
});

0 comments on commit caeb7ff

Please sign in to comment.