feat(marketing): project-branded drafts + project badges on the X/video queues (#570)

Item B+C of the video/X per-project targeting spec, plus the
company_goals.company_name field they depend on (migration 075).

- CompanyGoalsService.resolve_product_name is the single fallback chain
  (project name -> charter company_name -> RoboCo); XEngine and
  VideoEngine both call it and their prompt builders are pure functions
  taking product_name — release posts/videos stop hardcoding RoboCo.
- The X and video queue responses carry project_slug/project_name via one
  shared unloaded-guard helper (api/schemas/project_fields.py); both
  panel queues render a shared ProjectBadge so multi-project drafts are
  tellable apart.
- Business -> Goals editor gains the company-name input.
- Fixes a pre-existing test-isolation leak: the company-goals routes test
  commits the charter singleton into the session-scoped test DB and
  polluted later suites; it now deletes the row on teardown.

Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
Renzo F
2026-07-18 19:11:03 +02:00
committed by GitHub
co-authored by Renn F
parent 388bab2488
commit 7e01c0cecf
30 changed files with 750 additions and 40 deletions
+8
View File
@@ -132,6 +132,7 @@ async def test_list_posts_returns_open_draft(
db_session: AsyncSession, ceo_client: AsyncClient
) -> None:
task = await _seed_draft(db_session)
project = await db_session.get(ProjectTable, task.project_id)
resp = await ceo_client.get("/api/x/posts")
assert resp.status_code == HTTPStatus.OK
body = resp.json()
@@ -139,6 +140,9 @@ async def test_list_posts_returns_open_draft(
assert body[0]["task_id"] == str(task.id)
assert body[0]["body"] == "draft body"
assert body[0]["release_version"] == "0.17.0"
assert project is not None
assert body[0]["project_slug"] == project.slug
assert body[0]["project_name"] == project.name
@pytest.mark.asyncio
@@ -204,6 +208,7 @@ async def test_history_returns_posted_and_rejected_newest_first(
f"/api/x/posts/{rejected.id}/reject", json={"reason": "off-brand tone"}
)
posted = await _seed_draft(db_session)
posted_project = await db_session.get(ProjectTable, posted.project_id)
with (
patch(
"roboco.services.x_post_service.build_x_client",
@@ -224,6 +229,9 @@ async def test_history_returns_posted_and_rejected_newest_first(
posted_row = next(row for row in body if row["task_id"] == str(posted.id))
assert posted_row["status"] == "completed"
assert posted_row["tweet_id"] == "42"
assert posted_project is not None
assert posted_row["project_slug"] == posted_project.slug
assert posted_row["project_name"] == posted_project.name
rejected_row = next(row for row in body if row["task_id"] == str(rejected.id))
assert rejected_row["status"] == "cancelled"
assert rejected_row["reject_reason"] == "off-brand tone"