All files / services/ai mock-ai.service.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 6/6
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77                                            2x               1x               1x 1x   1x                   1x                                   1x       1x      
// Mock AI service — used when AI features are explicitly disabled
// (ENABLE_AI_FEATURES != "true"). Returns deterministic placeholder content
// so dev/test flows that exercise AI code paths don't have to skip them.
 
import type {
	DraftPromptParams,
	MetaPromptParams,
	RewritePromptParams,
	TopicSuggestionPromptParams,
} from "./prompts";
import type {
	AIService,
	GenerateDraftResponse,
	GenerateMetaResponse,
	RewriteSectionResponse,
	SuggestTopicsResponse,
} from "./claude.service";
 
export class MockAIService implements AIService {
	async generateDraft(
		params: DraftPromptParams,
	): Promise<GenerateDraftResponse> {
		return {
			content: `# ${params.title}\n\n[Mock AI-generated content for blog about "${params.primaryKeyword}"]\n\nThis is a placeholder draft. AI features are currently disabled.`,
		};
	}
 
	async rewriteSection(
		_params: RewritePromptParams,
	): Promise<RewriteSectionResponse> {
		return {
			revisedContent:
				"[Mock AI-rewritten content]\n\nThis is a placeholder revision. AI features are currently disabled.",
		};
	}
 
	async generateMeta(params: MetaPromptParams): Promise<GenerateMetaResponse> {
		// Generate basic metadata from keyword
		const keyword = params.primaryKeyword;
		const slug = keyword.toLowerCase().replace(/\s+/g, "-");
 
		return {
			title: `${keyword.charAt(0).toUpperCase() + keyword.slice(1)} | Decor Rocket`,
			meta_description: `Learn about ${keyword} with expert tips and ideas from Decor Rocket.`,
			suggested_slug: slug,
		};
	}
 
	async suggestTopics(
		_params: TopicSuggestionPromptParams,
	): Promise<SuggestTopicsResponse> {
		return {
			suggestions: [
				{
					title: "Mock Blog Topic: Interior Design Ideas",
					blog_type: "general",
					primary_keyword: "interior design ideas",
					secondary_keywords: ["home decor", "design tips"],
					outline:
						"1. Introduction\n2. Main content\n3. Tips\n4. Conclusion\n5. CTA",
					seo_value:
						"Mock suggestion - AI features currently disabled for topic generation",
					pro_angle: "Feature pros with relevant expertise",
				},
			],
		};
	}
 
	async generateJSON<T>(_prompt: string): Promise<T> {
		return {} as T;
	}
 
	async generateText(_prompt: string): Promise<string> {
		return "[Mock AI text - AI features currently disabled]";
	}
}