diff --git a/posthog/api/test/test_organization_domain.py b/posthog/api/test/test_organization_domain.py index 82ded3bc1c7fe..b181b12780f55 100644 --- a/posthog/api/test/test_organization_domain.py +++ b/posthog/api/test/test_organization_domain.py @@ -1,5 +1,5 @@ import datetime -from unittest.mock import patch +from unittest.mock import ANY, patch from zoneinfo import ZoneInfo import dns.resolver @@ -84,7 +84,8 @@ def test_cannot_list_or_retrieve_domains_for_other_org(self): # Create domains - def test_create_domain(self): + @patch("posthoganalytics.capture") + def test_create_domain(self, mock_capture): self.organization_membership.level = OrganizationMembership.Level.ADMIN self.organization.available_product_features = [ {"key": "automatic_provisioning", "name": "automatic_provisioning"} @@ -116,6 +117,18 @@ def test_create_domain(self): self.assertEqual(instance.last_verification_retry, None) self.assertEqual(instance.sso_enforcement, "") + # Verify the domain creation capture event was called + mock_capture.assert_any_call( + self.user.distinct_id, + "organization domain created", + properties={ + "domain": "the.posthog.com", + "jit_provisioning_enabled": False, + "sso_enforcement": None, + }, + groups={"instance": ANY, "organization": str(self.organization.id)}, + ) + def test_cant_create_domain_without_feature(self): self.organization_membership.level = OrganizationMembership.Level.ADMIN self.organization_membership.save()