:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(approvals): round-trip the editor's full body in the bypass matrix (#102533)
Phil Haackeb2d61650f4b
diff --git a/products/approvals/backend/tests/test_feature_flag_bypass_matrix.py b/products/approvals/backend/tests/test_feature_flag_bypass_matrix.pyindex 82947b9e9c16..300de5306966 100644--- a/products/approvals/backend/tests/test_feature_flag_bypass_matrix.py+++ b/products/approvals/backend/tests/test_feature_flag_bypass_matrix.py@@ -263,22 +263,37 @@ class TestDirectAndCreateBypassMatrix(FeatureFlagBypassMatrixBase):def test_direct_patch_rollout_change_is_gated(self, _mock_enabled):_any_rollout_change_policy(self)flag = self._flag(active=True, rollout=20)+ # The editor saves the whole flag it loaded, so the gate sees the server-owned timestamps+ # come back too. last_called_at has to be set for the body to carry a real one.+ last_called_at = timezone.now() - timedelta(days=3)+ flag.last_called_at = last_called_at+ flag.save(update_fields=["last_called_at"])- response = self._patch(flag, {"filters": {"groups": [{"properties": [], "rollout_percentage": 90}]}})+ body = self.client.get(f"/api/projects/{self.team.id}/feature_flags/{flag.id}/").json()+ body["filters"] = {"groups": [{"properties": [], "rollout_percentage": 90}]}+ response = self._patch(flag, body)- assert response.status_code == 409+ assert response.status_code == 409, response.contentflag.refresh_from_db()assert flag.filters["groups"][0]["rollout_percentage"] == 20+ assert flag.last_called_at == last_called_atself._assert_one_pending_zero_applied()def test_create_active_is_gated(self, _mock_enabled):_enable_policy_for(self, "feature_flag.enable")+ # A client building a create from a flag it loaded sends the server-owned timestamps along.response = self._post(- {"key": "born-active", "active": True, "filters": {"groups": [{"rollout_percentage": 100}]}}+ {+ "key": "born-active",+ "active": True,+ "filters": {"groups": [{"rollout_percentage": 100}]},+ "created_at": (timezone.now() - timedelta(days=30)).isoformat(),+ "last_called_at": (timezone.now() - timedelta(days=3)).isoformat(),+ })- assert response.status_code == 409+ assert response.status_code == 409, response.contentassert response.json().get("code") == "approval_required"assert not FeatureFlag.objects.filter(team=self.team, key="born-active").exists()self._assert_one_pending_zero_applied()