fix: use account id in workflow app log filter

This commit is contained in:
hj24
2025-10-13 09:50:24 +08:00
parent 9fc2a0a3a1
commit b6d9360f72
2 changed files with 55 additions and 7 deletions

View File

@ -789,6 +789,48 @@ class TestWorkflowAppService:
assert result_account_filter["total"] == 3
assert all(log.created_by_role == CreatorUserRole.ACCOUNT for log in result_account_filter["data"])
# Test filtering by changed account email
original_email = account.email
new_email = "changed@example.com"
account.email = new_email
db_session_with_containers.commit()
assert account.email == new_email
# Results for new email, is expected to be the same as the original email
result_with_new_email = service.get_paginate_workflow_app_logs(
session=db_session_with_containers,
app_model=app,
created_by_account=new_email,
page=1,
limit=20
)
assert result_with_new_email["total"] == 3
assert all(log.created_by_role == CreatorUserRole.ACCOUNT for log in result_with_new_email["data"])
# Old email unbound, is expected to be 0
result_with_old_email = service.get_paginate_workflow_app_logs(
session=db_session_with_containers,
app_model=app,
created_by_account=original_email,
page=1,
limit=20
)
assert result_with_old_email["total"] == 0
# Result with unknown email, is expected to be 0
result_with_unknown_email = service.get_paginate_workflow_app_logs(
session=db_session_with_containers,
app_model=app,
created_by_account="unknown@example.com",
page=1,
limit=20
)
assert result_with_old_email["total"] == 0
account.email = original_email
db_session_with_containers.commit()
# Test filtering by non-existent session ID
result_no_session = service.get_paginate_workflow_app_logs(
session=db_session_with_containers,