itsulu-blog-publisher/addons/itsulu_blog_publisher/features/blog_generation.feature
Nicholas Riegel a0d2ba5506 fix: resolve remaining 9 BDD failures + production empty-body bug
PRODUCTION BUG: _create_blog_post never wrote the LLM body into the post.
Every auto-generated post was published empty. Add 'content': body_html
(content is the Odoo 17 blog.post body field; body_arch was removed).

BDD step/feature fixes (active features/ dir, not the dead tests/features/):
- body_arch → content in step + feature + given_published_blog_post
- then_non_empty_response: result.text → result.body_html (LLMResponse attr)
- llm_provider_selection feature: "provider not configured" → "not configured"
  (matches LLMRouter.__init__ message; the generate() fallback never fires)
- then_tokens_used_recorded: assert on result.tokens_used (router returns a
  response, it does not persist a log — that is the schedule's job)
- when_llm_router_called: configure the provider-under-test's own credential
  (Background only sets the Anthropic key, so openai/gemini bailed early)
- fails-gracefully: invalid key now drives mock side_effect=UserError so
  run_generation records an error log and creates no post

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 03:11:28 -04:00

41 lines
1.8 KiB
Gherkin

# =================================================================
# On-demand AI blog post generation
# =================================================================
Feature: On-demand AI blog post generation
As an ITSulu content admin
I want to trigger blog post generation with a single button click
So that I no longer need CoWork running on a Windows VM
Background:
Given the Anthropic API key is configured in Settings
And the blog "ITSulu Insights" exists in Odoo
Scenario: Generate and auto-publish a blog post from the backend
Given I am on the Blog Publisher backend form
And I enter topic "Prompt Governance in Enterprise AI"
And I select provider "anthropic" and model "claude-sonnet-4-20250514"
And I set auto-publish to True
When I click "Generate Now"
Then a blog.post record is created with a non-empty title
And the blog.post content contains at least 500 characters of HTML
And the blog.post is_published is True
And the SEO fields website_meta_title and website_meta_description are populated
And a generation log entry exists with state "success"
Scenario: Generate a blog post and leave it as draft
Given I am on the Blog Publisher backend form
And I enter topic "Open Source LLMs for Business"
And I set auto-publish to False
When I click "Generate Now"
Then a blog.post record is created with a non-empty title
And the blog.post is_published is False
Scenario: LLM API call fails gracefully
Given the Anthropic API key is invalid
And I enter topic "Any topic"
And I set auto-publish to True
When I click "Generate Now"
Then no blog.post record is created
And a generation log entry exists with state "error"
And the log contains a human-readable error message
And a "Retry" button is visible on the log record