From a5af9f0776160fa32e6a9413489aacec40677bc9 Mon Sep 17 00:00:00 2001 From: NathanPanchout Date: Thu, 24 Oct 2024 10:33:14 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20avoid=20documents=20in?= =?UTF-8?q?dexing=20in=20search=20engine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some documents are available publicly (without being logged) and may thus end-up being indexed by search engine. --- CHANGELOG.md | 1 + .../__tests__/app-impress/doc-routing.spec.ts | 16 ++++++++++++++++ .../apps/impress/src/pages/docs/[id]/index.tsx | 12 +++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 641829d0..61cfdc1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to - 🐛(i18n) same frontend and backend language using shared cookies #365 - 🐛(frontend) add default toolbar buttons #355 - 🐛(frontend) throttle error correctly display #378 +- 🐛(frontend) (frontend) avoid documents indexing in search engine #372 ## Removed diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-routing.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-routing.spec.ts index f86133e3..4e26ae2f 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-routing.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-routing.spec.ts @@ -7,6 +7,22 @@ test.describe('Doc Routing', () => { await page.goto('/'); }); + test('Check the presence of the meta tag noindex', async ({ page }) => { + const buttonCreateHomepage = page.getByRole('button', { + name: 'Create a new document', + }); + + await expect(buttonCreateHomepage).toBeVisible(); + await buttonCreateHomepage.click(); + await expect( + page.getByRole('button', { + name: 'Share', + }), + ).toBeVisible(); + const metaDescription = page.locator('meta[name="robots"]'); + await expect(metaDescription).toHaveAttribute('content', 'noindex'); + }); + test('checks alias docs url with homepage', async ({ page }) => { await expect(page).toHaveURL('/'); diff --git a/src/frontend/apps/impress/src/pages/docs/[id]/index.tsx b/src/frontend/apps/impress/src/pages/docs/[id]/index.tsx index 4690312a..61b6834d 100644 --- a/src/frontend/apps/impress/src/pages/docs/[id]/index.tsx +++ b/src/frontend/apps/impress/src/pages/docs/[id]/index.tsx @@ -1,4 +1,5 @@ import { Loader } from '@openfun/cunningham-react'; +import Head from 'next/head'; import { useRouter as useNavigate } from 'next/navigation'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; @@ -21,9 +22,14 @@ export function DocLayout() { } return ( - - - + <> + + + + + + + ); }