From 24189918f3f875a96704d033dbfb566843bae150 Mon Sep 17 00:00:00 2001 From: LEGO Technix <109212476+lego-technix@users.noreply.github.com> Date: Thu, 29 Dec 2022 18:49:00 +0100 Subject: [PATCH 1/6] sr: simplify rootRedirect condition --- nuxt.config.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nuxt.config.js b/nuxt.config.js index c1d6867ae..83ea76198 100755 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -18,8 +18,7 @@ const i18nConfigurationForInternationalDomain = { vueI18n: { fallbackLocale: 'fr', }, - rootRedirect: - config.isPixSite && !config.isFrenchDomain ? 'locale-choice' : undefined, + rootRedirect: config.isPixSite && !config.isFrenchDomain && 'locale-choice', } const nuxtConfig = { From afbc6b49ac45c5e3d244d1ec93ed3f5b39b1ed35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9becca?= Date: Tue, 27 Dec 2022 14:51:29 +0100 Subject: [PATCH 2/6] feat: add PixLink component --- components/PixLink.vue | 42 ++++++++++++++++++++++++++++ tests/components/PixLink.test.js | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 components/PixLink.vue create mode 100644 tests/components/PixLink.test.js diff --git a/components/PixLink.vue b/components/PixLink.vue new file mode 100644 index 000000000..9090f0894 --- /dev/null +++ b/components/PixLink.vue @@ -0,0 +1,42 @@ + + + diff --git a/tests/components/PixLink.test.js b/tests/components/PixLink.test.js new file mode 100644 index 000000000..1d502fdc1 --- /dev/null +++ b/tests/components/PixLink.test.js @@ -0,0 +1,47 @@ +import { mount } from '@vue/test-utils' +import PixLink from '~/components/PixLink' + +describe('Component: PixLink', () => { + let component + + beforeEach(() => { + component = mount(PixLink, { + shallow: true, + propsData: { href: '' }, + slots: { default: '

Dummy

' }, + stubs: ['nuxt-link'], + }) + }) + + describe('href is in domain', () => { + it('displays the component', async () => { + // given + await component.setProps({ href: '/fr-be' }) + + // when + const result = component.html() + + // then + expect(result).toEqual( + ` +

Dummy

+
` + ) + }) + }) + + describe('href is not in domain', () => { + it('displays the component', async () => { + // given + await component.setProps({ href: 'https://example.net/' }) + + // when + const result = component.html() + + // then + expect(result).toEqual(` +

Dummy

+
`) + }) + }) +}) From 46c82eb08d546458f60349e20740f65e6afb07ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9becca?= Date: Tue, 27 Dec 2022 14:52:03 +0100 Subject: [PATCH 3/6] feat: use pix-link in LocaleLink component --- components/LocaleLink.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/LocaleLink.vue b/components/LocaleLink.vue index 213b093c0..c2e44725e 100644 --- a/components/LocaleLink.vue +++ b/components/LocaleLink.vue @@ -1,8 +1,8 @@ diff --git a/components/HotNewsBanner.vue b/components/HotNewsBanner.vue index a95511e20..266b6ffbe 100644 --- a/components/HotNewsBanner.vue +++ b/components/HotNewsBanner.vue @@ -29,6 +29,9 @@ export default { this.hotNews = hotNews?.data?.description }, + watch: { + '$i18n.locale': '$fetch', + }, methods: { closeBanner() { this.isOpen = false diff --git a/components/NavigationSliceZone.vue b/components/NavigationSliceZone.vue index c45f7d25d..e6085309c 100644 --- a/components/NavigationSliceZone.vue +++ b/components/NavigationSliceZone.vue @@ -77,6 +77,9 @@ export default { } }, }, + watch: { + '$i18n.locale': '$fetch', + }, } From 568740e450b83ab5a10cb3b8761251bcecfe26c4 Mon Sep 17 00:00:00 2001 From: Vincent Hardouin Date: Tue, 27 Dec 2022 18:07:13 +0100 Subject: [PATCH 6/6] sr: add empty values for navigation --- components/FooterSliceZone.vue | 2 +- components/NavigationSliceZone.vue | 6 +++--- components/slices/NavigationZone.vue | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/FooterSliceZone.vue b/components/FooterSliceZone.vue index 3cdc5ff0c..8a726fdd0 100644 --- a/components/FooterSliceZone.vue +++ b/components/FooterSliceZone.vue @@ -57,7 +57,7 @@ export default { data() { return { socialMediasHoverMap: {}, - usedMainFooter: null, + usedMainFooter: [], } }, async fetch() { diff --git a/components/NavigationSliceZone.vue b/components/NavigationSliceZone.vue index e6085309c..7e2960383 100644 --- a/components/NavigationSliceZone.vue +++ b/components/NavigationSliceZone.vue @@ -35,7 +35,7 @@ export default { name: 'NavigationSliceZone', data() { return { - usedMainNavigation: null, + usedMainNavigation: [], } }, async fetch() { @@ -67,10 +67,10 @@ export default { burgerMenuLinks() { const navigationZone = this.usedMainNavigation.find( (slice) => slice.slice_type === 'navigation_zone' - ) + ) || { items: [] } const actionsZone = this.usedMainNavigation.find( (slice) => slice.slice_type === 'actions_zone' - ) + ) || { items: [] } return { navigationZone: navigationZone.items, actionsZone: actionsZone.items, diff --git a/components/slices/NavigationZone.vue b/components/slices/NavigationZone.vue index 2db7ca298..2752dce61 100644 --- a/components/slices/NavigationZone.vue +++ b/components/slices/NavigationZone.vue @@ -51,7 +51,7 @@ export default { props: { navigationZoneItems: { type: Array, - default: null, + default: () => [], }, }, data() { @@ -62,6 +62,10 @@ export default { }, computed: { navigationLinks() { + if (this.navigationZoneItems.length === 0) { + return null + } + return this.navigationZoneItems .map(({ items: navItems }) => navItems.reduce((navGroup, navItem) => {