From 3cea949519165d2b6e2a62c5639784f4d96ccc5f Mon Sep 17 00:00:00 2001 From: chihlasm Date: Fri, 27 Mar 2026 20:32:25 +0000 Subject: [PATCH] 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) --- backend/tests/test_script_builder.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/tests/test_script_builder.py b/backend/tests/test_script_builder.py index 3f12cfda..4cbe183a 100644 --- a/backend/tests/test_script_builder.py +++ b/backend/tests/test_script_builder.py @@ -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("""