diff --git a/components/FooterSliceZone.vue b/components/FooterSliceZone.vue index 92f5839b7..8a726fdd0 100644 --- a/components/FooterSliceZone.vue +++ b/components/FooterSliceZone.vue @@ -57,7 +57,7 @@ export default { data() { return { socialMediasHoverMap: {}, - usedMainFooter: null, + usedMainFooter: [], } }, async fetch() { @@ -75,6 +75,9 @@ export default { ) }, }, + watch: { + '$i18n.locale': '$fetch', + }, } 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/LanguageSwitcher/LanguageSwitcher.vue b/components/LanguageSwitcher/LanguageSwitcher.vue index 52d91fcd3..252975424 100644 --- a/components/LanguageSwitcher/LanguageSwitcher.vue +++ b/components/LanguageSwitcher/LanguageSwitcher.vue @@ -53,7 +53,7 @@ :selected-menu="selectedMenu" /> - + - + @@ -84,9 +84,9 @@ child.lang === currentLocaleCode, }" > - + {{ $t(option.name) }} - {{ $t(child.name) }} - +
@@ -98,9 +98,9 @@ option.lang === currentLocaleCode, }" > - + {{ $t(option.name) }} - + diff --git a/components/LanguageSwitcher/LanguageSwitcherSubMenu.vue b/components/LanguageSwitcher/LanguageSwitcherSubMenu.vue index f7b63c359..ec32a18e0 100644 --- a/components/LanguageSwitcher/LanguageSwitcherSubMenu.vue +++ b/components/LanguageSwitcher/LanguageSwitcherSubMenu.vue @@ -9,9 +9,9 @@ }" >
- + {{ $t(availableLanguage.name) }} - +
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/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/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) => { 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 = { diff --git a/tests/components/LanguageSwitcher.test.js b/tests/components/LanguageSwitcher.test.js index 9786816f0..a68fa5dda 100644 --- a/tests/components/LanguageSwitcher.test.js +++ b/tests/components/LanguageSwitcher.test.js @@ -1,5 +1,6 @@ import { shallowMount, mount } from '@vue/test-utils' import { config } from '~/config/environment' +import PixLink from '~/components/PixLink' import LanguageSwitcher from '~/components/LanguageSwitcher/LanguageSwitcher' import LanguageSwitcherSubMenu from '~/components/LanguageSwitcher/LanguageSwitcherSubMenu.vue' @@ -14,6 +15,8 @@ jest.mock('~/config/environment', () => ({ }, })) +LanguageSwitcherSubMenu.components = { 'pix-link': PixLink } + describe('Component: LanguageSwitcher', () => { describe('when site is pix-pro', () => { beforeEach(() => { @@ -51,7 +54,7 @@ describe('Component: LanguageSwitcher', () => { // when const wrapper = mount(LanguageSwitcher, { - components: { LanguageSwitcherSubMenu }, + components: { LanguageSwitcherSubMenu, PixLink }, mocks: { $t, $i18n }, stubs: { fa: true }, }) @@ -76,7 +79,7 @@ describe('Component: LanguageSwitcher', () => { // when const wrapper = mount(LanguageSwitcher, { - components: { LanguageSwitcherSubMenu }, + components: { LanguageSwitcherSubMenu, PixLink }, mocks: { $t, $i18n }, stubs: { fa: true }, }) 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

+
`) + }) + }) +})