From 0aab992a8af6a9696c4cb0f94c4e7a654004a4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CLilyL0u=E2=80=9D?= Date: Wed, 15 Jan 2025 15:40:08 +0000 Subject: [PATCH 1/5] filter out null values in the elements array --- src/app/components/Footer/index.tsx | 58 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/app/components/Footer/index.tsx b/src/app/components/Footer/index.tsx index b3418af8de8..c4d3da8a1c6 100644 --- a/src/app/components/Footer/index.tsx +++ b/src/app/components/Footer/index.tsx @@ -29,36 +29,38 @@ export default () => { collectiveNewsroomText, } = footer; - const elements = links?.map(({ id, text, href, lang }) => { - if (id === 'COOKIE_SETTINGS') { - if (isAmp) { - return ( - // @ts-expect-error we do not have a className - - {text} - - ); - } + const elements = links + ?.map(({ id, text, href, lang }) => { + if (id === 'COOKIE_SETTINGS') { + if (isAmp) { + return ( + // @ts-expect-error we do not have a className + + {text} + + ); + } - if (showAdsBasedOnLocation) { - return ( - - ); + if (showAdsBasedOnLocation) { + return ( + + ); + } + } else { + return ; } - } else { - return ; - } - return null; - }); + return null; + }) + .filter(Boolean); return (
From 367913a5291dc496d85d1a53c3adc9671e6c3912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CLilyL0u=E2=80=9D?= Date: Wed, 15 Jan 2025 16:27:12 +0000 Subject: [PATCH 2/5] screenshots --- .../PageLayoutWrapper/__snapshots__/index.test.tsx.snap | 7 ++----- .../containers/Footer/__snapshots__/index.test.jsx.snap | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/app/components/PageLayoutWrapper/__snapshots__/index.test.tsx.snap b/src/app/components/PageLayoutWrapper/__snapshots__/index.test.tsx.snap index 71ec1080e8f..cefb1a68b54 100644 --- a/src/app/components/PageLayoutWrapper/__snapshots__/index.test.tsx.snap +++ b/src/app/components/PageLayoutWrapper/__snapshots__/index.test.tsx.snap @@ -1006,13 +1006,13 @@ exports[`PageLayoutWrapper should render default page wrapper with children 1`] @media (min-width: 15rem) and (max-width: 37.4375rem) { .emotion-151 { - grid-template-rows: repeat(5, auto); + grid-template-rows: repeat(4, auto); } } @media (min-width: 37.5rem) and (max-width: 62.9375rem) { .emotion-151 { - grid-template-rows: repeat(4, auto); + grid-template-rows: repeat(3, auto); } } @@ -1697,9 +1697,6 @@ exports[`PageLayoutWrapper should render default page wrapper with children 1`] Contact the BBC -
  • -
  • Date: Wed, 15 Jan 2025 16:36:16 +0000 Subject: [PATCH 3/5] unit test checking no empty list items in footer --- src/app/components/Footer/index.test.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/components/Footer/index.test.tsx b/src/app/components/Footer/index.test.tsx index 4bf48529faa..5faf165f1be 100644 --- a/src/app/components/Footer/index.test.tsx +++ b/src/app/components/Footer/index.test.tsx @@ -21,6 +21,14 @@ describe('Footer', () => { '#', ); }); + + it('should not render an empty list item when the "Do not share or sell my info" link is not present', () => { + render(

    , { showAdsBasedOnLocation: false }); + const listItems = screen.getAllByRole('listitem'); + listItems.forEach(listItem => { + expect(listItem).not.toBeEmptyDOMElement(); + }); + }); }); describe('Collective News Text', () => { From 5b7b9fad6d572cb03bde6269f4297b33589649c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CLilyL0u=E2=80=9D?= Date: Wed, 15 Jan 2025 17:46:19 +0000 Subject: [PATCH 4/5] remove role=listitem --- src/app/components/Footer/List/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/components/Footer/List/index.tsx b/src/app/components/Footer/List/index.tsx index dbd523c49d6..08b5231d714 100644 --- a/src/app/components/Footer/List/index.tsx +++ b/src/app/components/Footer/List/index.tsx @@ -36,9 +36,7 @@ export default ({ )} {elements.map((elem, index) => ( // eslint-disable-next-line react/no-array-index-key -
  • - {elem} -
  • +
  • {elem}
  • ))} ); From 3597d9b9dc03286db54a31b0fb441028a328d8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CLilyL0u=E2=80=9D?= Date: Wed, 15 Jan 2025 18:00:39 +0000 Subject: [PATCH 5/5] snapshots updated --- .../__snapshots__/index.test.tsx.snap | 24 +++++-------------- .../Footer/__snapshots__/index.test.jsx.snap | 24 +++++-------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src/app/components/PageLayoutWrapper/__snapshots__/index.test.tsx.snap b/src/app/components/PageLayoutWrapper/__snapshots__/index.test.tsx.snap index cefb1a68b54..940cb4cf43d 100644 --- a/src/app/components/PageLayoutWrapper/__snapshots__/index.test.tsx.snap +++ b/src/app/components/PageLayoutWrapper/__snapshots__/index.test.tsx.snap @@ -1637,9 +1637,7 @@ exports[`PageLayoutWrapper should render default page wrapper with children 1`] Why you can trust the BBC
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +