From 7b9968cb825219e0c79f75b20ec97fc92646a0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Sat, 4 Jul 2026 11:43:30 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20corriger=20la=20d=C3=A9tection=20d'envir?= =?UTF-8?q?onnement=20dans=20robots.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__tests__/robots.test.js | 22 ++++++++++++++++++++++ app/robots.js | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/__tests__/robots.test.js diff --git a/app/__tests__/robots.test.js b/app/__tests__/robots.test.js new file mode 100644 index 0000000..a2e996c --- /dev/null +++ b/app/__tests__/robots.test.js @@ -0,0 +1,22 @@ +import {describe, it, expect, afterEach} from 'vitest' +import robots from '../robots' + +describe('robots', () => { + const originalNodeEnv = process.env.NODE_ENV + + afterEach(() => { + process.env.NODE_ENV = originalNodeEnv + }) + + it('autorise l\'indexation en production', () => { + process.env.NODE_ENV = 'production' + + expect(robots().rules).toEqual({userAgent: '*', allow: '/'}) + }) + + it('bloque l\'indexation hors production', () => { + process.env.NODE_ENV = 'development' + + expect(robots().rules).toEqual({userAgent: '*', disallow: '/'}) + }) +}) diff --git a/app/robots.js b/app/robots.js index c3e7dd2..8519f3a 100644 --- a/app/robots.js +++ b/app/robots.js @@ -1,5 +1,5 @@ export default function robots() { - const isProduction = process.env.NEXT_PUBLIC_ENV === 'production'; + const isProduction = process.env.NODE_ENV === 'production'; if (!isProduction) { return {