Files
vue-seo-layer/tests/pagePath.test.ts
Jakub Zych 160b53b2f5 feat: CMS head and one JSON-LD graph on every server-rendered page (tracer)
- Nitro middleware resolves page requests once and hands the answer to the
  render (event.context.seo); the route middleware reuses it
- useCmsSeo: html lang, hreflang links, og:locale and exactly one JSON-LD
  script with one @graph (CMS nodes plus useSchemaNode nodes, merged by @id)
- local module (configKey seo): cms (alias of public.seo.enabled),
  breadcrumbs, links.newTabHint, rootFiles, resolveFiles
- GET /api/__seo__/resolve for client navigation through the Nuxt server
- smoke harness: count=, exact header=, noheader=, reqheader=, repeated
  options, resolves/apicalls/noreport lines, --no-site; v0.1.1 suite runs
  unchanged against a backend without /site
2026-11-04 09:15:26 +01:00

32 lines
1.2 KiB
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { isPagePath } from '../app/utils/pagePath.ts'
test('isPagePath: Nuxt, layer and API paths are skipped', () => {
for (const p of ['/_nuxt/x', '/_nuxt/entry.js', '/__nuxt_error?url=/x', '/_seo/api/v1/resolve', '/_journal/api/v1/posts', '/api/x', '/api', '/api?x=1']) {
assert.equal(isPagePath(p), false, p)
}
})
test('isPagePath: asset and root files are skipped', () => {
for (const p of ['/favicon.ico', '/robots.txt', '/sitemap.xml', '/google0123.html', '/img/a.webp', '/fonts/x.woff2', '/blog/x/_payload.json', '/doc.pdf']) {
assert.equal(isPagePath(p), false, p)
}
})
test('isPagePath: pages are resolved, with their query', () => {
for (const p of ['/', '/blog/x', '/blog?page=2', '/autor/info@golem15.com', '/a.b/c', '/v1.2']) {
assert.equal(isPagePath(p), true, p)
}
})
test('isPagePath: resolveFiles extensions are resolved', () => {
assert.equal(isPagePath('/doc.pdf', ['pdf']), true)
assert.equal(isPagePath('/DOC.PDF', ['pdf']), true)
assert.equal(isPagePath('/a.png', ['pdf']), false)
})
test('isPagePath: no protocol-relative or relative input', () => {
for (const p of ['//evil.test/x', 'blog', '']) assert.equal(isPagePath(p), false, p)
})