Skip to content

Commit 0ac5a6b

Browse files
authored
fix(perf-issues): Add tests for managing detectors (#91772)
Add tests for feature flag check implemented in #91734, forgot them there
1 parent e7976a6 commit 0ac5a6b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/sentry/api/endpoints/test_project_performance_issue_settings.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,38 @@ def test_update_project_setting_invalid_option(self):
284284

285285
assert response.data == {"detail": "Invalid settings option"}
286286

287+
@with_feature("organizations:performance-view")
288+
@with_feature("organizations:performance-manage-detectors")
289+
def test_project_admins_can_manage_detectors(self):
290+
self.login_as(user=self.user, superuser=False)
291+
response = self.get_success_response(
292+
self.project.organization.slug,
293+
self.project.slug,
294+
n_plus_one_db_queries_detection_enabled=False,
295+
method="put",
296+
status_code=status.HTTP_200_OK,
297+
)
298+
299+
assert not response.data["n_plus_one_db_queries_detection_enabled"]
300+
301+
@with_feature("organizations:performance-view")
302+
@with_feature("organizations:performance-manage-detectors")
303+
def test_project_members_cannot_manage_detectors(self):
304+
user = self.create_user("member@localhost")
305+
self.create_member(
306+
organization=self.project.organization,
307+
user=user,
308+
role="member",
309+
)
310+
self.login_as(user=user)
311+
self.get_error_response(
312+
self.project.organization.slug,
313+
self.project.slug,
314+
n_plus_one_db_queries_detection_enabled=False,
315+
method="put",
316+
status_code=status.HTTP_403_FORBIDDEN,
317+
)
318+
287319
@patch("sentry.api.base.create_audit_entry")
288320
@with_feature("organizations:performance-view")
289321
def test_changing_admin_settings_creates_audit_log(self, create_audit_entry: MagicMock):

0 commit comments

Comments
 (0)