Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

test(handbook): Waechter fuer Hub, Kapitel und das Flash-Budget im Cloud-Kapitel

purple583484b2e415
diff --git a/scripts/check-cloud-sales.mjs b/scripts/check-cloud-sales.mjs
index 734a4f9b..fb6df854 100644
--- a/scripts/check-cloud-sales.mjs
+++ b/scripts/check-cloud-sales.mjs
@@ -102,8 +102,12 @@ for (const span of pricing.querySelectorAll('[data-pack-id]')) {
}
assert.equal(pricing.querySelectorAll('[data-pack-id]').length, packs.length, 'Every pack must appear, and nothing else')
-for (const doc of [pricing, page]) {
+// Das Handbuch-Kapitel zu LU Cloud nennt dasselbe Tagesbudget mit demselben
+// Anker und haengt hier an derselben Quelle wie die beiden Verkaufsseiten.
+const handbookCloud = new JSDOM(readFileSync(new URL('../docs/guide/cloud/index.html', import.meta.url), 'utf8')).window.document
+for (const doc of [pricing, page, handbookCloud]) {
const limit = doc.querySelector('[data-flash-limit]')
+ assert.ok(limit, 'flash allowance anchor missing')
assert.equal(Number(limit.dataset.flashLimit), daily, 'flash allowance drift')
assert.ok(limit.textContent.startsWith(daily.toLocaleString('en-US')))
}
diff --git a/src/lib/__tests__/handbook-pages.test.ts b/src/lib/__tests__/handbook-pages.test.ts
new file mode 100644
index 00000000..9a5d0896
--- /dev/null
+++ b/src/lib/__tests__/handbook-pages.test.ts
@@ -0,0 +1,61 @@
+// @vitest-environment jsdom
+//
+// The handbook on locallyuncensored.com is one hub page plus one page per
+// chapter under docs/guide/. Every chapter page links back to the hub, every
+// page carries a JSON-LD block that parses, and the sitemap names every page.
+// Without this file a chapter could vanish, or lose its way back to the hub,
+// and nothing would notice until a reader did.
+import { existsSync, readFileSync } from 'node:fs'
+import { expect, it } from 'vitest'
+
+const CHAPTERS = [
+ 'what-it-is', 'install', 'first-start', 'chat', 'agent', 'code', 'create',
+ 'cloud', 'settings-and-troubleshooting', 'faq-and-glossary',
+] as const
+
+const parse = (path: string) => new DOMParser().parseFromString(readFileSync(path, 'utf8'), 'text/html')
+
+it('the hub page lists every chapter', () => {
+ const hub = parse('docs/guide/index.html')
+ expect(hub.querySelector('article[data-handbook-hub]')).not.toBeNull()
+ const listed = [...hub.querySelectorAll('.post-card[data-handbook-chapter]')].map((el) => el.getAttribute('data-handbook-chapter'))
+ expect(listed).toEqual([...CHAPTERS])
+ for (const slug of CHAPTERS) {
+ expect(hub.querySelector(`a[href="/guide/${slug}/"]`), slug).not.toBeNull()
+ }
+})
+
+it('every chapter page exists, links back to the hub, and carries parseable JSON-LD', () => {
+ for (const slug of CHAPTERS) {
+ const path = `docs/guide/${slug}/index.html`
+ expect(existsSync(path), path).toBe(true)
+ const page = parse(path)
+ expect(page.querySelector(`article[data-handbook-chapter="${slug}"]`), slug).not.toBeNull()
+ expect(page.querySelector('a[href="/guide/"]'), `${slug} has no link to the hub`).not.toBeNull()
+ expect(page.querySelector('link[rel="canonical"]')?.getAttribute('href')).toBe(`https://locallyuncensored.com/guide/${slug}/`)
+ const blocks = [...page.querySelectorAll('script[type="application/ld+json"]')]
+ expect(blocks.length, slug).toBeGreaterThan(0)
+ for (const block of blocks) {
+ const ld = JSON.parse(block.textContent!)
+ expect(ld['@type'], slug).toBe('TechArticle')
+ expect(ld.isPartOf?.url, slug).toBe('https://locallyuncensored.com/guide/')
+ }
+ const description = page.querySelector('meta[name="description"]')!.getAttribute('content')
+ expect(page.querySelector('meta[property="og:description"]')!.getAttribute('content'), slug).toBe(description)
+ expect(description, slug).not.toMatch(/[–—]/u)
+ }
+})
+
+it('the sitemap names the hub and every chapter', () => {
+ const sitemap = readFileSync('docs/sitemap.xml', 'utf8')
+ expect(sitemap).toContain('<loc>https://locallyuncensored.com/guide/</loc>')
+ for (const slug of CHAPTERS) {
+ expect(sitemap, slug).toContain(`<loc>https://locallyuncensored.com/guide/${slug}/</loc>`)
+ }
+})
+
+it('no handbook page carries an em or en dash', () => {
+ for (const path of ['docs/guide/index.html', ...CHAPTERS.map((s) => `docs/guide/${s}/index.html`)]) {
+ expect(readFileSync(path, 'utf8'), path).not.toMatch(/[–—]|&[mn]dash;/u)
+ }
+})