fix: give test user a real team in test_shared_filter

The test was inserting a "Team Script" with team_id=NULL (since the
test user has no team), then expecting shared=true to return it.
SQL NULL=NULL is falsy, so the query correctly returned nothing.
Fix: create a team, assign it to the user, then test the filter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-03-27 20:32:25 +00:00
parent 1425b843a9
commit 3cea949519

View File

@@ -617,10 +617,24 @@ class TestScriptTemplateFilters:
"""shared=true returns only templates shared with the user's team."""
user_resp = await client.get("/api/v1/auth/me", headers=auth_headers)
user_id = user_resp.json()["id"]
team_id = user_resp.json().get("team_id")
cat_id = "b0000000-0000-0000-0000-000000000001"
# Create a team and assign the test user to it
team_id = str(uuid_mod.uuid4())
await test_db.execute(
sa.text("""
INSERT INTO teams (id, name, created_at)
VALUES (:tid, 'Test Team', NOW())
"""),
{"tid": team_id},
)
await test_db.execute(
sa.text("UPDATE users SET team_id = :tid WHERE id = :uid"),
{"tid": team_id, "uid": user_id},
)
await test_db.commit()
# Template shared with user's team
await test_db.execute(
sa.text("""