test(l1): E2E Playwright suite + seed L1 + coverage engineer test users

l1-workspace.spec.ts covers:
- L1 user lands on /l1, intakes a problem, takes notes (autosave), resolves
- L1 cannot access /pilot, /trees/new, /escalations (route guards)
- Engineer with can_cover_l1 sees the L1 Workspace nav + coverage banner
- escalate-without-walk path via direct API call returns escalated session

Seed script adds l1@resolutionflow.example.com (l1_tech) and
engineer-coverage@resolutionflow.example.com (engineer + can_cover_l1).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 14:42:31 -04:00
parent 1acc780359
commit 6937bcaabd
2 changed files with 236 additions and 15 deletions

View File

@@ -2,11 +2,13 @@
"""
Create test user accounts for local development.
Creates 4 accounts:
1. Super Admin platform-wide admin (manages everything)
2. Pro Solo User single user on a "pro" plan
3. Team Admin admin of a team account ("team" plan)
4. Team Engineer regular engineer on the same team account
Creates 6 accounts:
1. Super Admin platform-wide admin (manages everything)
2. Pro Solo User single user on a "pro" plan
3. Team Admin admin of a team account ("team" plan)
4. Team Engineer regular engineer on the same team account
5. L1 Tech l1_tech role on the Acme MSP team (E2E: L1 happy path)
6. Coverage Engineer engineer with can_cover_l1=True (E2E: coverage banner)
Usage:
cd backend
@@ -71,6 +73,29 @@ USERS = [
"account_name": "Acme MSP", # same shared account
"account_role": "engineer",
"plan": None, # uses the team_admin's account & subscription
"can_cover_l1": False,
},
{
"key": "l1_tech",
"name": "Lee L1Tech",
"email": "l1@resolutionflow.example.com",
"is_super_admin": False,
"is_team_admin": False,
"account_name": "Acme MSP", # same shared account as team_admin
"account_role": "l1_tech",
"plan": None, # uses the team_admin's account & subscription
"can_cover_l1": False,
},
{
"key": "coverage_engineer",
"name": "Casey Coverage",
"email": "engineer-coverage@resolutionflow.example.com",
"is_super_admin": False,
"is_team_admin": False,
"account_name": "Acme MSP", # same shared account as team_admin
"account_role": "engineer",
"plan": None, # uses the team_admin's account & subscription
"can_cover_l1": True,
},
]
@@ -114,7 +139,9 @@ async def main() -> None:
continue
# ---- Create or reuse Account ----
if cfg["key"] == "team_engineer":
# Users that share the Acme MSP account (no own account to create)
_acme_members = {"team_engineer", "l1_tech", "coverage_engineer"}
if cfg["key"] in _acme_members:
if team_account_id is None:
result = await conn.execute(
text("SELECT id FROM accounts WHERE name = :name"),
@@ -145,13 +172,14 @@ async def main() -> None:
# 7-day verification grace immediately. Without this, fixtures hit
# require_verified_email_after_grace once their created_at ages past
# 7 days and get walled out of protected routes.
can_cover_l1 = cfg.get("can_cover_l1", False)
await conn.execute(
text("""
INSERT INTO users (id, email, password_hash, name, role, is_super_admin,
is_team_admin, is_active, account_id, account_role,
created_at, email_verified_at)
can_cover_l1, created_at, email_verified_at)
VALUES (:id, :email, :pw, :name, 'engineer', :is_sa, :is_ta, true,
:account_id, :account_role, :now, :now)
:account_id, :account_role, :can_cover_l1, :now, :now)
"""),
{
"id": user_id,
@@ -162,12 +190,13 @@ async def main() -> None:
"is_ta": cfg["is_team_admin"],
"account_id": account_id,
"account_role": cfg["account_role"],
"can_cover_l1": can_cover_l1,
"now": now,
},
)
# Set account owner (skip for team_engineer — they don't own the account)
if cfg["key"] != "team_engineer":
# Set account owner (skip for shared-account members — they don't own the account)
if cfg["key"] not in _acme_members:
await conn.execute(
text("UPDATE accounts SET owner_id = :uid WHERE id = :aid"),
{"uid": user_id, "aid": account_id},
@@ -183,7 +212,8 @@ async def main() -> None:
{"id": uuid.uuid4(), "aid": account_id, "plan": cfg["plan"], "now": now},
)
print(f" [OK] {cfg['email']:40s} account_role={cfg['account_role']:<10s} plan={cfg['plan'] or '(shared)'}")
cover_flag = " [can_cover_l1]" if can_cover_l1 else ""
print(f" [OK] {cfg['email']:40s} account_role={cfg['account_role']:<12s} plan={cfg['plan'] or '(shared)'}{cover_flag}")
await engine.dispose()
@@ -194,10 +224,12 @@ async def main() -> None:
print("=" * 60)
print()
print(" Accounts:")
print(f" Super Admin : admin@resolutionflow.example.com")
print(f" Pro Solo : pro@resolutionflow.example.com")
print(f" Team Admin : teamadmin@resolutionflow.example.com")
print(f" Team Engineer: engineer@resolutionflow.example.com")
print(f" Super Admin : admin@resolutionflow.example.com")
print(f" Pro Solo : pro@resolutionflow.example.com")
print(f" Team Admin : teamadmin@resolutionflow.example.com")
print(f" Team Engineer : engineer@resolutionflow.example.com")
print(f" L1 Tech : l1@resolutionflow.example.com")
print(f" Coverage Engineer : engineer-coverage@resolutionflow.example.com")
print()