|
| 1 | +import { readFileSync } from "node:fs"; |
| 2 | +import { join } from "node:path"; |
| 3 | +import { describe, expect, it } from "vitest"; |
| 4 | +import { createFAQSchema } from "@/utils/web-schema"; |
| 5 | + |
| 6 | +const pageSource = readFileSync( |
| 7 | + join( |
| 8 | + process.cwd(), |
| 9 | + "app/(site)/(seo)/developer-documentation-videos/page.tsx", |
| 10 | + ), |
| 11 | + "utf-8", |
| 12 | +); |
| 13 | + |
| 14 | +const componentSource = readFileSync( |
| 15 | + join( |
| 16 | + process.cwd(), |
| 17 | + "components/pages/seo/DeveloperDocumentationVideosPage.tsx", |
| 18 | + ), |
| 19 | + "utf-8", |
| 20 | +); |
| 21 | + |
| 22 | +describe("DeveloperDocumentationVideosPage metadata", () => { |
| 23 | + it("contains canonical URL", () => { |
| 24 | + expect(pageSource).toContain( |
| 25 | + 'canonical: "https://cap.so/developer-documentation-videos"', |
| 26 | + ); |
| 27 | + }); |
| 28 | + |
| 29 | + it("contains OG url field", () => { |
| 30 | + expect(pageSource).toContain( |
| 31 | + 'url: "https://cap.so/developer-documentation-videos"', |
| 32 | + ); |
| 33 | + }); |
| 34 | + |
| 35 | + it("contains OG siteName field", () => { |
| 36 | + expect(pageSource).toContain('siteName: "Cap"'); |
| 37 | + }); |
| 38 | + |
| 39 | + it("contains OG locale field", () => { |
| 40 | + expect(pageSource).toContain('locale: "en_US"'); |
| 41 | + }); |
| 42 | + |
| 43 | + it("contains full OG image URL", () => { |
| 44 | + expect(pageSource).toContain('"https://cap.so/og.png"'); |
| 45 | + }); |
| 46 | + |
| 47 | + it("title targets developer documentation videos keyword", () => { |
| 48 | + expect(pageSource.toLowerCase()).toContain("developer documentation"); |
| 49 | + }); |
| 50 | +}); |
| 51 | + |
| 52 | +describe("DeveloperDocumentationVideosPage component content", () => { |
| 53 | + it("targets developer documentation keyword in title", () => { |
| 54 | + expect(componentSource.toLowerCase()).toContain("developer documentation"); |
| 55 | + }); |
| 56 | + |
| 57 | + it("includes comparison table", () => { |
| 58 | + expect(componentSource).toContain("comparisonTable"); |
| 59 | + }); |
| 60 | + |
| 61 | + it("includes recording modes section", () => { |
| 62 | + expect(componentSource).toContain("recordingModes"); |
| 63 | + }); |
| 64 | + |
| 65 | + it("mentions API demos", () => { |
| 66 | + expect(componentSource.toLowerCase()).toContain("api demo"); |
| 67 | + }); |
| 68 | + |
| 69 | + it("mentions SDK walkthroughs", () => { |
| 70 | + expect(componentSource.toLowerCase()).toContain("sdk"); |
| 71 | + }); |
| 72 | + |
| 73 | + it("includes migration guide", () => { |
| 74 | + expect(componentSource).toContain("migrationGuide"); |
| 75 | + }); |
| 76 | + |
| 77 | + it("mentions 4K resolution", () => { |
| 78 | + expect(componentSource).toContain("4K"); |
| 79 | + }); |
| 80 | + |
| 81 | + it("has badge set", () => { |
| 82 | + expect(componentSource).toContain("badge"); |
| 83 | + }); |
| 84 | + |
| 85 | + it("references self-hosted-screen-recording internal link", () => { |
| 86 | + expect(componentSource).toContain("/self-hosted-screen-recording"); |
| 87 | + }); |
| 88 | + |
| 89 | + it("references open-source-screen-recorder internal link", () => { |
| 90 | + expect(componentSource).toContain("/open-source-screen-recorder"); |
| 91 | + }); |
| 92 | + |
| 93 | + it("references solutions/employee-onboarding-platform internal link", () => { |
| 94 | + expect(componentSource).toContain( |
| 95 | + "/solutions/employee-onboarding-platform", |
| 96 | + ); |
| 97 | + }); |
| 98 | + |
| 99 | + it("mentions AI transcripts", () => { |
| 100 | + expect(componentSource.toLowerCase()).toContain("transcript"); |
| 101 | + }); |
| 102 | +}); |
| 103 | + |
| 104 | +describe("DeveloperDocumentationVideosPage FAQ schema", () => { |
| 105 | + const faqs = [ |
| 106 | + { |
| 107 | + question: "What is a developer documentation video?", |
| 108 | + answer: |
| 109 | + "A developer documentation video is a screen recording that demonstrates how to use an API, SDK, CLI tool, or technical workflow.", |
| 110 | + }, |
| 111 | + { |
| 112 | + question: "How do I embed a Cap video in my documentation?", |
| 113 | + answer: |
| 114 | + "Cap generates a shareable link the moment you stop recording. You can paste this URL directly into Notion, Confluence, Docusaurus, GitBook.", |
| 115 | + }, |
| 116 | + { |
| 117 | + question: "Can I record my terminal and IDE output in 4K?", |
| 118 | + answer: "Yes. Cap records at up to 4K resolution at 60fps.", |
| 119 | + }, |
| 120 | + { |
| 121 | + question: "Does Cap auto-generate transcripts for documentation?", |
| 122 | + answer: |
| 123 | + "Yes. Cap auto-generates captions and transcripts for every recording using AI transcription.", |
| 124 | + }, |
| 125 | + { |
| 126 | + question: "How do I share a documentation video with my team or users?", |
| 127 | + answer: |
| 128 | + "Cap generates a shareable link immediately when you stop recording — no upload wait, no file attachment.", |
| 129 | + }, |
| 130 | + { |
| 131 | + question: "Can I record videos for private internal documentation?", |
| 132 | + answer: |
| 133 | + "Yes. Cap supports password protection on individual recordings and expiry dates on share links.", |
| 134 | + }, |
| 135 | + { |
| 136 | + question: "What is the best screen recorder for developer documentation?", |
| 137 | + answer: |
| 138 | + "Cap is the best screen recorder for developer documentation because it combines 4K recording quality, instant shareable links, AI-generated transcripts, and self-hosted storage.", |
| 139 | + }, |
| 140 | + { |
| 141 | + question: "Does Cap work for recording API demos and SDK walkthroughs?", |
| 142 | + answer: |
| 143 | + "Yes. Cap is designed exactly for this use case. Record your terminal, IDE, browser, API client.", |
| 144 | + }, |
| 145 | + ]; |
| 146 | + |
| 147 | + it("produces valid FAQPage schema with 8 questions", () => { |
| 148 | + const schema = createFAQSchema(faqs); |
| 149 | + |
| 150 | + expect(schema["@context"]).toBe("https://schema.org"); |
| 151 | + expect(schema["@type"]).toBe("FAQPage"); |
| 152 | + expect(schema.mainEntity).toHaveLength(8); |
| 153 | + }); |
| 154 | + |
| 155 | + it("maps each FAQ to a Question entity with acceptedAnswer", () => { |
| 156 | + const schema = createFAQSchema(faqs); |
| 157 | + |
| 158 | + expect(schema.mainEntity[0]).toEqual({ |
| 159 | + "@type": "Question", |
| 160 | + name: "What is a developer documentation video?", |
| 161 | + acceptedAnswer: { |
| 162 | + "@type": "Answer", |
| 163 | + text: faqs[0].answer, |
| 164 | + }, |
| 165 | + }); |
| 166 | + }); |
| 167 | + |
| 168 | + it("produces JSON-serializable output", () => { |
| 169 | + const schema = createFAQSchema(faqs); |
| 170 | + expect(() => JSON.stringify(schema)).not.toThrow(); |
| 171 | + const parsed = JSON.parse(JSON.stringify(schema)); |
| 172 | + expect(parsed["@type"]).toBe("FAQPage"); |
| 173 | + expect(parsed.mainEntity).toHaveLength(8); |
| 174 | + }); |
| 175 | +}); |
| 176 | + |
| 177 | +describe("DeveloperDocumentationVideosPage SEO registry", () => { |
| 178 | + it("is registered in seo-pages.ts", () => { |
| 179 | + const seoPagesSource = readFileSync( |
| 180 | + join(process.cwd(), "lib/seo-pages.ts"), |
| 181 | + "utf-8", |
| 182 | + ); |
| 183 | + expect(seoPagesSource).toContain('"developer-documentation-videos"'); |
| 184 | + }); |
| 185 | + |
| 186 | + it("is registered in seo-metadata.ts", () => { |
| 187 | + const seoMetadataSource = readFileSync( |
| 188 | + join(process.cwd(), "lib/seo-metadata.ts"), |
| 189 | + "utf-8", |
| 190 | + ); |
| 191 | + expect(seoMetadataSource).toContain('"developer-documentation-videos"'); |
| 192 | + }); |
| 193 | +}); |
0 commit comments