mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
The Head of Marketing now markets features, not just releases: a default-off x_feature_spotlight loop periodically spawns the HoM to investigate what shipped (CHANGELOG, feature flags, docs/map, KB) and draft ONE held marketing post via propose_feature_spotlight, reviewed in the X post queue. - New x_feature source (distinct from x_post, fixing panel mislabeling) + a panel Feature-spotlight branch. - brand_voice column on company_goals (migration 061, single head) as the CEO-editable voice source, surfaced in Settings and injected into the HoM briefing; a VOICE GUIDE baseline in head-marketing.md. - propose_feature_spotlight verb (HoM-only), mirroring propose_roadmap. Gated by x_feature_spotlight_enabled (default off; flag-off dormancy proven). Also fixed two real bugs found mid-build: company_goals API schemas dropped brand_voice on GET/PUT; the live charter UI is goals-tab.tsx, not the unmounted company-goals-card.tsx. Full suite green (2935); migration single-head verified.
92 lines
3.4 KiB
Python
92 lines
3.4 KiB
Python
"""Tests for CompanyGoalsService — the singleton company charter."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
from uuid import uuid4
|
|
|
|
import pytest
|
|
from roboco.db.tables import CompanyGoalsTable
|
|
from roboco.services.company_goals import (
|
|
SINGLETON_ID,
|
|
get_company_goals_service,
|
|
)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_returns_empty_defaults_when_unset(db_session: Any) -> None:
|
|
# The "unset" contract is about no/empty charter row. The test DB is shared
|
|
# and route tests commit a charter to it, so establish a clean precondition
|
|
# rather than assume global emptiness.
|
|
existing = await db_session.get(CompanyGoalsTable, SINGLETON_ID)
|
|
if existing is not None:
|
|
await db_session.delete(existing)
|
|
await db_session.commit()
|
|
svc = get_company_goals_service(db_session)
|
|
goals = await svc.get()
|
|
assert goals["north_star"] == ""
|
|
assert goals["objectives"] == []
|
|
assert goals["constraints"] == []
|
|
assert goals["operating_policy"] == {}
|
|
assert goals["brand_voice"] == ""
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_upsert_then_get_roundtrips(db_session: Any) -> None:
|
|
svc = get_company_goals_service(db_session)
|
|
actor = uuid4()
|
|
await svc.upsert(
|
|
{
|
|
"north_star": "Ship a delightful product",
|
|
"objectives": [{"metric": "NPS", "target": 50, "status": "active"}],
|
|
"constraints": ["AGPL only"],
|
|
"operating_policy": {
|
|
"autonomy_level": "assisted",
|
|
"monthly_budget_cap": 500,
|
|
},
|
|
},
|
|
updated_by=actor,
|
|
)
|
|
goals = await svc.get()
|
|
assert goals["north_star"] == "Ship a delightful product"
|
|
assert goals["objectives"][0]["metric"] == "NPS"
|
|
assert goals["constraints"] == ["AGPL only"]
|
|
assert goals["operating_policy"]["autonomy_level"] == "assisted"
|
|
assert goals["updated_by"] == str(actor)
|
|
assert goals["updated_at"] is not None
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_upsert_is_singleton_and_partial(db_session: Any) -> None:
|
|
svc = get_company_goals_service(db_session)
|
|
await svc.upsert({"north_star": "First", "constraints": ["a"]})
|
|
# A second upsert updates the SAME row and only the provided keys.
|
|
await svc.upsert({"north_star": "Second"})
|
|
goals = await svc.get()
|
|
assert goals["north_star"] == "Second"
|
|
assert goals["constraints"] == ["a"] # untouched key preserved
|
|
|
|
# Exactly one row exists (singleton), found at the canonical id.
|
|
row = await db_session.get(CompanyGoalsTable, SINGLETON_ID)
|
|
assert row is not None
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_brand_voice_roundtrips(db_session: Any) -> None:
|
|
svc = get_company_goals_service(db_session)
|
|
await svc.upsert({"brand_voice": "Confident, dry wit, no exclamation points."})
|
|
goals = await svc.get()
|
|
assert goals["brand_voice"] == "Confident, dry wit, no exclamation points."
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_brand_voice_untouched_by_partial_upsert(db_session: Any) -> None:
|
|
svc = get_company_goals_service(db_session)
|
|
await svc.upsert({"brand_voice": "Speak as 'we'."})
|
|
# A later partial upsert that omits brand_voice must leave it unchanged —
|
|
# the same partial-update contract north_star/constraints already have.
|
|
await svc.upsert({"north_star": "Ship a delightful product"})
|
|
goals = await svc.get()
|
|
assert goals["brand_voice"] == "Speak as 'we'."
|
|
assert goals["north_star"] == "Ship a delightful product"
|