forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next-26177/auto-imported-from-github' into 'trunk'
NEXT-26177 - Implement language switch and smart buttons added by Extension SDK See merge request shopware/6/product/platform!10604
- Loading branch information
Showing
15 changed files
with
365 additions
and
3 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...02-03-implement-language-switch-and-smart-bar-buttons-for-main-module-in-app.md
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,11 @@ | ||
--- | ||
title: Implement language switch and smart bar buttons for main module in App | ||
issue: NEXT-26177 | ||
author: Vu Le | ||
author_email: [email protected] | ||
author_github: crisalder2806 | ||
--- | ||
# Administration | ||
* Added `smartBarButtonAdd` message handler in `app/init/main-module.init.ts` to handle adding language switch and smart buttons from `Admin Extension SDK` | ||
* Added `sw_extension_sdk_module_smart_bar_buttons`, `sw_extension_sdk_module_language_switch` blocks in `sw-extension-sdk/page/sw-extension-sdk-module/sw-extension-sdk-module.html.twig` to render language switch and smart bar buttons added by `Admin Extension SDK` | ||
* Changed `sw-extension-component-section/sw-extension-component-section.html.twig` to render tabs inside `card` component section |
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
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
142 changes: 142 additions & 0 deletions
142
...onent/extension-api/sw-extension-component-section/sw-extension-component-section.spec.js
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,142 @@ | ||
/** | ||
* @package admin | ||
*/ | ||
|
||
import { mount } from '@vue/test-utils'; | ||
import 'src/app/component/extension-api/sw-extension-component-section'; | ||
import 'src/app/component/base/sw-card'; | ||
import 'src/app/component/base/sw-tabs'; | ||
import 'src/app/component/base/sw-tabs-item'; | ||
import Vue from 'vue'; | ||
|
||
describe('src/app/component/extension-api/sw-extension-component-section', () => { | ||
let wrapper = null; | ||
let stubs; | ||
|
||
async function createWrapper() { | ||
return mount(await Shopware.Component.build('sw-extension-component-section'), { | ||
propsData: { | ||
positionIdentifier: 'test-position', | ||
}, | ||
stubs, | ||
}); | ||
} | ||
|
||
beforeAll(async () => { | ||
stubs = { | ||
'sw-card': await Shopware.Component.build('sw-card'), | ||
'sw-tabs': await Shopware.Component.build('sw-tabs'), | ||
'sw-tabs-item': await Shopware.Component.build('sw-tabs-item'), | ||
'sw-ignore-class': true, | ||
'sw-iframe-renderer': { | ||
template: '<div></div>', | ||
}, | ||
}; | ||
}); | ||
|
||
beforeEach(async () => { | ||
Vue.set(Shopware.State.get('extensionComponentSections'), 'identifier', {}); | ||
}); | ||
|
||
afterEach(() => { | ||
if (wrapper) { | ||
wrapper.destroy(); | ||
wrapper = null; | ||
} | ||
}); | ||
|
||
it('should be a Vue.js component', async () => { | ||
wrapper = await createWrapper(); | ||
expect(wrapper.vm).toBeTruthy(); | ||
}); | ||
|
||
it('should not render tabs in card section', async () => { | ||
Shopware.State.commit('extensionComponentSections/addSection', { | ||
component: 'card', | ||
positionId: 'test-position', | ||
props: { | ||
title: 'test-card', | ||
subtitle: 'test-card-description', | ||
}, | ||
}); | ||
|
||
wrapper = await createWrapper(); | ||
await flushPromises(); | ||
|
||
const tabs = wrapper.find('.sw-tabs'); | ||
expect(tabs.exists()).toBe(false); | ||
}); | ||
|
||
it('should render tabs in card section', async () => { | ||
Shopware.State.commit('extensionComponentSections/addSection', { | ||
component: 'card', | ||
positionId: 'test-position', | ||
props: { | ||
title: 'test-card', | ||
subtitle: 'test-card-description', | ||
tabs: [ | ||
{ | ||
name: 'tab-1', | ||
label: 'Tab 1', | ||
locationId: 'tab-1', | ||
}, | ||
{ | ||
name: 'tab-2', | ||
label: 'Tab 2', | ||
locationId: 'tab-2', | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
wrapper = await createWrapper(); | ||
await flushPromises(); | ||
|
||
const tabs = wrapper.findAll('.sw-tabs-item'); | ||
expect(tabs).toHaveLength(2); | ||
|
||
const activeTabs = wrapper.findAll('.sw-tabs-item--active'); | ||
expect(activeTabs).toHaveLength(1); | ||
|
||
const activeTab = activeTabs.at(0); | ||
expect(activeTab.text()).toBe('Tab 1'); | ||
}); | ||
|
||
it('should switch tab when clicking', async () => { | ||
Shopware.State.commit('extensionComponentSections/addSection', { | ||
component: 'card', | ||
positionId: 'test-position', | ||
props: { | ||
title: 'test-card', | ||
subtitle: 'test-card-description', | ||
tabs: [ | ||
{ | ||
name: 'tab-1', | ||
label: 'Tab 1', | ||
locationId: 'tab-1', | ||
}, | ||
{ | ||
name: 'tab-2', | ||
label: 'Tab 2', | ||
locationId: 'tab-2', | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
wrapper = await createWrapper(); | ||
await flushPromises(); | ||
|
||
// Default active tab | ||
const defaultIframe = wrapper.findComponent(stubs['sw-iframe-renderer']); | ||
expect(defaultIframe.vm.$attrs['location-id']).toBe('tab-1'); | ||
|
||
// Click the 2nd tab | ||
const tabItems = wrapper.findAll('.sw-tabs-item'); | ||
await tabItems.at(1).trigger('click'); | ||
|
||
// Check tab content | ||
const activeIframe = wrapper.findComponent(stubs['sw-iframe-renderer']); | ||
expect(activeIframe.vm.$attrs['location-id']).toBe('tab-2'); | ||
}); | ||
}); |
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
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
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
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
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
Oops, something went wrong.