Files
vue-seo-layer/tests/routes.test.ts
Jakub Zych 9cc2cda924 feat: noindex for declared and signed-in routes
- app plugin seo-route-robots: a page whose meta sets requiresAuth: true
  gets robots noindex, nofollow, a page with seo.robots gets its value,
  a path under seo.noindexRoutes gets noindex, nofollow; meta tag above
  the CMS head entry and X-Robots-Tag during SSR, never on staging
- requiresAuth and seo added to Nuxt's page meta extraction keys
- playground /konto, /szkic and /prywatne with their smoke lines
2026-11-04 11:49:14 +01:00

20 lines
940 B
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { pageMetaRobots, robotsNoindex } from '../lib/routes.ts'
test('pageMetaRobots: seo.robots, then requiresAuth, else the CMS decides', () => {
assert.equal(pageMetaRobots({ requiresAuth: true }), 'noindex, nofollow')
assert.equal(pageMetaRobots({ requiresAuth: true, seo: { robots: 'noindex, follow' } }), 'noindex, follow')
assert.equal(pageMetaRobots({ seo: { robots: ' index, follow ' } }), 'index, follow')
assert.equal(pageMetaRobots({ requiresAuth: false }), null)
assert.equal(pageMetaRobots({ seo: { breadcrumbs: false } }), null)
assert.equal(pageMetaRobots(undefined), null)
})
test('robotsNoindex: noindex and none keep a page out', () => {
assert.equal(robotsNoindex('noindex, follow'), true)
assert.equal(robotsNoindex('none'), true)
assert.equal(robotsNoindex('index, follow'), false)
assert.equal(robotsNoindex(null), false)
})