Browse Source

add electron to list and adapt tests

Simon Hellmayr 17 hours ago
parent
commit
c4a9e428a3

+ 9 - 0
src/sentry/api/endpoints/team_projects.py

@@ -22,6 +22,7 @@ from sentry.apidocs.examples.team_examples import TeamExamples
 from sentry.apidocs.parameters import CursorQueryParam, GlobalParams
 from sentry.apidocs.utils import inline_sentry_response_serializer
 from sentry.constants import PROJECT_SLUG_MAX_LENGTH, RESERVED_PROJECT_SLUGS, ObjectStatus
+from sentry.models.options.project_option import ProjectOption
 from sentry.models.project import Project
 from sentry.models.team import Team
 from sentry.seer.similarity.utils import project_is_seer_eligible
@@ -222,4 +223,12 @@ class TeamProjectsEndpoint(TeamEndpoint, EnvironmentMixin):
             if project_is_seer_eligible(project):
                 project.update_option("sentry:similarity_backfill_completed", int(time.time()))
 
+            # Add electron symbol server by default to both electron and javascript-electron projects
+            if project.platform and project.platform.endswith("electron"):
+                symbol_sources = ProjectOption.objects.get_value(
+                    project=project, key="sentry:builtin_symbol_sources"
+                )
+                symbol_sources.append("electron")
+                project.update_option("sentry:builtin_symbol_sources", symbol_sources)
+
         return Response(serialize(project, request.user), status=201)

+ 41 - 0
tests/sentry/api/endpoints/test_team_projects.py

@@ -284,3 +284,44 @@ class TeamProjectsCreateTest(APITestCase, TestCase):
             )
             is None
         )
+
+    def test_builtin_symbol_sources_electron(self):
+        """
+        Test that project option for builtin symbol sources contains ["electron"] when creating
+        an Electron project, but uses defaults for other platforms.
+        """
+        # Test Electron project
+        response = self.get_success_response(
+            self.organization.slug,
+            self.team.slug,
+            name="electron-app",
+            slug="electron-app",
+            platform="electron",
+            status_code=201,
+        )
+
+        electron_project = Project.objects.get(id=response.data["id"])
+        assert electron_project.platform == "electron"
+        symbol_sources = ProjectOption.objects.get_value(
+            project=electron_project, key="sentry:builtin_symbol_sources"
+        )
+        assert "electron" in symbol_sources
+
+    def test_builtin_symbol_sources_not_electron(self):
+        # Test non-Electron project (e.g. Python)
+        response = self.get_success_response(
+            self.organization.slug,
+            self.team.slug,
+            name="python-app",
+            slug="python-app",
+            platform="python",
+            status_code=201,
+        )
+
+        python_project = Project.objects.get(id=response.data["id"])
+        assert python_project.platform == "python"
+        # Should use default value, not ["electron"]
+        symbol_sources = ProjectOption.objects.get_value(
+            project=python_project, key="sentry:builtin_symbol_sources"
+        )
+        assert "electron" not in symbol_sources